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
Delete from the current cursor position to the end of the line.
func (ls *linestate) deleteToEnd() { ls.buf = ls.buf[:ls.pos] ls.refreshLine() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Store) DeleteLine(line int) (string, error) {\n\tif line < 0 || line >= len(s.lines) {\n\t\treturn \"\", fmt.Errorf(\"newLine: Invalid line %v\", line)\n\t}\n\toriginal := s.lines[line].String()\n\tif line < len(s.lines)-1 {\n\t\tcopy(s.lines[line:], s.lines[line+1:])\n\t}\n\ts.lines[len(s.lines)-1] = nil // or the zero value of T\n\ts.lines = s.lines[:len(s.lines)-1]\n\tcs := s.undoFac()\n\tcs.ChangeLine(line, original, \"\")\n\tcs.RemoveLine(line)\n\ts.AddUndoSet(cs)\n\treturn original, nil\n}", "func (e *LineEditor) DelChar() {\n\n\t// different handling for at the beginning of the line or middle of line\n\tif e.Cx > 0 {\n\t\trow := e.Row\n\t\tcopy(row[e.Cx-1:], row[e.Cx:])\n\t\trow = row[:len(row)-1]\n\t\te.Row = row\n\t\te.Cx--\n\t}\n}", "func (tv *TextView) CursorDelete(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\tif tv.HasSelection() {\n\t\ttv.DeleteSelection()\n\t\treturn\n\t}\n\t// note: no update b/c signal from buf will drive update\n\torg := tv.CursorPos\n\ttv.CursorForward(steps)\n\ttv.Buf.DeleteText(org, tv.CursorPos, true, true)\n\ttv.SetCursorShow(org)\n}", "func (ls *linestate) editDelete() {\n\tif len(ls.buf) > 0 && ls.pos < len(ls.buf) {\n\t\tls.buf = append(ls.buf[:ls.pos], ls.buf[ls.pos+1:]...)\n\t\tls.refreshLine()\n\t}\n}", "func ClearLinePartialForward() {\n\temitEscape(\"K\")\n}", "func ClearLinePartialBackward() {\n\temitEscape(\"K\", 1)\n}", "func (hw *HighlightedWriter) EraseLine() {\n\thw.delegate.EraseLine()\n}", "func (m *Model) deleteAfterCursor() bool {\n\tm.value = m.value[:m.pos]\n\treturn m.setCursor(len(m.value))\n}", "func (w *VT100Writer) EraseLine() {\n\tw.WriteRaw([]byte{0x1b, '[', '2', 'K'})\n}", "func ClearLine() {\n\temitEscape(\"K\", 2)\n}", "func (s *Store) Delete(ln, col, cnt int) error {\n\tif ln < 0 || ln >= len(s.lines) {\n\t\treturn fmt.Errorf(\"Delete: line %v out of range\", ln)\n\t}\n\ts.lines[ln].delete(col, cnt)\n\ts.AddUndoSet(s.lines[ln].changeSet(ln, s.undoFac))\n\treturn nil\n}", "func ClearLine() {\n\tfmt.Printf(CSI+EraseLineSeq, 2)\n}", "func ClearLineEnd() {\n\tfmt.Printf(\"\\033[0K\")\n}", "func ClearLineEnd() {\n\tfmt.Printf(\"\\033[0K\")\n}", "func (hw *HighlightedWriter) EraseEndOfLine() {\n\thw.delegate.EraseEndOfLine()\n}", "func (e *Editor) Delete(runes int) {\n\tif runes == 0 {\n\t\treturn\n\t}\n\n\tif l := e.caret.end.ofs - e.caret.start.ofs; l != 0 {\n\t\te.caret.start.ofs = e.editBuffer.deleteRunes(e.caret.start.ofs, l)\n\t\trunes -= sign(runes)\n\t}\n\n\te.caret.start.ofs = e.editBuffer.deleteRunes(e.caret.start.ofs, runes)\n\te.caret.start.xoff = 0\n\te.ClearSelection()\n\te.invalidate()\n}", "func (e *ObservableEditableBuffer) DeleteAt(rp0, rp1 int) {\n\tp0 := e.f.RuneTuple(rp0)\n\tp1 := e.f.RuneTuple(rp1)\n\n\te.Delete(p0, p1)\n}", "func (builder *Builder) EraseLine(m EraseMode) *Builder {\n\treturn builder.With(EraseLine(m))\n}", "func (w *VT100Writer) EraseStartOfLine() {\n\tw.WriteRaw([]byte{0x1b, '[', '1', 'K'})\n}", "func ClearLine(conn io.Writer) {\n\tclearline := \"\\x1B[2K\"\n\tWrite(conn, clearline+\"\\r\", ColorModeNone)\n}", "func (hw *HighlightedWriter) EraseStartOfLine() {\n\thw.delegate.EraseStartOfLine()\n}", "func (tv *TextView) CursorEndLine() {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\torg := tv.CursorPos\n\tpos := tv.CursorPos\n\n\tgotwrap := false\n\tif wln := tv.WrappedLines(pos.Ln); wln > 1 {\n\t\tsi, ri, _ := tv.WrappedLineNo(pos)\n\t\tri = len(tv.Renders[pos.Ln].Spans[si].Text) - 1\n\t\tnwc, _ := tv.Renders[pos.Ln].SpanPosToRuneIdx(si, ri)\n\t\tif si == len(tv.Renders[pos.Ln].Spans)-1 { // last span\n\t\t\tri++\n\t\t\tnwc++\n\t\t}\n\t\ttv.CursorCol = ri\n\t\tpos.Ch = nwc\n\t\ttv.CursorPos = pos\n\t\tgotwrap = true\n\t}\n\tif !gotwrap {\n\t\ttv.CursorPos.Ch = tv.Buf.LineLen(tv.CursorPos.Ln)\n\t\ttv.CursorCol = tv.CursorPos.Ch\n\t}\n\ttv.SetCursor(tv.CursorPos)\n\ttv.ScrollCursorToRight()\n\ttv.RenderCursor(true)\n\ttv.CursorSelect(org)\n}", "func (w *VT100Writer) EraseEndOfLine() {\n\tw.WriteRaw([]byte{0x1b, '[', 'K'})\n}", "func (term *Terminal) ClearLine() {\n\tfmt.Printf(\"\\r%s\\r\", term.clearer)\n}", "func ClearLine(headerWidth int) string {\n\tout := \"\"\n\tout += fmt.Sprint(cursorAbsoluteLeft)\n\tout += fmt.Sprint(clearLine)\n\tout += fmt.Sprint(cursorRight(headerWidth))\n\n\treturn out\n}", "func (tb *TextBuf) DeleteText(st, ed TextPos, saveUndo, signal bool) *TextBufEdit {\n\tst = tb.ValidPos(st)\n\ted = tb.ValidPos(ed)\n\tif st == ed {\n\t\treturn nil\n\t}\n\tif !st.IsLess(ed) {\n\t\tlog.Printf(\"giv.TextBuf DeleteText: starting position must be less than ending!: st: %v, ed: %v\\n\", st, ed)\n\t\treturn nil\n\t}\n\ttb.FileModCheck() // note: could bail if modified but not clear that is better?\n\ttbe := tb.Region(st, ed)\n\ttb.SetChanged()\n\ttb.LinesMu.Lock()\n\ttbe.Delete = true\n\tif ed.Ln == st.Ln {\n\t\ttb.Lines[st.Ln] = append(tb.Lines[st.Ln][:st.Ch], tb.Lines[st.Ln][ed.Ch:]...)\n\t\ttb.LinesMu.Unlock()\n\t\tif saveUndo {\n\t\t\ttb.SaveUndo(tbe)\n\t\t}\n\t\ttb.LinesEdited(tbe)\n\t} else {\n\t\t// first get chars on start and end\n\t\tstln := st.Ln + 1\n\t\tcpln := st.Ln\n\t\ttb.Lines[st.Ln] = tb.Lines[st.Ln][:st.Ch]\n\t\teoedl := len(tb.Lines[ed.Ln][ed.Ch:])\n\t\tvar eoed []rune\n\t\tif eoedl > 0 { // save it\n\t\t\teoed = make([]rune, eoedl)\n\t\t\tcopy(eoed, tb.Lines[ed.Ln][ed.Ch:])\n\t\t}\n\t\ttb.Lines = append(tb.Lines[:stln], tb.Lines[ed.Ln+1:]...)\n\t\tif eoed != nil {\n\t\t\ttb.Lines[cpln] = append(tb.Lines[cpln], eoed...)\n\t\t}\n\t\ttb.NLines = len(tb.Lines)\n\t\ttb.LinesMu.Unlock()\n\t\tif saveUndo {\n\t\t\ttb.SaveUndo(tbe)\n\t\t}\n\t\ttb.LinesDeleted(tbe)\n\t}\n\n\tif signal {\n\t\ttb.TextBufSig.Emit(tb.This(), int64(TextBufDelete), tbe)\n\t}\n\tif tb.Autosave {\n\t\tgo tb.AutoSave()\n\t}\n\treturn tbe\n}", "func ClearLine() {\n\tfmt.Printf(\"\\033[2K\")\n}", "func ClearLine() {\n\tfmt.Printf(\"\\033[2K\")\n}", "func (e *LineEditor) CursorEnd() {\n\te.Cx = len(e.Row)\n}", "func (s *Screen) ClearLine() {\n\tfmt.Fprint(s.Terminal, \"\\u001b[2K\")\n}", "func (tv *TextView) Redo() {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttbe := tv.Buf.Redo()\n\tif tbe != nil {\n\t\tif tbe.Delete {\n\t\t\ttv.SetCursorShow(tbe.Reg.Start)\n\t\t} else {\n\t\t\ttv.SetCursorShow(tbe.Reg.End)\n\t\t}\n\t} else {\n\t\ttv.ScrollCursorToCenterIfHidden()\n\t}\n\ttv.SavePosHistory(tv.CursorPos)\n}", "func (m *Model) deleteBeforeCursor() bool {\n\tm.value = m.value[m.pos:]\n\tm.offset = 0\n\treturn m.setCursor(0)\n}", "func (tv *TextView) CursorDeleteWord(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\tif tv.HasSelection() {\n\t\ttv.DeleteSelection()\n\t\treturn\n\t}\n\t// note: no update b/c signal from buf will drive update\n\torg := tv.CursorPos\n\ttv.CursorForwardWord(steps)\n\ttv.Buf.DeleteText(org, tv.CursorPos, true, true)\n\ttv.SetCursorShow(org)\n}", "func (cur *cursor) invalidateAtEnd() {\n\tcur.idx = int(cur.nd.count)\n}", "func (i *Input) backspace() {\n\tcurLine := i.lines[i.cursorLineIndex]\n\t// at the beginning of the buffer, nothing to do\n\tif len(curLine) == 0 && i.cursorLineIndex == 0 {\n\t\treturn\n\t}\n\n\t// at the beginning of a line somewhere in the buffer\n\tif i.cursorLinePos == 0 {\n\t\tprevLine := i.lines[i.cursorLineIndex-1]\n\t\t// remove the newline character from the prevline\n\t\tprevLine = prevLine[:len(curLine)-1] + curLine\n\t\ti.lines = append(i.lines[:i.cursorLineIndex], i.lines[i.cursorLineIndex+1:]...)\n\t\ti.cursorLineIndex--\n\t\ti.cursorLinePos = len(prevLine) - 1\n\t\treturn\n\t}\n\n\t// I'm at the end of a line\n\tif i.cursorLinePos == len(curLine)-1 {\n\t\ti.lines[i.cursorLineIndex] = curLine[:len(curLine)-1]\n\t\ti.cursorLinePos--\n\t\treturn\n\t}\n\n\t// I'm in the middle of a line\n\ti.lines[i.cursorLineIndex] = curLine[:i.cursorLinePos-1] + curLine[i.cursorLinePos:]\n\ti.cursorLinePos--\n}", "func (e *ObservableEditableBuffer) Delete(q0, q1 OffsetTuple) {\n\tbefore := e.getTagStatus()\n\tdefer e.notifyTagObservers(before)\n\n\te.f.Delete(q0, q1, e.seq)\n\tif e.seq < 1 {\n\t\te.f.FlattenHistory()\n\t}\n\te.deleted(q0, q1)\n}", "func (tv *TextView) CursorKill() {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\torg := tv.CursorPos\n\tpos := tv.CursorPos\n\n\tatEnd := false\n\tif wln := tv.WrappedLines(pos.Ln); wln > 1 {\n\t\tsi, ri, _ := tv.WrappedLineNo(pos)\n\t\tllen := len(tv.Renders[pos.Ln].Spans[si].Text)\n\t\tif si == wln-1 {\n\t\t\tllen--\n\t\t}\n\t\tatEnd = (ri == llen)\n\t} else {\n\t\tllen := tv.Buf.LineLen(pos.Ln)\n\t\tatEnd = (tv.CursorPos.Ch == llen)\n\t}\n\tif atEnd {\n\t\ttv.CursorForward(1)\n\t} else {\n\t\ttv.CursorEndLine()\n\t}\n\ttv.Buf.DeleteText(org, tv.CursorPos, true, true)\n\ttv.SetCursorShow(org)\n}", "func (e *Editor) ClearSelection() {\n\te.caret.end = e.caret.start\n}", "func (c *Canvas) Delete(cr *Cursor) error {\n\tif cr.X >= canvasWidth || cr.Y >= canvasHeight {\n\t\treturn fmt.Errorf(`(%d, %d) is out of the Canvas size`, cr.X, cr.Y)\n\t}\n\n\t(*c)[cr.Y][cr.X] = 0\n\n\treturn nil\n}", "func ClearLine() string {\n\tif runtime.GOOS == \"windows\" {\n\t\tif w := stdoutTerminalWidth(); w > 0 {\n\t\t\treturn strings.Repeat(\" \", w-1) + \"\\r\"\n\t\t}\n\t\treturn \"\"\n\t}\n\treturn \"\\x1b[2K\"\n}", "func (ls *linestate) editMoveEnd() {\n\tif ls.pos != len(ls.buf) {\n\t\tls.pos = len(ls.buf)\n\t\tls.refreshLine()\n\t}\n}", "func (s *Store) ResetLine(line int, st string) (string, error) {\n\tif line < 0 || line >= len(s.lines) {\n\t\treturn \"\", fmt.Errorf(\"ResetLine: Invalid offset %v\", line)\n\t}\n\toriginal := s.lines[line].String()\n\ts.lines[line].reset(st)\n\tcs := s.undoFac()\n\tcs.ChangeLine(line, original, st)\n\ts.AddUndoSet(cs)\n\treturn original, nil\n}", "func (s *Screen) ClearLines() {\n\ts.ScreenCursor.Save()\n\ts.ScreenCursor.Home()\n\ts.ClearFromCursor(true)\n\ts.ScreenCursor.Return()\n}", "func (ls *linestate) deletePrevWord() {\n\toldPos := ls.pos\n\t// remove spaces\n\tfor ls.pos > 0 && ls.buf[ls.pos-1] == ' ' {\n\t\tls.pos--\n\t}\n\t// remove word\n\tfor ls.pos > 0 && ls.buf[ls.pos-1] != ' ' {\n\t\tls.pos--\n\t}\n\tls.buf = append(ls.buf[:ls.pos], ls.buf[oldPos:]...)\n\tls.refreshLine()\n}", "func (t *tui) end(g *gotui.Gui, v *gotui.View) error {\n\t_, cy := v.Cursor()\n\tlines := v.ViewBufferLines()\n\t// Return if we're on a line with zero width.\n\tif len(lines) == 0 || len(lines[cy]) == 0 {\n\t\treturn nil\n\t}\n\t// Set the last column to either the width of the view or one character after the last.\n\tlastCol, _ := v.Size()\n\tif len(lines[cy]) < lastCol {\n\t\tlastCol = len(lines[cy]) + 1\n\t}\n\tv.SetCursor(lastCol-1, cy)\n\treturn nil\n}", "func (m *Model) deleteWordRight() bool {\n\tif m.pos >= len(m.value) || len(m.value) == 0 {\n\t\treturn false\n\t}\n\n\tif m.EchoMode != EchoNormal {\n\t\treturn m.deleteAfterCursor()\n\t}\n\n\toldPos := m.pos\n\tm.setCursor(m.pos + 1)\n\tfor unicode.IsSpace(m.value[m.pos]) {\n\t\t// ignore series of whitespace after cursor\n\t\tm.setCursor(m.pos + 1)\n\n\t\tif m.pos >= len(m.value) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor m.pos < len(m.value) {\n\t\tif !unicode.IsSpace(m.value[m.pos]) {\n\t\t\tm.setCursor(m.pos + 1)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif m.pos > len(m.value) {\n\t\tm.value = m.value[:oldPos]\n\t} else {\n\t\tm.value = append(m.value[:oldPos], m.value[m.pos:]...)\n\t}\n\n\treturn m.setCursor(oldPos)\n}", "func (tv *TextView) LinesDeleted(tbe *TextBufEdit) {\n\tstln := tbe.Reg.Start.Ln\n\tedln := tbe.Reg.End.Ln\n\tdsz := edln - stln\n\n\ttv.Renders = append(tv.Renders[:stln], tv.Renders[edln:]...)\n\ttv.Offs = append(tv.Offs[:stln], tv.Offs[edln:]...)\n\n\ttv.NLines -= dsz\n\n\ttv.LayoutLines(tbe.Reg.Start.Ln, tbe.Reg.Start.Ln, true)\n\ttv.RenderAllLines()\n}", "func clearRow(row int) error {\n\terr := setCursorRow(row)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tansi.EraseInLine(2)\n\treturn nil\n}", "func (c *CmdBuff) Delete() {\n\tif c.Empty() {\n\t\treturn\n\t}\n\tc.SetText(string(c.buff[:len(c.buff)-1]), \"\")\n\tc.fireBufferChanged(c.GetText(), c.GetSuggestion())\n\tif c.hasCancel() {\n\t\treturn\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 800*time.Millisecond)\n\tc.setCancel(cancel)\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\tc.fireBufferCompleted(c.GetText(), c.GetSuggestion())\n\t\tc.resetCancel()\n\t}()\n}", "func (tv *TextView) DeleteSelection() *TextBufEdit {\n\ttbe := tv.Buf.DeleteText(tv.SelectReg.Start, tv.SelectReg.End, true, true)\n\ttv.SelectReset()\n\treturn tbe\n}", "func ClearLineStart() {\n\tfmt.Printf(\"\\033[1K\")\n}", "func ClearLineStart() {\n\tfmt.Printf(\"\\033[1K\")\n}", "func (e *Editor) Line() (string, error) {\n\tif err := e.editReset(); err != nil {\n\t\treturn string(e.Buffer), err\n\t}\nline:\n\tfor {\n\t\tr, _, err := e.In.ReadRune()\n\t\tif err != nil {\n\t\t\treturn string(e.Buffer), err\n\t\t}\n\n\t\tswitch r {\n\t\tcase enter:\n\t\t\tbreak line\n\t\tcase ctrlC:\n\t\t\treturn string(e.Buffer), errors.New(\"try again\")\n\t\tcase backspace, ctrlH:\n\t\t\tif err := e.editBackspace(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlD:\n\t\t\tif len(e.Buffer) == 0 {\n\t\t\t\treturn string(e.Buffer), io.EOF\n\t\t\t}\n\n\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlT:\n\t\t\tif err := e.editSwap(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlB:\n\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlF:\n\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlP:\n\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlN:\n\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlU:\n\t\t\tif err := e.editReset(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlK:\n\t\t\tif err := e.editKillForward(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlA:\n\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlE:\n\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlL:\n\t\t\tif err := e.clearScreen(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tif err := e.refreshLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlW:\n\t\t\tif err := e.editDeletePrevWord(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase esc:\n\t\t\tr, _, err := e.In.ReadRune()\n\t\t\tif err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tswitch r {\n\t\t\tcase '[':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase '0', '1', '2', '4', '5', '6', '7', '8', '9':\n\t\t\t\t\t_, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase '3':\n\t\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch r {\n\t\t\t\t\tcase '~':\n\t\t\t\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'A':\n\t\t\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'B':\n\t\t\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'C':\n\t\t\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'D':\n\t\t\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase 'O':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase tab:\n\t\t\tif err := e.completeLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tdefault:\n\t\t\tif err := e.editInsert(r); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn string(e.Buffer), nil\n}", "func TextDeleteLines(n int) string {\n\treturn Esc + strconv.Itoa(n) + \"M\"\n}", "func (c *Cursor) Last() {\n\tc.pos = c.end - 1\n}", "func (tb *TextBuf) Redo() *TextBufEdit {\n\tif tb.UndoPos >= len(tb.Undos) {\n\t\treturn nil\n\t}\n\ttbe := tb.Undos[tb.UndoPos]\n\tif tbe.Delete {\n\t\ttb.DeleteText(tbe.Reg.Start, tbe.Reg.End, false, true)\n\t} else {\n\t\ttb.InsertText(tbe.Reg.Start, tbe.ToBytes(), false, true)\n\t}\n\ttb.UndoPos++\n\treturn tbe\n}", "func (r *runestring) Del(pos ...int) {\n\tfor _, i := range pos {\n\t\tif i >= 0 && i <= len(*r) {\n\t\t\t*r = append((*r)[:i], (*r)[i+1:]...)\n\t\t}\n\t}\n}", "func (ls *linestate) editBackspace() {\n\tif ls.pos > 0 && len(ls.buf) > 0 {\n\t\tls.buf = append(ls.buf[:ls.pos-1], ls.buf[ls.pos:]...)\n\t\tls.pos--\n\t\tls.refreshLine()\n\t}\n}", "func (w *Writer) Clear() {\n\tf, ok := io.Writer(w.Out).(*os.File)\n\tif ok && !isatty.IsTerminal(f.Fd()) {\n\t\tok = false\n\t}\n\tif !ok {\n\t\tfor i := 0; i < w.lineCount; i++ {\n\t\t\tfmt.Fprintf(w.Out, \"%c[%dA\", esc, 0) // move the cursor up\n\t\t\tfmt.Fprintf(w.Out, \"%c[2K\\r\", esc) // clear the line\n\t\t}\n\t\treturn\n\t}\n\tfd := f.Fd()\n\tvar csbi consoleScreenBufferInfo\n\tprocGetConsoleScreenBufferInfo.Call(fd, uintptr(unsafe.Pointer(&csbi)))\n\n\tfor i := 0; i < w.lineCount; i++ {\n\t\t// move the cursor up\n\t\tcsbi.cursorPosition.y--\n\t\tprocSetConsoleCursorPosition.Call(fd, uintptr(*(*int32)(unsafe.Pointer(&csbi.cursorPosition))))\n\t\t// clear the line\n\t\tcursor := coord{\n\t\t\tx: csbi.window.left,\n\t\t\ty: csbi.window.top + csbi.cursorPosition.y,\n\t\t}\n\t\tvar count, w dword\n\t\tcount = dword(csbi.size.x)\n\t\tprocFillConsoleOutputCharacter.Call(fd, uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&w)))\n\t}\n\tw.lineCount = 0\n}", "func (tb *TextBuf) LinesDeleted(tbe *TextBufEdit) {\n\ttb.LinesMu.Lock()\n\ttb.MarkupMu.Lock()\n\n\tstln := tbe.Reg.Start.Ln\n\tedln := tbe.Reg.End.Ln\n\n\ttb.LineBytes = append(tb.LineBytes[:stln], tb.LineBytes[edln:]...)\n\ttb.Markup = append(tb.Markup[:stln], tb.Markup[edln:]...)\n\ttb.Tags = append(tb.Tags[:stln], tb.Tags[edln:]...)\n\ttb.HiTags = append(tb.HiTags[:stln], tb.HiTags[edln:]...)\n\ttb.ByteOffs = append(tb.ByteOffs[:stln], tb.ByteOffs[edln:]...)\n\n\ttb.PiState.Src.LinesDeleted(stln, edln)\n\n\tst := tbe.Reg.Start.Ln\n\ttb.LineBytes[st] = []byte(string(tb.Lines[st]))\n\ttb.Markup[st] = HTMLEscapeBytes(tb.LineBytes[st])\n\ttb.MarkupLines(st, st)\n\ttb.MarkupMu.Unlock()\n\ttb.LinesMu.Unlock()\n\t// probably don't need to do global markup here..\n}", "func CursorPrevLine(r uint) {\n\temitEscape(\"F\", r)\n}", "func (m *Model) deleteWordLeft() bool {\n\tif m.pos == 0 || len(m.value) == 0 {\n\t\treturn false\n\t}\n\n\tif m.EchoMode != EchoNormal {\n\t\treturn m.deleteBeforeCursor()\n\t}\n\n\t// Linter note: it's critical that we acquire the initial cursor position\n\t// here prior to altering it via SetCursor() below. As such, moving this\n\t// call into the corresponding if clause does not apply here.\n\toldPos := m.pos //nolint:ifshort\n\n\tblink := m.setCursor(m.pos - 1)\n\tfor unicode.IsSpace(m.value[m.pos]) {\n\t\tif m.pos <= 0 {\n\t\t\tbreak\n\t\t}\n\t\t// ignore series of whitespace before cursor\n\t\tblink = m.setCursor(m.pos - 1)\n\t}\n\n\tfor m.pos > 0 {\n\t\tif !unicode.IsSpace(m.value[m.pos]) {\n\t\t\tblink = m.setCursor(m.pos - 1)\n\t\t} else {\n\t\t\tif m.pos > 0 {\n\t\t\t\t// keep the previous space\n\t\t\t\tblink = m.setCursor(m.pos + 1)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif oldPos > len(m.value) {\n\t\tm.value = m.value[:m.pos]\n\t} else {\n\t\tm.value = append(m.value[:m.pos], m.value[oldPos:]...)\n\t}\n\n\treturn blink\n}", "func (r *Range) Delete(args *DeleteRequest, reply *DeleteResponse) {\n\tif err := r.engine.del(args.Key); err != nil {\n\t\treply.Error = err\n\t}\n}", "func (tv *TextView) CursorBackspace(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\torg := tv.CursorPos\n\tif tv.HasSelection() {\n\t\torg = tv.SelectReg.Start\n\t\ttv.DeleteSelection()\n\t\ttv.SetCursorShow(org)\n\t\treturn\n\t}\n\t// note: no update b/c signal from buf will drive update\n\ttv.CursorBackward(steps)\n\ttv.ScrollCursorToCenterIfHidden()\n\ttv.RenderCursor(true)\n\ttv.Buf.DeleteText(tv.CursorPos, org, true, true)\n}", "func (i *Input) Backspace() {\n\tif i.Pos > 0 {\n\t\ti.Buffer.RemoveRune(i.Pos - 1)\n\t\ti.Pos--\n\t}\n}", "func (b *Buffer) MoveLinesDown(start int, end int) {\n\t// 0 <= start < end < len(b.lines)\n\t// if end == len(b.lines), we can't do anything here because the\n\t// last line is unaccessible, FIXME\n\tif start < 0 || start >= end || end >= len(b.lines)-1 {\n\t\treturn // what to do? FIXME\n\t}\n\tb.Insert(\n\t\tLoc{0, start},\n\t\tb.Line(end)+\"\\n\",\n\t)\n\tend++\n\tb.Remove(\n\t\tLoc{0, end},\n\t\tLoc{0, end + 1},\n\t)\n}", "func (pl *ProgramLine) RemoveUnusedLine() {\n\tif pl.previous != nil {\n\t\tpl.previous.next = pl.next\n\t} else {\n\t\tpl.parentBlock.firstLine = pl.next\n\t}\n\n\tif pl.next != nil {\n\t\tpl.next.previous = pl.previous\n\t} else {\n\t\tpl.parentBlock.lastLine = pl.previous\n\t}\n\n\tpl.forgetCallsOut()\n}", "func (t *Table) DeleteRow(row int) {\n\tif row == 0 {\n\t\tt.Row = t.Row[1:]\n\t} else {\n\t\tn := t.Row[0:row]\n\t\tif len(t.Row) > row {\n\t\t\tn = append(n, t.Row[row+1:]...)\n\t\t}\n\t\tt.Row = n\n\t}\n\t// Clean up LineAfter\n\tfor i := 0; i < len(t.LineAfter); i++ {\n\t\tif t.LineAfter[i] >= row {\n\t\t\tt.LineAfter[i]--\n\t\t}\n\t}\n\t// Clean up RowSets\n\tfor i := 0; i < len(t.RS); i++ {\n\t\tfor j := 0; j < len(t.RS[i].R); j++ {\n\t\t\tif t.RS[i].R[j] >= row {\n\t\t\t\tt.RS[i].R[j]--\n\t\t\t}\n\t\t}\n\t}\n}", "func (x *Reader) BackToLastCompleteLine() error {\n\tif x.File == nil {\n\t\treturn nil\n\t}\n\treturn x.SeekOffset(x.Offset)\n}", "func (bar *StatusBar) Del(pos int) (newLength int) {\n\tcopy(bar.Messages[pos:], bar.Messages[pos+1:])\n\tbar.Messages = bar.Messages[:cap(bar.Messages)-2]\n\tcopy(bar.Prefix[pos:], bar.Prefix[pos+1:])\n\tbar.Prefix = bar.Prefix[:cap(bar.Prefix)-2]\n\tbar.Disp()\n\treturn len(bar.Messages)\n}", "func (s *source) removeCursor(rm *cursor) {\n\ts.cursorsMu.Lock()\n\tdefer s.cursorsMu.Unlock()\n\n\tif rm.cursorsIdx != len(s.cursors)-1 {\n\t\ts.cursors[rm.cursorsIdx], s.cursors[len(s.cursors)-1] = s.cursors[len(s.cursors)-1], nil\n\t\ts.cursors[rm.cursorsIdx].cursorsIdx = rm.cursorsIdx\n\t} else {\n\t\ts.cursors[rm.cursorsIdx] = nil // do not let the memory hang around\n\t}\n\n\ts.cursors = s.cursors[:len(s.cursors)-1]\n\tif s.cursorsStart == len(s.cursors) {\n\t\ts.cursorsStart = 0\n\t}\n}", "func (w *Win) Delete(q0, q1 int64) (n int) {\n\tif EnableUndoExperiment {\n\t\tprintln(fmt.Sprintf(\"#%d,#%d d\\n\", q0, q1))\n\t}\n\treturn w.delete(q0, q1)\n}", "func (t *Trie) Delete(word string) {\n\tn := t.find(word)\n\tif n.end == true {\n\t\tn.end = false\n\t}\n}", "func CursorNextLine(r uint) {\n\temitEscape(\"E\", r)\n}", "func Clear() {\n\tm.Lock()\n\tfmt.Print(clearLine)\n\tm.Unlock()\n}", "func (t *TimeLine) Reset() {\n\tt.cursor = 0\n\tt.lastDelta = 0\n}", "func (c *Client) DeleteSaleOrderLine(id int64) error {\n\treturn c.DeleteSaleOrderLines([]int64{id})\n}", "func (e *Editor) deleteWord(distance int) {\n\tif distance == 0 {\n\t\treturn\n\t}\n\n\te.makeValid()\n\n\tif e.caret.start.ofs != e.caret.end.ofs {\n\t\te.Delete(1)\n\t\tdistance -= sign(distance)\n\t}\n\tif distance == 0 {\n\t\treturn\n\t}\n\n\t// split the distance information into constituent parts to be\n\t// used independently.\n\twords, direction := distance, 1\n\tif distance < 0 {\n\t\twords, direction = distance*-1, -1\n\t}\n\t// atEnd if offset is at or beyond either side of the buffer.\n\tatEnd := func(offset int) bool {\n\t\tidx := e.caret.start.ofs + offset*direction\n\t\treturn idx <= 0 || idx >= e.editBuffer.len()\n\t}\n\t// next returns the appropriate rune given the direction and offset.\n\tnext := func(offset int) (r rune) {\n\t\tidx := e.caret.start.ofs + offset*direction\n\t\tif idx < 0 {\n\t\t\tidx = 0\n\t\t} else if idx > e.editBuffer.len() {\n\t\t\tidx = e.editBuffer.len()\n\t\t}\n\t\tif direction < 0 {\n\t\t\tr, _ = e.editBuffer.runeBefore(idx)\n\t\t} else {\n\t\t\tr, _ = e.editBuffer.runeAt(idx)\n\t\t}\n\t\treturn r\n\t}\n\tvar runes = 1\n\tfor ii := 0; ii < words; ii++ {\n\t\tif r := next(runes); unicode.IsSpace(r) {\n\t\t\tfor r := next(runes); unicode.IsSpace(r) && !atEnd(runes); r = next(runes) {\n\t\t\t\trunes += 1\n\t\t\t}\n\t\t} else {\n\t\t\tfor r := next(runes); !unicode.IsSpace(r) && !atEnd(runes); r = next(runes) {\n\t\t\t\trunes += 1\n\t\t\t}\n\t\t}\n\t}\n\te.Delete(runes * direction)\n}", "func removeLines(fn string, start, n int) (err error) {\n\tlogs.INFO.Println(\"Clear file -> \", fn)\n\tif n < 0 {\n\t\tn = store.getLines()\n\t}\n\tif n == 0 {\n\t\tlogs.INFO.Println(\"Nothing to clear\")\n\t\tseek = 0\n\t\treturn nil\n\t}\n\tlogs.INFO.Println(\"Total lines -> \", n)\n\tif start < 1 {\n\t\tlogs.WARNING.Println(\"Invalid request. line numbers start at 1.\")\n\t}\n\tvar f *os.File\n\tif f, err = os.OpenFile(fn, os.O_RDWR, 0); err != nil {\n\t\tlogs.CRITICAL.Println(\"Failed to open the file -> \", err)\n\t\treturn\n\t}\n\tdefer func() {\n\t\tif cErr := f.Close(); err == nil {\n\t\t\terr = cErr\n\t\t}\n\t}()\n\tvar b []byte\n\tif b, err = ioutil.ReadAll(f); err != nil {\n\t\tlogs.CRITICAL.Println(\"Failed to reading the file -> \", err)\n\t\treturn\n\t}\n\tcut, ok := skip(b, start-1)\n\tif !ok {\n\t\tlogs.CRITICAL.Printf(\"less than %d lines -> \", start)\n\t\treturn\n\t}\n\tif n == 0 {\n\t\treturn nil\n\t}\n\ttail, ok := skip(cut, n)\n\tif !ok {\n\t\tlogs.CRITICAL.Printf(\"less than %d lines after line %d \", n, start)\n\t\treturn\n\t}\n\tt := int64(len(b) - len(cut))\n\tif err = f.Truncate(t); err != nil {\n\t\treturn\n\t}\n\t// Writing in the archive the bytes already with cut removed\n\tif len(tail) > 0 {\n\t\t_, err = f.WriteAt(tail, t)\n\t}\n\treturn\n}", "func RestoreCursorPos() {\n\temitEscape(\"u\")\n}", "func (s *Storage) RangeDelete(start, end []byte) error {\n\ts.kv.RangeDelete(start, end)\n\treturn nil\n}", "func (pl *ProgramLine) RemoveAllFollowingLines() {\n\tpl.parentBlock.lastLine = pl\n\n\tfor line := pl.next; line != nil; line = line.next {\n\t\tline.forgetCallsOut()\n\t}\n\n\tpl.next = nil\n}", "func (todo Todo) Remove() error {\n\treturn todo.updateInPlace(func(lineNumber int, line string) (string, bool) {\n\t\tif lineNumber == todo.Line {\n\t\t\treturn \"\", true\n\t\t}\n\n\t\treturn line, false\n\t})\n}", "func (Screen *ScreenManager) ResetLine(str string) (out string) {\n\treturn applyScreenTransform(str, func(idx int, line string) string {\n\t\treturn fmt.Sprintf(\"%s\"+RESET_LINE, line)\n\t})\n}", "func (c *Cursor) Delete() error {\n\tif c.bucket.tx.db == nil {\n\t\treturn ErrTxClosed\n\t} else if !c.bucket.Writable() {\n\t\treturn ErrTxNotWritable\n\t}\n\n\tkey, _, flags := c.keyValue()\n\t// Return an error if current value is a bucket.\n\tif (flags & bucketLeafFlag) != 0 {\n\t\treturn ErrIncompatibleValue\n\t}\n\t// 从node中移除,本质上将inode数组进行移动\n\tc.node().del(key)\n\n\treturn nil\n}", "func (file *File) Redo() {\n\tif file.buffHist == nil {\n\t\treturn\n\t}\n\tbuffer, mc := file.buffHist.Next()\n\tfile.buffer.ReplaceBuffer(buffer)\n\tfile.MultiCursor.ReplaceMC(mc)\n}", "func RestoreCursorPosition() {\n\tfmt.Printf(\"\\033[u\")\n}", "func RestoreCursorPosition() {\n\tfmt.Printf(\"\\033[u\")\n}", "func (h *Header) Del(key string) {\n\tfor i, ok := h.index(key); ok; i, ok = h.index(key) {\n\t\th.slice = append(h.slice[:i], h.slice[i+2:]...)\n\t}\n}", "func (ls *linestate) editMoveRight() {\n\tif ls.pos != len(ls.buf) {\n\t\tls.pos++\n\t\tls.refreshLine()\n\t}\n}", "func (tm *Term) End() error {\n\ttm.RowOff = 0\n\ttm.RowSt = tm.MaxRows - tm.RowsPer\n\treturn tm.Draw()\n}", "func Delete(seq Sequence, offset, length int) Sequence {\n\tinfo := seq.Info()\n\tinfo = tryExpand(info, offset, -length)\n\tseq = WithInfo(seq, info)\n\n\tff := seq.Features()\n\tfor i, f := range ff {\n\t\tff[i].Loc = f.Loc.Expand(offset, -length)\n\t}\n\tseq = WithFeatures(seq, ff)\n\n\tq := seq.Bytes()\n\tp := make([]byte, len(q)-length)\n\tcopy(p[:offset], q[:offset])\n\tcopy(p[offset:], q[offset+length:])\n\tseq = WithBytes(seq, p)\n\n\treturn seq\n}", "func (r *ride) unshiftLines() Line {\n\tline, lines := r.lines[0], r.lines[1:]\n\tr.lines = lines\n\treturn line\n}", "func (l *LinkedList) DeleteAtEnd() error {\n\t// validate the position\n\tif l.len == 0 {\n\t\tfmt.Println(\"No nodes in list\")\n\t\treturn errors.New(\"No nodes in list\")\n\t} else if l.len == 1 {\n\t\tl.head = nil\n\t\tl.tail = nil\n\t\tl.len--\n\t\treturn nil\n\t}\n\tl.tail = l.tail.prev\n\tl.tail.next = nil\n\tl.len--\n\treturn nil\n}", "func (m *Model) CursorEnd() {\n\tm.cursorEnd()\n}", "func (s *Basegff3Listener) ExitLine(ctx *LineContext) {}", "func (t *Table) renderDeleteByIndexLine(chainName string, ruleNum int) string {\n\treturn fmt.Sprintf(\"-D %s %d\", chainName, ruleNum)\n}", "func (e *T) erase() {\n\tif e.widx <= 0 {\n\t\treturn\n\t}\n\te.widx--\n\te.buf[e.widx] = 0\n}", "func (t *Table) renderDeleteByValueLine(chainName string, ruleNum int) (string, error) {\n\t// For non-cali chains, get the rule by number but delete using the full rule instead of rule number.\n\trules, ok := t.chainToFullRules[chainName]\n\tif !ok || ruleNum >= len(rules) {\n\t\treturn \"\", fmt.Errorf(\"Rendering delete for non-existent rule: Rule %d in %q\", ruleNum, chainName)\n\t}\n\n\trule := rules[ruleNum]\n\n\t// Make the append a delete.\n\treturn strings.Replace(rule, \"-A\", \"-D\", 1), nil\n}", "func (t *tui) arrowDown(g *gotui.Gui, v *gotui.View) error {\n\tcx, cy := v.Cursor()\n\tlines := v.ViewBufferLines()\n\tlineCount := len(v.ViewBufferLines()) - 1\n\tif lineCount == -1 {\n\t\treturn nil\n\t}\n\tlastLineLen := len(lines[lineCount])\n\tif cx == lastLineLen || (cx == 0 && cy == 0 && !t.sent.onLast()) {\n\t\tif cy == lineCount {\n\t\t\tv.Clear()\n\t\t\tv.SetCursor(0, 0)\n\t\t\tif !t.sent.onLast() {\n\t\t\t\tfmt.Fprint(v, t.sent.Forward().Text)\n\t\t\t}\n\t\t} else {\n\t\t\tif lineCount == 0 {\n\t\t\t\tv.SetCursor(cx, cy+1)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif cy == lineCount {\n\t\t\tv.SetCursor(lastLineLen, cy)\n\t\t} else {\n\t\t\tv.SetCursor(cx, cy+1)\n\t\t}\n\t}\n\treturn nil\n}" ]
[ "0.66155714", "0.65606886", "0.63854927", "0.63315856", "0.62901354", "0.625224", "0.616739", "0.6117216", "0.61087084", "0.5982817", "0.59359884", "0.58969957", "0.5829305", "0.5829305", "0.5826632", "0.58040184", "0.5768449", "0.5768401", "0.57607937", "0.5759273", "0.5754636", "0.574845", "0.5701554", "0.5688516", "0.5678474", "0.5645485", "0.559177", "0.559177", "0.5576589", "0.55699146", "0.5562907", "0.55587405", "0.5536239", "0.5525842", "0.5494775", "0.5464786", "0.54421836", "0.54132104", "0.5345211", "0.52947736", "0.52913684", "0.5279183", "0.52681494", "0.5265413", "0.5265116", "0.525157", "0.5224624", "0.51911473", "0.51792824", "0.51644164", "0.51432997", "0.51432997", "0.5132581", "0.5131733", "0.5125941", "0.5119042", "0.50731534", "0.5057631", "0.50405115", "0.5027918", "0.5000713", "0.49941808", "0.4959837", "0.49571928", "0.49448296", "0.4929656", "0.49218348", "0.4912699", "0.4868551", "0.48580343", "0.48552302", "0.48523954", "0.4843762", "0.48197442", "0.47956854", "0.47836247", "0.4771945", "0.47513846", "0.4738118", "0.47215992", "0.47203368", "0.47184974", "0.47169378", "0.47147137", "0.47079778", "0.46934098", "0.467493", "0.467493", "0.46721977", "0.46622723", "0.46603796", "0.46532446", "0.4644531", "0.46384782", "0.4638187", "0.463367", "0.46327448", "0.46324968", "0.4631209", "0.4620887" ]
0.7210541
0
Delete the previous space delimited word.
func (ls *linestate) deletePrevWord() { oldPos := ls.pos // remove spaces for ls.pos > 0 && ls.buf[ls.pos-1] == ' ' { ls.pos-- } // remove word for ls.pos > 0 && ls.buf[ls.pos-1] != ' ' { ls.pos-- } ls.buf = append(ls.buf[:ls.pos], ls.buf[oldPos:]...) ls.refreshLine() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *Model) deleteWordLeft() bool {\n\tif m.pos == 0 || len(m.value) == 0 {\n\t\treturn false\n\t}\n\n\tif m.EchoMode != EchoNormal {\n\t\treturn m.deleteBeforeCursor()\n\t}\n\n\t// Linter note: it's critical that we acquire the initial cursor position\n\t// here prior to altering it via SetCursor() below. As such, moving this\n\t// call into the corresponding if clause does not apply here.\n\toldPos := m.pos //nolint:ifshort\n\n\tblink := m.setCursor(m.pos - 1)\n\tfor unicode.IsSpace(m.value[m.pos]) {\n\t\tif m.pos <= 0 {\n\t\t\tbreak\n\t\t}\n\t\t// ignore series of whitespace before cursor\n\t\tblink = m.setCursor(m.pos - 1)\n\t}\n\n\tfor m.pos > 0 {\n\t\tif !unicode.IsSpace(m.value[m.pos]) {\n\t\t\tblink = m.setCursor(m.pos - 1)\n\t\t} else {\n\t\t\tif m.pos > 0 {\n\t\t\t\t// keep the previous space\n\t\t\t\tblink = m.setCursor(m.pos + 1)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif oldPos > len(m.value) {\n\t\tm.value = m.value[:m.pos]\n\t} else {\n\t\tm.value = append(m.value[:m.pos], m.value[oldPos:]...)\n\t}\n\n\treturn blink\n}", "func (e *T) eraseWord() {\n\tif e.widx <= 0 {\n\t\treturn\n\t}\n\n\t// number of boundary transitions\n\tn := 2\n\n\te.widx--\n\tif isWordRune(rune(e.buf[e.widx])) {\n\t\tn--\n\t}\n\te.buf[e.widx] = 0\n\n\tfor e.widx > 0 {\n\t\te.widx--\n\t\tisword := isWordRune(rune(e.buf[e.widx]))\n\t\tif n == 2 && isword {\n\t\t\tn--\n\t\t} else if n == 1 && !isword {\n\t\t\te.widx++\n\t\t\tbreak\n\t\t}\n\t\te.buf[e.widx] = 0\n\t}\n}", "func (m *Model) deleteWordRight() bool {\n\tif m.pos >= len(m.value) || len(m.value) == 0 {\n\t\treturn false\n\t}\n\n\tif m.EchoMode != EchoNormal {\n\t\treturn m.deleteAfterCursor()\n\t}\n\n\toldPos := m.pos\n\tm.setCursor(m.pos + 1)\n\tfor unicode.IsSpace(m.value[m.pos]) {\n\t\t// ignore series of whitespace after cursor\n\t\tm.setCursor(m.pos + 1)\n\n\t\tif m.pos >= len(m.value) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor m.pos < len(m.value) {\n\t\tif !unicode.IsSpace(m.value[m.pos]) {\n\t\t\tm.setCursor(m.pos + 1)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif m.pos > len(m.value) {\n\t\tm.value = m.value[:oldPos]\n\t} else {\n\t\tm.value = append(m.value[:oldPos], m.value[m.pos:]...)\n\t}\n\n\treturn m.setCursor(oldPos)\n}", "func (tv *TextView) CursorDeleteWord(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\tif tv.HasSelection() {\n\t\ttv.DeleteSelection()\n\t\treturn\n\t}\n\t// note: no update b/c signal from buf will drive update\n\torg := tv.CursorPos\n\ttv.CursorForwardWord(steps)\n\ttv.Buf.DeleteText(org, tv.CursorPos, true, true)\n\ttv.SetCursorShow(org)\n}", "func DeleteExtraSpace(src string) string {\n\t//删除字符串中的多余空格,有多个空格时,仅保留一个空格\n\tnewSrc := strings.Replace(src, \" \", \" \", -1) //替换tab为空格\n\tregStr := \"\\\\s{2,}\" //两个及两个以上空格的正则表达式\n\treg, _ := regexp.Compile(regStr) //编译正则表达式\n\tres := make([]byte, len(newSrc)) //定义字符数组切片\n\tcopy(res, newSrc) //将字符串复制到切片\n\tspcIndex := reg.FindStringIndex(string(res)) //在字符串中搜索\n\tfor len(spcIndex) > 0 { //找到适配项\n\t\tres = append(res[:spcIndex[0]+1], res[spcIndex[1]:]...) //删除多余空格\n\t\tspcIndex = reg.FindStringIndex(string(res)) //继续在字符串中搜索\n\t}\n\treturn string(res)\n}", "func (e *Editor) deleteWord(distance int) {\n\tif distance == 0 {\n\t\treturn\n\t}\n\n\te.makeValid()\n\n\tif e.caret.start.ofs != e.caret.end.ofs {\n\t\te.Delete(1)\n\t\tdistance -= sign(distance)\n\t}\n\tif distance == 0 {\n\t\treturn\n\t}\n\n\t// split the distance information into constituent parts to be\n\t// used independently.\n\twords, direction := distance, 1\n\tif distance < 0 {\n\t\twords, direction = distance*-1, -1\n\t}\n\t// atEnd if offset is at or beyond either side of the buffer.\n\tatEnd := func(offset int) bool {\n\t\tidx := e.caret.start.ofs + offset*direction\n\t\treturn idx <= 0 || idx >= e.editBuffer.len()\n\t}\n\t// next returns the appropriate rune given the direction and offset.\n\tnext := func(offset int) (r rune) {\n\t\tidx := e.caret.start.ofs + offset*direction\n\t\tif idx < 0 {\n\t\t\tidx = 0\n\t\t} else if idx > e.editBuffer.len() {\n\t\t\tidx = e.editBuffer.len()\n\t\t}\n\t\tif direction < 0 {\n\t\t\tr, _ = e.editBuffer.runeBefore(idx)\n\t\t} else {\n\t\t\tr, _ = e.editBuffer.runeAt(idx)\n\t\t}\n\t\treturn r\n\t}\n\tvar runes = 1\n\tfor ii := 0; ii < words; ii++ {\n\t\tif r := next(runes); unicode.IsSpace(r) {\n\t\t\tfor r := next(runes); unicode.IsSpace(r) && !atEnd(runes); r = next(runes) {\n\t\t\t\trunes += 1\n\t\t\t}\n\t\t} else {\n\t\t\tfor r := next(runes); !unicode.IsSpace(r) && !atEnd(runes); r = next(runes) {\n\t\t\t\trunes += 1\n\t\t\t}\n\t\t}\n\t}\n\te.Delete(runes * direction)\n}", "func (t *Trie) Delete(word string) {\n\tn := t.find(word)\n\tif n.end == true {\n\t\tn.end = false\n\t}\n}", "func (i *Input) Backspace() {\n\tif i.Pos > 0 {\n\t\ti.Buffer.RemoveRune(i.Pos - 1)\n\t\ti.Pos--\n\t}\n}", "func (tv *TextView) CursorBackspaceWord(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\torg := tv.CursorPos\n\tif tv.HasSelection() {\n\t\ttv.DeleteSelection()\n\t\ttv.SetCursorShow(org)\n\t\treturn\n\t}\n\t// note: no update b/c signal from buf will drive update\n\ttv.CursorBackwardWord(steps)\n\ttv.ScrollCursorToCenterIfHidden()\n\ttv.RenderCursor(true)\n\ttv.Buf.DeleteText(tv.CursorPos, org, true, true)\n}", "func deleted(s split, save func(string)) {\n\tif s.R != \"\" {\n\t\tsave(s.L + s.R[1:])\n\t}\n}", "func (s StringSet) Del(x string) { delete(s, x) }", "func removeSpace(s string) string {\n\trunes := []rune(s)\n\tout := runes[:0] // zero-length slice of original\n\tfor i := 0; i < len(runes); i++ {\n\t\tif i == 0 {\n\t\t\tout = append(out, runes[i])\n\t\t} else if !unicode.IsSpace(runes[i]) || !unicode.IsSpace(runes[i-1]) {\n\t\t\tout = append(out, runes[i])\n\t\t}\n\t}\n\treturn string(out)\n}", "func step1(w string) string {\n\tvar suffixes []string = []string{\"erendes\", \"erende\", \"hedens\", \"erede\", \"ethed\", \"heden\", \"endes\", \"erets\", \"heder\", \"ernes\", \"erens\", \"ered\", \"ende\", \"erne\", \"eres\", \"eren\", \"eret\", \"erer\", \"enes\", \"heds\", \"ens\", \"ene\", \"ere\", \"ers\", \"ets\", \"hed\", \"es\", \"et\", \"er\", \"en\", \"e\"}\n\n\tfor _, suffix := range suffixes {\n\t\tif searchInR1(w, suffix) {\n i := str.LastIndex(w, suffix)\n w = w[:i]\n break\n\t\t}\n\t}\n\n\t// s\n\t// delete if preceded by a valid s-ending\n\tif searchInR1(w, \"s\") {\n\t\tif hasValidEnding(w) == true {\n\t\t\tw = str.TrimSuffix(w, \"s\")\n\t\t}\n\t}\n\n\treturn w\n}", "func (l *ListInfo) deleteRune() {\n\tsc := []rune(l.Keyword)\n\tl.Keyword = string(sc[:(len(sc) - 1)])\n}", "func SpaceInOne(s string) string {\n\tvar old string\n\tfor old != s {\n\t\told = s\n\t\ts = spaceReplacer.Replace(s)\n\t}\n\treturn s\n}", "func (r *runestring) Del(pos ...int) {\n\tfor _, i := range pos {\n\t\tif i >= 0 && i <= len(*r) {\n\t\t\t*r = append((*r)[:i], (*r)[i+1:]...)\n\t\t}\n\t}\n}", "func removeExtraSpaces(s string) string {\n\tnewString := \"\"\n\tvar prev byte\n\tfor i, v := range s {\n\t\tif v == ' ' && prev == ' ' {\n\t\t\tprev = s[i]\n\t\t\tcontinue\n\t\t}\n\t\tprev = s[i]\n\t\tif v == '\\t' {\n\t\t\tcontinue\n\t\t}\n\t\t// If the value is \\n then we need to add \\n> to keep the formatting\n\t\t// of the spark message the same.\n\t\tif v == '\\n' {\n\t\t\tnewString += \"\\n> \"\n\t\t}\n\t\tnewString += string(v)\n\t}\n\tif len(newString) > 1000 {\n\t\tsubstring := newString[:999]\n\t\tsubstring += \"...\"\n\t\treturn substring\n\t}\n\treturn newString\n}", "func historyDelete(splited []string, length int) {\n if length == 2 {\n connect.DeleteGlobalMessages()\n return\n }\n connect.DeleteLocalMessages(splited[2:])\n}", "func RemoveMiddleSpaces(s string) string {\n\treturn strings.Join(Tokenize(s), \" \")\n}", "func RemoveChar(word string) string {\n\treturn word[1 : len(word)-1]\n}", "func (r Dictionary) Delete(word string) {\n\tdelete(r, word)\n}", "func (d Dictionary) Delete(word string) {\n\tdelete(d, word)\n}", "func (n *Node) Delete(w string) bool {\n\tcur := n\n\tvar found bool\n\tpath := []*Node{n}\n\tfor _, r := range w {\n\t\tcur, found = cur.children[r]\n\t\tif !found {\n\t\t\treturn false // word not present\n\t\t}\n\t\tpath = append(path, cur)\n\t}\n\tif !cur.term {\n\t\treturn false\n\t}\n\trr := []rune(w)\n\tfor i := len(path) - 2; i >= 0; i-- {\n\t\tif path[i+1].term || len(path[i+1].children) > 0 {\n\t\t\tbreak\n\t\t}\n\t\tdelete(path[i].children, rr[i])\n\t}\n\tcur.term = false\n\treturn true\n}", "func (a Topic) TrimSpace() Topic {\n\treturn Topic(strings.TrimSpace(string(a)))\n}", "func TrimSpace(operand string) string { return strings.TrimSpace(operand) }", "func removeExtraSpaces(val string) string {\n\treturn strings.Join(strings.Fields(val), \" \")\n}", "func lastWord(in string) string {\n\tif ss := strings.Fields(in); len(ss) > 0 {\n\t\treturn ss[len(ss)-1]\n\t}\n\treturn \"\"\n}", "func (e *elephant) deleteOldRaws(before int64) error {\n\treturn db.Unscoped().Model(&Sentiment{}).\n\t\tWhere(\"unix < ?\", before).\n\t\tDelete(&Sentiment{}).\n\t\tError\n}", "func removeAllAfter(s, seps string) string {\n\tfor _, c := range strings.Split(seps, \"\") {\n\t\tif c == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\ti := strings.Index(s, c)\n\t\tif i == -1 {\n\t\t\tcontinue\n\t\t}\n\n\t\ts = s[:i]\n\t}\n\n\treturn s\n}", "func (e *LineEditor) DelChar() {\n\n\t// different handling for at the beginning of the line or middle of line\n\tif e.Cx > 0 {\n\t\trow := e.Row\n\t\tcopy(row[e.Cx-1:], row[e.Cx:])\n\t\trow = row[:len(row)-1]\n\t\te.Row = row\n\t\te.Cx--\n\t}\n}", "func trimLast(text string) string {\n\ttextLen := len(text)\n\tif textLen == 0 {\n\t\treturn text\n\t}\n\treturn text[:textLen-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func nolast(x string) string {\n\treturn x[:len(x)-1]\n}", "func removeExtraNames(input string) string {\n\tinput = strings.Replace(input, \"-\", \" \", -1)\n\tsplitInput := strings.Split(input, \" \")\n\treturn splitInput[0]\n}", "func RemoveStep(message string) string {\n\tposition := strings.Index(message, \":\")\n\tif position > -1 {\n\t\treturn message[position+2:]\n\t}\n\treturn message\n}", "func trim(s string) string {\n\tfor len(s) > 0 {\n\t\tif s[0] <= ' ' {\n\t\t\ts = s[1:]\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\tfor len(s) > 0 {\n\t\tif s[len(s)-1] <= ' ' {\n\t\t\ts = s[:len(s)-1]\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\treturn s\n}", "func (cat *Category) UntrainToken(word string, count int) {\n\tcurCount, keyExists := cat.Tokens[word]\n\n\tif keyExists {\n\t\t// if we're removing equal or more counts than we have, we kill the token\n\t\tif count >= curCount {\n\t\t\tcat.Tally -= cat.Tokens[word]\n\t\t\tdelete(cat.Tokens, word)\n\t\t} else {\n\t\t\tcat.Tokens[word] -= count\n\t\t\tcat.Tally -= count\n\t\t}\n\t}\n}", "func trimSpace(b []byte) string {\n\treturn string(bytes.TrimRight(b, \" \"))\n}", "func trimSpace(b []byte) string {\n\treturn string(bytes.TrimRight(b, \" \"))\n}", "func (p *reParser) words(text, next string) {\n\twords := p.dict.InsertSplit(text)\n\tif len(words) == 0 {\n\t\treturn\n\t}\n\n\t// If the next operator is ??, we need to keep the last word\n\t// separate, so that the ?? will only apply to that word.\n\t// There are no other operators that grab the last word.\n\tvar last Word\n\tif next == \"??\" {\n\t\twords, last = words[:len(words)-1], words[len(words)-1]\n\t}\n\n\t// Add the words (with last possibly removed) into an opWords.\n\t// If there's one atop the stack, use it. Otherwise, add one.\n\tif len(words) > 0 {\n\t\tvar re *reSyntax\n\t\tif len(p.stack) > 0 && p.stack[len(p.stack)-1].op == opWords {\n\t\t\tre = p.stack[len(p.stack)-1]\n\t\t} else {\n\t\t\tre = p.push(&reSyntax{op: opWords})\n\t\t}\n\t\tfor _, w := range words {\n\t\t\tre.w = append(re.w, w.ID)\n\t\t}\n\t}\n\n\t// Add the last word if needed.\n\tif next == \"??\" {\n\t\tp.stack = append(p.stack, &reSyntax{op: opWords, w: []WordID{last.ID}})\n\t}\n}", "func trim(s []byte) []byte {\n\ti := 0\n\tfor i < len(s) && (s[i] == ' ' || s[i] == '\\t') {\n\t\ti++\n\t}\n\tn := len(s)\n\tfor n > i && (s[n-1] == ' ' || s[n-1] == '\\t') {\n\t\tn--\n\t}\n\treturn s[i:n]\n}", "func trim(s []byte) []byte {\n\ti := 0\n\tfor i < len(s) && (s[i] == ' ' || s[i] == '\\t') {\n\t\ti++\n\t}\n\tn := len(s)\n\tfor n > i && (s[n-1] == ' ' || s[n-1] == '\\t') {\n\t\tn--\n\t}\n\treturn s[i:n]\n}", "func (l *StringLexer) Backup() {\n\tl.pos -= l.width\n\tif l.width == 1 && l.pos >= 0 && l.inputLen() > l.pos {\n\t\tif l.input[l.pos] == '\\n' {\n\t\t\tl.line--\n\t\t}\n\t}\n}", "func TrimLeadingSpaces(p []byte) []byte {\n\tfor i := 0; i < len(p); i++ {\n\t\tif p[i] != 0x20 && p[i] != '\\t' {\n\t\t\treturn p[i:]\n\t\t}\n\t}\n\t// it was all spaces\n\treturn p[:0]\n}", "func SpacePrefix(line string) (prefix string) {\n\tfor len(line) > 0 {\n\t\tif line[0] != ' ' && line[0] != '\\t' {\n\t\t\tbreak\n\t\t}\n\n\t\tprefix = prefix + string(line[0])\n\n\t\tline = line[1:]\n\t}\n\n\treturn prefix\n}", "func lexSpace(l *lexer) stateFn {\r\n\tfor {\r\n\t\tif !isSpace(l.next()) {\r\n\t\t\tl.backup()\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n\t//l.emit(TokS)\r\n\tl.ignore()\r\n\treturn lexAny\r\n}", "func (tv *TextView) WordBefore(tp TextPos) *TextBufEdit {\n\ttxt := tv.Buf.Line(tp.Ln)\n\tch := tp.Ch\n\tch = ints.MinInt(ch, len(txt))\n\tst := ch\n\tfor i := ch - 1; i >= 0; i-- {\n\t\tif i == 0 { // start of line\n\t\t\tst = 0\n\t\t\tbreak\n\t\t}\n\t\tr1 := txt[i]\n\t\tr2 := txt[i-1]\n\t\tif tv.IsWordBreak(r1, r2) {\n\t\t\tst = i + 1\n\t\t\tbreak\n\t\t}\n\t}\n\tif st != ch {\n\t\treturn tv.Buf.Region(TextPos{Ln: tp.Ln, Ch: st}, tp)\n\t}\n\treturn nil\n}", "func FirstSpace(str string) string {\n\tif len(str) >= 1 && str[0] == ' ' {\n\t\treturn str[1:]\n\t} else {\n\t\treturn str\n\t}\n}", "func skipSpace(s string) (rest string) {\r\n\ti := 0\r\n\tfor ; i < len(s); i++ {\r\n\t\tif b := s[i]; b != ' ' && b != '\\t' {\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n\treturn s[i:]\r\n}", "func removeSpaces(val string) string {\n\treturn strings.Join(strings.Fields(val), \"_\")\n}", "func TrimSpace(ctx context.Context, t *mold.Transformer, v reflect.Value) error {\n\tv.Set(reflect.ValueOf(strings.TrimSpace(v.String())))\n\treturn nil\n}", "func (p Prefix) Shift(word string) {\n\tcopy(p, p[1:])\n\tp[len(p)-1] = word\n}", "func (b *Bar) TrimLeftSpace() *Bar {\n\tif isClosed(b.done) {\n\t\treturn b\n\t}\n\tb.trimLeftCh <- true\n\treturn b\n}", "func (l *Lexer) skipWitespace() {\n\tfor l.ch == ' ' || l.ch == '\\t' || l.ch == '\\n' || l.ch == '\\r' {\n\t\tl.readChar()\n\t}\n}", "func trimLeadingWhiteSpace(s []byte) []byte {\n\tfor (len(s) > 0) && ((s[0] == ' ') || (s[0] == '\\t')) {\n\t\ts = s[1:]\n\t}\n\treturn s\n}", "func (d Dictionary) Delete(word string) error {\r\n\t// 먼저 삭제할 단어가 있나 확인\r\n\t_, err := d.Search(word)\r\n\tswitch err {\r\n\tcase nil: //단어 있으면\r\n\t\tdelete(d, word)\r\n\tcase errNotFound: //단어 없으면\r\n\t\treturn errCantDelete //삭제할 수 없옹~\r\n\t}\r\n\t// 단어 삭제하고 nil 반환\r\n\treturn nil\r\n}", "func pop(s []string) string {\n\tpop := s[0]\n\ts = remove(s, pop)\n\treturn pop\n}", "func squashSpace(bytes []byte) []byte {\n\tvar r rune\n\tvar l, pos int\n\tout := bytes[:0] // zero-length slice of original\n\tisRunSquashed := false // Is the current run of spaces squashed?\n\tfor range string(bytes) {\n\t\tr, l = utf8.DecodeRune(bytes[pos:])\n\t\tif unicode.IsSpace(r) {\n\t\t\tif isRunSquashed {\n\t\t\t\tpos += l\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tout = append(out, ' ')\n\t\t\t\tisRunSquashed = true\n\t\t\t}\n\t\t} else {\n\t\t\tfor i := 0; i < l; i++ {\n\t\t\t\tout = append(out, bytes[pos+i])\n\t\t\t}\n\t\t\tisRunSquashed = false\n\t\t}\n\t\tpos += l\n\t}\n\treturn out\n}", "func (b *pebbleBucket) DelBeforeTS(ts uint64) error {\n\tstart, end := b.name, keyUpperBound(b.name)\n\titer := b.db.NewIter(b.prefixIterOpts)\n\tfor iter.First(); iter.Valid(); iter.Next() {\n\t\t_, kts := decodeBatchKey(iter.Key(), b.name)\n\t\tif kts > ts {\n\t\t\tend = iter.Key()\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn errors.Trace(b.db.DeleteRange(start, end, b.writeOpts))\n}", "func DeleteWhiteSpace(str string) string {\n\tif str == \"\" {\n\t\treturn str\n\t}\n\tsz := len(str)\n\tvar chs bytes.Buffer\n\tcount := 0\n\tfor i := 0; i < sz; i++ {\n\t\tch := rune(str[i])\n\t\tif !unicode.IsSpace(ch) {\n\t\t\tchs.WriteRune(ch)\n\t\t\tcount++\n\t\t}\n\t}\n\tif count == sz {\n\t\treturn str\n\t}\n\treturn chs.String()\n}", "func removeChar(str string, removedStr string) string {\n\treturn strings.Replace(str, removedStr, \" \", -1)\n}", "func (s *streamKey) trimBefore(id string) int {\n\ts.mu.Lock()\n\tvar delete []string\n\tfor _, entry := range s.entries {\n\t\tif entry.ID < id {\n\t\t\tdelete = append(delete, entry.ID)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\ts.mu.Unlock()\n\ts.delete(delete)\n\treturn len(delete)\n}", "func Delete(str string, pattern string) string {\n\treturn xstrings.Delete(str, pattern)\n}", "func (b *pebbleBucket) DelBeforeID(id uint64) error {\n\tstart := b.name\n\tend := keyUpperBound(append(start, store.U64ToByte(id)...))\n\treturn errors.Trace(b.db.DeleteRange(start, end, pebble.NoSync))\n}", "func (set StringSet) Del(str string) {\n\tdelete(set, str)\n}", "func (t *Text) TrimSpace() *Text {\n\tleft := 0\n\toutput := strings.TrimLeftFunc(t.output, func(r rune) bool {\n\t\tif unicode.IsSpace(r) {\n\t\t\tleft++\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t})\n\n\toutput = strings.TrimRightFunc(output, unicode.IsSpace)\n\tt.lines[t.textLines] = output\n\treturn t\n}", "func (p Prefix) Shift(word string) string {\r\n\telem := p[0]\r\n\tcopy(p, p[1:])\r\n\tp[len(p)-1] = word\r\n\treturn elem\r\n}", "func (ls *linestate) deleteToEnd() {\n\tls.buf = ls.buf[:ls.pos]\n\tls.refreshLine()\n}", "func Dashed(input string) string {\n\treturn strings.Join(lowerSlice(getElements(input)), \"-\")\n}", "func (e EmbeddedString) Trim() string {\n\ts := string(e)\n\tif strings.HasPrefix(s, \"// Copyright \") {\n\t\tif i := strings.Index(s, \"\\n\\n\"); i >= 0 {\n\t\t\ts = s[i+2:]\n\t\t}\n\t}\n\treturn s\n}", "func (db *FastDB) StrRem(key []byte) error {\n\tif err := db.checkKeyValue(key, nil); err != nil {\n\t\treturn err\n\t}\n\n\tdb.strIndex.mu.Lock()\n\tdefer db.strIndex.mu.Unlock()\n\n\te := storage.NewEntryNoExtra(key, nil, String, StringRem)\n\tif err := db.store(e); err != nil {\n\t\treturn err\n\t}\n\n\tdb.incrReclaimableSpace(key)\n\tdb.strIndex.idxList.Remove(key)\n\tdelete(db.expires[String], string(key))\n\treturn nil\n}", "func skipToNonSpaceCharacter(s *string) (ok bool) {\n\tfor i, c := range *s {\n\t\tif c != ' ' {\n\t\t\t*s = (*s)[i:]\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ClearLinePartialForward() {\n\temitEscape(\"K\")\n}", "func TrimRedundantSpaces(text string) string {\n\ttext = spaceRegex.ReplaceAllString(text, \" \")\n\treturn strings.TrimSpace(text)\n}", "func (tv *TextView) CursorBackwardWord(steps int) {\n\twupdt := tv.TopUpdateStart()\n\tdefer tv.TopUpdateEnd(wupdt)\n\ttv.ValidateCursor()\n\torg := tv.CursorPos\n\tfor i := 0; i < steps; i++ {\n\t\ttxt := tv.Buf.Line(tv.CursorPos.Ln)\n\t\tsz := len(txt)\n\t\tif sz > 0 && tv.CursorPos.Ch > 0 {\n\t\t\tch := ints.MinInt(tv.CursorPos.Ch, sz-1)\n\t\t\tvar done = false\n\t\t\tfor ch < sz && !done { // if on a wb, go past\n\t\t\t\tr1 := txt[ch]\n\t\t\t\tr2 := rune(-1)\n\t\t\t\tif ch > 0 {\n\t\t\t\t\tr2 = txt[ch-1]\n\t\t\t\t}\n\t\t\t\tif tv.IsWordBreak(r1, r2) {\n\t\t\t\t\tch--\n\t\t\t\t\tif ch == -1 {\n\t\t\t\t\t\tdone = true\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdone = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tdone = false\n\t\t\tfor ch < sz && ch >= 0 && !done {\n\t\t\t\tr1 := txt[ch]\n\t\t\t\tr2 := rune(-1)\n\t\t\t\tif ch > 0 {\n\t\t\t\t\tr2 = txt[ch-1]\n\t\t\t\t}\n\t\t\t\tif !tv.IsWordBreak(r1, r2) {\n\t\t\t\t\tch--\n\t\t\t\t} else {\n\t\t\t\t\tdone = true\n\t\t\t\t}\n\t\t\t}\n\t\t\ttv.CursorPos.Ch = ch\n\t\t} else {\n\t\t\tif tv.CursorPos.Ln > 0 {\n\t\t\t\ttv.CursorPos.Ln--\n\t\t\t\ttv.CursorPos.Ch = tv.Buf.LineLen(tv.CursorPos.Ln)\n\t\t\t} else {\n\t\t\t\ttv.CursorPos.Ch = 0\n\t\t\t}\n\t\t}\n\t}\n\ttv.SetCursorCol(tv.CursorPos)\n\ttv.SetCursorShow(tv.CursorPos)\n\ttv.CursorSelect(org)\n}", "func trim(name string) string {\n\treturn strings.TrimPrefix(name, Prefix)\n}", "func (c *Core) QuoteWord(s string) string {\n\tcharLeft, charRight := c.db.GetChars()\n\treturn doQuoteWord(s, charLeft, charRight)\n}", "func (i *Input) backspace() {\n\tcurLine := i.lines[i.cursorLineIndex]\n\t// at the beginning of the buffer, nothing to do\n\tif len(curLine) == 0 && i.cursorLineIndex == 0 {\n\t\treturn\n\t}\n\n\t// at the beginning of a line somewhere in the buffer\n\tif i.cursorLinePos == 0 {\n\t\tprevLine := i.lines[i.cursorLineIndex-1]\n\t\t// remove the newline character from the prevline\n\t\tprevLine = prevLine[:len(curLine)-1] + curLine\n\t\ti.lines = append(i.lines[:i.cursorLineIndex], i.lines[i.cursorLineIndex+1:]...)\n\t\ti.cursorLineIndex--\n\t\ti.cursorLinePos = len(prevLine) - 1\n\t\treturn\n\t}\n\n\t// I'm at the end of a line\n\tif i.cursorLinePos == len(curLine)-1 {\n\t\ti.lines[i.cursorLineIndex] = curLine[:len(curLine)-1]\n\t\ti.cursorLinePos--\n\t\treturn\n\t}\n\n\t// I'm in the middle of a line\n\ti.lines[i.cursorLineIndex] = curLine[:i.cursorLinePos-1] + curLine[i.cursorLinePos:]\n\ti.cursorLinePos--\n}", "func (a *insertApp) backward(app *App, args ...interface{}) {\n\tdb.Session.Apps().Remove(bson.M{\"name\": app.Name})\n}", "func (t *Trie) Remove(word string) error {\n\ttermNode, err := t.Find(word)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not find word %s in trie: %s\", word, err)\n\t}\n\n\ttermNode.SetTerm(false)\n\n\tcurNode := termNode\n\tfor !curNode.IsTerm() && !curNode.IsRoot() && len(curNode.Children()) == 0 {\n\t\tcurNode.Parent().RemoveChild(curNode.Value())\n\t\tcurNode = curNode.Parent()\n\t}\n\n\treturn nil\n}", "func (m *NodeMutation) ClearPrev() {\n\tm.clearedprev = true\n}", "func clearSpaces() {\n\tfor readSpace() {\n\t} //\tEat spaces and tabs until character.\n}", "func DelDirtyCharacter(str string) string {\n\tres := \"\"\n\tif len(str) > 0 {\n\t\treg, _ := regexp.Compile(\"[ \\f\\n\\r\\t\\v ]+\")\n\t\tres = reg.ReplaceAllString(str, \"\")\n\t}\n\treturn res\n}", "func (d Dictionary) Delete(word string) error {\n\t_, err := d.Search(word)\n\tif err != nil {\n\t\treturn errCantDelete\n\t}\n\tdelete(d, word)\n\treturn nil\n}", "func (m *Model) wordLeft() bool {\n\tif m.pos == 0 || len(m.value) == 0 {\n\t\treturn false\n\t}\n\n\tif m.EchoMode != EchoNormal {\n\t\treturn m.cursorStart()\n\t}\n\n\tblink := false\n\ti := m.pos - 1\n\tfor i >= 0 {\n\t\tif unicode.IsSpace(m.value[i]) {\n\t\t\tblink = m.setCursor(m.pos - 1)\n\t\t\ti--\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor i >= 0 {\n\t\tif !unicode.IsSpace(m.value[i]) {\n\t\t\tblink = m.setCursor(m.pos - 1)\n\t\t\ti--\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn blink\n}", "func TrimLeft(chars string, operand string) string { return strings.TrimLeft(operand, chars) }", "func removeSpaces(stringWithSpaces string) string {\n\t// First version: Split on spaces and join on nothing. It's simple to read, but may not benchmark well.\n\t// Using ReplaceAll is more straightforward but won't strip non-space whitespace characters\n\treturn strings.Replace(stringWithSpaces, \" \", \"\", -1)\n}", "func WordEol(s string, wordIdx int) string {\n\tsplit := strings.Split(s, \" \")\n\tif wordIdx > -1 && len(split) >= wordIdx {\n\t\treturn strings.Join(split[wordIdx:], \" \")\n\t}\n\n\treturn \"\"\n}", "func Drop(n int, s string) string {\n\tfor i := range s {\n\t\tif n <= 0 {\n\t\t\treturn s[i:]\n\t\t}\n\t\tn--\n\t}\n\treturn \"\"\n}", "func trimWS(input string) string {\n\n\tvar out strings.Builder\n\tfor _, v := range input {\n\t\tif !(v == '\\u0009' || v == '\\u0020' || v == '\\u000A' || v == '\\u000D' || v == ',') {\n\t\t\tout.WriteRune(v)\n\t\t}\n\t}\n\treturn out.String()\n\n}", "func trim_string_before_s(s string, x string) (r string) {\n\tif idx := strings.LastIndex(s, x); idx != -1 {\n\t\treturn s[idx+1:]\n\t}\n\treturn s\n}", "func (d *DeltaStrSet) RemoveSingle(l string) {\n\tif _, ok := d.items[l]; ok {\n\t\tdelete(d.items, l)\n\t}\n}", "func (m *Model) deleteBeforeCursor() bool {\n\tm.value = m.value[m.pos:]\n\tm.offset = 0\n\treturn m.setCursor(0)\n}", "func (puo *PatientrecordUpdateOne) ClearPrename() *PatientrecordUpdateOne {\n\tpuo.mutation.ClearPrename()\n\treturn puo\n}" ]
[ "0.6380284", "0.60116595", "0.587871", "0.5683424", "0.5532775", "0.5530384", "0.54660577", "0.53705055", "0.5324776", "0.52727824", "0.52578044", "0.52554303", "0.5165702", "0.51439315", "0.51089376", "0.5071629", "0.5062739", "0.50529975", "0.50131184", "0.5012857", "0.50095683", "0.49678227", "0.49608612", "0.4932126", "0.4907751", "0.4885621", "0.48472792", "0.4821388", "0.48147503", "0.48058057", "0.47908124", "0.47841647", "0.47841647", "0.47841647", "0.47841647", "0.47841647", "0.47841647", "0.47841647", "0.47841647", "0.47835913", "0.47802186", "0.47690833", "0.4745333", "0.47427532", "0.47427532", "0.47345328", "0.47134838", "0.47134838", "0.46966895", "0.46746942", "0.46730554", "0.46675998", "0.4658623", "0.4645769", "0.46387133", "0.4635457", "0.46347675", "0.46345899", "0.46265706", "0.4618161", "0.46153954", "0.4609061", "0.4608574", "0.46004742", "0.45871416", "0.45863476", "0.45794624", "0.45775437", "0.45733154", "0.4571286", "0.4557589", "0.4555515", "0.4554177", "0.45512238", "0.45464596", "0.45348167", "0.45320156", "0.45273826", "0.45264867", "0.45263952", "0.45220086", "0.45217696", "0.45210302", "0.45138013", "0.45127955", "0.45119745", "0.45103052", "0.4505527", "0.45027313", "0.45021486", "0.44915366", "0.44909462", "0.449093", "0.44897848", "0.4486702", "0.448571", "0.4482769", "0.44824898", "0.4472358", "0.44654015" ]
0.78003573
0
Show completions for the current line.
func (ls *linestate) completeLine() rune { // get a list of line completions lc := ls.ts.completionCallback(ls.String()) if len(lc) == 0 { // no line completions beep() return KeycodeNull } // navigate and display the line completions stop := false idx := 0 u := utf8{} var r rune for !stop { if idx < len(lc) { // save the line buffer savedBuf := ls.buf savedPos := ls.pos // show the completion ls.buf = []rune(lc[idx]) ls.pos = len(ls.buf) ls.refreshLine() // restore the line buffer ls.buf = savedBuf ls.pos = savedPos } else { // show the original buffer ls.refreshLine() } // navigate through the completions r = u.getRune(ls.ifd, nil) if r == KeycodeNull { // error on read stop = true } else if r == KeycodeTAB { // loop through the completions idx = (idx + 1) % (len(lc) + 1) if idx == len(lc) { beep() } } else if r == KeycodeESC { // could be an escape, could be an escape sequence if wouldBlock(ls.ifd, &timeout20ms) { // nothing more to read, looks like a single escape // re-show the original buffer if idx < len(lc) { ls.refreshLine() } // don't pass the escape key back r = KeycodeNull } else { // probably an escape sequence // update the buffer and return if idx < len(lc) { ls.buf = []rune(lc[idx]) ls.pos = len(ls.buf) } } stop = true } else { // update the buffer and return if idx < len(lc) { ls.buf = []rune(lc[idx]) ls.pos = len(ls.buf) } stop = true } } // return the last rune read return r }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *SoracomCompleter) Complete(d prompt.Document) []prompt.Suggest {\n\tline := d.CurrentLine()\n\n\t// return from hard corded Commands as atm don't have a way to find top-level commands from API definition\n\tif isFirstCommand(line) {\n\t\ts := filterFunc(Commands, line, prompt.FilterFuzzy)\n\t\tsort.Slice(s, func(i, j int) bool {\n\t\t\treturn s[i].Text < s[j].Text\n\t\t})\n\t\treturn s\n\t}\n\n\tif endsWithPipeOrRedirect(line) {\n\t\treturn []prompt.Suggest{}\n\t}\n\n\treturn s.findSuggestions(line)\n}", "func acceptCompletion(ed *Editor) {\n\tc := ed.completion\n\tif 0 <= c.selected && c.selected < len(c.candidates) {\n\t\ted.line, ed.dot = c.apply(ed.line, ed.dot)\n\t}\n\ted.mode = &ed.insert\n}", "func (o *ViewOptions) Complete(cmdline cmdline.Cmdline, args []string) (err error) {\n\treturn\n}", "func printCompletion() int {\n\tinfo := genUsage()\n\n\tswitch options.GetS(OPT_COMPLETION) {\n\tcase \"bash\":\n\t\tfmt.Printf(bash.Generate(info, \"rbinstall-clone\"))\n\tcase \"fish\":\n\t\tfmt.Printf(fish.Generate(info, \"rbinstall-clone\"))\n\tcase \"zsh\":\n\t\tfmt.Printf(zsh.Generate(info, optMap, \"rbinstall-clone\"))\n\tdefault:\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func TabCompleter(line []rune, pos int) (lastWord string, completions []*readline.CompletionGroup) {\n\n\t// Format and sanitize input\n\targs, last, lastWord := FormatInput(line)\n\n\t// Detect base command automatically\n\tvar command = detectedCommand(args, \"\") // add *commands.Context.Menu in the string here\n\n\t// Propose commands\n\tif noCommandOrEmpty(args, last, command) {\n\t\treturn CompleteMenuCommands(last, pos)\n\t}\n\n\t// Check environment variables\n\tif envVarAsked(args, last) {\n\n\t}\n\n\t// Base command has been identified\n\tif commandFound(command) {\n\n\t\t// If user asks for completions with \"-\" / \"--\", show command options\n\t\tif optionsAsked(args, last, command) {\n\n\t\t}\n\n\t\t// Check environment variables again\n\t\tif envVarAsked(args, last) {\n\n\t\t}\n\n\t\t// Propose argument completion before anything, and if needed\n\t\tif _, yes := argumentRequired(last, args, \"\", command, false); yes { // add *commands.Context.Menu in the string here\n\n\t\t}\n\n\t\t// Then propose subcommands\n\t\tif hasSubCommands(command, args) {\n\n\t\t}\n\n\t\t// Handle subcommand if found (maybe we should rewrite this function and use it also for base command)\n\t\tif _, ok := subCommandFound(last, args, command); ok {\n\n\t\t}\n\t}\n\n\t// -------------------- IMPORTANT ------------------------\n\t// WE NEED TO PASS A DEEP COPY OF THE OBJECTS: OTHERWISE THE COMPLETION SEARCH FUNCTION WILL MESS UP WITH THEM.\n\n\treturn\n}", "func (comp *completion) apply(line string, dot int) (string, int) {\n\ttext := comp.selectedCandidate().text\n\treturn line[:comp.begin] + text + line[comp.end:], comp.begin + len(text)\n}", "func showCursor() {\n\tfmt.Printf(\"\\033[?25h\")\n}", "func ShowCursor() {\n\tfmt.Printf(\"\\033[?25h\")\n}", "func ShowCursor() {\n\tfmt.Printf(\"\\033[?25h\")\n}", "func printCompletion() int {\n\tinfo := genUsage()\n\n\tswitch options.GetS(OPT_COMPLETION) {\n\tcase \"bash\":\n\t\tfmt.Printf(bash.Generate(info, \"init-exporter\"))\n\tcase \"fish\":\n\t\tfmt.Printf(fish.Generate(info, \"init-exporter\"))\n\tcase \"zsh\":\n\t\tfmt.Printf(zsh.Generate(info, optMap, \"init-exporter\"))\n\tdefault:\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func ShowCursor() {\n\tfmt.Printf(CSI + ShowCursorSeq)\n}", "func (tv *TextView) OfferComplete() {\n\tif tv.Buf.Complete == nil || tv.ISearch.On || tv.QReplace.On || tv.IsInactive() {\n\t\treturn\n\t}\n\tif !tv.Buf.Opts.Completion && !tv.ForceComplete {\n\t\treturn\n\t}\n\n\ttv.Buf.Complete.SrcLn = tv.CursorPos.Ln\n\ttv.Buf.Complete.SrcCh = tv.CursorPos.Ch\n\tst := TextPos{tv.CursorPos.Ln, 0}\n\ten := TextPos{tv.CursorPos.Ln, tv.CursorPos.Ch}\n\ttbe := tv.Buf.Region(st, en)\n\tvar s string\n\tif tbe != nil {\n\t\ts = string(tbe.ToBytes())\n\t\ts = strings.TrimLeft(s, \" \\t\") // trim ' ' and '\\t'\n\t}\n\n\t//\tcount := tv.Buf.ByteOffs[tv.CursorPos.Ln] + tv.CursorPos.Ch\n\tcpos := tv.CharStartPos(tv.CursorPos).ToPoint() // physical location\n\tcpos.X += 5\n\tcpos.Y += 10\n\ttv.Buf.SetByteOffs() // make sure the pos offset is updated!!\n\ttv.Buf.CurView = tv\n\ttv.Buf.Complete.Show(s, tv.CursorPos.Ln, tv.CursorPos.Ch, tv.Viewport, cpos, tv.ForceComplete)\n}", "func (c *Completer) Complete(d prompt.Document) []prompt.Suggest {\n\t// shell lib can request duplicate Complete request with empty strings as text\n\t// skipping to avoid cache reset\n\tif d.Text == \"\" {\n\t\treturn nil\n\t}\n\n\tmeta := extractMeta(c.ctx)\n\n\targsBeforeCursor := meta.CliConfig.Alias.ResolveAliases(strings.Split(d.TextBeforeCursor(), \" \"))\n\targsAfterCursor := meta.CliConfig.Alias.ResolveAliases(strings.Split(d.TextAfterCursor(), \" \"))\n\tcurrentArg := lastArg(argsBeforeCursor) + firstArg(argsAfterCursor)\n\n\t// leftArgs contains all arguments before the one with the cursor\n\tleftArgs := trimLastArg(argsBeforeCursor)\n\t// rightWords contains all words after the selected one\n\trightWords := trimFirstArg(argsAfterCursor)\n\n\tleftWords := append([]string{\"scw\"}, leftArgs...)\n\n\tacr := AutoComplete(c.ctx, leftWords, currentArg, rightWords)\n\n\tsuggestions := []prompt.Suggest(nil)\n\trawSuggestions := []string(acr.Suggestions)\n\n\t// if first suggestion is an option, all suggestions should be options\n\t// we sort them\n\tif len(rawSuggestions) > 0 && argIsOption(rawSuggestions[0]) {\n\t\trawSuggestions = sortOptions(meta, leftArgs, rawSuggestions[0], rawSuggestions)\n\t}\n\n\tfor _, suggest := range rawSuggestions {\n\t\tsuggestions = append(suggestions, prompt.Suggest{\n\t\t\tText: suggest,\n\t\t\tDescription: getSuggestDescription(meta, leftArgs, suggest),\n\t\t})\n\t}\n\n\treturn prompt.FilterHasPrefix(suggestions, currentArg, true)\n}", "func (c *Completer) Complete(ctx *Context, content IContent, line interface{}, index int) (interface{}, bool) {\n\treturn nil, false\n}", "func (w *VT100Writer) ShowCursor() {\n\tw.WriteRaw([]byte{0x1b, '[', '?', '1', '2', 'l', 0x1b, '[', '?', '2', '5', 'h'})\n}", "func CursorNextLine(n int) {\n\tfmt.Printf(CSI+CursorNextLineSeq, n)\n}", "func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error) {\n\t// should be the first defer statement to make sure it is executed last\n\t// and all the needed cleanup can be done before\n\tcancel, exit := internal.NewCancelationSignal(p.OnInterruptFunc)\n\tdefer exit()\n\n\tif len(text) == 0 || Sprint(text[0]) == \"\" {\n\t\ttext = []string{p.DefaultText}\n\t}\n\n\tp.text = p.TextStyle.Sprint(text[0])\n\tp.fuzzySearchMatches = append([]string{}, p.Options...)\n\n\tif p.MaxHeight == 0 {\n\t\tp.MaxHeight = DefaultInteractiveMultiselect.MaxHeight\n\t}\n\n\tmaxHeight := p.MaxHeight\n\tif maxHeight > len(p.fuzzySearchMatches) {\n\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t}\n\n\tif len(p.Options) == 0 {\n\t\treturn nil, fmt.Errorf(\"no options provided\")\n\t}\n\n\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[:maxHeight]...)\n\tp.displayedOptionsStart = 0\n\tp.displayedOptionsEnd = maxHeight\n\n\tfor _, option := range p.DefaultOptions {\n\t\tp.selectOption(option)\n\t}\n\n\tarea, err := DefaultArea.Start(p.renderSelectMenu())\n\tdefer area.Stop()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not start area: %w\", err)\n\t}\n\n\tif p.Filter && (p.KeyConfirm == keys.Space || p.KeySelect == keys.Space) {\n\t\treturn nil, fmt.Errorf(\"if filter/search is active, keys.Space can not be used for KeySelect or KeyConfirm\")\n\t}\n\n\tarea.Update(p.renderSelectMenu())\n\n\tcursor.Hide()\n\tdefer cursor.Show()\n\terr = keyboard.Listen(func(keyInfo keys.Key) (stop bool, err error) {\n\t\tkey := keyInfo.Code\n\n\t\tif p.MaxHeight > len(p.fuzzySearchMatches) {\n\t\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t\t} else {\n\t\t\tmaxHeight = p.MaxHeight\n\t\t}\n\n\t\tswitch key {\n\t\tcase p.KeyConfirm:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tarea.Update(p.renderFinishedMenu())\n\t\t\treturn true, nil\n\t\tcase p.KeySelect:\n\t\t\tif len(p.fuzzySearchMatches) > 0 {\n\t\t\t\t// Select option if not already selected\n\t\t\t\tp.selectOption(p.fuzzySearchMatches[p.selectedOption])\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.RuneKey:\n\t\t\tif p.Filter {\n\t\t\t\t// Fuzzy search for options\n\t\t\t\t// append to fuzzy search string\n\t\t\t\tp.fuzzySearchString += keyInfo.String()\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[:maxHeight]...)\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Space:\n\t\t\tif p.Filter {\n\t\t\t\tp.fuzzySearchString += \" \"\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tarea.Update(p.renderSelectMenu())\n\t\t\t}\n\t\tcase keys.Backspace:\n\t\t\t// Remove last character from fuzzy search string\n\t\t\tif len(p.fuzzySearchString) > 0 {\n\t\t\t\t// Handle UTF-8 characters\n\t\t\t\tp.fuzzySearchString = string([]rune(p.fuzzySearchString)[:len([]rune(p.fuzzySearchString))-1])\n\t\t\t}\n\n\t\t\tif p.fuzzySearchString == \"\" {\n\t\t\t\tp.fuzzySearchMatches = append([]string{}, p.Options...)\n\t\t\t}\n\n\t\t\tp.renderSelectMenu()\n\n\t\t\tif len(p.fuzzySearchMatches) > p.MaxHeight {\n\t\t\t\tmaxHeight = p.MaxHeight\n\t\t\t} else {\n\t\t\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t\t\t}\n\n\t\t\tp.selectedOption = 0\n\t\t\tp.displayedOptionsStart = 0\n\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Left:\n\t\t\t// Unselect all options\n\t\t\tp.selectedOptions = []int{}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Right:\n\t\t\t// Select all options\n\t\t\tp.selectedOptions = []int{}\n\t\t\tfor i := 0; i < len(p.Options); i++ {\n\t\t\t\tp.selectedOptions = append(p.selectedOptions, i)\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Up:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tif p.selectedOption > 0 {\n\t\t\t\tp.selectedOption--\n\t\t\t\tif p.selectedOption < p.displayedOptionsStart {\n\t\t\t\t\tp.displayedOptionsStart--\n\t\t\t\t\tp.displayedOptionsEnd--\n\t\t\t\t\tif p.displayedOptionsStart < 0 {\n\t\t\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\t\t}\n\t\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp.selectedOption = len(p.fuzzySearchMatches) - 1\n\t\t\t\tp.displayedOptionsStart = len(p.fuzzySearchMatches) - maxHeight\n\t\t\t\tp.displayedOptionsEnd = len(p.fuzzySearchMatches)\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t}\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Down:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tp.displayedOptions = p.fuzzySearchMatches[:maxHeight]\n\t\t\tif p.selectedOption < len(p.fuzzySearchMatches)-1 {\n\t\t\t\tp.selectedOption++\n\t\t\t\tif p.selectedOption >= p.displayedOptionsEnd {\n\t\t\t\t\tp.displayedOptionsStart++\n\t\t\t\t\tp.displayedOptionsEnd++\n\t\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t}\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.CtrlC:\n\t\t\tcancel()\n\t\t\treturn true, nil\n\t\t}\n\n\t\treturn false, nil\n\t})\n\tif err != nil {\n\t\tError.Println(err)\n\t\treturn nil, fmt.Errorf(\"failed to start keyboard listener: %w\", err)\n\t}\n\n\tvar result []string\n\tfor _, selectedOption := range p.selectedOptions {\n\t\tresult = append(result, p.Options[selectedOption])\n\t}\n\n\treturn result, nil\n}", "func Complete() *cobra.Command {\n\tcmd := &cobra.Command{\n\t\tUse: \"complete\",\n\t\tAliases: []string{\"completion\"},\n\t\tHidden: true,\n\t\tShort: \"Generate script for auto-completion\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif name, _ := cmd.Flags().GetString(\"executable\"); name != \"\" {\n\t\t\t\tcmd.Root().Use = name\n\t\t\t}\n\t\t\tswitch shell, _ := cmd.Flags().GetString(\"shell\"); shell {\n\t\t\tcase \"bash\":\n\t\t\t\treturn cmd.Root().GenBashCompletion(os.Stdout)\n\t\t\tcase \"zsh\":\n\t\t\t\treturn cmd.Root().GenZshCompletion(os.Stdout)\n\t\t\tcase \"fish\":\n\t\t\t\t// Fish does not accept `-` in variable names\n\t\t\t\tbuf := new(bytes.Buffer)\n\t\t\t\tif err := cmd.Root().GenFishCompletion(buf, true); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tscript := strings.Replace(buf.String(), \"__ttn-lw-\", \"__ttn_lw_\", -1)\n\t\t\t\t_, err := fmt.Print(script)\n\t\t\t\treturn err\n\t\t\tcase \"powershell\":\n\t\t\t\treturn cmd.Root().GenPowerShellCompletion(os.Stdout)\n\t\t\tdefault:\n\t\t\t\treturn errInvalidShell.WithAttributes(\"shell\", shell)\n\t\t\t}\n\t\t},\n\t}\n\tcmd.Flags().String(\"shell\", \"bash\", \"bash|zsh|fish|powershell\")\n\tcmd.Flags().String(\"executable\", \"\", \"Executable name to create generate auto completion script for\")\n\treturn cmd\n}", "func (s *SoracomCompleter) flagSuggestions(line string) []prompt.Suggest {\n\tcommands, flags := splitToCommandsAndFlags(line) // split again...\n\tmethods, found := s.searchMethods(commands)\n\tif !found || len(methods) != 1 {\n\t\treturn []prompt.Suggest{{\n\t\t\tText: \"Error\",\n\t\t\tDescription: \"cannot find matching command\",\n\t\t}}\n\t}\n\tmethod := methods[0]\n\n\tparams := make([]param, 0) // all parameters for the method\n\tfor _, p := range method.Parameters {\n\t\tparams = append(params, param{\n\t\t\tname: strings.ReplaceAll(p.Name, \"_\", \"-\"),\n\t\t\trequired: p.Required,\n\t\t\tdescription: p.Description,\n\t\t\tparamType: p.Type,\n\t\t\tenum: p.Enum,\n\t\t})\n\t}\n\n\t// soracom-cli will augment some commands with 'fetch-all' option, which is not defined in the swagger\n\tfor _, a := range commandsWithFetchAll {\n\t\tif strings.HasPrefix(commands, a) {\n\t\t\tparams = append(params, param{\n\t\t\t\tname: \"fetch-all\",\n\t\t\t\trequired: false,\n\t\t\t\tdescription: \"Do pagination automatically.\",\n\t\t\t})\n\t\t}\n\t}\n\n\tsort.Slice(params, func(i, j int) bool {\n\t\treturn params[i].name < params[j].name\n\t})\n\n\tflagsArray := strings.Split(flags, \" \")\n\tlastWord := flagsArray[len(flagsArray)-1]\n\tisEnteringFlag := true\n\n\tif len(flagsArray) > 1 {\n\t\tif strings.HasPrefix(flagsArray[len(flagsArray)-2], \"--\") &&\n\t\t\t(strings.HasSuffix(line, \" \") || !strings.HasPrefix(lastWord, \"--\")) {\n\t\t\tisEnteringFlag = false\n\t\t}\n\t}\n\tif strings.HasSuffix(line, \" \") {\n\t\tisEnteringFlag = false\n\t}\n\tif len(flagsArray)%2 == 0 && !strings.HasPrefix(lastWord, \"--\") && strings.HasSuffix(line, \" \") {\n\t\tisEnteringFlag = true\n\t}\n\n\tvar lastFlag string\n\tfor i := len(flagsArray) - 1; i >= 0; i-- {\n\t\tif strings.HasPrefix(flagsArray[i], \"--\") {\n\t\t\tlastFlag = strings.ReplaceAll(flagsArray[i], \"--\", \"\")\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// provide flag name suggestion if user is entering flag\n\tif isEnteringFlag {\n\t\tr := make([]prompt.Suggest, 0)\n\t\tfor _, p := range params {\n\t\t\tif !contains(parseFlags(flags), lib.OptionCase(p.name)) {\n\t\t\t\trequired := \"\"\n\t\t\t\tif p.required {\n\t\t\t\t\trequired = \"(required) \"\n\t\t\t\t}\n\n\t\t\t\tr = append(r, prompt.Suggest{\n\t\t\t\t\tText: \"--\" + lib.OptionCase(p.name),\n\t\t\t\t\tDescription: required + p.description,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn filterFunc(r, lastWord, prompt.FilterFuzzy)\n\t}\n\n\tif strings.HasPrefix(lastWord, \"--\") {\n\t\tlastWord = \"\"\n\t}\n\n\t// value suggestion\n\t// if last flag's value type is enum, provide possible values\n\tvar suggests []prompt.Suggest\n\tfor _, p := range params {\n\t\tif p.name == lastFlag {\n\t\t\tif len(p.enum) > 0 {\n\t\t\t\tfor _, e := range p.enum {\n\t\t\t\t\tsuggests = append(suggests, prompt.Suggest{\n\t\t\t\t\t\tText: e,\n\t\t\t\t\t\tDescription: \"\",\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(suggests) > 0 {\n\t\t\t\treturn filterFunc(suggests, lastWord, prompt.FilterFuzzy)\n\t\t\t}\n\t\t}\n\t}\n\n\t// if specific name is found, do more intelligent completion\n\tswitch lastFlag {\n\tcase \"status-filter\":\n\t\treturn s.statusFilterSuggestions(lastWord)\n\tcase \"speed-class-filter\":\n\t\treturn s.speedClassFilterSuggestions(lastWord)\n\tcase \"device-id\":\n\t\tif strings.HasPrefix(commands, \"device\") {\n\t\t\treturn s.inventoryDeviceIDFilterSuggestions(lastWord)\n\t\t}\n\t\tif strings.HasPrefix(commands, \"sigfox\") {\n\t\t\treturn s.sigfoxDeviceIDFilterSuggestions(lastWord)\n\t\t}\n\tcase \"imsi\":\n\t\treturn s.imsiFilterSuggestions(lastWord)\n\tcase \"order-id\":\n\t\treturn s.orderFilterSuggestions(lastWord)\n\tcase \"resource-id\": // `logs get` or `audit-logs napter get` uses 'resource-id' for imsi\n\t\treturn s.imsiFilterSuggestions(lastWord)\n\tcase \"group-id\":\n\t\treturn s.groupFilterSuggestions(lastWord)\n\t}\n\n\treturn suggests\n}", "func (c *completer) Complete(d prompt.Document) (s []*prompt.Suggest) {\n\tbc := d.TextBeforeCursor()\n\tif bc == \"\" {\n\t\treturn nil\n\t}\n\n\t// TODO: We should consider about spaces used as a part of test.\n\targs := strings.Split(spaces.ReplaceAllString(bc, \" \"), \" \")\n\tcmdName := args[0]\n\targs = args[1:] // Ignore command name.\n\n\tcmd, ok := c.cmds[cmdName]\n\tif !ok {\n\t\t// return all commands if current input is first command name\n\t\tif len(args) == 0 {\n\t\t\t// number of commands + help\n\t\t\tcmdNames := make([]*prompt.Suggest, 0, len(c.cmds))\n\t\t\tcmdNames = append(cmdNames, prompt.NewSuggestion(\"help\", \"show help message\"))\n\t\t\tfor name, cmd := range c.cmds {\n\t\t\t\tcmdNames = append(cmdNames, prompt.NewSuggestion(name, cmd.Synopsis()))\n\t\t\t}\n\n\t\t\ts = cmdNames\n\t\t}\n\t\treturn prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)\n\t}\n\n\tdefer func() {\n\t\tif len(s) != 0 {\n\t\t\ts = append(s, prompt.NewSuggestion(\"--help\", \"show command help message\"))\n\t\t}\n\t\ts = prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)\n\t}()\n\n\tfs, ok := cmd.FlagSet()\n\tif ok {\n\t\tif len(args) > 0 && strings.HasPrefix(args[len(args)-1], \"-\") {\n\t\t\tfs.VisitAll(func(f *pflag.Flag) {\n\t\t\t\ts = append(s, prompt.NewSuggestion(\"--\"+f.Name, f.Usage))\n\t\t\t})\n\t\t\treturn s\n\t\t}\n\n\t\t_ = fs.Parse(args)\n\t\targs = fs.Args()\n\t}\n\n\tcompFunc, ok := c.completions[cmdName]\n\tif !ok {\n\t\treturn s\n\t}\n\treturn compFunc(args)\n}", "func Display(possible ...Cmd) {\n\thint := randHint(possible)\n\tif hint != \"\" {\n\t\tui.Hint(hint, false)\n\t}\n}", "func (c *Completer) Help(ctx *Context, content IContent, line interface{}, index int) (interface{}, bool) {\n\treturn nil, false\n}", "func CursorNextLine(r uint) {\n\temitEscape(\"E\", r)\n}", "func updateCompleter(categories []string) {\n\n\tvar items []readline.PrefixCompleterInterface\n\n\tfor _, category := range categories {\n\t\titems = append(items, readline.PcItem(category))\n\t}\n\n\tcompleter = readline.NewPrefixCompleter(\n\t\treadline.PcItem(\"newEntry\",\n\t\t\titems...,\n\t\t),\n\t\treadline.PcItem(\"newCategory\"),\n\t)\n\n\tl.Config.AutoComplete = completer\n}", "func TestCompletionEntry_CursorPosition(t *testing.T) {\n\tentry := createEntry()\n\twin := test.NewWindow(entry)\n\twin.Resize(fyne.NewSize(500, 300))\n\tdefer win.Close()\n\n\tentry.OnChanged = func(s string) {\n\t\tentry.SetOptions([]string{\"foofoo\", \"barbar\", \"bazbaz\"})\n\t\tentry.ShowCompletion()\n\t}\n\tentry.SetText(\"barb\")\n\n\t// navigate to \"bar\" and press enter, the entry should contain\n\t// \"bar\" in value\n\twin.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeyDown})\n\twin.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeyDown})\n\twin.Canvas().Focused().TypedKey(&fyne.KeyEvent{Name: fyne.KeyReturn})\n\n\tassert.Equal(t, 6, entry.CursorColumn)\n\n}", "func (tm *Term) StatusLine() {\n\tpos := tm.RowSt\n\tif tm.Tail {\n\t\tpos = tm.RowOff\n\t}\n\tstat := fmt.Sprintf(\"Tail: %v\\tPos: %d\\tMaxRows: %d\\tNFile: %d\\tFileSt: %d\\t h = help [spc,n,p,r,f,l,b,w,s,t,a,e,v,u,m,l,c,q] \", tm.Tail, pos, tm.MaxRows, len(TheFiles), tm.FileSt)\n\ttm.DrawString(0, tm.Size.Y-1, stat, len(stat), termbox.AttrReverse, termbox.AttrReverse)\n}", "func genCompletion() {\n\tinfo := genUsage()\n\n\tswitch options.GetS(OPT_COMPLETION) {\n\tcase \"bash\":\n\t\tfmt.Printf(bash.Generate(info, \"shdoc\"))\n\tcase \"fish\":\n\t\tfmt.Printf(fish.Generate(info, \"shdoc\"))\n\tcase \"zsh\":\n\t\tfmt.Printf(zsh.Generate(info, optMap, \"shdoc\"))\n\tdefault:\n\t\tos.Exit(1)\n\t}\n\n\tos.Exit(0)\n}", "func ShowPreface(username string, duration int, free bool) {\n\ttb.Clear(tbutil.COLDEF, tbutil.COLDEF)\n\tcd := 3\n\tvar freestr string\n\tvar mode string\n\tif free {\n\t\tmode = \"Freestyle\"\n\t\tfreestr = \"For this mode, you aren't given a writing prompt. You can write whatever you please before the timer runs out.\" +\n\t\t\t\" During the test, press the Enter key to commit your sentence and begin a new line. You can also press the escape key to end the test.\"\n\t} else {\n\t\tmode = \"Prompt-Matching\"\n\t\tfreestr = \"For this mode, you are given a writing prompt to copy. You should try to match the prompt exactly.\" +\n\t\t\t\" During the test, press the Enter key to commit your sentence and recieve a new writing prompt. You can also press the escape key to end the test.\"\n\t}\n\n\n\tparams := fmt.Sprintf(\"[Test Mode: %s, Duration: %ds]\", mode, duration)\n\tpre := fmt.Sprintf(\"Welcome to my typing speed test, %s. This program will count down from %d, and then it'll measure how fast you can type words. %s\"+\n\t\t\" When you're ready, press any key to begin...\", username, cd, freestr)\n\n\t_, y := tbutil.Write(0, 0, tbutil.COLDEF, tbutil.COLDEF, params)\t\n\ttbutil.Write(0, y + 2, tbutil.COLDEF, tbutil.COLDEF, pre)\n\n\ttbutil.KeyContinue(false)\n\n\ttbutil.CountDown(0, 0, 3, \"%s\", nil)\n}", "func setCursorLoc(x, y int) {\n\tfmt.Printf(\"\\033[%v;%vH\", y, x)\n}", "func (b *Buffer) CycleAutocomplete(forward bool) {\n\tprevSuggestion := b.CurSuggestion\n\n\tif forward {\n\t\tb.CurSuggestion++\n\t} else {\n\t\tb.CurSuggestion--\n\t}\n\tif b.CurSuggestion >= len(b.Suggestions) {\n\t\tb.CurSuggestion = 0\n\t} else if b.CurSuggestion < 0 {\n\t\tb.CurSuggestion = len(b.Suggestions) - 1\n\t}\n\n\tc := b.GetActiveCursor()\n\tstart := c.Loc\n\tend := c.Loc\n\tif prevSuggestion < len(b.Suggestions) && prevSuggestion >= 0 {\n\t\tstart = end.Move(-util.CharacterCountInString(b.Completions[prevSuggestion]), b)\n\t}\n\n\tb.Replace(start, end, b.Completions[b.CurSuggestion])\n\tif len(b.Suggestions) > 1 {\n\t\tb.HasSuggestions = true\n\t}\n}", "func (file *File) AllLineFo(term string) {\n\tfile.MultiCursor.OnePerLine()\n\tpositions := make(map[int][]int)\n\tfound := 0\n\tfor _, cursor := range file.MultiCursor.Cursors() {\n\t\trow, col := cursor.RowCol()\n\t\tcols := file.buffer.GetRow(row).SearchAll(term, col, -1)\n\t\tpositions[row] = cols\n\t\tfound += len(cols)\n\t}\n\tif found > 0 {\n\t\tfile.MultiCursor.ResetRowsCols(positions)\n\t}\n}", "func edit(c *cli.Context) {\n\tlines := content()\n\n\targLen := len(c.Args())\n\n\tvar ind int\n\n\tswitch argLen {\n\tcase 0:\n\t\tind = 0\n\tcase 1:\n\t\tind, _ = strconv.Atoi(c.Args()[0])\n\tdefault:\n\t\tpanic(1)\n\t}\n\n\tselectedLine := lines[ind]\n\tlineArr := strings.Split(selectedLine, \" \")\n\n\tenv := os.Environ()\n\tvimBin, err := exec.LookPath(\"vim\")\n\tcheck(err)\n\n\tplusCmd := fmt.Sprint(\"+\", lineArr[0])\n\tplussCmd := []string{\"vim\", lineArr[1], plusCmd}\n\n\tdebug(\"Whole cmd: %v Index: %v\", plussCmd, c.Args()[0])\n\n\tif true {\n\t\texecErr := syscall.Exec(vimBin, plussCmd, env)\n\t\tcheck(execErr)\n\t}\n}", "func (c *Console) ShowCursor() *Console {\n\tPrint(_CSI + \"?25h\")\n\treturn c\n}", "func GuruComplete(filepath string, byteOffset int) ([]Completion, error) {\n\tstdout, _, exit, err := util.Exec(\n\t\t\"guru\", \"describe\", fmt.Sprintf(\"%s:#%d\", filepath, byteOffset))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif exit != 0 {\n\t\treturn nil, fmt.Errorf(\"non-zero exit: %d\", exit)\n\t}\n\n\tvar (\n\t\tcompletions []Completion\n\t\tlineState int\n\t)\n\tfor i, line := range strings.Split(stdout, \"\\n\") {\n\t\tif line == \"\" {\n\t\t\tbreak\n\t\t}\n\n\t\tsplit := strings.SplitN(line, \":\", 3)\n\t\tif len(split) < 3 {\n\t\t\treturn nil, fmt.Errorf(\"unexpected colum format in line: %d\", i)\n\t\t}\n\t\tfile, pos, desc := split[0], split[1], split[2]\n\n\t\tswitch desc {\n\t\tcase \" Methods:\":\n\t\t\tlineState = lineMethod\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch lineState {\n\t\tcase lineMethod:\n\t\t\tdesc = trimMethodPrefix(desc)\n\n\t\t\t// i believe [0] access is safe, i don't think Split will ever\n\t\t\t// return less than 1.\n\t\t\tsPos := strings.SplitN(pos, \"-\", 2)[0]\n\n\t\t\tsPosSplit := strings.SplitN(sPos, \".\", 2)\n\t\t\tif len(sPosSplit) < 2 {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected line.col format: %q\", sPos)\n\t\t\t}\n\n\t\t\tlineNo, err := strconv.Atoi(sPosSplit[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to lineNo to int: %q\", sPosSplit[0])\n\t\t\t}\n\n\t\t\tcol, err := strconv.Atoi(sPosSplit[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to col to int: %q\", sPosSplit[1])\n\t\t\t}\n\n\t\t\tcompletions = append(completions, Completion{\n\t\t\t\t// TODO(leeola): remove formatting on the desc for\n\t\t\t\t// methods. Guru adds lots of indentation, a method\n\t\t\t\t// prefix, etc.\n\t\t\t\tCompletion: desc,\n\t\t\t\tFile: file,\n\t\t\t\tLineNo: lineNo,\n\t\t\t\tColumn: col,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn completions, nil\n}", "func (o *ListOptions) Complete(ctx context.Context, cmdline cmdline.Cmdline, args []string) (err error) {\n\n\to.devfileList, err = o.clientset.RegistryClient.ListDevfileStacks(ctx, o.registryFlag, o.devfileFlag, o.filterFlag, o.detailsFlag, log.IsJSON())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (b *Buffer) Autocomplete(c Completer) bool {\n\tb.Completions, b.Suggestions = c(b)\n\tif len(b.Completions) != len(b.Suggestions) || len(b.Completions) == 0 {\n\t\treturn false\n\t}\n\tb.CurSuggestion = -1\n\tb.CycleAutocomplete(true)\n\treturn true\n}", "func (d *Dispatcher) CompletionSuggestions(parse *ParseResults) (*Suggestions, error) {\n\treturn d.CompletionSuggestionsCursor(parse, len(parse.Reader.String))\n}", "func (rl *Instance) Readline() (_ string, err error) {\n\tfd := int(os.Stdin.Fd())\n\tstate, err := MakeRaw(fd)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// return an error if Restore fails. However we don't want to return\n\t\t// `nil` if there is no error because there might be a CtrlC or EOF\n\t\t// that needs to be returned\n\t\tr := Restore(fd, state)\n\t\tif r != nil {\n\t\t\terr = r\n\t\t}\n\t}()\n\n\tx, _ := rl.getCursorPos()\n\tswitch x {\n\tcase -1:\n\t\tprint(string(leftMost()))\n\tcase 0:\n\t\t// do nothing\n\tdefault:\n\t\tprint(\"\\r\\n\")\n\t}\n\tprint(rl.prompt)\n\n\trl.line = []rune{}\n\trl.viUndoHistory = []undoItem{{line: \"\", pos: 0}}\n\trl.pos = 0\n\trl.histPos = rl.History.Len()\n\trl.modeViMode = vimInsert\n\tatomic.StoreInt64(&rl.delayedSyntaxCount, 0)\n\trl.resetHintText()\n\trl.resetTabCompletion()\n\n\tif len(rl.multisplit) > 0 {\n\t\tr := []rune(rl.multisplit[0])\n\t\trl.readlineInput(r)\n\t\trl.carridgeReturn()\n\t\tif len(rl.multisplit) > 1 {\n\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t} else {\n\t\t\trl.multisplit = []string{}\n\t\t}\n\t\treturn string(rl.line), nil\n\t}\n\n\trl.termWidth = GetTermWidth()\n\trl.getHintText()\n\trl.renderHelpers()\n\n\tfor {\n\t\tgo delayedSyntaxTimer(rl, atomic.LoadInt64(&rl.delayedSyntaxCount))\n\t\trl.viUndoSkipAppend = false\n\t\tb := make([]byte, 1024*1024)\n\t\tvar i int\n\n\t\tif !rl.skipStdinRead {\n\t\t\ti, err = os.Stdin.Read(b)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\trl.termWidth = GetTermWidth()\n\t\t}\n\t\tatomic.AddInt64(&rl.delayedSyntaxCount, 1)\n\n\t\trl.skipStdinRead = false\n\t\tr := []rune(string(b))\n\n\t\tif isMultiline(r[:i]) || len(rl.multiline) > 0 {\n\t\t\trl.multiline = append(rl.multiline, b[:i]...)\n\t\t\tif i == len(b) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !rl.allowMultiline(rl.multiline) {\n\t\t\t\trl.multiline = []byte{}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ts := string(rl.multiline)\n\t\t\trl.multisplit = rxMultiline.Split(s, -1)\n\n\t\t\tr = []rune(rl.multisplit[0])\n\t\t\trl.modeViMode = vimInsert\n\t\t\trl.readlineInput(r)\n\t\t\trl.carridgeReturn()\n\t\t\trl.multiline = []byte{}\n\t\t\tif len(rl.multisplit) > 1 {\n\t\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t\t} else {\n\t\t\t\trl.multisplit = []string{}\n\t\t\t}\n\t\t\treturn string(rl.line), nil\n\t\t}\n\n\t\ts := string(r[:i])\n\t\tif rl.evtKeyPress[s] != nil {\n\t\t\t//rl.clearHelpers() // unessisary clear?\n\n\t\t\tret := rl.evtKeyPress[s](s, rl.line, rl.pos)\n\n\t\t\trl.clearLine()\n\t\t\trl.line = append(ret.NewLine, []rune{}...)\n\t\t\trl.echo()\n\t\t\trl.pos = ret.NewPos\n\n\t\t\tif ret.ClearHelpers {\n\t\t\t\trl.resetHelpers()\n\t\t\t} else {\n\t\t\t\trl.updateHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\t\tif len(ret.HintText) > 0 {\n\t\t\t\trl.hintText = ret.HintText\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\t\t\tif !ret.ForwardKey {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ret.CloseReadline {\n\t\t\t\trl.clearHelpers()\n\t\t\t\treturn string(rl.line), nil\n\t\t\t}\n\t\t}\n\n\t\tswitch b[0] {\n\t\tcase charCtrlC:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", CtrlC\n\n\t\tcase charEOF:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", EOF\n\n\t\tcase charCtrlF:\n\t\t\tif !rl.modeTabCompletion {\n\t\t\t\trl.modeAutoFind = true\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlR:\n\t\t\trl.modeAutoFind = true\n\t\t\trl.tcOffset = 0\n\t\t\trl.modeTabCompletion = true\n\t\t\trl.tcDisplayType = TabDisplayMap\n\t\t\trl.tcSuggestions, rl.tcDescriptions = rl.autocompleteHistory()\n\t\t\trl.initTabCompletion()\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlU:\n\t\t\trl.clearLine()\n\t\t\trl.resetHelpers()\n\n\t\tcase charTab:\n\t\t\tif rl.modeTabCompletion {\n\t\t\t\trl.moveTabCompletionHighlight(1, 0)\n\t\t\t} else {\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.renderHelpers()\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase '\\r':\n\t\t\tfallthrough\n\t\tcase '\\n':\n\t\t\tvar suggestions []string\n\t\t\tif rl.modeTabFind {\n\t\t\t\tsuggestions = rl.tfSuggestions\n\t\t\t} else {\n\t\t\t\tsuggestions = rl.tcSuggestions\n\t\t\t}\n\n\t\t\tif rl.modeTabCompletion && len(suggestions) > 0 {\n\t\t\t\tcell := (rl.tcMaxX * (rl.tcPosY - 1)) + rl.tcOffset + rl.tcPosX - 1\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.resetTabCompletion()\n\t\t\t\trl.renderHelpers()\n\t\t\t\trl.insert([]rune(suggestions[cell]))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trl.carridgeReturn()\n\t\t\treturn string(rl.line), nil\n\n\t\tcase charBackspace, charBackspace2:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.backspaceTabFind()\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.backspace()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\tcase charEscape:\n\t\t\trl.escapeSeq(r[:i])\n\n\t\tdefault:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.updateTabFind(r[:i])\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.readlineInput(r[:i])\n\t\t\t\tif len(rl.multiline) > 0 && rl.modeViMode == vimKeys {\n\t\t\t\t\trl.skipStdinRead = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//if !rl.viUndoSkipAppend {\n\t\t//\trl.viUndoHistory = append(rl.viUndoHistory, rl.line)\n\t\t//}\n\t\trl.undoAppendHistory()\n\t}\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 BenchmarkCompletionFollowingEdit(b *testing.B) {\n\tfile := \"internal/lsp/source/completion/completion2.go\"\n\tfileContent := `\npackage completion\n\nfunc (c *completer) _() {\n\tc.inference.kindMatches(c.)\n\t// __MAGIC_STRING_1\n}\n`\n\tsetup := func(env *Env) {\n\t\tenv.CreateBuffer(file, fileContent)\n\t}\n\n\tn := 1\n\tbeforeCompletion := func(env *Env) {\n\t\told := fmt.Sprintf(\"__MAGIC_STRING_%d\", n)\n\t\tnew := fmt.Sprintf(\"__MAGIC_STRING_%d\", n+1)\n\t\tn++\n\t\tenv.RegexpReplace(file, old, new)\n\t}\n\n\tbenchmarkCompletion(completionBenchOptions{\n\t\tfile: file,\n\t\tlocationRegexp: `func \\(c \\*completer\\) _\\(\\) {\\n\\tc\\.inference\\.kindMatches\\((c)`,\n\t\tsetup: setup,\n\t\tbeforeCompletion: beforeCompletion,\n\t}, b)\n}", "func CompleteMenuCommands(last []rune, pos int) (lastWord string, completions []*readline.CompletionGroup) {\n\n\treturn\n}", "func (o *AppOptions) Complete(f kcmdutil.Factory, c *cobra.Command, args []string) error {\n\to.RESTClientGetter = f\n\n\tcmdutil.WarnAboutCommaSeparation(o.ErrOut, o.ObjectGeneratorOptions.Config.TemplateParameters, \"--param\")\n\terr := o.ObjectGeneratorOptions.Complete(f, c, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (hw *HighlightedWriter) ShowCursor() {\n\thw.delegate.ShowCursor()\n}", "func (ls *linestate) refreshShowHints() []string {\n\t// do we have a hints callback?\n\tif ls.ts.hintsCallback == nil {\n\t\t// no hints\n\t\treturn nil\n\t}\n\t// How many columns do we have for the hint?\n\thintCols := ls.cols - ls.promptWidth - runewidth.StringWidth(string(ls.buf))\n\tif hintCols <= 0 {\n\t\t// no space to display hints\n\t\treturn nil\n\t}\n\t// get the hint\n\th := ls.ts.hintsCallback(string(ls.buf))\n\tif h == nil || len(h.Hint) == 0 {\n\t\t// no hints\n\t\treturn nil\n\t}\n\t// trim the hint until it fits\n\thEnd := len(h.Hint)\n\tfor runewidth.StringWidth(h.Hint[:hEnd]) > hintCols {\n\t\thEnd--\n\t}\n\t// color fixup\n\tif h.Bold && h.Color < 0 {\n\t\th.Color = 37\n\t}\n\t// build the output string\n\tseq := make([]string, 0, 3)\n\tif h.Color >= 0 || h.Bold {\n\t\tseq = append(seq, fmt.Sprintf(\"\\033[%d;%d;49m\", btoi(h.Bold), h.Color))\n\t}\n\tseq = append(seq, h.Hint[:hEnd])\n\tif h.Color >= 0 || h.Bold {\n\t\tseq = append(seq, \"\\033[0m\")\n\t}\n\treturn seq\n}", "func (ts *TaskSet) DisplayByNext() {\n\tif ts.numTasksLoaded == 0 {\n\t\tfmt.Println(\"\\033[31mNo tasks found. Showing help.\\033[0m\")\n\t\tHelp(\"\")\n\t} else if len(ts.tasks) == 0 {\n\t\tExitFail(\"No matching tasks in given context or filter.\")\n\t} else if len(ts.tasks) == 1 {\n\t\tts.tasks[0].Display()\n\t\treturn\n\t} else {\n\t\tvar tasks []*Task\n\t\tw, h := MustGetTermSize()\n\n\t\th -= 8 // leave room for context message, header and prompt\n\n\t\tif h > len(ts.tasks) || h < 0 {\n\t\t\ttasks = ts.tasks\n\t\t} else {\n\t\t\ttasks = ts.tasks[:h]\n\t\t}\n\n\t\ttable := NewTable(\n\t\t\tw,\n\t\t\t\"ID\",\n\t\t\t\"Priority\",\n\t\t\t\"Tags\",\n\t\t\t\"Project\",\n\t\t\t\"Summary\",\n\t\t)\n\n\t\tfor _, t := range tasks {\n\t\t\tstyle := t.Style()\n\t\t\ttable.AddRow(\n\t\t\t\t[]string{\n\t\t\t\t\t// id should be at least 2 chars wide to match column header\n\t\t\t\t\t// (headers can be truncated)\n\t\t\t\t\tfmt.Sprintf(\"%-2d\", t.ID),\n\t\t\t\t\tt.Priority,\n\t\t\t\t\tstrings.Join(t.Tags, \" \"),\n\t\t\t\t\tt.Project,\n\t\t\t\t\tt.Summary,\n\t\t\t\t},\n\t\t\t\tstyle,\n\t\t\t)\n\t\t}\n\n\t\ttable.Render()\n\n\t\tif h >= len(ts.tasks) {\n\t\t\tfmt.Printf(\"\\n%v tasks.\\n\", len(ts.tasks))\n\t\t} else {\n\t\t\tfmt.Printf(\"\\n%v tasks, truncated to %v lines.\\n\", len(ts.tasks), h)\n\t\t}\n\t}\n}", "func (c *slotsCmd) Complete(cmd *cobra.Command, args []string) error {\n\tc.args = args\n\n\treturn nil\n}", "func PrintCommandLineWithCursor(cmd *cobra.Command, it *vt.Iterator) {\n\tif cursor := it.Cursor(); cursor != \"\" {\n\t\targs := cmd.Flags().Args()\n\t\tfor i, arg := range args {\n\t\t\targs[i] = fmt.Sprintf(\"'%s'\", arg)\n\t\t}\n\t\tflags := make([]string, 0)\n\t\tcmd.Flags().Visit(func(flag *pflag.Flag) {\n\t\t\tif flag.Name != \"cursor\" {\n\t\t\t\tvar f string\n\t\t\t\tswitch flag.Value.Type() {\n\t\t\t\tcase \"stringSlice\":\n\t\t\t\t\tss, _ := cmd.Flags().GetStringSlice(flag.Name)\n\t\t\t\t\tf = fmt.Sprintf(\"--%s='%s'\", flag.Name, strings.Join(ss, \",\"))\n\t\t\t\tdefault:\n\t\t\t\t\tf = fmt.Sprintf(\"--%s=%v\", flag.Name, flag.Value.String())\n\t\t\t\t}\n\t\t\t\tflags = append(flags, f)\n\t\t\t}\n\t\t})\n\t\tflags = append(flags, fmt.Sprintf(\"--cursor=%s\", cursor))\n\t\tcolor.New(color.Faint).Fprintf(\n\t\t\tansi.NewAnsiStderr(), \"\\nMORE WITH:\\n%s %s %s\\n\",\n\t\t\tcmd.CommandPath(), strings.Join(args, \" \"), strings.Join(flags, \" \"))\n\t}\n}", "func newCmdCompletion() *cobra.Command {\n\texample := ` # bash <= 3.2:\n # To load shell completion into your current shell session\n source /dev/stdin <<< \"$(linkerd completion bash)\"\n\n # bash >= 4.0:\n source <(linkerd completion bash)\n\n # To load shell completion for every shell session\n # bash <= 3.2 on osx:\n brew install bash-completion # ensure you have bash-completion 1.3+\n linkerd completion bash > $(brew --prefix)/etc/bash_completion.d/linkerd\n\n # bash >= 4.0 on osx:\n brew install bash-completion@2\n linkerd completion bash > $(brew --prefix)/etc/bash_completion.d/linkerd\n\n # bash >= 4.0 on linux:\n linkerd completion bash > /etc/bash_completion.d/linkerd\n\n # You will need to start a new shell for this setup to take effect.\n\n # zsh:\n # If shell completion is not already enabled in your environment you will need\n # to enable it. You can execute the following once:\n\n echo \"autoload -U compinit && compinit\" >> ~/.zshrc\n\n # create a linkerd 'plugins' folder and add it to your $fpath\n mkdir $ZSH/plugins/linkerd && echo \"fpath=($ZSH/plugins/linkerd $fpath)\" >> ~/.zshrc\n\n # To load completions for each session, execute once:\n linkerd completion zsh > \"${fpath[1]}/_linkerd\" && exec $SHELL\n\n # You will need to start a new shell for this setup to take effect.\n\n # fish:\n linkerd completion fish | source\n\n # To load fish shell completions for each session, execute once:\n linkerd completion fish > ~/.config/fish/completions/linkerd.fish`\n\n\tcmd := &cobra.Command{\n\t\tUse: \"completion [bash|zsh|fish]\",\n\t\tShort: \"Output shell completion code for the specified shell (bash, zsh or fish)\",\n\t\tLong: \"Output shell completion code for the specified shell (bash, zsh or fish).\",\n\t\tExample: example,\n\t\tArgs: cobra.ExactArgs(1),\n\t\tValidArgs: []string{\"bash\", \"zsh\", \"fish\"},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tout, err := getCompletion(args[0], cmd.Parent())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tfmt.Print(out)\n\t\t\treturn nil\n\t\t},\n\t}\n\n\treturn cmd\n}", "func (c *impl) CmdLine() {\n\tlog.Log.Println(\"cfmedias\", c.currentVersion)\n\n\tc.repl = liner.NewLiner()\n\tc.repl.SetCompleter(c.completer)\n\n\tfor c.replActive = true; c.replActive; {\n\t\tc.reading = true\n\t\tcmd, err := c.repl.Prompt(\"> \")\n\t\t//c.repl.Close()\n\t\tc.reading = false\n\t\tif err != nil && c.replActive {\n\t\t\tfmt.Println(err)\n\t\t\tc.replActive = false\n\t\t\tbreak\n\t\t}\n\t\tif !c.replActive {\n\t\t\treturn\n\t\t}\n\n\t\tcmd = strings.Replace(cmd, `\\ `, maxUnicodeString, -1)\n\t\tcmd = strings.Replace(cmd, `\\\\`, `\\`, -1)\n\t\tsplit := strings.Split(cmd, \" \")\n\n\t\tif len(split) > 0 && len(cmd) > 0 {\n\t\t\t// convert arg list to map, using format\n\t\t\t// name=max fruits=apple fruits=orange\n\t\t\t// ==> map[name: [max], fruits: [apple, orange]]\n\t\t\targs := make(core.ArgMap)\n\t\t\tfor _, e := range split[1:] {\n\t\t\t\te = strings.Replace(e, maxUnicodeString, ` `, -1)\n\t\t\t\ttuple := strings.Split(e, \"=\")\n\t\t\t\tif _, ok := args[tuple[0]]; !ok {\n\t\t\t\t\targs[tuple[0]] = make([]string, 0)\n\t\t\t\t}\n\t\t\t\tif len(tuple) > 0 {\n\t\t\t\t\targs[tuple[0]] = append(args[tuple[0]],\n\t\t\t\t\t\tstrings.Join(tuple[1:], \"=\"))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult := c.Cmd(core.CommandContext{split[0], args, core.AuthRoot, nil})\n\t\t\tif result.Error != core.ErrorCmdNotFound {\n\t\t\t\tc.repl.AppendHistory(cmd)\n\t\t\t}\n\t\t\tbytes, _ := json.MarshalIndent(result, \"\", \" \")\n\t\t\tos.Stdout.Write(bytes)\n\t\t\tfmt.Println()\n\t\t}\n\t}\n}", "func (ge *CurrentGrantExecutable) Show() string {\n\treturn fmt.Sprintf(`SHOW GRANTS OF %v \"%v\"`, ge.granteeType, ge.granteeName)\n}", "func (o *Options) Complete(args []string) {\n\to.Items = args\n}", "func CompleteCommand(a ...interface{}) []string {\n\trv := []string{}\n\n\tif len(a) == 0 || comp.Line() == \"\" {\n\t\treturn rv\n\t}\n\n\tx := a[0].(*Command)\n\tword := comp.Word()\n\n\tfor k, _ := range x.Commands {\n\t\tif word == \" \" || strings.HasPrefix(k, word) {\n\t\t\trv = append(rv, k)\n\t\t}\n\t}\n\n\tfor _, k := range x.Params {\n\t\tif word == \" \" || strings.HasPrefix(k, word) {\n\t\t\trv = append(rv, k)\n\t\t}\n\t}\n\n\tsort.Strings(rv)\n\treturn rv\n}", "func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {\n\t// In situations where a pseudo tty is allocated (e.g. within a docker container),\n\t// window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.\n\tif r.col == 0 {\n\t\treturn\n\t}\n\tdefer func() { debug.AssertNoError(r.out.Flush()) }()\n\tr.move(r.previousCursor, 0)\n\n\tline := buffer.Text()\n\tprefix := r.getCurrentPrefix()\n\tcursor := runewidth.StringWidth(prefix) + runewidth.StringWidth(line)\n\n\t// prepare area\n\t_, y := r.toPos(cursor)\n\n\th := y + 1 + int(completion.max)\n\tif h > int(r.row) || completionMargin > int(r.col) {\n\t\tr.renderWindowTooSmall()\n\t\treturn\n\t}\n\n\t// Rendering\n\tr.out.HideCursor()\n\tdefer r.out.ShowCursor()\n\n\tr.renderPrefix()\n\tr.out.SetColor(r.inputTextColor, r.inputBGColor, false)\n\tr.out.WriteStr(line)\n\tr.out.SetColor(DefaultColor, DefaultColor, false)\n\tr.lineWrap(cursor)\n\n\tr.out.EraseDown()\n\n\tcursor = r.backward(cursor, runewidth.StringWidth(line)-buffer.DisplayCursorPosition())\n\n\tr.renderCompletion(buffer, completion)\n\tif suggest, ok := completion.GetSelectedSuggestion(); ok {\n\t\tcursor = r.backward(cursor, runewidth.StringWidth(buffer.Document().GetWordBeforeCursorUntilSeparator(completion.wordSeparator)))\n\n\t\tr.out.SetColor(r.previewSuggestionTextColor, r.previewSuggestionBGColor, false)\n\t\tr.out.WriteStr(suggest.Text)\n\t\tr.out.SetColor(DefaultColor, DefaultColor, false)\n\t\tcursor += runewidth.StringWidth(suggest.Text)\n\n\t\trest := buffer.Document().TextAfterCursor()\n\t\tr.out.WriteStr(rest)\n\t\tcursor += runewidth.StringWidth(rest)\n\t\tr.lineWrap(cursor)\n\n\t\tcursor = r.backward(cursor, runewidth.StringWidth(rest))\n\t}\n\tr.previousCursor = cursor\n}", "func (gto *GetOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {\n\tgto.Context = genericclioptions.NewContext(cmd)\n\tgto.componentName = gto.Context.ComponentAllowingEmpty(true)\n\treturn\n}", "func (o *options) complete(cmd *cobra.Command, args []string) error {\n\to.args = args\n\n\treturn o.Init(cmd)\n}", "func (file *File) SearchLineFo(term string) {\n\tfile.MultiCursor.OnePerLine()\n\tfor idx, cursor := range file.MultiCursor.Cursors() {\n\t\trow, col := cursor.RowCol()\n\t\tline := file.buffer.GetRow(row)\n\t\tc0, _ := line.Search(term, col, -1)\n\t\tif c0 >= 0 {\n\t\t\tfile.MultiCursor.SetCol(idx, c0)\n\t\t}\n\t}\n}", "func Completion(cmd *cobra.Command, args []string) {\n\terr := cmd.Root().GenBashCompletionFile(completionTarget)\n\tcompletion(err, args...)\n}", "func (o *addBaseOptions) Complete(cmd *cobra.Command, args []string) error {\n\treturn nil\n}", "func CompleteCommandOptions(args []string, last []rune, cmd *flags.Command) (lastWord string, completions []*readline.CompletionGroup) {\n\n\treturn\n}", "func sameLinePrint(format string, a ...interface{}) {\n\tfmt.Fprint(os.Stdout, \"\\033[G\\033[K\") // move the cursor left and clear the line\n\tfmt.Fprintf(os.Stdout, format+\"\\n\", a...)\n\tfmt.Fprint(os.Stdout, \"\\033[A\") // move the cursor up\n}", "func printHint() {\n\tprint(\"orbi - Embeddable Interactive ORuby Shell\\n\\n\")\n}", "func (pc *implantPathCompleter) Do(ctx *commands.ShellContext, line []rune, pos int) (options [][]rune, offset int) {\n\n\tsplitLine := strings.Split(string(line), \" \")\n\tline = trimSpaceLeft([]rune(splitLine[len(splitLine)-1]))\n\n\t// 1) Get the absolute path. There are two cases:\n\t// - The path is \"rounded\" with a slash: no filter to keep.\n\t// - The path is not a slash: a filter to keep for later.\n\t// We keep a boolean for remembering which case we found\n\tlinePath := \"\"\n\tlastPath := \"\"\n\tswitch ctx.CurrentAgent.OS {\n\tcase \"windows\":\n\t\tif strings.HasSuffix(string(line), \"\\\\\") {\n\t\t\t// Trim the non needed slash\n\t\t\tlinePath = string(line)\n\t\t} else if string(line) == \"\" {\n\t\t\tlinePath = \".\"\n\t\t} else {\n\t\t\tsplitPath := strings.Split(string(line), \"\\\\\")\n\t\t\tlinePath = strings.Join(splitPath[:len(splitPath)-1], \"\\\\\") + \"\\\\\"\n\t\t\tlastPath = splitPath[len(splitPath)-1]\n\t\t}\n\tdefault:\n\t\tif strings.HasSuffix(string(line), \"/\") {\n\t\t\t// If the the line is just \"/\", it means we start from filesystem root\n\t\t\tif string(line) == \"/\" {\n\t\t\t\tlinePath = \"/\"\n\t\t\t} else if string(line) == \"~/\" {\n\t\t\t\t// If we look for \"~\", we need to build the path manually\n\t\t\t\tlinePath = filepath.Join(\"/home\", ctx.CurrentAgent.Username)\n\n\t\t\t} else if strings.HasPrefix(string(line), \"~/\") && string(line) != \"~/\" {\n\t\t\t\t// If we used the \"~\" at the beginning, we still need to build the path\n\t\t\t\thomePath := filepath.Join(\"/home\", ctx.CurrentAgent.Username)\n\t\t\t\tlinePath = filepath.Join(homePath, strings.TrimPrefix(string(line), \"~/\"))\n\t\t\t} else {\n\t\t\t\t// Trim the non needed slash\n\t\t\t\tlinePath = strings.TrimSuffix(string(line), \"/\")\n\t\t\t}\n\t\t} else if strings.HasPrefix(string(line), \"~/\") && string(line) != \"~/\" {\n\t\t\t// If we used the \"~\" at the beginning, we still need to build the path\n\t\t\thomePath := filepath.Join(\"/home\", ctx.CurrentAgent.Username)\n\t\t\tlinePath = filepath.Join(homePath, filepath.Dir(strings.TrimPrefix(string(line), \"~/\")))\n\t\t\tlastPath = filepath.Base(string(line))\n\n\t\t} else if string(line) == \"\" {\n\t\t\tlinePath = \".\"\n\t\t} else {\n\t\t\t// linePath = string(line)\n\t\t\tlinePath = filepath.Dir(string(line))\n\t\t\tlastPath = filepath.Base(string(line))\n\t\t}\n\t}\n\n\t// 2) We take the absolute path we found, and get all dirs in it.\n\tvar dirs []string\n\n\trpc := ctx.Server.RPC\n\tdata, _ := proto.Marshal(&ghostpb.LsReq{\n\t\tGhostID: ctx.CurrentAgent.ID,\n\t\tPath: linePath,\n\t})\n\tresp := <-rpc(&ghostpb.Envelope{\n\t\tType: ghostpb.MsgLsReq,\n\t\tData: data,\n\t}, defaultTimeout)\n\tif resp.Err != \"\" {\n\t\tfmt.Printf(RPCError+\"%s\\n\", resp.Err)\n\t\treturn\n\t}\n\n\tdirList := &ghostpb.Ls{}\n\terr := proto.Unmarshal(resp.Data, dirList)\n\tif err != nil {\n\t\tfmt.Printf(Error+\"Unmarshaling envelope error: %v\\n\", err)\n\t\treturn\n\t}\n\n\tfor _, fileInfo := range dirList.Files {\n\t\tif fileInfo.IsDir {\n\t\t\tdirs = append(dirs, fileInfo.Name)\n\t\t}\n\t}\n\n\tswitch lastPath {\n\tcase \"\":\n\t\tfor _, dir := range dirs {\n\t\t\tsearch := \"\"\n\t\t\tif ctx.CurrentAgent.OS == \"windows\" {\n\t\t\t\tsearch = dir + \"\\\\\"\n\t\t\t} else {\n\t\t\t\tsearch = dir + \"/\"\n\t\t\t}\n\t\t\tif !hasPrefix([]rune(lastPath), []rune(search)) {\n\t\t\t\tsLine, sOffset := doInternal([]rune(lastPath), pos, len([]rune(lastPath)), []rune(search))\n\t\t\t\toptions = append(options, sLine...)\n\t\t\t\toffset = sOffset\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tfiltered := []string{}\n\t\tfor _, dir := range dirs {\n\t\t\tif strings.HasPrefix(dir, lastPath) {\n\t\t\t\tfiltered = append(filtered, dir)\n\t\t\t}\n\t\t}\n\n\t\tfor _, dir := range filtered {\n\t\t\tsearch := \"\"\n\t\t\tif ctx.CurrentAgent.OS == \"windows\" {\n\t\t\t\tsearch = dir + \"\\\\\"\n\t\t\t} else {\n\t\t\t\tsearch = dir + \"/\"\n\t\t\t}\n\t\t\tif !hasPrefix([]rune(lastPath), []rune(search)) {\n\t\t\t\tsLine, sOffset := doInternal([]rune(lastPath), pos, len([]rune(lastPath)), []rune(search))\n\t\t\t\toptions = append(options, sLine...)\n\t\t\t\toffset = sOffset\n\t\t\t}\n\t\t}\n\t}\n\n\treturn options, offset\n}", "func (v *TextView) StartsDisplayLine(iter *TextIter) bool {\n\treturn gobool(C.gtk_text_view_starts_display_line(v.native(), iter.native()))\n}", "func getNextViewLine(g *gocui.Gui, v *gocui.View) (string, error) {\n\tvar l string\n\tvar err error\n\n\t_, cy := v.Cursor()\n\tif l, err = v.Line(cy + 1); err != nil {\n\t\tl = \"\"\n\t}\n\n\treturn l, err\n}", "func (c *Completer) Query(source []byte, cursor int) (*Result, error) {\n\tcmd := exec.Command(c.GocodePath, \"-f=json\", \"autocomplete\", fmt.Sprintf(\"%d\", cursor))\n\n\tin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = writeClose(in, source)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tout, err := cmd.Output()\n\tif err != nil {\n\t\tif _, ok := err.(*exec.Error); ok {\n\t\t\t// cannot invoke gocode\n\t\t\tc.unavailable = true\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tvar result Result\n\terr = json.Unmarshal(out, &result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &result, nil\n}", "func (o *SearchComponentOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {\n\to.Context = genericclioptions.NewContext(cmd)\n\to.searchTerm = args[0]\n\n\to.components, err = catalog.SearchComponent(o.Client, o.searchTerm)\n\treturn err\n}", "func (app *App) doCompletion(args []string) (exitCode int) {\n\tif hasCompletionFlag(args) {\n\t\tcompletions, exitCode := doCompletion(app, args[1:])\n\t\tfor _, completion := range completions {\n\t\t\t_, _ = fmt.Fprintln(app.Stdout, completion)\n\t\t}\n\t\treturn int(exitCode)\n\t}\n\tapp.Subcommands = append(app.Subcommands, completionCommand(app.Name))\n\treturn -1\n}", "func completer(d prompt.Document) []prompt.Suggest {\n\tkeywords := []prompt.Suggest{\n\t\t{Text: \"SELECT\", Description: \"keyword\"},\n\t\t{Text: \"FROM\", Description: \"keyword\"},\n\t\t{Text: \"WHERE\", Description: \"keyword\"},\n\t\t{Text: \"LIMIT\", Description: \"keyword\"},\n\t\t{Text: \"DESC\", Description: \"keyword\"},\n\t\t{Text: \"TABLE\", Description: \"keyword\"},\n\t\t{Text: \"LIKE\", Description: \"keyword\"},\n\t\t{Text: \"ALL\", Description: \"keyword\"},\n\t\t{Text: \"AND\", Description: \"keyword\"},\n\t\t{Text: \"UPDATE\", Description: \"keyword\"},\n\t\t{Text: \"SET\", Description: \"keyword\"},\n\t\t{Text: \"RETRUNING\", Description: \"keyword\"},\n\t}\n\n\twordBefore := d.GetWordBeforeCursor()\n\tif wordBefore == \"\" {\n\t\treturn []prompt.Suggest{}\n\t}\n\tif d.TextBeforeCursor() == \" \" {\n\t\treturn tableNameSuggestions\n\t}\n\tif wordBefore == strings.ToUpper(wordBefore) && wordBefore != \"_\" && wordBefore != \"-\" && wordBefore != \" \" {\n\t\treturn prompt.FilterHasPrefix(keywords, d.GetWordBeforeCursor(), true)\n\t}\n\treturn prompt.FilterHasPrefix(tableNameSuggestions, d.GetWordBeforeCursor(), true)\n}", "func ShowSearch() {\n\tfmt.Printf(\"%v\\n\", searchText)\n}", "func (c *Completer) Query(ctx *Context, content IContent, line interface{}, index int) (interface{}, bool) {\n\treturn nil, false\n}", "func CommandShowActive(conf Config, ctx, query Query) error {\n\tts, err := LoadTaskSet(conf.Repo, conf.IDsFile, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tquery = query.Merge(ctx)\n\tts.Filter(query)\n\tts.FilterByStatus(STATUS_ACTIVE)\n\tts.DisplayByNext(ctx, true)\n\n\treturn nil\n}", "func (u Universe) Show() {\n\tfor _, row := range u {\n\t\tfor _, column := range row {\n\t\t\tif column {\n\t\t\t\tfmt.Print(\"*\")\n\t\t\t} else {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t}\n}", "func AutoComplete(text string, completionTree *CompTree, queryFunc SearchMethod) ([]Suggestion, error) {\n\tvar prev *CompTree = nil\n\tcurr := completionTree\n\tcurr = prev\n\tcurr = completionTree\n\n\tfields, err := shlex.Split(strings.TrimSpace(text))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlast := fields[len(fields)-1]\n\t// i.e. in \"git checkout --fie\", remove \"git\"\n\tfields = fields[1:]\n\tfor i, field := range fields {\n\t\tif strings.HasPrefix(field, \"-\") {\n\t\t\tcontinue\n\t\t}\n\t\tif i == len(fields)-1 && !strings.HasSuffix(text, \" \") {\n\t\t\tcontinue\n\t\t}\n\t\tif curr.Sub[field] != nil {\n\t\t\tprev = curr\n\t\t\tcurr = curr.Sub[field]\n\t\t} else if curr.Args[field] != nil {\n\t\t\tprev = curr\n\t\t\tcurr = curr.Args[field]\n\t\t}\n\t}\n\ts := make([]Suggestion, 0, 20)\n\t// ends with sub & space\n\tif curr == nil {\n\t\treturn s, nil\n\t} else if strings.HasSuffix(text, \" \") {\n\t\tif curr.Args != nil {\n\t\t\tfor k, v := range curr.Args {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif curr.Sub != nil {\n\t\t\tfor k, v := range curr.Sub {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif curr.Dynamic != nil {\n\t\t\ts = append(s, curr.Dynamic(\"\")...)\n\t\t}\n\n\t} else if strings.HasPrefix(last, \"-\") { // ends with flag\n\t\thasTwoDashes := strings.HasPrefix(last, \"--\")\n\t\tsearchTerm := strings.TrimPrefix(last, \"-\")\n\t\tsearchTerm = strings.TrimPrefix(searchTerm, \"-\")\n\t\tfor k, v := range curr.Flags {\n\t\t\tif hasTwoDashes && len(k) > 1 && (strings.HasPrefix(k, searchTerm) || searchTerm == \"\") {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t\tif !hasTwoDashes && len(k) == 1 {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\t// if NOT a flag and IS a \"search\" value\n\tif !strings.HasPrefix(last, \"-\") && !strings.HasSuffix(text, \" \") {\n\t\tfor k, v := range curr.Args {\n\t\t\tif queryFunc(k, last) {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tfor k, v := range curr.Sub {\n\t\t\tif queryFunc(k, last) {\n\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\tName: k,\n\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif curr.Dynamic != nil {\n\t\t\tfor _, v := range curr.Dynamic(\"\") {\n\t\t\t\tif queryFunc(v.Name, last) {\n\t\t\t\t\ts = append(s, Suggestion{\n\t\t\t\t\t\tName: v.Name,\n\t\t\t\t\t\tDesc: v.Desc,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// ends with = (suggest flag args)\n\tif strings.HasPrefix(last, \"-\") && strings.HasSuffix(last, \"=\") {\n\t\tflagName := strings.TrimPrefix(last, \"-\")\n\t\tflagName = strings.TrimPrefix(flagName, \"-\")\n\t\tflagName = strings.TrimSuffix(flagName, \"=\")\n\t\tflagCompleter := curr.Flags[flagName]\n\t\tfor k, v := range flagCompleter.Args {\n\t\t\ts = append(s, Suggestion{\n\t\t\t\tName: k,\n\t\t\t\tDesc: v.Desc,\n\t\t\t})\n\t\t}\n\t\tfor k, v := range flagCompleter.Sub {\n\t\t\ts = append(s, Suggestion{\n\t\t\t\tName: k,\n\t\t\t\tDesc: v.Desc,\n\t\t\t})\n\t\t}\n\t}\n\n\t// ends with flag & space\n\t// ends with sub\n\n\treturn s, nil\n}", "func CompleteCommandArguments(cmd *flags.Command, arg string, line []rune, pos int) (lastWord string, completions []*readline.CompletionGroup) {\n\n\t_, _, lastWord = FormatInput(line)\n\n\treturn\n}", "func (parser *MarpaParser) recordCompletion(start, end int, term Term) {\n\tc := AhfaCompletion{start, end, term}\n\tparser.cnodes = append(parser.cnodes, c)\n}", "func newCompletionCmd() *cobra.Command {\n\tvar completionCmd = &cobra.Command{\n\t\tUse: \"completion [bash|zsh|fish]\",\n\t\tShort: \"Generate completion script\",\n\t\tLong: `To load completions:\n\nBash:\n\n$ source <(eden completion bash)\n\n# To load completions for each session, execute once:\nLinux:\n $ eden utils completion bash > /etc/bash_completion.d/eden\nMacOS:\n $ eden utils completion bash > /usr/local/etc/bash_completion.d/eden\n\nZsh:\n\n# If shell completion is not already enabled in your environment you will need\n# to enable it. You can execute the following once:\n\n$ echo \"autoload -U compinit; compinit\" >> ~/.zshrc\n\n# To load completions for each session, execute once:\n$ eden utils completion zsh > \"${fpath[1]}/_eden\"\n\n# You will need to start a new shell for this setup to take effect.\n\nFish:\n\n$ eden utils completion fish | source\n\n# To load completions for each session, execute once:\n$ eden utils completion fish > ~/.config/fish/completions/eden.fish\n`,\n\t\tDisableFlagsInUseLine: true,\n\t\tValidArgs: []string{\"bash\", \"zsh\", \"fish\"},\n\t\tArgs: cobra.ExactValidArgs(1),\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tswitch args[0] {\n\t\t\tcase \"bash\":\n\t\t\t\terr := cmd.Root().GenBashCompletion(os.Stdout)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr,\n\t\t\t\t\t\t\"Completions generation error: %s\",\n\t\t\t\t\t\terr.Error())\n\t\t\t\t}\n\t\t\tcase \"zsh\":\n\t\t\t\terr := cmd.Root().GenZshCompletion(os.Stdout)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr,\n\t\t\t\t\t\t\"Completions generation error: %s\",\n\t\t\t\t\t\terr.Error())\n\t\t\t\t}\n\t\t\tcase \"fish\":\n\t\t\t\terr := cmd.Root().GenFishCompletion(os.Stdout, true)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Fprintf(os.Stderr,\n\t\t\t\t\t\t\"Completions generation error: %s\",\n\t\t\t\t\t\terr.Error())\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t}\n\treturn completionCmd\n}", "func (p *Parser) WithOptCompleter(c Completer) *Parser {\n\tp.nextCompleter = c\n\treturn p\n}", "func Usage() {\n\tfmt.Fprintf(os.Stderr, \"Usage of %s:\\n\", os.Args[0])\n\tfmt.Fprintf(os.Stderr, \"\\tgen-bash-completion\\n\")\n\tos.Exit(2)\n}", "func (d *Dispatcher) CompletionSuggestionsCursor(parse *ParseResults, cursor int) (*Suggestions, error) {\n\tctx := parse.Context\n\n\tnodeBeforeCursor, err := ctx.FindSuggestionContext(cursor)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tparent := nodeBeforeCursor.Parent\n\tstart := min(nodeBeforeCursor.Start, cursor)\n\n\tfullInput := parse.Reader.String\n\ttruncatedInput := fullInput[:cursor]\n\ttruncatedInputLowerCase := strings.ToLower(truncatedInput)\n\tsuggestions := make([]*Suggestions, 0, len(parent.Children()))\n\tparent.ChildrenOrdered().Range(func(_ string, node CommandNode) bool {\n\t\tif !CanProvideSuggestions(node) {\n\t\t\treturn true\n\t\t}\n\t\tsuggestions = append(suggestions, ProvideSuggestions(node, ctx.build(truncatedInput), &SuggestionsBuilder{\n\t\t\tInput: truncatedInput,\n\t\t\tInputLowerCase: truncatedInputLowerCase,\n\t\t\tStart: start,\n\t\t\tRemaining: truncatedInput[start:],\n\t\t\tRemainingLowerCase: truncatedInputLowerCase[start:],\n\t\t}))\n\t\treturn true\n\t})\n\n\treturn MergeSuggestions(fullInput, suggestions), nil\n}", "func Line(prompt string) (string, error) {\n\tins := getInstance()\n\tins.SetPrompt(prompt)\n\treturn ins.Readline()\n}", "func (tb *TextBuf) CompleteText(s string) {\n\tif s == \"\" {\n\t\treturn\n\t}\n\t// give the completer a chance to edit the completion before insert,\n\t// also it return a number of runes past the cursor to delete\n\tst := TextPos{tb.Complete.SrcLn, 0}\n\ten := TextPos{tb.Complete.SrcLn, tb.LineLen(tb.Complete.SrcLn)}\n\tvar tbes string\n\ttbe := tb.Region(st, en)\n\tif tbe != nil {\n\t\ttbes = string(tbe.ToBytes())\n\t}\n\tc := tb.Complete.GetCompletion(s)\n\tpos := TextPos{tb.Complete.SrcLn, tb.Complete.SrcCh}\n\ted := tb.Complete.EditFunc(tb.Complete.Context, tbes, tb.Complete.SrcCh, c, tb.Complete.Seed)\n\tif ed.ForwardDelete > 0 {\n\t\tdelEn := TextPos{tb.Complete.SrcLn, tb.Complete.SrcCh + ed.ForwardDelete}\n\t\ttb.DeleteText(pos, delEn, true, false)\n\t}\n\t// now the normal completion insertion\n\tst = pos\n\tst.Ch -= len(tb.Complete.Seed)\n\ttb.DeleteText(st, pos, true, false)\n\ttb.InsertText(st, []byte(ed.NewText), true, true)\n\tif tb.CurView != nil {\n\t\tep := st\n\t\tep.Ch += len(ed.NewText) + ed.CursorAdjust\n\t\ttb.CurView.SetCursorShow(ep)\n\t\ttb.CurView = nil\n\t}\n}", "func (u Universe) Show() {\n\tfmt.Print(\"\\x0c\", u.String())\n}", "func (u Universe) Show() {\n\tfmt.Print(\"\\x0c\", u.String())\n}", "func FactoryCompletion(factory CommandFactory, log logging.Logger, cmdName string) func(*cli.Context) {\n\treturn func(c *cli.Context) {\n\t\tcmd := factory(c, log, cmdName)\n\n\t\t// If the command implements AutocompleteCommand, run the autocomplete.\n\t\tif aCmd, ok := cmd.(AutocompleteCommand); ok {\n\t\t\tif err := aCmd.Autocomplete(c.Args()...); err != nil {\n\t\t\t\tlog.Error(\n\t\t\t\t\t\"Autocompletion of a command encountered error. command:%s, err:%s\",\n\t\t\t\t\tcmdName, err,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\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 advanceScreen(rows int) {\n\tsetCursorRow(terminalHeight)\n\tfmt.Print(strings.Repeat(lineBreak, rows))\n}", "func (file *File) AllLineBa(term string) {\n\tfile.MultiCursor.OnePerLine()\n\tpositions := make(map[int][]int)\n\tfound := 0\n\tfor _, cursor := range file.MultiCursor.Cursors() {\n\t\trow, col := cursor.RowCol()\n\t\tcols := file.buffer.GetRow(row).SearchAll(term, col, 0)\n\t\tpositions[row] = cols\n\t\tfound += len(cols)\n\t}\n\tif found > 0 {\n\t\tfile.MultiCursor.ResetRowsCols(positions)\n\t}\n}", "func (a *Autocompleter) Suggest(prefix string, num int, fuzzy bool) (ret []Suggestion, err error) {\n\tconn := a.pool.Get()\n\tdefer conn.Close()\n\n\tseropts := DefaultSuggestOptions\n\tseropts.Num = num\n\tseropts.Fuzzy = fuzzy\n\targs, inc := a.Serialize(prefix, seropts)\n\n\tvals, err := redis.Strings(conn.Do(\"FT.SUGGET\", args...))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tret = ProcessSugGetVals(vals, inc, true, false)\n\n\treturn\n}", "func (tb *TextBuf) CompleteExtend(s string) {\n\tif s == \"\" {\n\t\treturn\n\t}\n\tpos := TextPos{tb.Complete.SrcLn, tb.Complete.SrcCh}\n\tst := pos\n\tst.Ch -= len(tb.Complete.Seed)\n\ttb.DeleteText(st, pos, true, false)\n\ttb.InsertText(st, []byte(s), true, true)\n\tif tb.CurView != nil {\n\t\tep := st\n\t\tep.Ch += len(s)\n\t\ttb.CurView.SetCursorShow(ep)\n\t\ttb.CurView = nil\n\t}\n}", "func (tv *TextView) JumpToLinePrompt() {\n\tgi.StringPromptDialog(tv.Viewport, \"\", \"Line no..\",\n\t\tgi.DlgOpts{Title: \"Jump To Line\", Prompt: \"Line Number to jump to\"},\n\t\ttv.This(), func(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tdlg := send.(*gi.Dialog)\n\t\t\tif sig == int64(gi.DialogAccepted) {\n\t\t\t\tval := gi.StringPromptDialogValue(dlg)\n\t\t\t\tln, ok := kit.ToInt(val)\n\t\t\t\tif ok {\n\t\t\t\t\ttv.JumpToLine(int(ln))\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n}", "func (o *Options) Complete(cmd *cobra.Command, args []string) error {\n\to.args = args\n\n\tclientConfig := o.configFlags.ToRawKubeConfigLoader()\n\tvar err error\n\to.rawConfig, err = clientConfig.RawConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcurrentContext, exists := o.rawConfig.Contexts[o.rawConfig.CurrentContext]\n\tif !exists {\n\t\treturn errNoContext\n\t}\n\tcurrentAuthInfo, exists := o.rawConfig.AuthInfos[currentContext.AuthInfo]\n\tif !exists {\n\t\treturn errNoUser\n\t}\n\n\to.authInfo = currentContext.AuthInfo\n\to.resultingAuthInfo = currentAuthInfo.DeepCopy()\n\n\treturn nil\n}", "func usage() {\n\tfor _, key := range commandKeys {\n\t\tfmt.Printf(\"%v\\n\", commands[key])\n\t}\n\n}", "func usage() {\n\tfor _, key := range commandKeys {\n\t\tfmt.Printf(\"%v\\n\", commands[key])\n\t}\n\n}", "func (info *Info) Run(c Cursor) {\n\tp := c.P()\n\tif !info.HeadLess {\n\t\tp.Printf(\"info %v {\", info.Domain)\n\t\tp.ShiftIn()\n\t\tdefer p.ShiftOut(\"}\")\n\t}\n\n\tips := info.run(c)\n\tif c.E() != nil {\n\t\treturn\n\t}\n\n\tif !info.HideResult {\n\t\tips.PrintResult(c)\n\n\t\tif len(info.NameServers) > 0 {\n\t\t\tp.Print()\n\t\t\tfor _, ns := range info.NameServers {\n\t\t\t\tp.Printf(\"// %v\", ns)\n\t\t\t}\n\t\t}\n\n\t\tif len(info.Records) > 0 {\n\t\t\tp.Print()\n\t\t\tfor _, rr := range info.Records {\n\t\t\t\tp.Printf(\"// %s\", rr.Digest())\n\t\t\t}\n\t\t}\n\t}\n}", "func BufferComplete(b *Buffer) ([]string, []string) {\n\tc := b.GetActiveCursor()\n\tinput, argstart := GetWord(b)\n\n\tif argstart == -1 {\n\t\treturn []string{}, []string{}\n\t}\n\n\tinputLen := util.CharacterCount(input)\n\n\tsuggestionsSet := make(map[string]struct{})\n\n\tvar suggestions []string\n\tfor i := c.Y; i >= 0; i-- {\n\t\tl := b.LineBytes(i)\n\t\twords := bytes.FieldsFunc(l, util.IsNonAlphaNumeric)\n\t\tfor _, w := range words {\n\t\t\tif bytes.HasPrefix(w, input) && util.CharacterCount(w) > inputLen {\n\t\t\t\tstrw := string(w)\n\t\t\t\tif _, ok := suggestionsSet[strw]; !ok {\n\t\t\t\t\tsuggestionsSet[strw] = struct{}{}\n\t\t\t\t\tsuggestions = append(suggestions, strw)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor i := c.Y + 1; i < b.LinesNum(); i++ {\n\t\tl := b.LineBytes(i)\n\t\twords := bytes.FieldsFunc(l, util.IsNonAlphaNumeric)\n\t\tfor _, w := range words {\n\t\t\tif bytes.HasPrefix(w, input) && util.CharacterCount(w) > inputLen {\n\t\t\t\tstrw := string(w)\n\t\t\t\tif _, ok := suggestionsSet[strw]; !ok {\n\t\t\t\t\tsuggestionsSet[strw] = struct{}{}\n\t\t\t\t\tsuggestions = append(suggestions, strw)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif len(suggestions) > 1 {\n\t\tsuggestions = append(suggestions, string(input))\n\t}\n\n\tcompletions := make([]string, len(suggestions))\n\tfor i := range suggestions {\n\t\tcompletions[i] = util.SliceEndStr(suggestions[i], c.X-argstart)\n\t}\n\n\treturn completions, suggestions\n}", "func (client UsageDetailsClient) ListComplete(ctx context.Context, 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.List\")\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.List(ctx, expand, filter, skiptoken, top, apply)\n\treturn\n}", "func completionColorizer(completed bool) string {\n\tif completed {\n\t\treturn color.HiGreenString(\"pwnd\")\n\t}\n\n\treturn color.HiYellowString(\"incomplete\")\n}", "func CmdShow(c *cli.Context) error {\n\tconfig, err := config.FromFile(c)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error: %v\", err)\n\t}\n\n\tfiles, err := config.FilesToParse(c)\n\tif err != nil {\n\t\tif c.GlobalBool(\"debug\") || config.Debug {\n\t\t\tlog.Printf(\"error while making list of files to parse: %v\", err)\n\t\t}\n\t}\n\n\tlog.Printf(\"Enver config file: %s\", c.GlobalString(\"config\"))\n\tlog.Printf(\"Debug mode: %t\", c.GlobalBool(\"debug\") || config.Debug)\n\tlog.Printf(\"Quiet: %t\", c.GlobalBool(\"quiet\") || config.Quiet)\n\tlog.Println(\"Files:\")\n\tfor _, f := range files {\n\t\tlog.Printf( \"\\t- %s\", f)\n\t}\n\n\treturn nil\n}", "func DrawHelp(v *gocui.View) {\n\n\tfmt.Fprint(v, style.Header(`\n\t--> PRESS CTRL+I TO CLOSE THIS AND CONTINUE. YOU CAN OPEN IT AGAIN WITH CRTL+I AT ANY TIME. <-- \n _ ___ \n /_\\ __| _ )_ _ _____ __ _____ ___ \n / _ \\ |_ / _ \\ '_/ _ \\ V V (_-</ -_) \n /_/ \\_\\/__|___/_| \\___/\\_/\\_//__/\\___| \n Interactive CLI for browsing Azure resources \n# Navigation \n \n| Key | Does | \n| ----------- | -------------------- | \n| ⇧ / ⇩ | Select resource | \n| ⇦ / ⇨ | Select Menu/JSON | \n| Backspace | Go back | \n| ENTER | Expand/View resource | \n| F5 | Refresh | \n| CTRL+I | Show this page | \n \n# Operations\t \n \n| Key | Does | | \n| ------------------- | ------------------------- | ---------------------------------------------------------------------------------- | \n| CTRL+E | Toggle Browse JSON | For longer responses you can move the cursor to scroll the doc | \n| CTLT+F | Toggle Fullscreen | Gives a fullscreen view of the JSON for smaller terminals | \n| CTRL+O (o for open) | Open Portal | Opens the portal at the currently selected resource | \n| DEL | Delete resource | The currently selected resource will be deleted (Requires double press to confirm) | \n| CTLT+S | Save JSON to clipboard | Saves the last JSON response to the clipboard for export | \n| CTLT+A | View Actions for resource | This allows things like ListKeys on storage or Restart on VMs | \n \nFor bugs, issue or to contribute visit: https://github.com/lawrencegripper/azbrowse \n \n# Status Icons \n \nDeleting: ☠ Failed: ⛈ Updating: ⟳ Resuming/Starting: ⛅ Provisioning: ⌛ \nCreating\\Preparing: 🏗 Scaling: ⚖ Suspended/Suspending: ⛔ Succeeded: 🌣 \n \n--> PRESS CTRL+I TO CLOSE THIS AND CONTINUE. YOU CAN OPEN IT AGAIN WITH CRTL+I AT ANY TIME. <-- \n\n`))\n\n}", "func (c *Console) Summary(text string) <-chan struct{} {\n\tch := make(chan struct{})\n\tc.jobs <- func() {\n\t\tc.summary = text\n\t\tfmt.Fprintf(c.File, \"\\r%c[2K\", 27)\n\t\tfmt.Fprintf(c.File, \"%s\\r\", text)\n\t\tclose(ch)\n\t}\n\treturn ch\n}" ]
[ "0.577039", "0.5513616", "0.54690325", "0.535265", "0.5350186", "0.5346948", "0.53078324", "0.52985865", "0.52985865", "0.52361923", "0.5227993", "0.5221723", "0.5212293", "0.5185051", "0.51619595", "0.51104", "0.5102009", "0.5090584", "0.50661045", "0.5064182", "0.50274915", "0.49770582", "0.4951627", "0.49089575", "0.48861536", "0.48808074", "0.4829634", "0.4825313", "0.4813657", "0.47987163", "0.47706562", "0.47684014", "0.4751468", "0.47498435", "0.47494635", "0.47440833", "0.47434178", "0.47359502", "0.4727249", "0.47009575", "0.46845517", "0.4670106", "0.46660545", "0.46487117", "0.4639216", "0.46373656", "0.4587309", "0.45758098", "0.4564645", "0.45613626", "0.4536696", "0.45287755", "0.45194536", "0.45094588", "0.449386", "0.4491284", "0.44900894", "0.44856605", "0.44393843", "0.4439316", "0.4438101", "0.44301742", "0.44201976", "0.44100934", "0.44040784", "0.43888563", "0.43729484", "0.43714687", "0.43648133", "0.43621054", "0.43548563", "0.4351912", "0.43502015", "0.43487495", "0.43338272", "0.4328938", "0.43284622", "0.43282747", "0.43250838", "0.43134272", "0.42870095", "0.42735925", "0.42735925", "0.42722145", "0.42609552", "0.42606637", "0.425636", "0.42529133", "0.42494068", "0.4247482", "0.42453465", "0.4242483", "0.4242483", "0.4240891", "0.42363715", "0.42317462", "0.4227974", "0.42266637", "0.42253867", "0.4220562" ]
0.6026927
0
Return a string for the current line buffer.
func (ls *linestate) String() string { return string(ls.buf) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Buffer() string {\n\treturn C.GoString(C.rl_line_buffer)\n}", "func (cl *charLine) string() string {\n\treturn string(*cl)\n}", "func (l Line) String() string {\n\treturn *(*string)(unsafe.Pointer(&l.line))\n}", "func (s *Buffer) String() string {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\treturn s.buffer.String()\n}", "func (l *Line) String() string { return string(l.s) }", "func (b *Buffer) String() string {\n\treturn string(b.buf)\n}", "func (e *ObservableEditableBuffer) String() string {\n\treturn e.f.String()\n}", "func (b *Buffer) Line(n int) string {\n\tif n >= len(b.lines) {\n\t\treturn \"\"\n\t}\n\treturn string(b.lines[n].data)\n}", "func (p *StringBuilder) String() string {\n\treturn string(p.buffer)\n}", "func (b *LimitedBuffer) String() string {\n\treturn string(b.buf)\n}", "func (p *parser) line() string {\n\tif !p.valid() {\n\t\treturn \"\"\n\t}\n\tl := p.lines[p.idx]\n\tp.idx++\n\treturn l\n}", "func (w *Wrap) String() string {\n\treturn w.buf.String()\n}", "func (b *SafeBuffer) String() string {\n\tb.m.RLock()\n\tdefer b.m.RUnlock()\n\treturn b.b.String()\n}", "func (l *StringLexer) BufferString() string {\n\treturn l.input[l.start:l.pos]\n}", "func (buffer *Buffer) String() string {\n\tif buffer == nil {\n\t\treturn \"<nil>\"\n\t}\n\treturn buffer.B.String()\n}", "func (w *Reflow) String() string {\n\treturn w.buf.String()\n}", "func (i *Input) Buffer() Buffer {\n\tbuf := i.Block.Buffer()\n\n\t// offset used to display the line numbers\n\ttextXOffset := 0\n\n\tbufferLines := i.lines[:]\n\tfirstLine := 0\n\tlastLine := i.innerArea.Dy()\n\tif i.IsMultiLine {\n\t\tif i.cursorLineIndex >= lastLine {\n\t\t\tfirstLine += i.cursorLineIndex - lastLine + 1\n\t\t\tlastLine += i.cursorLineIndex - lastLine + 1\n\t\t}\n\n\t\tif len(i.lines) < lastLine {\n\t\t\tbufferLines = i.lines[firstLine:]\n\t\t} else {\n\t\t\tbufferLines = i.lines[firstLine:lastLine]\n\t\t}\n\t}\n\n\tif i.ShowLineNo {\n\t\t// forcing space for up to 1K\n\t\tif lastLine < LINE_NO_MIN_SPACE {\n\t\t\ttextXOffset = len(strconv.Itoa(LINE_NO_MIN_SPACE)) + 2\n\t\t} else {\n\t\t\ttextXOffset = len(strconv.Itoa(lastLine)) + 2 // one space at the beginning and one at the end\n\t\t}\n\t}\n\n\ttext := strings.Join(bufferLines, NEW_LINE)\n\n\t// if the last line is empty then we add a fake space to make sure line numbers are displayed\n\tif len(bufferLines) > 0 && bufferLines[len(bufferLines)-1] == \"\" && i.ShowLineNo {\n\t\ttext += \" \"\n\t}\n\n\tfg, bg := i.TextFgColor, i.TextBgColor\n\tcs := i.TextBuilder.Build(text, fg, bg)\n\ty, x, n := 0, 0, 0\n\tlineNoCnt := 1\n\n\tfor n < len(cs) {\n\t\tw := cs[n].Width()\n\n\t\tif x == 0 && i.ShowLineNo {\n\t\t\tcurLineNoString := \" \" + strconv.Itoa(lineNoCnt) +\n\t\t\t\tstrings.Join(make([]string, textXOffset-len(strconv.Itoa(lineNoCnt))-1), \" \")\n\t\t\t//i.debugMessage = \"Line no: \" + curLineNoString\n\t\t\tcurLineNoRunes := i.TextBuilder.Build(curLineNoString, fg, bg)\n\t\t\tfor lineNo := 0; lineNo < len(curLineNoRunes); lineNo++ {\n\t\t\t\tbuf.Set(i.innerArea.Min.X+x+lineNo, i.innerArea.Min.Y+y, curLineNoRunes[lineNo])\n\t\t\t}\n\t\t\tlineNoCnt++\n\t\t}\n\n\t\tif cs[n].Ch == '\\n' {\n\t\t\ty++\n\t\t\tn++\n\t\t\tx = 0 // set x = 0\n\t\t\tcontinue\n\t\t}\n\t\tbuf.Set(i.innerArea.Min.X+x+textXOffset, i.innerArea.Min.Y+y, cs[n])\n\n\t\tn++\n\t\tx += w\n\t}\n\n\tcursorXOffset := i.X + textXOffset\n\tif i.BorderLeft {\n\t\tcursorXOffset++\n\t}\n\n\tcursorYOffset := i.Y// termui.TermHeight() - i.innerArea.Dy()\n\tif i.BorderTop {\n\t\tcursorYOffset++\n\t}\n\tif lastLine > i.innerArea.Dy() {\n\t\tcursorYOffset += i.innerArea.Dy() - 1\n\t} else {\n\t\tcursorYOffset += i.cursorLineIndex\n\t}\n\tif i.IsCapturing {\n\t\ti.CursorX = i.cursorLinePos+cursorXOffset\n\t\ti.CursorY = cursorYOffset\n\t\ttermbox.SetCursor(i.cursorLinePos+cursorXOffset, cursorYOffset)\n\t}\n\n\t/*\n\t\tif i.DebugMode {\n\t\t\tposition := fmt.Sprintf(\"%s li: %d lp: %d n: %d\", i.debugMessage, i.cursorLineIndex, i.cursorLinePos, len(i.lines))\n\n\t\t\tfor idx, char := range position {\n\t\t\t\tbuf.Set(i.innerArea.Min.X+i.innerArea.Dx()-len(position) + idx,\n\t\t\t\t\ti.innerArea.Min.Y+i.innerArea.Dy()-1,\n\t\t\t\t\tCell{Ch: char, Fg: i.TextFgColor, Bg: i.TextBgColor})\n\t\t\t}\n\t\t}\n\t*/\n\treturn buf\n}", "func Line() string {\n\treturn \"================================================================================\"\n}", "func (b *Buf) String() string { return string(b.b) }", "func (p *StreamParser) LineText() string {\n\treturn p.machine.LineText()\n}", "func (ml *MemoryLogger) String() string {\n\treturn ml.RingBuffer.String()\n}", "func (e *Editor) Line() (string, error) {\n\tif err := e.editReset(); err != nil {\n\t\treturn string(e.Buffer), err\n\t}\nline:\n\tfor {\n\t\tr, _, err := e.In.ReadRune()\n\t\tif err != nil {\n\t\t\treturn string(e.Buffer), err\n\t\t}\n\n\t\tswitch r {\n\t\tcase enter:\n\t\t\tbreak line\n\t\tcase ctrlC:\n\t\t\treturn string(e.Buffer), errors.New(\"try again\")\n\t\tcase backspace, ctrlH:\n\t\t\tif err := e.editBackspace(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlD:\n\t\t\tif len(e.Buffer) == 0 {\n\t\t\t\treturn string(e.Buffer), io.EOF\n\t\t\t}\n\n\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlT:\n\t\t\tif err := e.editSwap(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlB:\n\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlF:\n\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlP:\n\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlN:\n\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlU:\n\t\t\tif err := e.editReset(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlK:\n\t\t\tif err := e.editKillForward(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlA:\n\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlE:\n\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlL:\n\t\t\tif err := e.clearScreen(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tif err := e.refreshLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlW:\n\t\t\tif err := e.editDeletePrevWord(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase esc:\n\t\t\tr, _, err := e.In.ReadRune()\n\t\t\tif err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tswitch r {\n\t\t\tcase '[':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase '0', '1', '2', '4', '5', '6', '7', '8', '9':\n\t\t\t\t\t_, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase '3':\n\t\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch r {\n\t\t\t\t\tcase '~':\n\t\t\t\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'A':\n\t\t\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'B':\n\t\t\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'C':\n\t\t\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'D':\n\t\t\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase 'O':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase tab:\n\t\t\tif err := e.completeLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tdefault:\n\t\t\tif err := e.editInsert(r); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn string(e.Buffer), nil\n}", "func (s *RawMessage) String() string {\n\treturn s.Lines.String()\n}", "func (ps *Parser) currentChar() string {\n\treturn string(ps.Runes[ps.Offset])\n}", "func Line() string {\n\treturn fmt.Sprintf(\"%v@%v-%v-%v\",\n\t\tInfo.User,\n\t\tInfo.Host,\n\t\tInfo.Version,\n\t\tInfo.GitRevision)\n}", "func (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}", "func (e *Env) GetLine() (string, error) {\n\t//fmt.Println(\"GetLine\")\n\tif e.fileInfo.curFileScanner == nil {\n\t\t//fmt.Println(\"Getline openNextFile\")\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\tfor !(e.fileInfo.curFileScanner).Scan() {\n\t\t//fmt.Printf(\"Getline scan finished -> openNextFile: Scanner.Err=%v\\n\", e.fileInfo.curFileScanner.Err())\n\t\tif err := e.fileInfo.curFileScanner.Err(); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif len(e.fileInfo.files) == 0 {\n\t\t\t// when read from Stdin\n\t\t\treturn \"\", io.EOF\n\t\t}\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\te.IncFNR()\n\te.IncNR()\n\treturn e.fileInfo.curFileScanner.Text(), nil\n}", "func (b *LogBuffer) String() string {\n\tvar str strings.Builder\n\tstr.WriteString(\"{\")\n\tif b.header != nil && len(b.header) != 0 {\n\t\tb.headerMU.RLock()\n\t\thdr, err := json.Marshal(b.header)\n\t\tb.headerMU.RUnlock()\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error encoding logBuffer JSON\")\n\t\t}\n\t\tstr.Write(hdr[1 : len(hdr)-1])\n\t\tstr.WriteString(\",\")\n\t}\n\tstr.WriteString(\"\\\"entries\\\":[\" + strings.TrimSuffix(b.Buff.String(), \",\") + \"]\")\n\tif b.AddBanner {\n\t\tstr.WriteString(b.banner)\n\t}\n\tstr.WriteString(\"}\\n\")\n\treturn str.String()\n}", "func sendAndGetOneLine(conn *Conn, command string) string {\n\tconn.WriteAndFlushString(command)\n\tline, _, _ := conn.bufReader.ReadLine()\n\tres := string(line)\n\tfmt.Printf(\"res : %s\\n\", res)\n\treturn res\n}", "func (h *History) GetLine(idx int) string {\n return h.histories[idx]\n}", "func (rb *RabinKarp) CurrentWindowText() string {\n\treturn rb.Text[rb.Start:rb.End]\n}", "func (n *Node) Line() string {\n\treturn linestr(n.Pos)\n}", "func (l *Line) ToString() string {\n\treturn string(l.runes)\n}", "func (s *BufferSink) String() string {\n\treturn s.buf.String()\n}", "func (t *TmplParser) String() string {\n\treturn t.buffer.String()\n}", "func (t *LineTable) string(off uint32) string {\n\treturn t.stringFrom(t.funcdata, off)\n}", "func (b *buffer) Flush() string {\n\treturn strings.Join(b.lines, \"\")\n}", "func (l *Lexer) Current() string {\n\treturn l.input[l.start:l.pos]\n}", "func (rw *ReadWrite) GetStr() string {\n\tn := rw.GetSize()\n\ts := rw.GetN(n)\n\ttrace.ClientServer.Println(\" <-\", s)\n\treturn s\n}", "func (c *ConsoleWrapper) CurrentState() string {\n\treturn c.state.String()\n}", "func (c *ConsoleWrapper) CurrentState() string {\n\treturn c.state.String()\n}", "func (e *formattedEmail) String() string {\n\treturn e.buffer.String()\n}", "func (str selfString) LineNumber() uint {\n\treturn str.lineNumber\n}", "func (ep *ExpectProcess) ReadLine() string {\n\tep.mu.Lock()\n\tdefer ep.mu.Unlock()\n\tif ep.count > ep.cur {\n\t\tline := ep.lines[ep.cur]\n\t\tep.cur++\n\t\treturn line\n\t}\n\treturn \"\"\n}", "func srcLine(src []byte, p token.Position) string {\n\t// Run to end of line in both directions if not at line start/end.\n\tlo, hi := p.Offset, p.Offset+1\n\tfor lo > 0 && src[lo-1] != '\\n' {\n\t\tlo--\n\t}\n\tfor hi < len(src) && src[hi-1] != '\\n' {\n\t\thi++\n\t}\n\treturn string(src[lo:hi])\n}", "func (w *Writer) String() string {\n\treturn w.buf.String()\n}", "func (b *AppendOnlyBufferedBatch) String() string {\n\t// String should not be used in the fast paths, so we will set the length on\n\t// the wrapped batch (which might be a bit expensive but is ok).\n\tb.batch.SetLength(b.length)\n\treturn b.batch.String()\n}", "func (io *Io) NextLine() string {\n\tif io.nextToken < len(io.tokens) {\n\t\tpanic(\"io.nextToken < len(io.tokens)\")\n\t}\n\n\tvar buffer bytes.Buffer\n\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer.Write(line)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn buffer.String()\n}", "func (b *Buffer) GetString() (ret string) {\n\tlength, err := b.data.ReadByte()\n\tif err != nil || length == 0 {\n\t\treturn ret\n\t}\n\tStrData := make([]byte, length)\n\tif _, err := io.ReadFull(b.data, StrData); err != nil {\n\t\treturn ret\n\t}\n\tif bytes.Contains(StrData, []byte(\"\\x1b\\n\\xf5\\n\")) {\n\t\tStrData = StrData[4:]\n\t}\n\treturn string(StrData)\n}", "func (r *Reader) String() string {\n\treturn string(r.v[r.p:])\n}", "func nextLine() string {\n\t_, _, line, _ := runtime.Caller(1)\n\treturn strconv.Itoa(line + 1)\n}", "func (line Line) String() string {\n\tif len(line) == 0 {\n\t\treturn lineWKTEmpty\n\t}\n\treturn lineWKTPrefix + pointsString(line)\n}", "func SourceLine() string {\n\tvar out []string\n\tfor i := 0; i < 2; i++ {\n\t\t_, file, line, ok := runtime.Caller(i)\n\t\tif ok {\n\t\t\tslash := strings.LastIndex(file, \"/\")\n\t\t\tfile = file[slash+1:]\n\t\t\tmsg := fmt.Sprintf(\"%s:%d\", file, line)\n\t\t\tout = append(out, msg)\n\t\t}\n\t}\n\treturn strings.Join(out, \" -> \")\n}", "func NextLine() string {\n\tsc.Scan()\n\treturn sc.Text()\n}", "func (i *Input) ToString() string {\n\treturn i.Buffer.ToString()\n}", "func (reader *ExtentReader) String() (m string) {\n\treturn fmt.Sprintf(\"inode (%v) extentKey(%v)\", reader.inode,\n\t\treader.key.Marshal())\n}", "func (p *Par) Buffer() Buffer {\n\tbuf := p.Block.Buffer()\n\n\tfg, bg := p.TextFgColor, p.TextBgColor\n\tcs := DefaultTxBuilder.Build(p.Text, fg, bg)\n\n\t// wrap if WrapLength set\n\tif p.WrapLength < 0 {\n\t\tcs = wrapTx(cs, p.Width-2)\n\t} else if p.WrapLength > 0 {\n\t\tcs = wrapTx(cs, p.WrapLength)\n\t}\n\n\ty, x, n := 0, 0, 0\n\tfor y < p.innerArea.Dy() && n < len(cs) {\n\t\tw := cs[n].Width()\n\t\tif cs[n].Ch == '\\n' || x+w > p.innerArea.Dx() {\n\t\t\ty++\n\t\t\tx = 0 // set x = 0\n\t\t\tif cs[n].Ch == '\\n' {\n\t\t\t\tn++\n\t\t\t}\n\n\t\t\tif y >= p.innerArea.Dy() {\n\t\t\t\tbuf.Set(p.innerArea.Min.X+p.innerArea.Dx()-1,\n\t\t\t\t\tp.innerArea.Min.Y+p.innerArea.Dy()-1,\n\t\t\t\t\tCell{Ch: '…', Fg: p.TextFgColor, Bg: p.TextBgColor})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tbuf.Set(p.innerArea.Min.X+x, p.innerArea.Min.Y+y, cs[n])\n\n\t\tn++\n\t\tx += w\n\t}\n\n\treturn buf\n}", "func (file *File) ToString() string {\n\treturn file.buffer.ToString(file.newline)\n}", "func (e *ExportReader) readLine() ([]byte, error) {\n\tline, err := e.buf.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// trim the trailing newline\n\treturn line[:len(line)-1], nil\n}", "func (b *Builder) String() string {\n\tp := unsafe.Pointer(&b.buf)\n\tsp := (*string)(p)\n\ts := *sp\n\t// return *(*string)(unsafe.Pointer(&b.buf))\n\treturn s\n}", "func (pos *Position) String() string {\n\tif *pos.file == \"\" {\n\t\treturn fmt.Sprintf(\"L:%v|C:%v\", pos.Line, pos.Column)\n\t}\n\treturn fmt.Sprintf(\"%v|L:%v|C:%v\", *pos.file, pos.Line, pos.Column)\n}", "func LF(d ...int) string {\n\tdepth := 1\n\tif len(d) > 0 {\n\t\tdepth = d[0]\n\t}\n\t_, file, line, ok := runtime.Caller(depth)\n\tif ok {\n\t\treturn fmt.Sprintf(\"File: %s LineNo:%d\", file, line)\n\t} else {\n\t\treturn fmt.Sprintf(\"File: Unk LineNo:Unk\")\n\t}\n}", "func (l *Linenoise) historyNext(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// next history item\n\tif ls.historyIndex < 0 {\n\t\tls.historyIndex = 0\n\t}\n\treturn l.historyGet(ls.historyIndex)\n}", "func (r Replacement) String() string {\n\treturn fmt.Sprintf(\"%s:%X\", r.Addr, r.Buf)\n}", "func (self Source) GetBuffer() (buffer Buffer) {\n\treturn Buffer(self.Geti(AlBuffer))\n}", "func (b *Buffer) getLineMetaChars() int {\n // we add 1 cause each line has a separator to separate line number from the actual content\n return b.lineNumberDigits + 1\n}", "func (r renderer) LineBreak(out *bytes.Buffer) {}", "func (a *ChannelArea) Buffer() []byte {\n\treturn a.buffer\n}", "func (tr *testTalker) getLine() string {\n\tif len(tr.input) < 1 {\n\t\tpanic(\"getLine(): unexpected call to getLine, got no more input data.\")\n\t}\n\tinput := tr.input[0]\n\ttr.input = tr.input[1:]\n\treturn input\n}", "func (e *Etcd) Buffer() *gbytes.Buffer {\n\treturn e.session.Buffer()\n}", "func (r *Reader) GetStr() string {\n\tn := r.Get2()\n\ts := string(r.buf[:n])\n\tr.buf = r.buf[n:]\n\treturn s\n}", "func (m *Magic) Buffer(data []byte) (string, error) {\n\tif m.ptr == nil {\n\t\treturn \"\", ConnectionError\n\t}\n\n\tptr := unsafe.Pointer(&data)\n\tsz := C.size_t(len(data))\n\tcr := C.magic_buffer(m.ptr, ptr, sz)\n\n\tif cr == nil {\n\t\treturn \"\", m.check()\n\t}\n\n\tr := C.GoString(cr)\n\tC.free(unsafe.Pointer(cr))\n\treturn r, nil\n}", "func (tb *TextBuf) Line(ln int) []rune {\n\ttb.LinesMu.RLock()\n\tdefer tb.LinesMu.RUnlock()\n\tif ln >= tb.NLines || ln < 0 {\n\t\treturn nil\n\t}\n\treturn tb.Lines[ln]\n}", "func (t *Token) String() string {\n\treturn t.parent.input[t.startPos:t.endPos]\n}", "func bufferToString(buffer *bytes.Buffer, unsafePtr *bool) string {\n defer buffer.Reset()//ensure buffer is reset\n if !*unsafePtr {\n return buffer.String()\n }\n bb := buffer.Bytes()\n s := *(*string)(unsafe.Pointer(&bb))\n return s\n}", "func (c *Conn) readLine() (string, error) {\n\tif c.server.ReadTimeout != 0 {\n\t\tif err := c.conn.SetReadDeadline(time.Now().Add(c.server.ReadTimeout)); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn c.text.ReadLine()\n}", "func SourceLine(e error) string {\n\tfile, line := Location(e)\n\tif line != 0 {\n\t\treturn fmt.Sprintf(\"%s:%d\", file, line)\n\t}\n\treturn \"\"\n}", "func (e *Editor) Text() string {\n\treturn e.editBuffer.String()\n}", "func getViewLine(g *gocui.Gui, v *gocui.View) (string, error) {\n\tvar l string\n\tvar err error\n\n\t_, cy := v.Cursor()\n\tif l, err = v.Line(cy); err != nil {\n\t\tl = \"\"\n\t}\n\n\treturn l, err\n}", "func (b *buffer) Line(content string, indent int) {\n\tb.Write(fmt.Sprintf(\"%s\\n\", content), indent)\n}", "func (r Renderer) renderBotLine(dir string, line int) {\n\tfmt.Print(getBotLine(dir, line))\n}", "func (p *parser) peek() string {\n\tif p.valid() {\n\t\treturn p.lines[p.idx]\n\t}\n\treturn \"\"\n}", "func (l *logLine) String() string {\n\treturn fmt.Sprintf(\"{t:%d, m:\\\"%s\\\", s:\\\"%s\\\"}\", l.Time, l.Message, l.Step)\n}", "func GetClosestMatchContextLine(haystack, needle string) string {\n\tadditonalContext := 15\n\tmaxContextLength := 60\n\tstacks := []string{}\n\tfor _, line := range strings.Split(haystack, \"\\n\") {\n\t\tnormalizedHay, err := Normalize(line)\n\t\tif err != nil {\n\t\t\treturn \"ERR: \" + err.Error()\n\t\t}\n\t\tstacks = append(stacks, normalizedHay)\n\t}\n\n\tmatches := fuzzy.Find(needle, stacks)\n\tif len(matches) == 0 {\n\t\treturn \"\"\n\t}\n\n\tm := matches[0] // only look at the best (first) match\n\n\tb := strings.Builder{}\n\tfor i := max(m.MatchedIndexes[0]-additonalContext, 0); i < min(len(m.Str), m.MatchedIndexes[len(m.MatchedIndexes)-1]+additonalContext); i++ {\n\t\tb.WriteByte(m.Str[i])\n\t}\n\n\t// trim off any annoying components we may not care about\n\tres := strings.TrimSpace(b.String())\n\treturn res[0:min(maxContextLength, len(res))]\n}", "func (b *buffer) buffer() []byte {\n\treturn b.buf[b.offset:]\n}", "func String() string {\n\tglobalData.RLock()\n\tdefer globalData.RUnlock()\n\treturn globalData.mode.String()\n}", "func (s *Store) LineString(line int) (string, error) {\n\tif line < 0 || line >= len(s.lines) {\n\t\treturn \"\", fmt.Errorf(\"LineString: Invalid offset %v\", line)\n\t}\n\treturn s.lines[line].String(), nil\n}", "func (r *textprotoReader) ReadLine() (string, error) {\n\tline, err := r.readLineSlice()\n\treturn string(line), err\n}", "func Name() string {\n\treturn C.GoString(C.rl_readline_name)\n}", "func (serial_reader *SerialReader) ReadLine() string {\n\tresult := make([]byte, 0)\n\tlastRead := make([]byte, 1)\n\n\t// read byte by byte until the Line Feed character\n\tfor lastRead[0] != LF_CHAR {\n\t\tn, err := serial_reader.Read(lastRead)\n\t\tif (err != nil) || (n != 1) {\n\t\t\tpanic(log.Critical(err))\n\t\t}\n\n\t\tresult = append(result, lastRead[0])\n\t}\n\n\treturn string(result)\n}", "func (b *Buffer) GetName() string {\n\treturn b.name\n}", "func (msg *Message) RenderBuffer() *bytes.Buffer {\n\tbuffer := bufpool.New()\n\n\tif msg.Sender != EMPTY {\n\t\tbuffer.WriteString(COLON)\n\t\tbuffer.WriteString(msg.Sender)\n\t\tbuffer.WriteString(SPACE)\n\t}\n\n\tif msg.Code > 0 {\n\t\tbuffer.WriteString(fmt.Sprintf(PADNUM, msg.Code))\n\t} else if msg.Command != EMPTY {\n\t\tbuffer.WriteString(msg.Command)\n\t}\n\n\tif len(msg.Params) > 0 {\n\t\tif len(msg.Params) > 14 {\n\t\t\tmsg.Params = msg.Params[0:15]\n\t\t}\n\n\t\tbuffer.WriteString(SPACE)\n\t\tbuffer.WriteString(strings.Join(msg.Params, SPACE))\n\t}\n\n\tif msg.Text != EMPTY {\n\t\tbuffer.WriteString(SPACE)\n\t\tbuffer.WriteString(COLON)\n\t\tbuffer.WriteString(msg.Text)\n\t}\n\n\tbuffer.WriteString(CRLF)\n\n\treturn buffer\n}", "func current() string {\n\treturn \"CURRENT\"\n}", "func (c *CmdBuff) GetText() string {\n\tc.mx.RLock()\n\tdefer c.mx.RUnlock()\n\n\treturn string(c.buff)\n}", "func (c *CircBuf) String() string {\n\treturn fmt.Sprintf(\"CircBuf{len: %v, head: %v, tail: %v, space: %v, count: %v, buf: %v}\", len(c.buf), c.head, c.tail, c.Space(), c.Count(), c.buf)\n}", "func (bbw *Writer) String() string {\n\treturn fmt.Sprintf(\"{len(buf)=%d, clsdPos=%d, offs=%d, noExt=%t}\", len(bbw.buf), bbw.clsdPos, bbw.offs, bbw.noExt)\n}", "func GitCurrentPosition(path string) string {\n\targs := []string{\"log\", \"-1\", \"--color=always\", \"--format=%C(auto)%D %C(242)(%aN %ar)%Creset\"}\n\toutput := common.GitRun(path, args, true)\n\treturn strings.TrimSuffix(string(output), \"\\n\")\n}", "func (m *Message) getString() string {\n\tb := m.bufferForGet()\n\n\tindex := bytes.IndexByte(b.Bytes[b.Offset:], 0)\n\tif index == -1 {\n\t\tpanic(\"no string found\")\n\t}\n\ts := string(b.Bytes[b.Offset : b.Offset+index])\n\n\tindex++\n\n\tif trailing := index % messageWordSize; trailing != 0 {\n\t\t// Account for padding, moving index to the next word boundary.\n\t\tindex += messageWordSize - trailing\n\t}\n\n\tb.Advance(index)\n\n\treturn s\n}", "func (client *Client) ReadLine() string {\n\tline, err := client.connection.ReadLine()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"<= %v\\n\", line)\n\treturn line\n}", "func (p Point) Buffer() *Buffer {\n\treturn p.buffer\n}" ]
[ "0.76548827", "0.65308124", "0.6421607", "0.63664526", "0.63140243", "0.627917", "0.62193185", "0.61950177", "0.6194839", "0.6048672", "0.60193306", "0.5938888", "0.59302855", "0.59241825", "0.5886821", "0.58820885", "0.5872686", "0.5866819", "0.58072776", "0.5759639", "0.5699521", "0.56817615", "0.56801796", "0.56755096", "0.56662774", "0.56566715", "0.5630415", "0.5604461", "0.55675995", "0.5555416", "0.55401754", "0.5480607", "0.5475054", "0.54635894", "0.5444404", "0.54138356", "0.5405714", "0.5376563", "0.5371012", "0.53551304", "0.53551304", "0.53445053", "0.53402156", "0.53372484", "0.53245777", "0.53114617", "0.5305283", "0.53039813", "0.5291909", "0.5275332", "0.5271708", "0.52572817", "0.52555484", "0.52368534", "0.5234882", "0.5193241", "0.5193008", "0.51632094", "0.5143506", "0.5136776", "0.51357514", "0.5126939", "0.51266253", "0.5113835", "0.5107969", "0.5089634", "0.5063233", "0.5056707", "0.5048033", "0.5045049", "0.50409997", "0.5038253", "0.5026632", "0.5021888", "0.5019626", "0.5017014", "0.50140625", "0.501228", "0.5000029", "0.4994479", "0.49926215", "0.49908268", "0.49884492", "0.49882162", "0.4987376", "0.49830273", "0.49826425", "0.49795586", "0.49753034", "0.49588588", "0.49578437", "0.49473476", "0.4936853", "0.49313763", "0.49304038", "0.49232605", "0.49165946", "0.4915939", "0.4915455", "0.4904873" ]
0.7019718
1
NewLineNoise returns a new line editor.
func NewLineNoise() *Linenoise { l := Linenoise{} l.historyMaxlen = 32 return &l }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewLineEditor() *LineEditor {\n\treturn &LineEditor{\n\t\tCx: 0,\n\t\tRow: ERow{},\n\t}\n}", "func (s *Store) NewLine(ln int, st string) {\n\tif ln <= 0 {\n\t\ts.lines = append([]*line{newLine(st)}, s.lines...)\n\t\treturn\n\t}\n\tif ln >= len(s.lines) {\n\t\ts.lines = append(s.lines, newLine(st))\n\t\treturn\n\t}\n\ts.lines = append(s.lines[:ln], append([]*line{newLine(st)}, s.lines[ln:]...)...)\n\tcs := s.undoFac()\n\tcs.AddLine(ln)\n\tcs.ChangeLine(ln+1, \"\", st)\n\ts.AddUndoSet(cs)\n\treturn\n}", "func (g *Generator) NewLine() {\n\tg.Printf(\"\\n\")\n}", "func NewLine() *Line {\n\treturn &Line{}\n}", "func NewLine(num ...int) (int, error) {\n\tif len(num) == 0 {\n\t\treturn fmt.Print(\"\\n\")\n\t}\n\n\tlineNum := num[0]\n\n\tif lineNum <= 1 {\n\t\tlineNum = 1\n\t}\n\n\treturn fmt.Print(strings.Repeat(\"\\n\", lineNum))\n}", "func NewLine(x, y string) string {\n\tif x == \"\" {\n\t\treturn y\n\t}\n\treturn x + \"\\n\" + y\n\n}", "func (o *Obj) Newline() *Obj {\n\to.Body += \"\\n\"\n\n\treturn o\n}", "func newLine(no int, str string, opts *Options, f *File) *line {\n\treturn &line{\n\t\tno: no,\n\t\tstr: str,\n\t\tindent: indent(str),\n\t\ttokens: strings.Split(strings.TrimLeft(str, space), space),\n\t\topts: opts,\n\t\tfile: f,\n\t}\n}", "func (s *SimPDF) NewLine(size float64) {\n\tif size == 0 {\n\t\ts.PDF.Ln(-1)\n\t} else {\n\t\ts.PDF.Ln(size)\n\t}\n}", "func NewLine(format string) *Line {\n\treturn &Line{format}\n}", "func (w *Writer) Newline() io.Writer {\n\treturn &newline{writer: w}\n}", "func (this *Tidy) Newline(val int) (bool, error) {\n\tswitch val {\n\tcase LF, CRLF, CR:\n\t\treturn this.optSetInt(C.TidyNewline, (C.ulong)(val))\n\t}\n\treturn false, errors.New(\"Argument val int is out of range (0,1,2)\")\n}", "func NewLine(text string) *Line {\n\treturn &Line{text, time.Now(), nil}\n}", "func newLine(page Page, startX, startY, endX, endY, lineWidth int) *line {\n\tstrokes := make([]int, 2)\n\tstrokes[0] = endX\n\tstrokes[1] = endY\n\treturn &line{\n\t\tgraphicsObject: graphicsObject{\n\t\t\tpage: page,\n\t\t},\n\t\tstartX: startX,\n\t\tstartY: startY,\n\t\tstrokes: strokes,\n\t\tcolor: newColorUndef(),\n\t\tlineWidth: lineWidth,\n\t\tlcs: lineCapStyleUndefined,\n\t\tljs: lineJoinStyleUndefined,\n\t}\n}", "func newReadline(repl *repl.REPL) *readline {\n\trl := &readline{\n\t\tState: liner.NewLiner(),\n\t\trepl: repl,\n\t}\n\thome := homeDirectory()\n\tif home != \"\" {\n\t\trl.historyFile = filepath.Join(home, HistoryFileName)\n\t}\n\trl.SetTabCompletionStyle(liner.TabPrints)\n\trl.SetWordCompleter(rl.Completer)\n\treturn rl\n}", "func PromptEditor(g *gocui.Gui, offset int, callback func(bool, string)) gocui.Editor {\n\tpromptEditor := func(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool {\n\t\tcx, _ := v.Cursor()\n\t\tcancel := false\n\t\tdone := false\n\t\tconsumed := true\n\n\t\tswitch {\n\t\tcase ch != 0 && mod == 0:\n\t\t\tv.EditWrite(ch)\n\t\tcase key == gocui.KeySpace:\n\t\t\tv.EditWrite(' ')\n\t\tcase key == gocui.KeyBackspace || key == gocui.KeyBackspace2:\n\t\t\tif cx > offset {\n\t\t\t\tv.EditDelete(true)\n\t\t\t} else {\n\t\t\t\tcancel = true\n\t\t\t}\n\t\tcase key == gocui.KeyDelete:\n\t\t\tv.EditDelete(false)\n\t\tcase key == gocui.KeyInsert:\n\t\t\t// v.Overwrite = !v.Overwrite\n\t\tcase key == gocui.KeyEnter:\n\t\t\t// v.EditNewLine()\n\t\t\tdone = true\n\t\tcase key == gocui.KeyEsc || key == gocui.KeyCtrlG:\n\t\t\tcancel = true\n\t\tcase key == gocui.KeyArrowDown:\n\t\t\t// v.MoveCursor(0, 1, false)\n\t\tcase key == gocui.KeyArrowUp:\n\t\t\t// v.MoveCursor(0, -1, false)\n\t\tcase key == gocui.KeyArrowLeft:\n\t\t\tif cx > offset {\n\t\t\t\tv.MoveCursor(-1, 0, false)\n\t\t\t}\n\t\tcase key == gocui.KeyArrowRight:\n\t\t\tv.MoveCursor(1, 0, false)\n\t\tdefault:\n\t\t\tconsumed = false\n\t\t}\n\n\t\tif done || cancel {\n\t\t\tcontent := strings.TrimSpace(getFirstLine(v.Buffer()))\n\t\t\tif offset > len(content) {\n\t\t\t\toffset = len(content)\n\t\t\t}\n\t\t\tcallback(done, content[offset:])\n\t\t}\n\n\t\treturn consumed\n\t}\n\n\treturn gocui.EditorFunc(promptEditor)\n}", "func (e *Editor) Line() (string, error) {\n\tif err := e.editReset(); err != nil {\n\t\treturn string(e.Buffer), err\n\t}\nline:\n\tfor {\n\t\tr, _, err := e.In.ReadRune()\n\t\tif err != nil {\n\t\t\treturn string(e.Buffer), err\n\t\t}\n\n\t\tswitch r {\n\t\tcase enter:\n\t\t\tbreak line\n\t\tcase ctrlC:\n\t\t\treturn string(e.Buffer), errors.New(\"try again\")\n\t\tcase backspace, ctrlH:\n\t\t\tif err := e.editBackspace(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlD:\n\t\t\tif len(e.Buffer) == 0 {\n\t\t\t\treturn string(e.Buffer), io.EOF\n\t\t\t}\n\n\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlT:\n\t\t\tif err := e.editSwap(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlB:\n\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlF:\n\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlP:\n\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlN:\n\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlU:\n\t\t\tif err := e.editReset(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlK:\n\t\t\tif err := e.editKillForward(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlA:\n\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlE:\n\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlL:\n\t\t\tif err := e.clearScreen(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tif err := e.refreshLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlW:\n\t\t\tif err := e.editDeletePrevWord(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase esc:\n\t\t\tr, _, err := e.In.ReadRune()\n\t\t\tif err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tswitch r {\n\t\t\tcase '[':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase '0', '1', '2', '4', '5', '6', '7', '8', '9':\n\t\t\t\t\t_, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase '3':\n\t\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch r {\n\t\t\t\t\tcase '~':\n\t\t\t\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'A':\n\t\t\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'B':\n\t\t\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'C':\n\t\t\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'D':\n\t\t\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase 'O':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase tab:\n\t\t\tif err := e.completeLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tdefault:\n\t\t\tif err := e.editInsert(r); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn string(e.Buffer), nil\n}", "func NewRepl() (*Repl, error) {\n\trl, err := readline.New(\"box> \")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb, err := builder.NewBuilder(true, []string{})\n\tif err != nil {\n\t\trl.Close()\n\t\treturn nil, err\n\t}\n\n\treturn &Repl{readline: rl, builder: b}, nil\n}", "func (s *BasePCREListener) EnterNewline_convention(ctx *Newline_conventionContext) {}", "func AddCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {\n\tnName, err := NoteName(c)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\n\tif exists := i.NoteExists(nName); exists == true {\n\t\treturn n, fmt.Errorf(\"Note already exists\")\n\t}\n\n\tn.Name = nName\n\tn.Temporary = c.Bool(\"t\")\n\n\t// Only open editor if -p (read from clipboard) isnt set\n\tif c.IsSet(\"p\") {\n\t\tnText, err := clipboard.ReadAll()\n\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\t\tn.Text = nText\n\t} else {\n\t\tif err := writer.WriteNote(&n); err != nil {\n\t\t\treturn n, err\n\t\t}\n\t}\n\n\tif err := i.SaveNote(&n); err != nil {\n\t\treturn n, err\n\t}\n\n\treturn n, nil\n}", "func (rl *Instance) Readline() (_ string, err error) {\n\tfd := int(os.Stdin.Fd())\n\tstate, err := MakeRaw(fd)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// return an error if Restore fails. However we don't want to return\n\t\t// `nil` if there is no error because there might be a CtrlC or EOF\n\t\t// that needs to be returned\n\t\tr := Restore(fd, state)\n\t\tif r != nil {\n\t\t\terr = r\n\t\t}\n\t}()\n\n\tx, _ := rl.getCursorPos()\n\tswitch x {\n\tcase -1:\n\t\tprint(string(leftMost()))\n\tcase 0:\n\t\t// do nothing\n\tdefault:\n\t\tprint(\"\\r\\n\")\n\t}\n\tprint(rl.prompt)\n\n\trl.line = []rune{}\n\trl.viUndoHistory = []undoItem{{line: \"\", pos: 0}}\n\trl.pos = 0\n\trl.histPos = rl.History.Len()\n\trl.modeViMode = vimInsert\n\tatomic.StoreInt64(&rl.delayedSyntaxCount, 0)\n\trl.resetHintText()\n\trl.resetTabCompletion()\n\n\tif len(rl.multisplit) > 0 {\n\t\tr := []rune(rl.multisplit[0])\n\t\trl.readlineInput(r)\n\t\trl.carridgeReturn()\n\t\tif len(rl.multisplit) > 1 {\n\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t} else {\n\t\t\trl.multisplit = []string{}\n\t\t}\n\t\treturn string(rl.line), nil\n\t}\n\n\trl.termWidth = GetTermWidth()\n\trl.getHintText()\n\trl.renderHelpers()\n\n\tfor {\n\t\tgo delayedSyntaxTimer(rl, atomic.LoadInt64(&rl.delayedSyntaxCount))\n\t\trl.viUndoSkipAppend = false\n\t\tb := make([]byte, 1024*1024)\n\t\tvar i int\n\n\t\tif !rl.skipStdinRead {\n\t\t\ti, err = os.Stdin.Read(b)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\trl.termWidth = GetTermWidth()\n\t\t}\n\t\tatomic.AddInt64(&rl.delayedSyntaxCount, 1)\n\n\t\trl.skipStdinRead = false\n\t\tr := []rune(string(b))\n\n\t\tif isMultiline(r[:i]) || len(rl.multiline) > 0 {\n\t\t\trl.multiline = append(rl.multiline, b[:i]...)\n\t\t\tif i == len(b) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !rl.allowMultiline(rl.multiline) {\n\t\t\t\trl.multiline = []byte{}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ts := string(rl.multiline)\n\t\t\trl.multisplit = rxMultiline.Split(s, -1)\n\n\t\t\tr = []rune(rl.multisplit[0])\n\t\t\trl.modeViMode = vimInsert\n\t\t\trl.readlineInput(r)\n\t\t\trl.carridgeReturn()\n\t\t\trl.multiline = []byte{}\n\t\t\tif len(rl.multisplit) > 1 {\n\t\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t\t} else {\n\t\t\t\trl.multisplit = []string{}\n\t\t\t}\n\t\t\treturn string(rl.line), nil\n\t\t}\n\n\t\ts := string(r[:i])\n\t\tif rl.evtKeyPress[s] != nil {\n\t\t\t//rl.clearHelpers() // unessisary clear?\n\n\t\t\tret := rl.evtKeyPress[s](s, rl.line, rl.pos)\n\n\t\t\trl.clearLine()\n\t\t\trl.line = append(ret.NewLine, []rune{}...)\n\t\t\trl.echo()\n\t\t\trl.pos = ret.NewPos\n\n\t\t\tif ret.ClearHelpers {\n\t\t\t\trl.resetHelpers()\n\t\t\t} else {\n\t\t\t\trl.updateHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\t\tif len(ret.HintText) > 0 {\n\t\t\t\trl.hintText = ret.HintText\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\t\t\tif !ret.ForwardKey {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ret.CloseReadline {\n\t\t\t\trl.clearHelpers()\n\t\t\t\treturn string(rl.line), nil\n\t\t\t}\n\t\t}\n\n\t\tswitch b[0] {\n\t\tcase charCtrlC:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", CtrlC\n\n\t\tcase charEOF:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", EOF\n\n\t\tcase charCtrlF:\n\t\t\tif !rl.modeTabCompletion {\n\t\t\t\trl.modeAutoFind = true\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlR:\n\t\t\trl.modeAutoFind = true\n\t\t\trl.tcOffset = 0\n\t\t\trl.modeTabCompletion = true\n\t\t\trl.tcDisplayType = TabDisplayMap\n\t\t\trl.tcSuggestions, rl.tcDescriptions = rl.autocompleteHistory()\n\t\t\trl.initTabCompletion()\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlU:\n\t\t\trl.clearLine()\n\t\t\trl.resetHelpers()\n\n\t\tcase charTab:\n\t\t\tif rl.modeTabCompletion {\n\t\t\t\trl.moveTabCompletionHighlight(1, 0)\n\t\t\t} else {\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.renderHelpers()\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase '\\r':\n\t\t\tfallthrough\n\t\tcase '\\n':\n\t\t\tvar suggestions []string\n\t\t\tif rl.modeTabFind {\n\t\t\t\tsuggestions = rl.tfSuggestions\n\t\t\t} else {\n\t\t\t\tsuggestions = rl.tcSuggestions\n\t\t\t}\n\n\t\t\tif rl.modeTabCompletion && len(suggestions) > 0 {\n\t\t\t\tcell := (rl.tcMaxX * (rl.tcPosY - 1)) + rl.tcOffset + rl.tcPosX - 1\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.resetTabCompletion()\n\t\t\t\trl.renderHelpers()\n\t\t\t\trl.insert([]rune(suggestions[cell]))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trl.carridgeReturn()\n\t\t\treturn string(rl.line), nil\n\n\t\tcase charBackspace, charBackspace2:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.backspaceTabFind()\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.backspace()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\tcase charEscape:\n\t\t\trl.escapeSeq(r[:i])\n\n\t\tdefault:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.updateTabFind(r[:i])\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.readlineInput(r[:i])\n\t\t\t\tif len(rl.multiline) > 0 && rl.modeViMode == vimKeys {\n\t\t\t\t\trl.skipStdinRead = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//if !rl.viUndoSkipAppend {\n\t\t//\trl.viUndoHistory = append(rl.viUndoHistory, rl.line)\n\t\t//}\n\t\trl.undoAppendHistory()\n\t}\n}", "func NewLine(width, height int, x, y float64) *Line {\n\timg := ebiten.NewImage(width, height)\n\timg.Fill(colornames.Black)\n\tgeoM := &ebiten.GeoM{}\n\tgeoM.Translate(x, y)\n\treturn &Line{img: img, geoM: geoM}\n}", "func NewEditor(t TTY, sigs SignalSource) *Editor {\n\tlp := newLoop()\n\ted := &Editor{loop: lp, tty: t, sigs: sigs}\n\tlp.HandleCb(ed.handle)\n\tlp.RedrawCb(ed.redraw)\n\treturn ed\n}", "func NewLineReader(c Completer, r io.Reader, w io.Writer) *LineReader {\n\treturn &LineReader{C: c, R: r, W: w, Line: bytes.NewBufferString(\"\")}\n}", "func NewLinesMessage(args ...interface{}) Composer {\n\treturn &lineMessenger{\n\t\tLines: args,\n\t}\n}", "func NewLinesOfText(val int) LinesOfTextField {\n\treturn LinesOfTextField{quickfix.FIXInt(val)}\n}", "func NewRow() Row {\n\treturn Row{Height: \"200px\", Editable: true}\n}", "func (e *Editor) NumLines() int {\n\te.makeValid()\n\treturn len(e.lines)\n}", "func (f *Formatter) nl() {\n\tio.WriteString(f.w, \"\\n\")\n}", "func NewLineGenerator(n int) *LineGenerator {\n\treturn &LineGenerator{\n\t\tnodes: n,\n\t}\n}", "func NewInput(s string, isMultiLine bool) *Input {\n\ttextArea := &Input{\n\t\tBlock: *NewBlock(),\n\t\tTextFgColor: ThemeAttr(\"par.text.fg\"),\n\t\tTextBgColor: ThemeAttr(\"par.text.bg\"),\n\t\tTextBuilder: NewMarkdownTxBuilder(),\n\t\tIsMultiLine: isMultiLine,\n\t\tShowLineNo: false,\n\n\t\tcursorLineIndex: 0,\n\t\tcursorLinePos: 0,\n\t}\n\n\tif s != \"\" {\n\t\ttextArea.SetText(s)\n\t}\n\n\tif isMultiLine {\n\t\ttextArea.SpecialChars = multiLineCharMap\n\t} else {\n\t\ttextArea.SpecialChars = singleLineCharMap\n\t}\n\n\treturn textArea\n}", "func getNextViewLine(g *gocui.Gui, v *gocui.View) (string, error) {\n\tvar l string\n\tvar err error\n\n\t_, cy := v.Cursor()\n\tif l, err = v.Line(cy + 1); err != nil {\n\t\tl = \"\"\n\t}\n\n\treturn l, err\n}", "func TextInsertLines(n int) string {\n\treturn Esc + strconv.Itoa(n) + \"L\"\n}", "func NewLine(num int, a, b, step float64) model.Collection {\n\tline := NewLineGenerator(a, b, step)\n\tcollection := line.Num(num)\n\treturn collection\n}", "func makeLine(l *string, strLen int, offset int) {\n\n\t//*l = \" \" + *l\n\tfor i := 0; i < offset; i++ {\n\t\t*l = \" \" + *l\n\t}\n\tlen := 0\n\tfor _, c := range *l {\n\t\tlen += runewidth.RuneWidth(c)\n\t}\n\tif len > strLen {\n\t\t*l = (*l)[:strLen]\n\t\treturn\n\t}\n\tfor len < strLen {\n\t\t*l += \" \"\n\t\tlen++\n\t}\n}", "func CreateLine(coinTypeCode coin.CoinTypeCode, authType account.AuthType, fullPubKey string) string {\n\t// 0: coinTypeCode\n\t// 1: authType\n\t// 2: fullPubKey\n\treturn fmt.Sprintf(\"%s,%s,%s\\n\", coinTypeCode.String(), authType.String(), fullPubKey)\n}", "func NewLineReader(prompt string) *LineReader {\n\treadline.Completer = readline.FilenameCompleter\n\treadline.LoadHistory(defaultHistPath)\n\n\treturn &LineReader{\n\t\tPrompt: prompt,\n\t}\n}", "func (tv *TextView) RenderLineNo(ln int) {\n\tif !tv.HasLineNos() {\n\t\treturn\n\t}\n\tvp := tv.Viewport\n\tsty := &tv.Sty\n\tspc := sty.BoxSpace()\n\tfst := sty.Font\n\tfst.BgColor.SetColor(nil)\n\trs := &vp.Render\n\tlfmt := fmt.Sprintf(\"%d\", tv.LineNoDigs)\n\tlfmt = \"%\" + lfmt + \"d\"\n\tlnstr := fmt.Sprintf(lfmt, ln+1)\n\ttv.LineNoRender.SetString(lnstr, &fst, &sty.UnContext, &sty.Text, true, 0, 0)\n\tpos := tv.RenderStartPos()\n\tlst := tv.CharStartPos(TextPos{Ln: ln}).Y // note: charstart pos includes descent\n\tpos.Y = lst + mat32.FromFixed(sty.Font.Face.Face.Metrics().Ascent) - +mat32.FromFixed(sty.Font.Face.Face.Metrics().Descent)\n\tpos.X = float32(tv.VpBBox.Min.X) + spc\n\ttv.LineNoRender.Render(rs, pos)\n\t// if ic, ok := tv.LineIcons[ln]; ok {\n\t// \t// todo: render icon!\n\t// }\n}", "func (x* xmlWriter) newLine() {\n\tx.longAttr = x.tagOpen\n\tx.lineStarted = false\n\tif _, err := io.WriteString(x.w, \"\\n\"); err != nil {\n\t\tpanic(err);\n\t}\n}", "func IgnoringNewLines() StringOpt {\n\treturn func(c *AssertableString) {\n\t\tc.actual = c.actual.AddDecorator(values.RemoveNewLines)\n\t}\n}", "func NewJSONGetOptionNewLine(val string) JSONGetOption { return &getOptionNewLine{val} }", "func newlReplacer(s string) string {\n\ts = strings.Replace(s, \"\\n\", `\\n`, -1)\n\ts = strings.Replace(s, \"\\r\", `\\r`, -1)\n\treturn s\n}", "func newParagraph(initText string, border bool, location int, wid int, ht int) *widgets.Paragraph {\n\tp := widgets.NewParagraph()\n\tp.Text = initText\n\tp.Border = border\n\tp.SetRect(0, location, wid, location+ht)\n\tp.TextStyle.Fg = ui.ColorWhite\n\treturn p\n}", "func (w *ScrollWidget) NextLine() error {\n\terr := MoveLines(w.view, w.current, w.max, 1)\n\tw.current = GetLine(w.view)\n\treturn err\n}", "func (tv *TextView) WrappedLineNo(pos TextPos) (si, ri int, ok bool) {\n\tif pos.Ln >= len(tv.Renders) {\n\t\treturn 0, 0, false\n\t}\n\treturn tv.Renders[pos.Ln].RuneSpanPos(pos.Ch)\n}", "func NewLineFromString(s string) *Line {\n\treturn &Line{[]rune(s)}\n}", "func Newline(a interfaces.AssumeCredentialProcess) {\n\ts := a.GetDestination()\n\tfmt.Fprintln(s)\n}", "func NewEditor() *Editor {\n\tvar e Editor\n\te.autotimer = time.NewTicker(10 * time.Second)\n\terr := e.l.load(autosave)\n\tif err != nil {\n\t\t// autosave is broken, reset level\n\t\tgeo := Mx{}\n\t\tgeo.Scale(100, 0.5)\n\t\te.l = NewLevel()\n\t\te.l.Blocks = []*Block{{T: geo}}\n\t}\n\treturn &e\n}", "func TestNewLines(t *testing.T) {\n\ttests := []struct {\n\t\ttoken token.Token\n\t\tliteral string\n\t\tline int\n\t}{\n\t\t{token.INT, \"100\", 1},\n\t\t{token.NEWLINE, \"NEWLINE\", 1},\n\t\t{token.LET, \"let\", 4},\n\t\t{token.IDVAL, \"hey\", 4},\n\t\t{token.ASSIGN, \"=\", 4},\n\t\t{token.INT, \"200\", 4},\n\t\t{token.NEWLINE, \"NEWLINE\", 4},\n\t\t{token.LET, \"let\", 5},\n\t\t{token.IDVAL, \"x\", 5},\n\t\t{token.ASSIGN, \"=\", 5},\n\t\t{token.INT, \"0xff\", 5},\n\t\t{token.GEQUALS, \">=\", 5},\n\t\t{token.INT, \"5000\", 5},\n\t\t{token.NEWLINE, \"NEWLINE\", 5},\n\t\t{token.STRING, \"bye\", 12},\n\t\t{token.EOF, \"EOF\", 12},\n\t}\n\tscanner := Init(`\n100\n\n# Hopefully the lines are now working.\nlet hey = 200\nlet x = 0xff >= 5000\n\n\n# we only want 1 NEWLINE to be seen just\n# after content and then ignore the rest.\n\n\n\"bye\"`)\n\tfor i, tt := range tests {\n\t\ttok, literal, lineno := scanner.NextToken()\n\t\tif tok != tt.token {\n\t\t\tt.Fatalf(\"test[%d] - Invalid Token. expected=%q, got=%q\",\n\t\t\t\ti, tt.token.String(), tok.String())\n\t\t}\n\t\tif literal != tt.literal {\n\t\t\tt.Fatalf(\"test[%d] - Invalid Literal. expected=%q, got=%q\",\n\t\t\t\ti, tt.literal, literal)\n\t\t}\n\t\tif lineno != tt.line {\n\t\t\tt.Fatalf(\"test[%d](%s) - Invalid line index. expected=%d, got=%d.\\n-> `%s`\",\n\t\t\t\ti, tt.literal, tt.line, lineno, literal)\n\t\t}\n\t}\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 Line() *Statement {\n\treturn newStatement().Line()\n}", "func Line(prompt string) (string, error) {\n\tins := getInstance()\n\tins.SetPrompt(prompt)\n\treturn ins.Readline()\n}", "func New(r io.Reader, buflen int, secure bool, f EditFn) *T {\n\tif buflen < 1 {\n\t\tbuflen = 4096\n\t}\n\tif f == nil {\n\t\tf = BasicLineEdit\n\t}\n\tbuf := make([]byte, buflen+1)\n\treturn &T{\n\t\teditFn: f,\n\t\tsrc: r,\n\t\trbuf: buf[:1],\n\t\tbuf: buf[1:],\n\t\tsecure: secure,\n\t}\n}", "func NewLine() {\n\tif t, ok := logger.(interface {\n\t\tHelper()\n\t}); ok {\n\t\tt.Helper()\n\t}\n\n\tlogger.Log(\"\")\n}", "func NewCRLF(w io.Writer) *CRLF {\n\treturn &CRLF{w}\n}", "func (s *Statement) Line() *Statement {\n\tt := token{\n\t\ttyp: layoutToken,\n\t\tcontent: \"\\n\",\n\t}\n\t*s = append(*s, t)\n\treturn s\n}", "func New(options ...Option) io.WriteCloser {\n\tvar l lineWriter\n\tfor _, option := range options {\n\t\toption.apply(&l)\n\t}\n\n\t// default to stdout if not set\n\tif l.out == nil {\n\t\tl.out = os.Stdout\n\t}\n\treturn &l\n}", "func handleNewCommand() {\n\tneoCliRoot := os.Getenv(\"GOPATH\") + \"/src/github.com/ivpusic/neo/cmd/neo\"\n\n\tif len(*templateName) == 0 {\n\t\tlogger.Info(\"Creating Neo project\")\n\t\trunCmd(neoCliRoot+\"/scripts/neo-template\", []string{*projectName})\n\n\t} else {\n\t\tswitch *templateName {\n\t\tcase \"angular\":\n\t\t\tlogger.Info(\"Creating Neo Angular project\")\n\t\t\trunCmd(neoCliRoot+\"/scripts/angular-template\", []string{*projectName})\n\t\tcase \"html\":\n\t\t\tlogger.Info(\"Creating Neo HTML project\")\n\t\t\trunCmd(neoCliRoot+\"/scripts/neo-html-template\", []string{*projectName})\n\t\tdefault:\n\t\t\tlogger.Errorf(\"Unkonown template %s!\", *projectName)\n\t\t}\n\t}\n}", "func newTerminalPrompter() *terminalPrompter {\n\tp := new(terminalPrompter)\n\t// Get the original mode before calling NewLiner.\n\t// This is usually regular \"cooked\" mode where characters echo.\n\tnormalMode, _ := liner.TerminalMode()\n\t// Turn on liner. It switches to raw mode.\n\tptr.State = liner.NewLiner()\n\trawMode, err := liner.TerminalMode()\n\tif err != nil || !liner.TerminalSupported() {\n\t\tptr.supported = false\n\t} else {\n\t\tptr.supported = true\n\t\tptr.normalMode = normalMode\n\t\tptr.rawMode = rawMode\n\t\t// Switch back to normal mode while we're not prompting.\n\t\tnormalMode.ApplyMode()\n\t}\n\tptr.SetCtrlCAborts(true)\n\tptr.SetTabCompletionStyle(liner.TabPrints)\n\tptr.SetMultiLineMode(true)\n\treturn p\n}", "func Line() string {\n\treturn \"================================================================================\"\n}", "func New(uf undo.Factory) TextStorer {\n\treturn &Store{undoFac: uf, delim: \"\\n\"}\n}", "func (l *Linenoise) edit(ifd, ofd int, prompt, init string) (string, error) {\n\t// create the line state\n\tls := newLineState(ifd, ofd, prompt, l)\n\t// set and output the initial line\n\tls.editSet(init)\n\t// The latest history entry is always our current buffer\n\tl.HistoryAdd(ls.String())\n\n\tu := utf8{}\n\n\tfor {\n\t\tr := u.getRune(syscall.Stdin, nil)\n\t\tif r == KeycodeNull {\n\t\t\tcontinue\n\t\t}\n\t\t// Autocomplete when the callback is set.\n\t\t// It returns the character to be handled next.\n\t\tif r == KeycodeTAB && l.completionCallback != nil {\n\t\t\tr = ls.completeLine()\n\t\t\tif r == KeycodeNull {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif r == KeycodeCR || r == l.hotkey {\n\t\t\tl.historyPop(-1)\n\t\t\tif l.hintsCallback != nil {\n\t\t\t\t// Refresh the line without hints to leave the\n\t\t\t\t// line as the user typed it after the newline.\n\t\t\t\thcb := l.hintsCallback\n\t\t\t\tl.hintsCallback = nil\n\t\t\t\tls.refreshLine()\n\t\t\t\tl.hintsCallback = hcb\n\t\t\t}\n\t\t\ts := ls.String()\n\t\t\tif r == l.hotkey {\n\t\t\t\treturn s + string(l.hotkey), nil\n\t\t\t}\n\t\t\treturn s, nil\n\t\t} else if r == KeycodeBS {\n\t\t\t// backspace: remove the character to the left of the cursor\n\t\t\tls.editBackspace()\n\n\t\t} else if r == KeycodeESC {\n\t\t\tif wouldBlock(ifd, &timeout20ms) {\n\t\t\t\t// looks like a single escape- abandon the line\n\t\t\t\tl.historyPop(-1)\n\t\t\t\treturn \"\", nil\n\t\t\t}\n\t\t\t// escape sequence\n\t\t\ts0 := u.getRune(ifd, &timeout20ms)\n\t\t\ts1 := u.getRune(ifd, &timeout20ms)\n\t\t\tif s0 == '[' {\n\t\t\t\t// ESC [ sequence\n\t\t\t\tif s1 >= '0' && s1 <= '9' {\n\t\t\t\t\t// Extended escape, read additional byte.\n\t\t\t\t\ts2 := u.getRune(ifd, &timeout20ms)\n\t\t\t\t\tif s2 == '~' {\n\t\t\t\t\t\tif s1 == '3' {\n\t\t\t\t\t\t\t// delete\n\t\t\t\t\t\t\tls.editDelete()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif s1 == 'A' {\n\t\t\t\t\t\t// cursor up\n\t\t\t\t\t\tls.editSet(l.historyPrev(ls))\n\t\t\t\t\t} else if s1 == 'B' {\n\t\t\t\t\t\t// cursor down\n\t\t\t\t\t\tls.editSet(l.historyNext(ls))\n\t\t\t\t\t} else if s1 == 'C' {\n\t\t\t\t\t\t// cursor right\n\t\t\t\t\t\tls.editMoveRight()\n\t\t\t\t\t} else if s1 == 'D' {\n\t\t\t\t\t\t// cursor left\n\t\t\t\t\t\tls.editMoveLeft()\n\t\t\t\t\t} else if s1 == 'H' {\n\t\t\t\t\t\t// cursor home\n\t\t\t\t\t\tls.editMoveHome()\n\t\t\t\t\t} else if s1 == 'F' {\n\t\t\t\t\t\t// cursor end\n\t\t\t\t\t\tls.editMoveEnd()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if s0 == '0' {\n\t\t\t\t// ESC 0 sequence\n\t\t\t\tif s1 == 'H' {\n\t\t\t\t\t// cursor home\n\t\t\t\t\tls.editMoveHome()\n\t\t\t\t} else if s1 == 'F' {\n\t\t\t\t\t// cursor end\n\t\t\t\t\tls.editMoveEnd()\n\t\t\t\t}\n\t\t\t}\n\t\t} else if r == KeycodeCtrlA {\n\t\t\t// go to the start of the line\n\t\t\tls.editMoveHome()\n\t\t} else if r == KeycodeCtrlB {\n\t\t\t// cursor left\n\t\t\tls.editMoveLeft()\n\t\t} else if r == KeycodeCtrlC {\n\t\t\t// return QUIT\n\t\t\treturn \"\", ErrQuit\n\t\t} else if r == KeycodeCtrlD {\n\t\t\tif len(ls.buf) > 0 {\n\t\t\t\t// delete: remove the character to the right of the cursor.\n\t\t\t\tls.editDelete()\n\t\t\t} else {\n\t\t\t\t// nothing to delete - QUIT\n\t\t\t\tl.historyPop(-1)\n\t\t\t\treturn \"\", ErrQuit\n\t\t\t}\n\t\t} else if r == KeycodeCtrlE {\n\t\t\t// go to the end of the line\n\t\t\tls.editMoveEnd()\n\t\t} else if r == KeycodeCtrlF {\n\t\t\t// cursor right\n\t\t\tls.editMoveRight()\n\t\t} else if r == KeycodeCtrlH {\n\t\t\t// backspace: remove the character to the left of the cursor\n\t\t\tls.editBackspace()\n\t\t} else if r == KeycodeCtrlK {\n\t\t\t// delete to the end of the line\n\t\t\tls.deleteToEnd()\n\t\t} else if r == KeycodeCtrlL {\n\t\t\t// clear screen\n\t\t\tclearScreen()\n\t\t\tls.refreshLine()\n\t\t} else if r == KeycodeCtrlN {\n\t\t\t// next history item\n\t\t\tls.editSet(l.historyNext(ls))\n\t\t} else if r == KeycodeCtrlP {\n\t\t\t// previous history item\n\t\t\tls.editSet(l.historyPrev(ls))\n\t\t} else if r == KeycodeCtrlT {\n\t\t\t// swap current character with the previous\n\t\t\tls.editSwap()\n\t\t} else if r == KeycodeCtrlU {\n\t\t\t// delete the whole line\n\t\t\tls.deleteLine()\n\t\t} else if r == KeycodeCtrlW {\n\t\t\t// delete previous word\n\t\t\tls.deletePrevWord()\n\t\t} else {\n\t\t\t// insert the character into the line buffer\n\t\t\tls.editInsert(r)\n\t\t}\n\t}\n}", "func NewLineBreaks() *LineBreaks {\n\treturn &LineBreaks{\n\t\tCursors: NewCursors(),\n\t}\n}", "func LineStyle(children ...Element) *CompoundElement { return newCE(\"LineStyle\", children) }", "func (s *Symbolizer) newLiner(filepath string, f *elf.File, quality *debuginfopb.DebuginfoQuality) (liner, error) {\n\tswitch {\n\tcase quality.HasDwarf:\n\t\tlnr, err := addr2line.DWARF(s.logger, filepath, f, s.demangler)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create DWARF liner: %w\", err)\n\t\t}\n\n\t\treturn lnr, nil\n\tcase quality.HasGoPclntab:\n\t\tlnr, err := addr2line.Go(s.logger, filepath, f)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create Go liner: %w\", err)\n\t\t}\n\n\t\treturn lnr, nil\n\t\t// TODO CHECK plt\n\tcase quality.HasSymtab || quality.HasDynsym:\n\t\tlnr, err := addr2line.Symbols(s.logger, filepath, f, s.demangler)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create Symtab liner: %w\", err)\n\t\t}\n\n\t\treturn lnr, nil\n\tdefault:\n\t\treturn nil, ErrLinerFailed\n\t}\n}", "func NewMultiLineEntry(text string, placeholder string, isReadOnly bool) (entry *widget.Entry) {\n\tentry = widget.NewMultiLineEntry()\n\tentry.SetText(text)\n\tentry.SetPlaceHolder(placeholder)\n\tentry.SetReadOnly(isReadOnly)\n\treturn\n}", "func isNewLine(r rune) bool {\n\treturn r == '\\n' || r == '\\r'\n}", "func enterMode(mode string) {\n\teditorMode = mode\n\t// TODO maybe not the best place to clear this\n\tmessage(\"\")\n}", "func (lm *LineMgr) Alloc() (line *Line, err error) {\n\tlm.mtx.Lock()\n\tdefer lm.mtx.Unlock()\n\tline, err = NewLine()\n\tif err != nil {\n\t\tutils.Logger.Error(\"NewLine Error with %s\", err.Error())\n\t\treturn\n\t}\n\tlm.lines.PushBack(line)\n\treturn\n}", "func removeNewLines(raw []byte) []byte {\n\t// check if a `\\r` is present and save the position.\n\t// if no `\\r` is found, check if a `\\n` is present.\n\tfoundR := bytes.IndexByte(raw, rChar)\n\tfoundN := bytes.IndexByte(raw, nChar)\n\tstart := 0\n\n\tswitch {\n\tcase foundN != -1:\n\t\tif foundR > foundN {\n\t\t\tstart = foundN\n\t\t} else if foundR != -1 {\n\t\t\tstart = foundR\n\t\t}\n\tcase foundR != -1:\n\t\tstart = foundR\n\tdefault:\n\t\treturn raw\n\t}\n\n\tfor i := start; i < len(raw); i++ {\n\t\tswitch raw[i] {\n\t\tcase rChar, nChar:\n\t\t\traw[i] = ' '\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n\treturn raw\n}", "func (tb *TextBuf) IndentLine(ln, n int) *TextBufEdit {\n\tasv := tb.AutoSaveOff()\n\tdefer tb.AutoSaveRestore(asv)\n\n\ttabSz := tb.Opts.TabSize\n\tichr := indent.Tab\n\tif tb.Opts.SpaceIndent {\n\t\tichr = indent.Space\n\t}\n\n\tcurli, _ := tb.LineIndent(ln, tabSz)\n\tif n > curli {\n\t\t// fmt.Printf(\"autoindent: ins %v\\n\", n)\n\t\treturn tb.InsertText(TextPos{Ln: ln}, indent.Bytes(ichr, n-curli, tabSz), true, true)\n\t} else if n < curli {\n\t\tspos := indent.Len(ichr, n, tabSz)\n\t\tcpos := indent.Len(ichr, curli, tabSz)\n\t\ttb.DeleteText(TextPos{Ln: ln, Ch: spos}, TextPos{Ln: ln, Ch: cpos}, true, true)\n\t\t// fmt.Printf(\"IndentLine deleted: %v at: %v\\n\", string(tbe.ToBytes()), tbe.Reg)\n\t}\n\treturn nil\n}", "func NewLine(p complex128, q complex128) Circle {\n\t// TODO check this matrix\n\treturn Circle{\n\t\tA: 0,\n\t\tC: p - q,\n\t\tD: 1,\n\t}\n}", "func NewEdit(idd uintptr) *Edit {\n\treturn &Edit{WindowBase: WindowBase{idd: idd}}\n}", "func (s *BasePCREListener) ExitNewline_convention(ctx *Newline_conventionContext) {}", "func (c *Coder) NewCodeContent() string {\n\taux := \"\"\n\tfor _, line := range c.Lines {\n\t\taux = aux + line\n\t}\n\treturn aux\n}", "func (tv *TextView) RenderLineNosBox(st, ed int) {\n\tif !tv.HasLineNos() {\n\t\treturn\n\t}\n\trs := &tv.Viewport.Render\n\tpc := &rs.Paint\n\tsty := &tv.Sty\n\tspc := sty.BoxSpace()\n\tclr := sty.Font.BgColor.Color.Highlight(10)\n\tspos := tv.CharStartPos(TextPos{Ln: st})\n\tspos.X = float32(tv.VpBBox.Min.X)\n\tepos := tv.CharEndPos(TextPos{Ln: ed + 1})\n\tepos.Y -= tv.LineHeight\n\tepos.X = spos.X + tv.LineNoOff - spc\n\t// fmt.Printf(\"line box: st %v ed: %v spos %v epos %v\\n\", st, ed, spos, epos)\n\tpc.FillBoxColor(rs, spos, epos.Sub(spos), clr)\n}", "func New() *Repl {\n\treturn &Repl{\n\t\tansi: NewANSI(true),\n\t\tconfig: defaultConfig(),\n\t\tevaluator: interpreter.New(),\n\t}\n}", "func (ts *System) WriteLine(str string) {\n\tts.pages[ts.page].lines[ts.pages[ts.page].line] = &line{}\n\n\tline := \"\"\n\tfor _, char := range strings.Split(str, \"\") {\n\t\tif char == \"\\t\" {\n\t\t\tchar = \" \"\n\t\t}\n\n\t\tline += char\n\n\t\tif ts.pages[ts.page].editable {\n\t\t\tts.needsDraw = append(ts.needsDraw, char)\n\t\t}\n\t}\n\n\tif !ts.pages[ts.page].editable {\n\t\tts.delegateKeyPress(engo.Key(-1), &input.Modifiers{Output: true, Line: &line})\n\t\tts.delegateKeyPress(engo.KeyEnter, &input.Modifiers{Ignore: true, Output: true})\n\t} else {\n\t\tts.needsDraw = append(ts.needsDraw, \"\\n\")\n\t}\n}", "func (e *Editor) prepend(s string) {\n\tif e.singleLine {\n\t\ts = strings.ReplaceAll(s, \"\\n\", \" \")\n\t}\n\te.caret.start.ofs = e.editBuffer.deleteRunes(e.caret.start.ofs,\n\t\te.caret.end.ofs-e.caret.start.ofs) // Delete any selection first.\n\te.editBuffer.prepend(e.caret.start.ofs, s)\n\te.caret.start.xoff = 0\n\te.invalidate()\n}", "func NewEditor(querySelector string, options EditorOptions) *Editor {\n\tinst := js.Global().Get(\"MediumEditor\").New(querySelector, options.Value())\n\treturn &Editor{inst: &inst}\n}", "func NormalizeNewLines(inputText string) string {\n\t// replace CR LF \\r\\n (windows) with LF \\n (unix)\n\tinputText = strings.Replace(inputText, \"\\r\\n\", \"\\n\", -1)\n\t// replace CF \\r (mac) with LF \\n (unix)\n\tinputText = strings.Replace(inputText, \"\\r\", \"\\n\", -1)\n\n\treturn inputText\n}", "func EraseNewLines(inputText string) string {\n\t// replace CR LF \\n (windows / linux)\n\tinputText = strings.Replace(inputText, \"\\n\", \"\", -1)\n\t// replace CF \\r (mac)\n\tinputText = strings.Replace(inputText, \"\\r\", \"\", -1)\n\n\treturn inputText\n}", "func (tv *TextView) LinesInserted(tbe *TextBufEdit) {\n\tstln := tbe.Reg.Start.Ln + 1\n\tnsz := (tbe.Reg.End.Ln - tbe.Reg.Start.Ln)\n\tif stln > len(tv.Renders) { // invalid\n\t\treturn\n\t}\n\n\t// Renders\n\ttmprn := make([]gi.TextRender, nsz)\n\tnrn := append(tv.Renders, tmprn...)\n\tcopy(nrn[stln+nsz:], nrn[stln:])\n\tcopy(nrn[stln:], tmprn)\n\ttv.Renders = nrn\n\n\t// Offs\n\ttmpof := make([]float32, nsz)\n\tnof := append(tv.Offs, tmpof...)\n\tcopy(nof[stln+nsz:], nof[stln:])\n\tcopy(nof[stln:], tmpof)\n\ttv.Offs = nof\n\n\ttv.NLines += nsz\n\n\ttv.LayoutLines(tbe.Reg.Start.Ln, tbe.Reg.End.Ln, false)\n\ttv.RenderAllLines()\n}", "func (builder *Builder) NextLine(n uint) *Builder {\n\treturn builder.With(NextLine(n))\n}", "func ProjectExpelFactory() (cli.Command, error) {\n\tcomm, err := newCommand(\"nerd project expel\", \"move the current project away from its current cluster\", \"\", nil)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to create command\")\n\t}\n\tcmd := &ProjectExpel{\n\t\tcommand: comm,\n\t}\n\n\tcmd.runFunc = cmd.DoRun\n\treturn cmd, nil\n}", "func lexNewline(t *Tokeniser) stateFunc {\n\tr, w := t.currentRune()\n\thasNewline := r == '\\n'\n\t// Check first if it has newline, if it does, emit the semicolon before going to\n\t// ignore the newlines\n\t// The semicolons emitted here will have no width as they are automatically inserted\n\tif hasNewline && t.prevToken != nil {\n\t\tswitch t.prevToken.Type {\n\t\tcase SELF, NAME, INT, FLOAT, STR, FALSE, TRUE, BREAK, CONT, RETURN, RROUND, RSQUARE, RCURLY, NULL:\n\t\t\tt.emit(SEMICOLON)\n\t\t}\n\t}\n\tfor hasNewline {\n\t\tt.advance(w)\n\t\tr, w = t.currentRune()\n\t\thasNewline = r == '\\n'\n\t}\n\tt.ignore()\n\treturn lexCode\n}", "func LineEdits(before string, edits []TextEdit) []TextEdit {\n\tif len(edits) == 0 {\n\t\treturn nil\n\t}\n\tc, edits, partial := prepareEdits(before, edits)\n\tif partial {\n\t\tedits = lineEdits(before, c, edits)\n\t}\n\treturn edits\n}", "func (r renderer) LineBreak(out *bytes.Buffer) {}", "func edit(c *cli.Context) {\n\tlines := content()\n\n\targLen := len(c.Args())\n\n\tvar ind int\n\n\tswitch argLen {\n\tcase 0:\n\t\tind = 0\n\tcase 1:\n\t\tind, _ = strconv.Atoi(c.Args()[0])\n\tdefault:\n\t\tpanic(1)\n\t}\n\n\tselectedLine := lines[ind]\n\tlineArr := strings.Split(selectedLine, \" \")\n\n\tenv := os.Environ()\n\tvimBin, err := exec.LookPath(\"vim\")\n\tcheck(err)\n\n\tplusCmd := fmt.Sprint(\"+\", lineArr[0])\n\tplussCmd := []string{\"vim\", lineArr[1], plusCmd}\n\n\tdebug(\"Whole cmd: %v Index: %v\", plussCmd, c.Args()[0])\n\n\tif true {\n\t\texecErr := syscall.Exec(vimBin, plussCmd, env)\n\t\tcheck(execErr)\n\t}\n}", "func EscapeNewlines(str string) string {\n\treturn strings.Replace(str, \"\\n\", \"\\\\n\", -1)\n}", "func New(str string) (*PN, error) {\n\tcur := &PN{}\n\tfor _, line := range strings.Split(str, \"\\n\") {\n\t\tm := reTreeLine.FindStringSubmatch(line)\n\t\tif len(line) != len(m[0]) {\n\t\t\treturn nil, ErrBadTreeString\n\t\t}\n\t\tif m[1] == \"}\" {\n\t\t\tcur = cur.P\n\t\t}\n\t\tif m[2] != \"\" {\n\t\t\tkind := stringsymbol.Symbol(m[2])\n\t\t\tval := handleSlash.Replace(m[3])\n\t\t\tch := &PN{\n\t\t\t\tLexeme: lexeme.New(kind).Set(val),\n\t\t\t\tP: cur,\n\t\t\t}\n\t\t\tcur.C = append(cur.C, ch)\n\t\t\tif m[4] == \"{\" {\n\t\t\t\tcur = ch\n\t\t\t}\n\t\t}\n\t}\n\tcur = cur.C[0]\n\tcur.P = nil\n\treturn cur, nil\n}", "func NewCli(paths []string, modelsDirs []string) *readline.Instance {\n\tauto := NewComplt(paths, modelsDirs)\n\tl, err := readline.NewEx(&readline.Config{\n\t\tPrompt: BasePrompt,\n\t\tHistoryFile: \"/tmp/actrsh.tmp\",\n\t\tAutoComplete: auto,\n\t\tInterruptPrompt: \"^C\",\n\t\tEOFPrompt: \"exit\",\n\t\tHistorySearchFold: true,\n\t})\n\tpanicErr(err)\n\treturn l\n\n}", "func cutNewLines(s string) string {\n\tr := strings.SplitN(s, \"\\r\", 2)\n\tr = strings.SplitN(r[0], \"\\n\", 2)\n\treturn r[0]\n}", "func NewLine(p Vector, q Vector) *Line {\n\tline := &Line{\n\t\tp: p,\n\t\tq: q,\n\t}\n\n\tpq := line.q.Subtract(line.p)\n\tangle := Angle(pq, Right)\n\n\tif angle < 0 {\n\t\tline.angle = 360 + angle\n\t} else {\n\t\tline.angle = angle\n\t}\n\n\tline.treeNodes = []*quadTreeNode{}\n\n\treturn line\n}", "func (mc *MultiCursor) OnePerLine() {\n\n\t// Create a map of rows for deduplication.\n\tcols := make(map[int]int)\n\tfor _, cursor := range mc.cursors {\n\t\tr, c := cursor.RowCol()\n\t\t_, exist := cols[r]\n\t\tif !exist {\n\t\t\tcols[r] = c\n\t\t}\n\t\tif c < cols[r] {\n\t\t\tcols[r] = c\n\t\t}\n\t}\n\n\t// Recreate the cursors from the map.\n\tmc.cursors = []Cursor{}\n\tfor r, c := range cols {\n\t\tmc.cursors = append(mc.cursors, MakeCursor(r, c))\n\t}\n\n}", "func GetLineIndex(v *gocui.View) int {\n\t_, cy := v.Cursor()\n\treturn cy\n}", "func (r repl) ReadLine() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\toldState, err := term.MakeRaw(fd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\terr := term.Restore(fd, oldState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\treturn r.term.ReadLine()\n}", "func New(cmd *cobra.Command, args []string) {\n\t// Create object for current working directory\n\tpwd, err := teflon.NewTeflonObject(\".\")\n\tif err != nil {\n\t\tlog.Fatalln(\"Couldn't create object for '.' :\", err)\n\t}\n\n\t// Create a show.\n\tif showFlag {\n\t\tnshws, err := pwd.CreateShow(args[0], newShowProtoFlag)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(\"ABORT: Couldnt create show:\", err)\n\t\t}\n\t\tfor _, shw := range nshws {\n\t\t\tfmt.Println(shw.Path)\n\t\t}\n\t\treturn\n\t}\n\n\t// If nothing else commands otherwise new will create an ordinary file-system\n\t// object.\n\tnobjs, err := pwd.CreateObject(args[0], newFileFlag)\n\tif err != nil {\n\t\tlog.Fatalln(\"ABORT: Couldn't create objects:\", err)\n\t}\n\tclose(teflon.Events)\n\tfor _, obj := range nobjs {\n\t\tfmt.Println(obj.Path)\n\t}\n}", "func interact() {\n\tev, st := newEvalerAndStore()\n\tdefer closeStore(st)\n\n\tsigch := make(chan os.Signal, sigchSize)\n\tsignal.Notify(sigch)\n\n\ted := edit.NewEditor(os.Stdin, sigch, ev, st)\n\n\tdatadir, err := store.EnsureDataDir()\n\tprintError(err)\n\tif err == nil {\n\t\t// XXX\n\t\terr := ev.Source(datadir + \"/rc.elv\")\n\t\tif err != nil && !os.IsNotExist(err) {\n\t\t\tprintError(err)\n\t\t}\n\t}\n\n\tcmdNum := 0\n\n\tusername := \"???\"\n\tuser, err := user.Current()\n\tif err == nil {\n\t\tusername = user.Username\n\t}\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\thostname = \"???\"\n\t}\n\trpromptStr := username + \"@\" + hostname\n\tprompt := func() string {\n\t\treturn util.Getwd() + \"> \"\n\t}\n\trprompt := func() string {\n\t\treturn rpromptStr\n\t}\n\n\treadLine := func() edit.LineRead {\n\t\treturn ed.ReadLine(prompt, rprompt)\n\t}\n\n\tusingBasic := false\n\n\tif !sys.IsATTY(0) {\n\t\treadLine = basicReadLine\n\t\tusingBasic = true\n\t}\n\n\tfor {\n\t\tcmdNum++\n\t\t// name := fmt.Sprintf(\"<tty %d>\", cmdNum)\n\n\t\tlr := readLine()\n\t\t// signal.Stop(sigch)\n\n\t\tif lr.EOF {\n\t\t\tbreak\n\t\t} else if lr.Err != nil {\n\t\t\tfmt.Println(\"Editor error:\", lr.Err)\n\t\t\tif !usingBasic {\n\t\t\t\tfmt.Println(\"Falling back to basic line editor\")\n\t\t\t\treadLine = basicReadLine\n\t\t\t\tusingBasic = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tn, err := parse.Parse(lr.Line)\n\t\tprintError(err)\n\n\t\tif err == nil {\n\t\t\terr := ev.EvalInteractive(lr.Line, n)\n\t\t\tprintError(err)\n\t\t}\n\t}\n}", "func NewLineText(path string) Text {\r\n\ttxt, err := os.ReadFile(path)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tgen := Text{\r\n\t\tdatamap: make(map[string][]string),\r\n\t\ttextdata: string(txt),\r\n\t}\r\n\treturn gen.generateMarkov()\r\n\r\n}" ]
[ "0.69335365", "0.61699903", "0.61023545", "0.60246354", "0.5971946", "0.59482497", "0.5906088", "0.5841152", "0.58139503", "0.57714456", "0.5633337", "0.54948366", "0.54569215", "0.53570414", "0.5312351", "0.5303593", "0.52962285", "0.5134063", "0.5115456", "0.50289315", "0.4984843", "0.4965363", "0.49342054", "0.49037638", "0.48764157", "0.48354262", "0.48273134", "0.48025945", "0.47858283", "0.47682685", "0.47347477", "0.47198743", "0.4711434", "0.47045493", "0.46830893", "0.4680539", "0.4667672", "0.46578142", "0.46560538", "0.46347386", "0.46303126", "0.46076182", "0.4603412", "0.4602315", "0.4596103", "0.45956853", "0.4590136", "0.45894524", "0.45863226", "0.45811263", "0.45721126", "0.45374572", "0.4523701", "0.4518607", "0.4513263", "0.45087054", "0.45035875", "0.44985193", "0.4497747", "0.4494929", "0.4493731", "0.44822344", "0.44684014", "0.44543228", "0.44513163", "0.44490796", "0.4422727", "0.4417775", "0.4411149", "0.44023636", "0.44007093", "0.4398809", "0.43925104", "0.4388132", "0.43812516", "0.4368297", "0.4361298", "0.43475303", "0.43390143", "0.43315488", "0.43258378", "0.43231562", "0.43043146", "0.42982948", "0.4296637", "0.429207", "0.42913198", "0.4290611", "0.4281249", "0.42682648", "0.42582026", "0.4258188", "0.42542318", "0.42484364", "0.42460397", "0.4242708", "0.42418024", "0.42379653", "0.42366543", "0.4228797" ]
0.5784365
9
edit a line in raw mode
func (l *Linenoise) edit(ifd, ofd int, prompt, init string) (string, error) { // create the line state ls := newLineState(ifd, ofd, prompt, l) // set and output the initial line ls.editSet(init) // The latest history entry is always our current buffer l.HistoryAdd(ls.String()) u := utf8{} for { r := u.getRune(syscall.Stdin, nil) if r == KeycodeNull { continue } // Autocomplete when the callback is set. // It returns the character to be handled next. if r == KeycodeTAB && l.completionCallback != nil { r = ls.completeLine() if r == KeycodeNull { continue } } if r == KeycodeCR || r == l.hotkey { l.historyPop(-1) if l.hintsCallback != nil { // Refresh the line without hints to leave the // line as the user typed it after the newline. hcb := l.hintsCallback l.hintsCallback = nil ls.refreshLine() l.hintsCallback = hcb } s := ls.String() if r == l.hotkey { return s + string(l.hotkey), nil } return s, nil } else if r == KeycodeBS { // backspace: remove the character to the left of the cursor ls.editBackspace() } else if r == KeycodeESC { if wouldBlock(ifd, &timeout20ms) { // looks like a single escape- abandon the line l.historyPop(-1) return "", nil } // escape sequence s0 := u.getRune(ifd, &timeout20ms) s1 := u.getRune(ifd, &timeout20ms) if s0 == '[' { // ESC [ sequence if s1 >= '0' && s1 <= '9' { // Extended escape, read additional byte. s2 := u.getRune(ifd, &timeout20ms) if s2 == '~' { if s1 == '3' { // delete ls.editDelete() } } } else { if s1 == 'A' { // cursor up ls.editSet(l.historyPrev(ls)) } else if s1 == 'B' { // cursor down ls.editSet(l.historyNext(ls)) } else if s1 == 'C' { // cursor right ls.editMoveRight() } else if s1 == 'D' { // cursor left ls.editMoveLeft() } else if s1 == 'H' { // cursor home ls.editMoveHome() } else if s1 == 'F' { // cursor end ls.editMoveEnd() } } } else if s0 == '0' { // ESC 0 sequence if s1 == 'H' { // cursor home ls.editMoveHome() } else if s1 == 'F' { // cursor end ls.editMoveEnd() } } } else if r == KeycodeCtrlA { // go to the start of the line ls.editMoveHome() } else if r == KeycodeCtrlB { // cursor left ls.editMoveLeft() } else if r == KeycodeCtrlC { // return QUIT return "", ErrQuit } else if r == KeycodeCtrlD { if len(ls.buf) > 0 { // delete: remove the character to the right of the cursor. ls.editDelete() } else { // nothing to delete - QUIT l.historyPop(-1) return "", ErrQuit } } else if r == KeycodeCtrlE { // go to the end of the line ls.editMoveEnd() } else if r == KeycodeCtrlF { // cursor right ls.editMoveRight() } else if r == KeycodeCtrlH { // backspace: remove the character to the left of the cursor ls.editBackspace() } else if r == KeycodeCtrlK { // delete to the end of the line ls.deleteToEnd() } else if r == KeycodeCtrlL { // clear screen clearScreen() ls.refreshLine() } else if r == KeycodeCtrlN { // next history item ls.editSet(l.historyNext(ls)) } else if r == KeycodeCtrlP { // previous history item ls.editSet(l.historyPrev(ls)) } else if r == KeycodeCtrlT { // swap current character with the previous ls.editSwap() } else if r == KeycodeCtrlU { // delete the whole line ls.deleteLine() } else if r == KeycodeCtrlW { // delete previous word ls.deletePrevWord() } else { // insert the character into the line buffer ls.editInsert(r) } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func edit(c *cli.Context) {\n\tlines := content()\n\n\targLen := len(c.Args())\n\n\tvar ind int\n\n\tswitch argLen {\n\tcase 0:\n\t\tind = 0\n\tcase 1:\n\t\tind, _ = strconv.Atoi(c.Args()[0])\n\tdefault:\n\t\tpanic(1)\n\t}\n\n\tselectedLine := lines[ind]\n\tlineArr := strings.Split(selectedLine, \" \")\n\n\tenv := os.Environ()\n\tvimBin, err := exec.LookPath(\"vim\")\n\tcheck(err)\n\n\tplusCmd := fmt.Sprint(\"+\", lineArr[0])\n\tplussCmd := []string{\"vim\", lineArr[1], plusCmd}\n\n\tdebug(\"Whole cmd: %v Index: %v\", plussCmd, c.Args()[0])\n\n\tif true {\n\t\texecErr := syscall.Exec(vimBin, plussCmd, env)\n\t\tcheck(execErr)\n\t}\n}", "func EditRawOvf(r io.Reader, scheme EditScheme) (*bytes.Buffer, error) {\n\traw, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = xmlutil.ValidateFormatting(raw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tscanner := bufio.NewScanner(bytes.NewReader(raw))\n\n\tendOfLineChars := lfEol\n\tlenRaw := len(raw)\n\tif lenRaw > 1 && raw[lenRaw-2] == '\\r' {\n\t\tendOfLineChars = crLfEol\n\t}\n\n\tnewData := bytes.NewBuffer(nil)\n\n\tfor scanner.Scan() {\n\t\terr := processNextToken(scanner, endOfLineChars, newData, scheme)\n\t\tif err != nil {\n\t\t\treturn newData, err\n\t\t}\n\t}\n\n\terr = scanner.Err()\n\tif err != nil {\n\t\treturn newData, err\n\t}\n\n\treturn newData, nil\n}", "func (l *Linenoise) readRaw(prompt, init string) (string, error) {\n\t// set rawmode for stdin\n\tl.enableRawMode(syscall.Stdin)\n\tdefer l.disableRawMode(syscall.Stdin)\n\t// edit the line\n\ts, err := l.edit(syscall.Stdin, syscall.Stdout, prompt, init)\n\tfmt.Printf(\"\\r\\n\")\n\treturn s, err\n}", "func (ls *linestate) editInsert(r rune) {\n\tls.buf = append(ls.buf[:ls.pos], append([]rune{r}, ls.buf[ls.pos:]...)...)\n\tls.pos++\n\tls.refreshLine()\n}", "func (c *Console) EditRow(id Row, text string) <-chan struct{} {\n\tch := make(chan struct{})\n\tc.jobs <- func() {\n\t\tdiff := c.rowCount - int(id)\n\t\tfmt.Fprintf(c.File, \"%c[%dA\", 27, diff)\n\t\tfmt.Fprintf(c.File, \"\\r%c[2K\", 27)\n\t\tfmt.Fprintf(c.File, \"%s\\n\", strings.TrimSpace(text))\n\t\tfmt.Fprintf(c.File, \"%c[%dB\", 27, diff)\n\t\tclose(ch)\n\t}\n\treturn ch\n}", "func (conn *Conn) Raw(rawline string) {\n\t// Avoid command injection by enforcing one command per line.\n\tconn.out <- cutNewLines(rawline)\n}", "func (ls *linestate) editSet(s string) {\n\tls.buf = []rune(s)\n\tls.pos = len(ls.buf)\n\tls.refreshLine()\n}", "func (ls *linestate) editSwap() {\n\tif ls.pos > 0 && ls.pos < len(ls.buf) {\n\t\ttmp := ls.buf[ls.pos-1]\n\t\tls.buf[ls.pos-1] = ls.buf[ls.pos]\n\t\tls.buf[ls.pos] = tmp\n\t\tif ls.pos != len(ls.buf)-1 {\n\t\t\tls.pos++\n\t\t}\n\t\tls.refreshLine()\n\t}\n}", "func (ls *linestate) editDelete() {\n\tif len(ls.buf) > 0 && ls.pos < len(ls.buf) {\n\t\tls.buf = append(ls.buf[:ls.pos], ls.buf[ls.pos+1:]...)\n\t\tls.refreshLine()\n\t}\n}", "func (c *client) Edit(filename string, update bool, filter Filter) error {\n\tif filename == \"-\" {\n\t\treturn EditStream(c.o.InStream, c.o.OutStream, filename, filter)\n\t}\n\n\tif update {\n\t\treturn UpdateFile(filename, filter)\n\t}\n\n\treturn ReadFile(filename, c.o.OutStream, filter)\n}", "func EditCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {\n\tnName, err := NoteName(c)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\n\tn, err = i.LoadNote(nName)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\n\tif err := writer.WriteNote(&n); err != nil {\n\t\treturn n, err\n\t}\n\n\tif err := i.SaveNote(&n); err != nil {\n\t\treturn n, err\n\t}\n\n\treturn n, nil\n\n}", "func (e *Editor) Line() (string, error) {\n\tif err := e.editReset(); err != nil {\n\t\treturn string(e.Buffer), err\n\t}\nline:\n\tfor {\n\t\tr, _, err := e.In.ReadRune()\n\t\tif err != nil {\n\t\t\treturn string(e.Buffer), err\n\t\t}\n\n\t\tswitch r {\n\t\tcase enter:\n\t\t\tbreak line\n\t\tcase ctrlC:\n\t\t\treturn string(e.Buffer), errors.New(\"try again\")\n\t\tcase backspace, ctrlH:\n\t\t\tif err := e.editBackspace(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlD:\n\t\t\tif len(e.Buffer) == 0 {\n\t\t\t\treturn string(e.Buffer), io.EOF\n\t\t\t}\n\n\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlT:\n\t\t\tif err := e.editSwap(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlB:\n\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlF:\n\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlP:\n\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlN:\n\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlU:\n\t\t\tif err := e.editReset(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlK:\n\t\t\tif err := e.editKillForward(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlA:\n\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlE:\n\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlL:\n\t\t\tif err := e.clearScreen(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tif err := e.refreshLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase ctrlW:\n\t\t\tif err := e.editDeletePrevWord(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tcase esc:\n\t\t\tr, _, err := e.In.ReadRune()\n\t\t\tif err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\n\t\t\tswitch r {\n\t\t\tcase '[':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase '0', '1', '2', '4', '5', '6', '7', '8', '9':\n\t\t\t\t\t_, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase '3':\n\t\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch r {\n\t\t\t\t\tcase '~':\n\t\t\t\t\t\tif err := e.editDelete(); err != nil {\n\t\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'A':\n\t\t\t\t\tif err := e.editHistoryPrev(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'B':\n\t\t\t\t\tif err := e.editHistoryNext(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'C':\n\t\t\t\t\tif err := e.editMoveRight(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'D':\n\t\t\t\t\tif err := e.editMoveLeft(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase 'O':\n\t\t\t\tr, _, err := e.In.ReadRune()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t}\n\n\t\t\t\tswitch r {\n\t\t\t\tcase 'H':\n\t\t\t\t\tif err := e.editMoveHome(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\tcase 'F':\n\t\t\t\t\tif err := e.editMoveEnd(); err != nil {\n\t\t\t\t\t\treturn string(e.Buffer), err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase tab:\n\t\t\tif err := e.completeLine(); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\tdefault:\n\t\t\tif err := e.editInsert(r); err != nil {\n\t\t\t\treturn string(e.Buffer), err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn string(e.Buffer), nil\n}", "func (i *UI) rawReadline(f *os.File) (string, error) {\n\tvar resultBuf []byte\n\tfor {\n\t\tvar buf [1]byte\n\t\tn, err := f.Read(buf[:])\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif n == 0 || buf[0] == '\\n' || buf[0] == '\\r' {\n\t\t\tbreak\n\t\t}\n\n\t\tif buf[0] == 3 {\n\t\t\treturn \"\", ErrInterrupted\n\t\t}\n\n\t\tif i.mask {\n\t\t\tfmt.Fprintf(i.Writer, i.maskVal)\n\t\t}\n\n\t\tresultBuf = append(resultBuf, buf[0])\n\t}\n\n\tfmt.Fprintf(i.Writer, \"\\n\")\n\treturn string(resultBuf), nil\n}", "func (rec *Record) Edit(editNotes bool) error {\n\n\tline := liner.NewLiner()\n\tdefer line.Close()\n\tline.SetCtrlCAborts(true)\n\n\tpos := -1\n\n\tvar err error\n\tvar editedValue string\n\n\taborted := fmt.Errorf(\"Aborted\")\n\n\tif editedValue, err = line.PromptWithSuggestion(config.TitleLabel, rec.Title, pos); err != nil {\n\t\treturn aborted\n\t}\n\trec.Title = editedValue\n\n\tif editedValue, err = line.PromptWithSuggestion(config.AccountLabel, rec.Account, pos); err != nil {\n\t\treturn aborted\n\t}\n\trec.Account = editedValue\n\n\tif editedValue, err = line.PromptWithSuggestion(config.PasswordLabel, rec.Password, pos); err != nil {\n\t\treturn aborted\n\t}\n\trec.Password = editedValue\n\n\ttagsString := strings.Join(rec.Tags, \", \")\n\n\tif editedValue, err = line.PromptWithSuggestion(config.TagsLabel, tagsString, pos); err != nil {\n\t\treturn aborted\n\t}\n\trec.Tags = tagsStringToArray(editedValue)\n\n\tif editedValue, err = line.PromptWithSuggestion(config.URLLabel, rec.Url, pos); err != nil {\n\t\treturn aborted\n\t}\n\trec.Url = editedValue\n\n\tif editNotes {\n\t\t// handle multi-line notes\n\t\tlog.Info(\"\\n%s\", config.NotesLabel)\n\n\t\tlines := strings.Split(rec.Notes, \"\\n\")\n\n\t\twriteBack := \"\"\n\t\tlineIdx := 0\n\n\t\taborted := false\n\n\t\tfor {\n\t\t\tproposal := \"\"\n\n\t\t\tif lineIdx < len(lines) {\n\t\t\t\tproposal = lines[lineIdx]\n\t\t\t}\n\n\t\t\tinput, err := line.PromptWithSuggestion(\"\", proposal, len(proposal))\n\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Debug(\"Aborted? : %v\", err)\n\t\t\t\taborted = true\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\twriteBack += input + \"\\n\"\n\t\t\tlineIdx++\n\t\t}\n\n\t\tif !aborted {\n\t\t\trec.Notes = writeBack\n\t\t}\n\t}\n\n\treturn nil\n}", "func (w *Writer) UpdateLine(fd *os.File, cursorPos int64, newValue string) error {\n\terr := writeFileAt(fd, newValue, cursorPos)\n\tif err != nil {\n\t\tcore.PrintAndExit(err)\n\t}\n\treturn nil\n}", "func (ui *ReplApp) evalLine(line string) (quit bool) {\n\t// these vars are used in many places below\n\tengine := ui.engine\n\tcmds := ui.commands\n\toutput := ui.output\n\tmeProfileFile := ui.meProfileFile\n\tcontactsFile := ui.contactsFile\n\tprivateKeyFile := ui.privateKeyFile\n\n\t// parse raw line into command struct\n\tcmd := cmds.parse(line)\n\tif cmd.err != nil {\n\t\tif cmd.cmd != \"\" { // ignore blank lines\n\t\t\tlog.Printf(\"Error: %s\\n\", cmd.err)\n\t\t}\n\t\treturn\n\t}\n\n\t// process specific command\n\t// each block could really be in it's own function\n\t// or a function in the command definitions\n\tswitch cmd.cmd {\n\tcase \"exit\":\n\t\treturn true\n\n\tcase \"help\":\n\t\tfmt.Fprintln(output, cmds.help()) // uses commanddefs\n\n\tcase \"ip\":\n\t\tfmt.Fprintln(output, \"getting external ip...\")\n\t\tip, err := GetIP()\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Fprintf(output, \"external IP address:\\t%s\\nlistening on port:\\t%s\\n\", ip, engine.Me.Port)\n\n\tcase \"me\":\n\t\tswitch cmd = *cmd.leaf(); cmd.cmd {\n\t\tcase \"show\":\n\t\t\tfmt.Fprintf(output, \"I am \\\"%s\\\"\\nPubKey: %s\\nPrivKey: %s\\n\",\n\t\t\t\tengine.Me,\n\t\t\t\tbase64.RawStdEncoding.EncodeToString(engine.Me.PublicSigningKey),\n\t\t\t\tbase64.RawStdEncoding.EncodeToString(engine.PrivSignKey))\n\n\t\tcase \"edit\":\n\t\t\tp, err := ParseProfile(cmd.args[0])\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tp.PublicSigningKey = engine.Me.PublicSigningKey // preserve key\n\t\t\terr = WriteProfile(p, meProfileFile)\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\tengine.Me = p\n\n\t\t\terr = WritePrivateKey(engine.PrivSignKey, privateKeyFile)\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\n\tcase \"contacts\":\n\n\t\tswitch cmd = *cmd.leaf(); cmd.cmd {\n\t\tcase \"list\":\n\t\t\tfor i, c := range engine.Contacts {\n\t\t\t\tif c != nil {\n\t\t\t\t\tfmt.Fprintf(output, \"%d\\t%s\\t%s\\n\", i, c,\n\t\t\t\t\t\tbase64.RawStdEncoding.EncodeToString(c.PublicSigningKey))\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase \"add\":\n\t\t\tvar p *Profile\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\n\t\t\tif err == nil {\n\t\t\t\tif sess, ok := engine.GetSession(n); ok {\n\t\t\t\t\tp = sess.Other\n\t\t\t\t\tif p == nil {\n\t\t\t\t\t\tlog.Printf(\"session %d had a nil Other\", n)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tp, err = ParseProfile(arg)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// overwrite contact if existing Equal() one found\n\t\t\t// TODO: do i really want to overwrite? what about having 2\n\t\t\t// contacts with different names but the same address?\n\t\t\t// i guess the question boils down to the definition of Profile\n\t\t\tif index := engine.FindContact(p); index >= 0 {\n\t\t\t\told := engine.Contacts[index]\n\t\t\t\tengine.Contacts[index] = p\n\t\t\t\tlog.Printf(\"overwrote #%d '%s' with '%s'\\n\", index, old, p)\n\t\t\t} else {\n\t\t\t\tengine.AddContact(p)\n\t\t\t\tlog.Printf(\"added %s\\n\", p)\n\t\t\t}\n\n\t\t\terr = WriteContacts(engine.Contacts, contactsFile)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tlog.Println(\"did not save changes to disk\")\n\t\t\t}\n\n\t\tcase \"delete\":\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tremoved := engine.Contacts[n]\n\t\t\tif engine.RemoveContact(n) {\n\t\t\t\tlog.Printf(\"deleted %s\\n\", removed)\n\n\t\t\t\terr = WriteContacts(engine.Contacts, contactsFile)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\tlog.Println(\"did not save changes to disk\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t}\n\t\t}\n\n\tcase \"requests\":\n\t\tswitch cmd = *cmd.leaf(); cmd.cmd {\n\t\tcase \"list\":\n\t\t\tfor i, r := range engine.Requests {\n\t\t\t\tif r != nil {\n\t\t\t\t\tfmt.Fprintf(output, \"%d\\t%s at %s (%s ago)\\n\", i,\n\t\t\t\t\t\tr.Profile,\n\t\t\t\t\t\tr.Time().Format(time.Kitchen),\n\t\t\t\t\t\ttime.Since(r.Time()))\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase \"accept\":\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\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\tif _, ok := engine.GetRequest(n); !ok {\n\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terr = engine.AcceptRequest(engine.Requests[n])\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\tlog.Println(\"request accepted\")\n\n\t\tcase \"reject\":\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif engine.RemoveRequest(n) {\n\t\t\t\tlog.Println(\"removed request\")\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t}\n\t\t}\n\n\tcase \"sessions\":\n\t\tswitch cmd = *cmd.leaf(); cmd.cmd {\n\t\tcase \"list\":\n\t\t\tfor i, s := range engine.Sessions {\n\t\t\t\tif s != nil {\n\t\t\t\t\tfmt.Fprintf(output, \"%d\\t%s\\n\", i, s)\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase \"start\":\n\t\t\tvar p *Profile\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\n\t\t\tif err == nil {\n\t\t\t\tif p, _ = engine.GetContact(n); p == nil {\n\t\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp, err = ParseProfile(arg)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif i := engine.FindContact(p); i >= 0 {\n\t\t\t\t\tp = engine.Contacts[i] // use profile from contacts if available\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\terr = engine.SendRequest(p)\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\tlog.Println(\"request sent\")\n\n\t\tcase \"drop\":\n\t\t\targ := cmd.args[0]\n\t\t\tn, err := strconv.Atoi(arg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif engine.RemoveSession(n) {\n\t\t\t\tlog.Println(\"dropped session\")\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\t}\n\t\t}\n\n\tcase \"msg\":\n\t\tn, err := strconv.Atoi(cmd.args[0])\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tif _, ok := engine.GetSession(n); !ok {\n\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\treturn\n\t\t}\n\n\t\terr = engine.Sessions[n].SendText(cmd.args[1])\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\tlog.Println(\"sent\")\n\n\tcase \"show\":\n\t\tn, err := strconv.Atoi(cmd.args[0])\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t\ts, ok := engine.GetSession(n)\n\t\tif !ok {\n\t\t\tlog.Printf(\"%d not found\\n\", n)\n\t\t\treturn\n\t\t}\n\n\t\tconst num = 5\n\t\tstart := len(s.Msgs) - num\n\t\tif start < 0 {\n\t\t\tstart = 0\n\t\t} // clamp\n\t\tshow := s.Msgs[start:]\n\t\tfor i, t := range show {\n\t\t\tfmt.Fprintf(output, \"%d %s\\t| %s > %s\\n\", i,\n\t\t\t\tt.From().Name,\n\t\t\t\tt.TimeStamp.Time().Format(time.Kitchen),\n\t\t\t\tt.Message)\n\t\t}\n\n\t}\n\n\treturn\n}", "func interact() {\n\tev, st := newEvalerAndStore()\n\tdefer closeStore(st)\n\n\tsigch := make(chan os.Signal, sigchSize)\n\tsignal.Notify(sigch)\n\n\ted := edit.NewEditor(os.Stdin, sigch, ev, st)\n\n\tdatadir, err := store.EnsureDataDir()\n\tprintError(err)\n\tif err == nil {\n\t\t// XXX\n\t\terr := ev.Source(datadir + \"/rc.elv\")\n\t\tif err != nil && !os.IsNotExist(err) {\n\t\t\tprintError(err)\n\t\t}\n\t}\n\n\tcmdNum := 0\n\n\tusername := \"???\"\n\tuser, err := user.Current()\n\tif err == nil {\n\t\tusername = user.Username\n\t}\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\thostname = \"???\"\n\t}\n\trpromptStr := username + \"@\" + hostname\n\tprompt := func() string {\n\t\treturn util.Getwd() + \"> \"\n\t}\n\trprompt := func() string {\n\t\treturn rpromptStr\n\t}\n\n\treadLine := func() edit.LineRead {\n\t\treturn ed.ReadLine(prompt, rprompt)\n\t}\n\n\tusingBasic := false\n\n\tif !sys.IsATTY(0) {\n\t\treadLine = basicReadLine\n\t\tusingBasic = true\n\t}\n\n\tfor {\n\t\tcmdNum++\n\t\t// name := fmt.Sprintf(\"<tty %d>\", cmdNum)\n\n\t\tlr := readLine()\n\t\t// signal.Stop(sigch)\n\n\t\tif lr.EOF {\n\t\t\tbreak\n\t\t} else if lr.Err != nil {\n\t\t\tfmt.Println(\"Editor error:\", lr.Err)\n\t\t\tif !usingBasic {\n\t\t\t\tfmt.Println(\"Falling back to basic line editor\")\n\t\t\t\treadLine = basicReadLine\n\t\t\t\tusingBasic = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tn, err := parse.Parse(lr.Line)\n\t\tprintError(err)\n\n\t\tif err == nil {\n\t\t\terr := ev.EvalInteractive(lr.Line, n)\n\t\t\tprintError(err)\n\t\t}\n\t}\n}", "func BasicLineEdit(i int, b byte) Op {\n\tswitch b {\n\tcase '\\b', 0x7f: // ^H, ^?\n\t\treturn Erase\n\tcase 0x17: // ^W\n\t\treturn EraseWord\n\tcase 0x15: // ^U\n\t\treturn Kill\n\tcase 0x04: // ^D\n\t\tif i == 0 {\n\t\t\treturn Close\n\t\t}\n\t\treturn Flush\n\tcase '\\n':\n\t\treturn Append | Flush\n\tdefault:\n\t\treturn Append\n\t}\n}", "func (ls *linestate) editMoveRight() {\n\tif ls.pos != len(ls.buf) {\n\t\tls.pos++\n\t\tls.refreshLine()\n\t}\n}", "func (r *rawMode) enter() (err error) {\n\tr.state, err = readline.MakeRaw(r.StdinFd)\n\treturn err\n}", "func (e *Editor) Adjust() error {\n\t// https://groups.google.com/forum/#!topic/comp.os.vms/bDKSY6nG13k\n\tif _, err := e.Out.WriteString(\"\\x1b7\\x1b[999;999H\\x1b[6n\"); err != nil {\n\t\treturn err\n\t}\n\n\tif err := e.Out.Flush(); err != nil {\n\t\treturn err\n\t}\n\n\tres, err := e.In.ReadString('R')\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tms := curPosPattern.FindStringSubmatch(res)\n\tr, err := strconv.Atoi(ms[1])\n\tif err != nil {\n\t\treturn err\n\t}\n\tc, err := strconv.Atoi(ms[2])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := e.Out.WriteString(\"\\x1b8\"); err != nil {\n\t\treturn err\n\t}\n\n\te.Cols = c\n\te.Rows = r\n\n\treturn nil\n}", "func (c *Eth) Edit(vsys string, e Entry) error {\n var err error\n\n _, fn := c.versioning()\n\n c.con.LogAction(\"(edit) ethernet interface %q\", e.Name)\n\n // Set xpath.\n path := c.xpath([]string{e.Name})\n\n // Edit the interface.\n _, err = c.con.Edit(path, fn(e), nil, nil)\n if err != nil {\n return err\n }\n\n // Check if we should skip the import step.\n if vsys == \"\" || e.Mode == \"ha\" || e.Mode == \"aggregate-group\" {\n return nil\n }\n\n // Perform vsys import.\n return c.con.ImportInterfaces(vsys, []string{e.Name})\n}", "func (ls *linestate) editBackspace() {\n\tif ls.pos > 0 && len(ls.buf) > 0 {\n\t\tls.buf = append(ls.buf[:ls.pos-1], ls.buf[ls.pos:]...)\n\t\tls.pos--\n\t\tls.refreshLine()\n\t}\n}", "func (i *IRC) writeLine(command string, args ...string) (int, error) {\n\tl := util.MakeSimpleIRCLine(command, args...)\n\tlBytes, err := l.LineBytes()\n\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\treturn i.write(lBytes, !(command == \"PING\" && i.SuppressPing))\n}", "func (tpl Template) EditRow() error {\n\t_, err := DB.Exec(\n\t\t`UPDATE template SET \n\t\t name = ?,\n\t\t remark = ?,\n\t\t script = ?,\n\t\t package_id_str = ?\n\t\tWHERE\n\t\t id = ?`,\n\t\ttpl.Name,\n\t\ttpl.Remark,\n\t\ttpl.Script,\n\t\ttpl.PackageIDStr,\n\t\ttpl.ID,\n\t)\n\treturn err\n}", "func (p *MultiLineParser) sendLine() {\n\tdefer func() {\n\t\tp.buffer.Reset()\n\t\tp.rawDataLen = 0\n\t}()\n\n\tcontent := make([]byte, p.buffer.Len())\n\tcopy(content, p.buffer.Bytes())\n\tif len(content) > 0 || p.rawDataLen > 0 {\n\t\tp.lineHandler.Handle(NewMessage(content, p.status, p.rawDataLen, p.timestamp))\n\t}\n}", "func (rl *Instance) Readline() (_ string, err error) {\n\tfd := int(os.Stdin.Fd())\n\tstate, err := MakeRaw(fd)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// return an error if Restore fails. However we don't want to return\n\t\t// `nil` if there is no error because there might be a CtrlC or EOF\n\t\t// that needs to be returned\n\t\tr := Restore(fd, state)\n\t\tif r != nil {\n\t\t\terr = r\n\t\t}\n\t}()\n\n\tx, _ := rl.getCursorPos()\n\tswitch x {\n\tcase -1:\n\t\tprint(string(leftMost()))\n\tcase 0:\n\t\t// do nothing\n\tdefault:\n\t\tprint(\"\\r\\n\")\n\t}\n\tprint(rl.prompt)\n\n\trl.line = []rune{}\n\trl.viUndoHistory = []undoItem{{line: \"\", pos: 0}}\n\trl.pos = 0\n\trl.histPos = rl.History.Len()\n\trl.modeViMode = vimInsert\n\tatomic.StoreInt64(&rl.delayedSyntaxCount, 0)\n\trl.resetHintText()\n\trl.resetTabCompletion()\n\n\tif len(rl.multisplit) > 0 {\n\t\tr := []rune(rl.multisplit[0])\n\t\trl.readlineInput(r)\n\t\trl.carridgeReturn()\n\t\tif len(rl.multisplit) > 1 {\n\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t} else {\n\t\t\trl.multisplit = []string{}\n\t\t}\n\t\treturn string(rl.line), nil\n\t}\n\n\trl.termWidth = GetTermWidth()\n\trl.getHintText()\n\trl.renderHelpers()\n\n\tfor {\n\t\tgo delayedSyntaxTimer(rl, atomic.LoadInt64(&rl.delayedSyntaxCount))\n\t\trl.viUndoSkipAppend = false\n\t\tb := make([]byte, 1024*1024)\n\t\tvar i int\n\n\t\tif !rl.skipStdinRead {\n\t\t\ti, err = os.Stdin.Read(b)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\trl.termWidth = GetTermWidth()\n\t\t}\n\t\tatomic.AddInt64(&rl.delayedSyntaxCount, 1)\n\n\t\trl.skipStdinRead = false\n\t\tr := []rune(string(b))\n\n\t\tif isMultiline(r[:i]) || len(rl.multiline) > 0 {\n\t\t\trl.multiline = append(rl.multiline, b[:i]...)\n\t\t\tif i == len(b) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !rl.allowMultiline(rl.multiline) {\n\t\t\t\trl.multiline = []byte{}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ts := string(rl.multiline)\n\t\t\trl.multisplit = rxMultiline.Split(s, -1)\n\n\t\t\tr = []rune(rl.multisplit[0])\n\t\t\trl.modeViMode = vimInsert\n\t\t\trl.readlineInput(r)\n\t\t\trl.carridgeReturn()\n\t\t\trl.multiline = []byte{}\n\t\t\tif len(rl.multisplit) > 1 {\n\t\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t\t} else {\n\t\t\t\trl.multisplit = []string{}\n\t\t\t}\n\t\t\treturn string(rl.line), nil\n\t\t}\n\n\t\ts := string(r[:i])\n\t\tif rl.evtKeyPress[s] != nil {\n\t\t\t//rl.clearHelpers() // unessisary clear?\n\n\t\t\tret := rl.evtKeyPress[s](s, rl.line, rl.pos)\n\n\t\t\trl.clearLine()\n\t\t\trl.line = append(ret.NewLine, []rune{}...)\n\t\t\trl.echo()\n\t\t\trl.pos = ret.NewPos\n\n\t\t\tif ret.ClearHelpers {\n\t\t\t\trl.resetHelpers()\n\t\t\t} else {\n\t\t\t\trl.updateHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\t\tif len(ret.HintText) > 0 {\n\t\t\t\trl.hintText = ret.HintText\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\t\t\tif !ret.ForwardKey {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ret.CloseReadline {\n\t\t\t\trl.clearHelpers()\n\t\t\t\treturn string(rl.line), nil\n\t\t\t}\n\t\t}\n\n\t\tswitch b[0] {\n\t\tcase charCtrlC:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", CtrlC\n\n\t\tcase charEOF:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", EOF\n\n\t\tcase charCtrlF:\n\t\t\tif !rl.modeTabCompletion {\n\t\t\t\trl.modeAutoFind = true\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlR:\n\t\t\trl.modeAutoFind = true\n\t\t\trl.tcOffset = 0\n\t\t\trl.modeTabCompletion = true\n\t\t\trl.tcDisplayType = TabDisplayMap\n\t\t\trl.tcSuggestions, rl.tcDescriptions = rl.autocompleteHistory()\n\t\t\trl.initTabCompletion()\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlU:\n\t\t\trl.clearLine()\n\t\t\trl.resetHelpers()\n\n\t\tcase charTab:\n\t\t\tif rl.modeTabCompletion {\n\t\t\t\trl.moveTabCompletionHighlight(1, 0)\n\t\t\t} else {\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.renderHelpers()\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase '\\r':\n\t\t\tfallthrough\n\t\tcase '\\n':\n\t\t\tvar suggestions []string\n\t\t\tif rl.modeTabFind {\n\t\t\t\tsuggestions = rl.tfSuggestions\n\t\t\t} else {\n\t\t\t\tsuggestions = rl.tcSuggestions\n\t\t\t}\n\n\t\t\tif rl.modeTabCompletion && len(suggestions) > 0 {\n\t\t\t\tcell := (rl.tcMaxX * (rl.tcPosY - 1)) + rl.tcOffset + rl.tcPosX - 1\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.resetTabCompletion()\n\t\t\t\trl.renderHelpers()\n\t\t\t\trl.insert([]rune(suggestions[cell]))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trl.carridgeReturn()\n\t\t\treturn string(rl.line), nil\n\n\t\tcase charBackspace, charBackspace2:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.backspaceTabFind()\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.backspace()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\tcase charEscape:\n\t\t\trl.escapeSeq(r[:i])\n\n\t\tdefault:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.updateTabFind(r[:i])\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.readlineInput(r[:i])\n\t\t\t\tif len(rl.multiline) > 0 && rl.modeViMode == vimKeys {\n\t\t\t\t\trl.skipStdinRead = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//if !rl.viUndoSkipAppend {\n\t\t//\trl.viUndoHistory = append(rl.viUndoHistory, rl.line)\n\t\t//}\n\t\trl.undoAppendHistory()\n\t}\n}", "func (w *IPWriter) SetCurrentLine(n uint) {\n\tw.currentLine = n\n}", "func (ls *linestate) completeLine() rune {\n\t// get a list of line completions\n\tlc := ls.ts.completionCallback(ls.String())\n\tif len(lc) == 0 {\n\t\t// no line completions\n\t\tbeep()\n\t\treturn KeycodeNull\n\t}\n\t// navigate and display the line completions\n\tstop := false\n\tidx := 0\n\tu := utf8{}\n\tvar r rune\n\tfor !stop {\n\t\tif idx < len(lc) {\n\t\t\t// save the line buffer\n\t\t\tsavedBuf := ls.buf\n\t\t\tsavedPos := ls.pos\n\t\t\t// show the completion\n\t\t\tls.buf = []rune(lc[idx])\n\t\t\tls.pos = len(ls.buf)\n\t\t\tls.refreshLine()\n\t\t\t// restore the line buffer\n\t\t\tls.buf = savedBuf\n\t\t\tls.pos = savedPos\n\t\t} else {\n\t\t\t// show the original buffer\n\t\t\tls.refreshLine()\n\t\t}\n\t\t// navigate through the completions\n\t\tr = u.getRune(ls.ifd, nil)\n\t\tif r == KeycodeNull {\n\t\t\t// error on read\n\t\t\tstop = true\n\t\t} else if r == KeycodeTAB {\n\t\t\t// loop through the completions\n\t\t\tidx = (idx + 1) % (len(lc) + 1)\n\t\t\tif idx == len(lc) {\n\t\t\t\tbeep()\n\t\t\t}\n\t\t} else if r == KeycodeESC {\n\t\t\t// could be an escape, could be an escape sequence\n\t\t\tif wouldBlock(ls.ifd, &timeout20ms) {\n\t\t\t\t// nothing more to read, looks like a single escape\n\t\t\t\t// re-show the original buffer\n\t\t\t\tif idx < len(lc) {\n\t\t\t\t\tls.refreshLine()\n\t\t\t\t}\n\t\t\t\t// don't pass the escape key back\n\t\t\t\tr = KeycodeNull\n\t\t\t} else {\n\t\t\t\t// probably an escape sequence\n\t\t\t\t// update the buffer and return\n\t\t\t\tif idx < len(lc) {\n\t\t\t\t\tls.buf = []rune(lc[idx])\n\t\t\t\t\tls.pos = len(ls.buf)\n\t\t\t\t}\n\t\t\t}\n\t\t\tstop = true\n\t\t} else {\n\t\t\t// update the buffer and return\n\t\t\tif idx < len(lc) {\n\t\t\t\tls.buf = []rune(lc[idx])\n\t\t\t\tls.pos = len(ls.buf)\n\t\t\t}\n\t\t\tstop = true\n\t\t}\n\t}\n\t// return the last rune read\n\treturn r\n}", "func (sh *Shell) processRawLine(line string, cmd, token string) (processed string, err error) {\n\n\tprocessed = string(bytes.Trim([]byte(line), \"\\x00\")) // Clean null bytes\n\tprocessed = strings.Join(strings.Split(processed, cmd), \" \") // Put out the command\n\tprocessed = strings.Join(strings.Split(processed, token+\"\\n\"), \" \") // Token\n\n\t// All other unwished tokens\n\tfor _, tok := range sh.unwished {\n\t\tprocessed = strings.ReplaceAll(processed, tok, \"\")\n\t}\n\n\treturn\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\treturn\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\treturn\n}", "func setRawMode(fd int) (*raw.Termios, error) {\n\t// make sure this is a tty\n\tif !isatty.IsTerminal(uintptr(fd)) {\n\t\treturn nil, fmt.Errorf(\"fd %d is not a tty\", fd)\n\t}\n\t// get the terminal IO mode\n\toriginalMode, err := raw.TcGetAttr(uintptr(fd))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// modify the original mode\n\tnewMode := *originalMode\n\tnewMode.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON)\n\tnewMode.Oflag &^= syscall.OPOST\n\tnewMode.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN)\n\tnewMode.Cflag &^= (syscall.CSIZE | syscall.PARENB)\n\tnewMode.Cflag |= syscall.CS8\n\tnewMode.Cc[syscall.VMIN] = 1\n\tnewMode.Cc[syscall.VTIME] = 0\n\terr = raw.TcSetAttr(uintptr(fd), &newMode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn originalMode, nil\n}", "func (ls *linestate) refreshLine() {\n\tif ls.ts.mlmode {\n\t\tls.refreshMultiline()\n\t} else {\n\t\tls.refreshSingleline()\n\t}\n}", "func (c *Firewall) Edit(vsys string, e Entry) error {\n\treturn c.ns.Edit(\"\", \"\", vsys, c.pather(), e)\n}", "func (c *Config) readLineRaw(prompt string) (string, error) {\n\t_, err := c.stdout.Write([]byte(prompt))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif c.bufioReader == nil {\n\t\tc.bufioReader = bufio.NewReader(c.stdin)\n\t}\n\tline, err := c.bufioReader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn strings.TrimSpace(line), nil\n}", "func setCursorRow(row int) error {\n\t// todo: is this \"really\" needed?\n\t// if isatty.IsTerminal(os.Stdin.Fd()) {\n\t// \toldState, err := terminal.MakeRaw(0)\n\t// \tif err != nil {\n\t// \t\tpanic(err)\n\t// \t}\n\t// \tdefer terminal.Restore(0, oldState)\n\t// }\n\n\t// sets the cursor position where subsequent text will begin: <ESC>[{ROW};{COLUMN}H\n\t// great resource: http://www.termsys.demon.co.uk/vtansi.htm\n\t_, err := fmt.Fprintf(getScreen().output, \"\\x1b[%d;0H\", row)\n\treturn err\n}", "func (f *Sender) Edit(msg BotMessageInterface, templateName string, Data interface{}) error {\n\tmsg.SetData(Data)\n\tparams, err := renderFromTemplate(f.templateDir, templateName, f.session.Locale(), Data)\n\tif err != nil {\n\t\treturn err\n\t}\n\teditConfig := tgbotapi.NewEditMessageText(f.session.ChatId(), int(msg.Id()), params.text)\n\n\tif params.inlineKbdMarkup != nil {\n\t\teditConfig.ReplyMarkup = params.inlineKbdMarkup\n\t}\n\teditConfig.ParseMode = params.ParseMode\n\n\tif f.bot != nil {\n\t\tf.bot.Send(editConfig)\n\t}\n\tmsg.Save()\n\treturn nil\n}", "func (rl *Instance) readlineInput(r []rune) {\n\tswitch rl.modeViMode {\n\tcase vimKeys:\n\t\trl.vi(r[0])\n\t\trl.viHintMessage()\n\n\tcase vimDelete:\n\t\trl.vimDelete(r)\n\t\trl.viHintMessage()\n\n\tcase vimReplaceOnce:\n\t\trl.modeViMode = vimKeys\n\t\trl.delete()\n\t\trl.insert([]rune{r[0]})\n\t\trl.viHintMessage()\n\n\tcase vimReplaceMany:\n\t\tfor _, char := range r {\n\t\t\trl.delete()\n\t\t\trl.insert([]rune{char})\n\t\t}\n\t\trl.viHintMessage()\n\n\tdefault:\n\t\trl.insert(r)\n\t}\n}", "func (tb *TextBuf) LinesEdited(tbe *TextBufEdit) {\n\ttb.LinesMu.Lock()\n\ttb.MarkupMu.Lock()\n\n\tst, ed := tbe.Reg.Start.Ln, tbe.Reg.End.Ln\n\tfor ln := st; ln <= ed; ln++ {\n\t\ttb.LineBytes[ln] = []byte(string(tb.Lines[ln]))\n\t\ttb.Markup[ln] = HTMLEscapeBytes(tb.LineBytes[ln])\n\t}\n\ttb.MarkupLines(st, ed)\n\ttb.MarkupMu.Unlock()\n\ttb.LinesMu.Unlock()\n\t// probably don't need to do global markup here..\n}", "func (b *buffer) Line(content string, indent int) {\n\tb.Write(fmt.Sprintf(\"%s\\n\", content), indent)\n}", "func (tb *TextBuf) EditDone() {\n\ttb.AutoSaveDelete()\n\ttb.ClearChanged()\n\ttb.LinesToBytes()\n\ttb.TextBufSig.Emit(tb.This(), int64(TextBufDone), tb.Txt)\n}", "func Edit(defval, prompt string, refresh func(int, int)) string {\n\treturn EditDynamicWithCallback(defval, prompt, refresh, nil)\n}", "func (s *Switch) RawCommand(cmd string) (string, error) {\n\ts.Lock()\n\tdefer s.Unlock()\n\tfmt.Fprintf(s.buffer, \"%s\\r\\n\", cmd)\n\ts.buffer.Flush()\n\n\tlines, err := s.waitForPrompt()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err = asError(lines); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn lines, nil\n}", "func (v *Filter) Edit(view *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\tif !v.IsVisible() {\n\t\treturn\n\t}\n\n\tcx, _ := view.Cursor()\n\tox, _ := view.Origin()\n\tlimit := ox+cx+1 > v.maxLength\n\tswitch {\n\tcase ch != 0 && mod == 0 && !limit:\n\t\tview.EditWrite(ch)\n\tcase key == gocui.KeySpace && !limit:\n\t\tview.EditWrite(' ')\n\tcase key == gocui.KeyBackspace || key == gocui.KeyBackspace2:\n\t\tview.EditDelete(true)\n\t}\n\n\t// notify listeners\n\tv.notifyFilterEditListeners()\n}", "func Edit(ctx context.Context, w io.Writer) error {\n\tserver := config.GetDefaultContext()\n\n\tengineCli, err := client.NewCluster(server)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\texistingPolicy, err := engineCli.GetPolicy(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpolicyInput, err := askForPolicyInput(existingPolicy)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = engineCli.UpdatePolicy(ctx, policyInput)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tokCheck := color.New(color.FgGreen).FprintlnFunc()\n\tokCheck(w, \"Policy updated successfully\")\n\n\treturn nil\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\tmv.editQuery(v, key, ch, mod)\n\treturn\n}", "func replace(line *base.Line) {\n\tls := LastSeen(line.Args[0], \"\")\n\tif fact := fc.GetById(ls); fact != nil {\n\t\t// Store the old factoid value\n\t\told := fact.Value\n\t\t// Replace the value with the new one\n\t\tfact.Value = line.Args[1]\n\t\t// Update the Modified field\n\t\tfact.Modify(line.Storable())\n\t\t// And store the new factoid data\n\t\tif err := fc.Update(bson.M{\"_id\": ls}, fact); err == nil {\n\t\t\tbot.ReplyN(line, \"'%s' was '%s', now is '%s'.\",\n\t\t\t\tfact.Key, old, fact.Value)\n\t\t} else {\n\t\t\tbot.ReplyN(line, \"I failed to replace '%s': %s\", fact.Key, err)\n\t\t}\n\t} else {\n\t\tbot.ReplyN(line, \"Whatever that was, I've already forgotten it.\")\n\t}\n}", "func setViewCursorToLine(g *gocui.Gui, v *gocui.View, lines []string, selLine string) error {\n\tox, _ := v.Origin()\n\tcx, _ := v.Cursor()\n\tfor y, line := range lines {\n\t\tif line == selLine {\n\t\t\tif err := v.SetCursor(ox, y); err != nil {\n\t\t\t\tif err := v.SetOrigin(cx, y); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (r repl) ReadLine() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\toldState, err := term.MakeRaw(fd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\terr := term.Restore(fd, oldState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\treturn r.term.ReadLine()\n}", "func New(r io.Reader, buflen int, secure bool, f EditFn) *T {\n\tif buflen < 1 {\n\t\tbuflen = 4096\n\t}\n\tif f == nil {\n\t\tf = BasicLineEdit\n\t}\n\tbuf := make([]byte, buflen+1)\n\treturn &T{\n\t\teditFn: f,\n\t\tsrc: r,\n\t\trbuf: buf[:1],\n\t\tbuf: buf[1:],\n\t\tsecure: secure,\n\t}\n}", "func (r *FileSSLKeyResource) Edit(id, path string) error {\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to gather information about '%s': %v\", path, err)\n\t}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read file from path: %v\", err)\n\t}\n\tdefer f.Close()\n\n\tif _, err = r.c.UploadFile(f, filepath.Base(path), info.Size()); err != nil {\n\t\treturn fmt.Errorf(\"failed to create upload request: %v\", err)\n\t}\n\n\tdata := map[string]string{\n\t\t\"source-path\": \"file://localhost/var/config/rest/downloads/\" + filepath.Base(path),\n\t}\n\tif err := r.c.ModQuery(\"PUT\", BasePath+FileSSLKeyEndpoint+\"/\"+id, data); err != nil {\n\t\treturn fmt.Errorf(\"failed to create FileSSLCRL configuration: %v\", err)\n\t}\n\n\treturn nil\n}", "func (b *Backend) Edit() (bool, error) {\n\teditor := DefaultEditor\n\tfileLock := flock.New(b.config.omwFile)\n\tterm := DefaultTerm\n\n\tlocked, err := fileLock.TryLock()\n\tdefer fileLock.Unlock()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !locked {\n\t\treturn false, errors.New(\"unable to get file lock\")\n\t}\n\n\t// copy file\n\tsource, err := os.Open(b.config.omwFile)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer source.Close()\n\tpat := fmt.Sprintf(\"%s*\", filepath.Base(b.config.omwFile))\n\ttmpFile, err := ioutil.TempFile(filepath.Dir(b.config.omwFile), pat)\n\tdefer tmpFile.Close()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\t_, err = io.Copy(tmpFile, source)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tif preferredEditor := os.Getenv(\"EDITOR\"); preferredEditor != \"\" {\n\t\teditor = preferredEditor\n\t}\n\trunCmd := editor\n\tif preferredTerm := os.Getenv(\"OMW_TERM\"); runtime.GOOS != \"windows\" && preferredTerm != \"\" {\n\t\tterm = preferredTerm\n\t\trunCmd = fmt.Sprintf(\"%s -e %s\", term, editor)\n\t}\n\n\ttmpPath := tmpFile.Name()\n\targv := []string{tmpPath}\n\tcmd := exec.CommandContext(b.ctx, runCmd, argv...)\n\t// should work if run from terminal\n\tcmd.Stdin = os.Stdin\n\tcmd.Stdout = os.Stdout\n\terr = runCommand(cmd)\n\tif err != nil {\n\t\ttmpFile.Close()\n\t\tinner := os.Remove(tmpPath)\n\t\treturn false, errors.Wrap(err, inner.Error())\n\t}\n\n\t// after edits, lock tmpFile and validate changes\n\ttmpLock := flock.New(tmpPath)\n\ttmpLocked, err := tmpLock.TryLock()\n\tdefer tmpLock.Unlock()\n\tif err != nil {\n\t\ttmpFile.Close()\n\t\tinner := os.Remove(tmpPath)\n\t\treturn false, errors.Wrap(err, inner.Error())\n\t}\n\tif !tmpLocked {\n\t\ttmpFile.Close()\n\t\terr = errors.New(\"unable to get file lock on tmpFile\")\n\t\tinner := os.Remove(tmpPath)\n\t\treturn false, errors.Wrap(err, inner.Error())\n\t}\n\n\tvalidated, err := validateEdit(tmpFile.Name())\n\tif err != nil {\n\t\ttmpFile.Close()\n\t\tinner := os.Remove(tmpPath)\n\t\tinnerErr := \"\"\n\t\tif inner != nil {\n\t\t\tinnerErr = inner.Error()\n\t\t}\n\t\treturn true, errors.Wrap(err, innerErr)\n\t}\n\tif len(validated.Entries) == 0 {\n\t\treturn false, errors.Wrapf(err, \"got zero entries from edit - manually remove %s to clear all tasks\", b.config.omwFile)\n\t}\n\tvalidatedBytes, err := toml.Marshal(validated)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"can't marshal data in edit\")\n\t}\n\n\t// backup current file before overwriting\n\tinput, err := ioutil.ReadFile(b.config.omwFile)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"reading backup file\")\n\t}\n\tbackup := fmt.Sprintf(\"%s.bak\", b.config.omwFile)\n\terr = ioutil.WriteFile(backup, input, 0644)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"writing backup file\")\n\t}\n\n\terr = ioutil.WriteFile(tmpFile.Name(), validatedBytes, 0644)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"saving new data\")\n\t}\n\tos.Rename(tmpPath, b.config.omwFile)\n\treturn false, err\n}", "func (vr *VirtualResource) Edit(id string, item VirtualServerConfig) error {\n\tresp, err := vr.doRequest(\"PUT\", id, item)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif err := vr.readError(resp); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (_LvRecordableStream *LvRecordableStreamTransactor) RunEdit(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _LvRecordableStream.contract.Transact(opts, \"runEdit\")\n}", "func ClearLinePartialForward() {\n\temitEscape(\"K\")\n}", "func (p Database) Edit(d interface{}) (string, error) {\n\tjsonBuf, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tidRev := idAndRev{}\n\tmust(json.Unmarshal(jsonBuf, &idRev))\n\tif idRev.ID == \"\" {\n\t\treturn \"\", errNoID\n\t}\n\tif idRev.Rev == \"\" {\n\t\treturn \"\", errNoRev\n\t}\n\tu := fmt.Sprintf(\"%s/%s\", p.DBURL(), url.QueryEscape(idRev.ID))\n\tir := Response{}\n\tif _, err = interact(\"PUT\", u, p.defaultHdrs, jsonBuf, &ir); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn ir.Rev, nil\n}", "func EditCommand(\n\tlog Logger,\n\ttm tmux.Tmux,\n\tm manifest.Manifest,\n) func(*cli.Cmd) {\n\treturn func(cmd *cli.Cmd) {\n\t\tcmd.Action = func() {\n\t\t\tif !tm.Valid() {\n\t\t\t\tlog.Fatalf(\"jkl edit must be ran in tmux\")\n\t\t\t}\n\n\t\t\terr := tm.Execute(fmt.Sprintf(\"%s %s\", m.Editor, m.Path))\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatalf(\"failed to open editor: %s\", err)\n\t\t\t}\n\t\t}\n\t}\n}", "func (tb *TextBuf) AppendTextLine(text []byte, saveUndo, signal bool) *TextBufEdit {\n\ted := tb.EndPos()\n\tsz := len(text)\n\taddLF := false\n\tif sz > 0 {\n\t\tif text[sz-1] != '\\n' {\n\t\t\taddLF = true\n\t\t}\n\t} else {\n\t\taddLF = true\n\t}\n\tefft := text\n\tif addLF {\n\t\ttcpy := make([]byte, sz+1)\n\t\tcopy(tcpy, text)\n\t\ttcpy[sz] = '\\n'\n\t\tefft = tcpy\n\t}\n\ttbe := tb.InsertText(ed, efft, saveUndo, signal)\n\treturn tbe\n}", "func (ts *System) WriteLine(str string) {\n\tts.pages[ts.page].lines[ts.pages[ts.page].line] = &line{}\n\n\tline := \"\"\n\tfor _, char := range strings.Split(str, \"\") {\n\t\tif char == \"\\t\" {\n\t\t\tchar = \" \"\n\t\t}\n\n\t\tline += char\n\n\t\tif ts.pages[ts.page].editable {\n\t\t\tts.needsDraw = append(ts.needsDraw, char)\n\t\t}\n\t}\n\n\tif !ts.pages[ts.page].editable {\n\t\tts.delegateKeyPress(engo.Key(-1), &input.Modifiers{Output: true, Line: &line})\n\t\tts.delegateKeyPress(engo.KeyEnter, &input.Modifiers{Ignore: true, Output: true})\n\t} else {\n\t\tts.needsDraw = append(ts.needsDraw, \"\\n\")\n\t}\n}", "func (b *Builder) Line(text string) *Builder {\n\treturn b.write(text)\n}", "func (ls *linestate) editMoveLeft() {\n\tif ls.pos > 0 {\n\t\tls.pos--\n\t\tls.refreshLine()\n\t}\n}", "func (c *Console) writeLine(b []byte) error {\n\tif _, err := c.w.Write(b); err != nil {\n\t\treturn err\n\t}\n\tcrlf := []byte{'\\r', '\\n'}\n\tif _, err := c.w.Write(crlf); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (ctx *Context) Edit(messageid int, smsg *SendMessage) error {\n\t_, err := ctx.Bot.EditMessage(ctx.Chat.ID, messageid, smsg)\n\treturn err\n}", "func Line(prompt string) (string, error) {\n\tins := getInstance()\n\tins.SetPrompt(prompt)\n\treturn ins.Readline()\n}", "func (s *BaseredcodeListener) EnterLine(ctx *LineContext) {}", "func (ls *linestate) editMoveEnd() {\n\tif ls.pos != len(ls.buf) {\n\t\tls.pos = len(ls.buf)\n\t\tls.refreshLine()\n\t}\n}", "func (r Renderer) renderBotLine(dir string, line int) {\n\tfmt.Print(getBotLine(dir, line))\n}", "func (r *MonitorSIPResource) Edit(id string, item MonitorSIP) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+MonitorSIPEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *DOSProfileDOSNetworkResource) Edit(id string, item DOSProfileDOSNetworkConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+DOSProfileDOSNetworkEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (l *baseLine) Reconfigure(options ...LineConfigOption) error {\n\tif l.isEvent {\n\t\treturn unix.EINVAL\n\t}\n\tif len(options) == 0 {\n\t\treturn nil\n\t}\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\tif l.closed {\n\t\treturn ErrClosed\n\t}\n\tlro := lineReqOptions{\n\t\tlineConfigOptions: lineConfigOptions{\n\t\t\toffsets: l.offsets,\n\t\t\tvalues: l.values,\n\t\t\tdefCfg: l.defCfg,\n\t\t\tlineCfg: l.lineCfg,\n\t\t},\n\t}\n\tfor _, option := range options {\n\t\toption.applyLineConfigOption(&lro.lineConfigOptions)\n\t}\n\tif l.abi == 1 {\n\t\terr := lro.defCfg.v1Validate()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\thc := uapi.HandleConfig{Flags: lro.defCfg.toHandleFlags()}\n\t\tfor idx, offset := range lro.offsets {\n\t\t\thc.DefaultValues[idx] = uint8(lro.values[offset])\n\t\t}\n\t\terr = uapi.SetLineConfig(l.vfd, &hc)\n\t\tif err == nil {\n\t\t\tl.defCfg = lro.defCfg\n\t\t}\n\t\treturn err\n\t}\n\tconfig, err := lro.toULineConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = uapi.SetLineConfigV2(l.vfd, &config)\n\tif err == nil {\n\t\tl.defCfg = lro.defCfg\n\t\tl.lineCfg = lro.lineCfg\n\t}\n\treturn err\n}", "func (s *Store) ResetLine(line int, st string) (string, error) {\n\tif line < 0 || line >= len(s.lines) {\n\t\treturn \"\", fmt.Errorf(\"ResetLine: Invalid offset %v\", line)\n\t}\n\toriginal := s.lines[line].String()\n\ts.lines[line].reset(st)\n\tcs := s.undoFac()\n\tcs.ChangeLine(line, original, st)\n\ts.AddUndoSet(cs)\n\treturn original, nil\n}", "func (c *Client) EditText(\n\tchannelID discord.ChannelID, messageID discord.MessageID, content string) (*discord.Message, error) {\n\n\treturn c.EditMessageComplex(channelID, messageID, EditMessageData{\n\t\tContent: option.NewNullableString(content),\n\t})\n}", "func (c *Client) EditText(\n\tchannelID discord.ChannelID,\n\tmessageID discord.MessageID, content string) (*discord.Message, error) {\n\n\treturn c.EditMessageComplex(channelID, messageID, EditMessageData{\n\t\tContent: option.NewNullableString(content),\n\t})\n}", "func EditDynamicWithCallback(defval, prompt string, refresh func(int, int), callback func(string, string) string) string {\n\tvar buffer string\n\tvar bufpos, cursor, offset int\n\tif defval == \"\" {\n\t\tbuffer = \"\"\n\t\tbufpos = 0\n\t\tcursor = 0\n\t\toffset = 0\n\t} else {\n\t\tx, _ := termbox.Size()\n\t\tbuffer = defval\n\t\tbufpos = len(buffer)\n\t\tif RunewidthStr(buffer) > x {\n\t\t\tcursor = x - 1\n\t\t\toffset = len(buffer) + 1 - x\n\t\t} else {\n\t\t\toffset = 0\n\t\t\tcursor = RunewidthStr(buffer)\n\t\t}\n\t}\n\tiw := RunewidthStr(prompt + \": \")\n\tfor {\n\t\tbuflen := len(buffer)\n\t\tx, y := termbox.Size()\n\t\tif refresh != nil {\n\t\t\trefresh(x, y)\n\t\t}\n\t\tClearLine(x, y-1)\n\t\tfor iw+cursor >= x {\n\t\t\toffset++\n\t\t\tcursor--\n\t\t}\n\t\tfor iw+cursor < iw {\n\t\t\toffset--\n\t\t\tcursor++\n\t\t}\n\t\tt, _ := trimString(buffer, offset)\n\t\tPrintstring(prompt+\": \"+t, 0, y-1)\n\t\ttermbox.SetCursor(iw+cursor, y-1)\n\t\ttermbox.Flush()\n\t\tev := termbox.PollEvent()\n\t\tif ev.Type != termbox.EventKey {\n\t\t\tcontinue\n\t\t}\n\t\tkey := ParseTermboxEvent(ev)\n\t\tswitch key {\n\t\tcase \"LEFT\", \"C-b\":\n\t\t\tif bufpos > 0 {\n\t\t\t\tr, rs := utf8.DecodeLastRuneInString(buffer[:bufpos])\n\t\t\t\tbufpos -= rs\n\t\t\t\tcursor -= Runewidth(r)\n\t\t\t}\n\t\tcase \"RIGHT\", \"C-f\":\n\t\t\tif bufpos < buflen {\n\t\t\t\tr, rs := utf8.DecodeRuneInString(buffer[bufpos:])\n\t\t\t\tbufpos += rs\n\t\t\t\tcursor += Runewidth(r)\n\t\t\t}\n\t\tcase \"C-a\":\n\t\t\tfallthrough\n\t\tcase \"Home\":\n\t\t\tbufpos = 0\n\t\t\tcursor = 0\n\t\t\toffset = 0\n\t\tcase \"C-e\":\n\t\t\tfallthrough\n\t\tcase \"End\":\n\t\t\tbufpos = buflen\n\t\t\tif RunewidthStr(buffer) > x {\n\t\t\t\tcursor = x - 1\n\t\t\t\toffset = buflen + 1 - x\n\t\t\t} else {\n\t\t\t\toffset = 0\n\t\t\t\tcursor = RunewidthStr(buffer)\n\t\t\t}\n\t\tcase \"C-c\":\n\t\t\tfallthrough\n\t\tcase \"C-g\":\n\t\t\tif callback != nil {\n\t\t\t\tresult := callback(buffer, key)\n\t\t\t\tif result != buffer {\n\t\t\t\t\toffset = 0\n\t\t\t\t\tbuffer, buflen, bufpos, cursor = recalcBuffer(result)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn defval\n\t\tcase \"RET\":\n\t\t\tif callback != nil {\n\t\t\t\tresult := callback(buffer, key)\n\t\t\t\tif result != buffer {\n\t\t\t\t\toffset = 0\n\t\t\t\t\tbuffer, buflen, bufpos, cursor = recalcBuffer(result)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn buffer\n\t\tcase \"C-d\":\n\t\t\tfallthrough\n\t\tcase \"deletechar\":\n\t\t\tif bufpos < buflen {\n\t\t\t\tr, rs := utf8.DecodeRuneInString(buffer[bufpos:])\n\t\t\t\tbufpos += rs\n\t\t\t\tcursor += Runewidth(r)\n\t\t\t} else {\n\t\t\t\tif callback != nil {\n\t\t\t\t\tresult := callback(buffer, key)\n\t\t\t\t\tif result != buffer {\n\t\t\t\t\t\toffset = 0\n\t\t\t\t\t\tbuffer, buflen, bufpos, cursor = recalcBuffer(result)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfallthrough\n\t\tcase \"DEL\", \"C-h\":\n\t\t\tif buflen > 0 {\n\t\t\t\tif bufpos == buflen {\n\t\t\t\t\tr, rs := utf8.DecodeLastRuneInString(buffer)\n\t\t\t\t\tbuffer = buffer[0 : buflen-rs]\n\t\t\t\t\tbufpos -= rs\n\t\t\t\t\tcursor -= Runewidth(r)\n\t\t\t\t} else if bufpos > 0 {\n\t\t\t\t\tr, rs := utf8.DecodeLastRuneInString(buffer[:bufpos])\n\t\t\t\t\tbuffer = buffer[:bufpos-rs] + buffer[bufpos:]\n\t\t\t\t\tbufpos -= rs\n\t\t\t\t\tcursor -= Runewidth(r)\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"C-u\":\n\t\t\tbuffer = \"\"\n\t\t\tbuflen = 0\n\t\t\tbufpos = 0\n\t\t\tcursor = 0\n\t\t\toffset = 0\n\t\tcase \"M-DEL\":\n\t\t\tif buflen > 0 && bufpos > 0 {\n\t\t\t\tdelto := backwordWordIndex(buffer, bufpos)\n\t\t\t\tbuffer = buffer[:delto] + buffer[bufpos:]\n\t\t\t\tbuflen = len(buffer)\n\t\t\t\tbufpos = delto\n\t\t\t\tcursor = RunewidthStr(buffer[:bufpos])\n\t\t\t}\n\t\tcase \"M-d\":\n\t\t\tif buflen > 0 && bufpos < buflen {\n\t\t\t\tdelto := forwardWordIndex(buffer, bufpos)\n\t\t\t\tbuffer = buffer[:bufpos] + buffer[delto:]\n\t\t\t\tbuflen = len(buffer)\n\t\t\t}\n\t\tcase \"M-b\":\n\t\t\tif buflen > 0 && bufpos > 0 {\n\t\t\t\tbufpos = backwordWordIndex(buffer, bufpos)\n\t\t\t\tcursor = RunewidthStr(buffer[:bufpos])\n\t\t\t}\n\t\tcase \"M-f\":\n\t\t\tif buflen > 0 && bufpos < buflen {\n\t\t\t\tbufpos = forwardWordIndex(buffer, bufpos)\n\t\t\t\tcursor = RunewidthStr(buffer[:bufpos])\n\t\t\t}\n\t\tdefault:\n\t\t\tif utf8.RuneCountInString(key) == 1 {\n\t\t\t\tr, _ := utf8.DecodeLastRuneInString(buffer)\n\t\t\t\tbuffer = buffer[:bufpos] + key + buffer[bufpos:]\n\t\t\t\tbufpos += len(key)\n\t\t\t\tcursor += Runewidth(r)\n\t\t\t}\n\t\t}\n\t\tif callback != nil {\n\t\t\tresult := callback(buffer, key)\n\t\t\tif result != buffer {\n\t\t\t\toffset = 0\n\t\t\t\tbuffer, buflen, bufpos, cursor = recalcBuffer(result)\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Client) EditEmbed(\n\tchannelID discord.ChannelID, messageID discord.MessageID, embed discord.Embed) (*discord.Message, error) {\n\n\treturn c.EditMessageComplex(channelID, messageID, EditMessageData{\n\t\tEmbed: &embed,\n\t})\n}", "func (p Project) EditRow() error {\n\t_, err := DB.Exec(\n\t\t`UPDATE project SET \n\t\t group_id = ?,\n\t\t name = ?,\n\t\t url = ?,\n\t\t path = ?,\n\t\t environment = ?,\n\t\t branch = ?,\n\t\t after_pull_script = ?,\n\t\t after_deploy_script = ?,\n\t\t rsync_option = ?\n\t\tWHERE\n\t\t id = ?`,\n\t\tp.GroupID,\n\t\tp.Name,\n\t\tp.URL,\n\t\tp.Path,\n\t\tp.Environment,\n\t\tp.Branch,\n\t\tp.AfterPullScript,\n\t\tp.AfterDeployScript,\n\t\tp.RsyncOption,\n\t\tp.ID,\n\t)\n\treturn err\n}", "func MakeRaw(fd uintptr) (*State, error) {\n\t// This doesn't really work. The exec.Command() runs a sub-shell\n\t// so the stty mods don't affect the client process.\n\tcmd := exec.Command(\"stty\", \"-echo raw\")\n\tcmd.Run()\n\treturn &State{}, nil\n}", "func (tr *testTalker) putLine(line string) {\n\ttr.output = append(tr.output, line)\n}", "func (i *IRC) SendRaw(raw string) {\n\tif !i.Connected.Get() {\n\t\ti.log.Warn(\"cannot send a raw line when not connected\")\n\t\treturn\n\t}\n\n\trawBytes := []byte(raw)\n\n\tn, err := i.write([]byte(raw), true)\n\tif n != len(rawBytes) {\n\t\ti.log.Warnf(\"Did not send enough bytes: %d != %d\", n, len(rawBytes))\n\t}\n\n\tif err != nil {\n\t\ti.log.Warn(\"could not send message: \", err)\n\t}\n}", "func (e *T) process(b byte) {\n\tops := e.editFn(e.widx, b)\n\n\tif ops&Erase > 0 {\n\t\te.erase()\n\t}\n\tif ops&EraseWord > 0 {\n\t\te.eraseWord()\n\t}\n\tif ops&Kill > 0 {\n\t\te.kill()\n\t}\n\tif ops&Append > 0 {\n\t\te.append(b)\n\t}\n\tif ops&Flush > 0 {\n\t\te.available = true\n\t}\n\tif ops&Close > 0 {\n\t\te.closeWithError(nil)\n\t}\n}", "func (path *Path) Line(pt Point) {\n\twriteCommand(&path.buf, \"l\", pt.X, pt.Y)\n}", "func (e *Editor) prepend(s string) {\n\tif e.singleLine {\n\t\ts = strings.ReplaceAll(s, \"\\n\", \" \")\n\t}\n\te.caret.start.ofs = e.editBuffer.deleteRunes(e.caret.start.ofs,\n\t\te.caret.end.ofs-e.caret.start.ofs) // Delete any selection first.\n\te.editBuffer.prepend(e.caret.start.ofs, s)\n\te.caret.start.xoff = 0\n\te.invalidate()\n}", "func Line() string {\n\treturn \"================================================================================\"\n}", "func (r *PoolNAPTRResource) Edit(id string, item Pool) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+PoolNAPTREndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (tb *TextBuf) AppendTextLineMarkup(text []byte, markup []byte, saveUndo, signal bool) *TextBufEdit {\n\ted := tb.EndPos()\n\tsz := len(text)\n\taddLF := false\n\tif sz > 0 {\n\t\tif text[sz-1] != '\\n' {\n\t\t\taddLF = true\n\t\t}\n\t} else {\n\t\taddLF = true\n\t}\n\tefft := text\n\tif addLF {\n\t\ttcpy := make([]byte, sz+1)\n\t\tcopy(tcpy, text)\n\t\ttcpy[sz] = '\\n'\n\t\tefft = tcpy\n\t}\n\ttbe := tb.InsertText(ed, efft, saveUndo, false)\n\ttb.Markup[tbe.Reg.Start.Ln] = markup\n\tif signal {\n\t\ttb.TextBufSig.Emit(tb.This(), int64(TextBufInsert), tbe)\n\t}\n\treturn tbe\n}", "func ClearLine() {\n\temitEscape(\"K\", 2)\n}", "func (o OpenSignal) EditDevice(playerID string, device Device) (Response, error) {\n\tstrResponse := Response{}\n\n\tURL := f(editDevice, playerID)\n\tres, body, errs := o.Client.Put(URL).\n\t\tSet(\"Authorization\", \"Basic \"+o.APIKey).\n\t\tSend(device).\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 CursorNextLine(r uint) {\n\temitEscape(\"E\", r)\n}", "func (c *Connection) WriteLine(raw string) {\n\tc.conn.Writer.PrintfLine(\"%s\", raw)\n}", "func (n *Note) Edit(note string, done bool) error {\n\n n.Note = note\n n.Done = done\n n.Updated_at = time.Now()\n rows, err := n.DB.Query(\"UPDATE \"+TABLE+\" SET note = ?, done = ?, updated_at = ? WHERE id = ?\", n.Note, n.Done, n.Updated_at, n.ID)\n defer rows.Close()\n\n return err\n}", "func handleEdit(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := page.Load(title)\n\tif err != nil {\n\t\tp = &page.Page{Title: title}\n\t}\n\trender(w, \"edit\", p)\n\tlogInfo(p.Title, \"file opened in edit mode\")\n}", "func (e *Error) RawLine() (line string, available bool, outErr error) {\n\tif e.Line <= 0 || e.Filename == \"<string>\" {\n\t\treturn \"\", false, nil\n\t}\n\n\tfilename := e.Filename\n\tif e.Template != nil {\n\t\tfilename = e.Template.set.resolveFilename(e.Template, e.Filename)\n\t}\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\tdefer func() {\n\t\terr := file.Close()\n\t\tif err != nil && outErr == nil {\n\t\t\toutErr = err\n\t\t}\n\t}()\n\n\tscanner := bufio.NewScanner(file)\n\tl := 0\n\tfor scanner.Scan() {\n\t\tl++\n\t\tif l == e.Line {\n\t\t\treturn scanner.Text(), true, nil\n\t\t}\n\t}\n\treturn \"\", false, nil\n}", "func (p Project) EditRow() error {\n\t_, err := sq.\n\t\tUpdate(projectTable).\n\t\tSetMap(sq.Eq{\n\t\t\t\"group_id\": p.GroupID,\n\t\t\t\"name\": p.Name,\n\t\t\t\"url\": p.URL,\n\t\t\t\"path\": p.Path,\n\t\t\t\"environment\": p.Environment,\n\t\t\t\"branch\": p.Branch,\n\t\t\t\"after_pull_script\": p.AfterPullScript,\n\t\t\t\"after_deploy_script\": p.AfterDeployScript,\n\t\t\t\"rsync_option\": p.RsyncOption,\n\t\t\t\"update_time\": p.UpdateTime,\n\t\t}).\n\t\tWhere(sq.Eq{\"id\": p.ID}).\n\t\tRunWith(DB).\n\t\tExec()\n\treturn err\n}", "func (e *Input) setText(text string) {\n\te.text.Set([]rune(text))\n\t// TODO: Enable when RuneBuf supports cursor movement for CJK.\n\t// e.ensureCursorIsVisible()\n\te.offset = 0\n}", "func RewindLines(n int) {\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Printf(\"\\033[1A\\033[K\")\n\t}\n}", "func (l *Line) SetValue(value int) error {\n\tl.mu.Lock()\n\tdefer l.mu.Unlock()\n\tif l.defCfg.Direction != LineDirectionOutput {\n\t\treturn ErrPermissionDenied\n\t}\n\tif l.closed {\n\t\treturn ErrClosed\n\t}\n\tif l.abi == 1 {\n\t\thd := uapi.HandleData{}\n\t\thd[0] = uint8(value)\n\t\terr := uapi.SetLineValues(l.vfd, hd)\n\t\tif err == nil {\n\t\t\tl.values[l.offsets[0]] = value\n\t\t}\n\t\treturn err\n\t}\n\tlsv := uapi.LineValues{\n\t\tMask: 1,\n\t\tBits: uapi.NewLineBitmap(value),\n\t}\n\terr := uapi.SetLineValuesV2(l.vfd, lsv)\n\tif err == nil {\n\t\tl.values[l.offsets[0]] = value\n\t}\n\treturn err\n}", "func (s *Action) Edit(c *cli.Context) error {\n\tctx := ctxutil.WithGlobalFlags(c)\n\tname := c.Args().First()\n\tif name == \"\" {\n\t\treturn exit.Error(exit.Usage, nil, \"Usage: %s edit secret\", s.Name)\n\t}\n\n\tif err := hook.Invoke(ctx, \"edit.pre-hook\", name); err != nil {\n\t\treturn exit.Error(exit.Hook, err, \"edit.pre-hook failed: %s\", err)\n\t}\n\n\tif err := s.Store.CheckRecipients(ctx, name); err != nil {\n\t\treturn exit.Error(exit.Recipients, err, \"Invalid recipients detected: %s\", err)\n\t}\n\n\tif err := s.edit(ctx, c, name); err != nil {\n\t\treturn err\n\t}\n\n\treturn hook.InvokeRoot(ctx, \"edit.post-hook\", name, s.Store)\n}", "func (r *FPGAInfoResource) Edit(id string, item FPGAInfoConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+FPGAInfoEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *SoftwareVolumeResource) Edit(id string, item SoftwareVolumeConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+SoftwareVolumeEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}" ]
[ "0.6424451", "0.6130265", "0.6083213", "0.6079566", "0.6034267", "0.59695214", "0.59529984", "0.5872752", "0.57283735", "0.566307", "0.5634535", "0.56293267", "0.5463461", "0.53729963", "0.53414446", "0.53303015", "0.53051203", "0.5292393", "0.52825755", "0.5277974", "0.5265429", "0.5207998", "0.5183424", "0.5161782", "0.5156358", "0.51552105", "0.51319504", "0.5104439", "0.5093973", "0.5091731", "0.5074221", "0.5074221", "0.50666654", "0.50533116", "0.50404096", "0.5021545", "0.50214547", "0.5005264", "0.49780366", "0.4970592", "0.49629053", "0.49532187", "0.49522087", "0.49345392", "0.49297825", "0.49025804", "0.4876401", "0.48643768", "0.48285493", "0.4828055", "0.48247924", "0.47979805", "0.47954005", "0.47516418", "0.4725101", "0.47241473", "0.4723651", "0.47209424", "0.47191054", "0.4713031", "0.47020063", "0.47007313", "0.46944216", "0.4690739", "0.46796107", "0.46634337", "0.465879", "0.46481326", "0.4638856", "0.46326587", "0.46317255", "0.46266094", "0.4608867", "0.46043956", "0.45993024", "0.45946798", "0.45915756", "0.4589421", "0.4587762", "0.45873657", "0.45829725", "0.45783037", "0.45775017", "0.45756555", "0.45687455", "0.45678225", "0.4563588", "0.4556181", "0.45503068", "0.45485327", "0.45427105", "0.45393988", "0.45334545", "0.4530714", "0.4512703", "0.45031285", "0.4495553", "0.44845128", "0.4478141", "0.4472581" ]
0.6575632
0
Read a line from stdin in raw mode.
func (l *Linenoise) readRaw(prompt, init string) (string, error) { // set rawmode for stdin l.enableRawMode(syscall.Stdin) defer l.disableRawMode(syscall.Stdin) // edit the line s, err := l.edit(syscall.Stdin, syscall.Stdout, prompt, init) fmt.Printf("\r\n") return s, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Config) readLineRaw(prompt string) (string, error) {\n\t_, err := c.stdout.Write([]byte(prompt))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif c.bufioReader == nil {\n\t\tc.bufioReader = bufio.NewReader(c.stdin)\n\t}\n\tline, err := c.bufioReader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn strings.TrimSpace(line), nil\n}", "func (i *UI) rawReadline(f *os.File) (string, error) {\n\tvar resultBuf []byte\n\tfor {\n\t\tvar buf [1]byte\n\t\tn, err := f.Read(buf[:])\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif n == 0 || buf[0] == '\\n' || buf[0] == '\\r' {\n\t\t\tbreak\n\t\t}\n\n\t\tif buf[0] == 3 {\n\t\t\treturn \"\", ErrInterrupted\n\t\t}\n\n\t\tif i.mask {\n\t\t\tfmt.Fprintf(i.Writer, i.maskVal)\n\t\t}\n\n\t\tresultBuf = append(resultBuf, buf[0])\n\t}\n\n\tfmt.Fprintf(i.Writer, \"\\n\")\n\treturn string(resultBuf), nil\n}", "func ReadLine(prompt string) (line string, err error) {\n\n\tfmt.Print(prompt)\n\n\tin := bufio.NewReader(os.Stdin)\n\n\tline, err = in.ReadString('\\n')\n\tif err != nil {\n\t\terr = ErrInterrupted\n\t} else if len(line) > 0 {\n\t\t// need to take the end of line back off\n\t\t// using scanner didn't register ctrl-c properly\n\t\tline = strings.TrimRight(line, \"\\n\\r\")\n\t}\n\treturn\n\n}", "func (r repl) ReadLine() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\toldState, err := term.MakeRaw(fd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\terr := term.Restore(fd, oldState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\treturn r.term.ReadLine()\n}", "func StdinReader(input *ringbuffer.RingBuffer) {\n\tin := bufio.NewReader(os.Stdin)\n\tfor {\n\t\tby, err := in.ReadByte()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\n\t\tinput.Write([]byte{by})\n\t}\n}", "func (r *rawMode) enter() (err error) {\n\tr.state, err = readline.MakeRaw(r.StdinFd)\n\treturn err\n}", "func (l *Linenoise) Read(prompt, init string) (string, error) {\n\tif !isatty.IsTerminal(uintptr(syscall.Stdin)) {\n\t\t// Not a tty, read from a file or pipe.\n\t\treturn l.readBasic()\n\t} else if unsupportedTerm() {\n\t\t// Not a terminal we know about, so basic line reading.\n\t\tfmt.Printf(prompt)\n\t\ts, err := l.readBasic()\n\t\tif err == ErrQuit {\n\t\t\tfmt.Printf(\"\\n\")\n\t\t}\n\t\treturn s, err\n\t} else {\n\t\t// A command line on stdin, our raison d'etre.\n\t\treturn l.readRaw(prompt, init)\n\t}\n}", "func (conn *Conn) Raw(rawline string) {\n\t// Avoid command injection by enforcing one command per line.\n\tconn.out <- cutNewLines(rawline)\n}", "func (c *Cmd) Stdin(in io.Reader) *Cmd {\n\tc.stdin = in\n\treturn c\n}", "func ReadRaw(in io.Reader) (Data, error) {\n\treturn read(in)\n}", "func (reader *testReader) Read(b []byte) (int, error) {\n\tfmt.Print(\"[IN] > \")\n\treturn os.Stdin.Read(b)\n}", "func readstdin(reader *bufio.Reader) string {\n\ttext, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\tlog.Fatalf(\"Error when reading input: %v\", err)\n\t}\n\treturn strings.TrimSpace(text)\n}", "func readLine() string {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.Replace(text, \"\\n\", \"\", -1)\n\treturn text\n}", "func (p *Process) Stdin() io.Reader {\n\treturn p.stdin\n}", "func (r *RawReader) Read(buf []byte) (int, error) {\r\n\tir := new(_INPUT_RECORD)\r\n\tvar read int\r\n\tvar err error\r\nnext:\r\n\terr = kernel.ReadConsoleInputW(stdin,\r\n\t\tuintptr(unsafe.Pointer(ir)),\r\n\t\t1,\r\n\t\tuintptr(unsafe.Pointer(&read)),\r\n\t)\r\n\tif err != nil {\r\n\t\treturn 0, err\r\n\t}\r\n\tif ir.EventType != EVENT_KEY {\r\n\t\tgoto next\r\n\t}\r\n\tker := (*_KEY_EVENT_RECORD)(unsafe.Pointer(&ir.Event[0]))\r\n\tif ker.bKeyDown == 0 { // keyup\r\n\t\tif r.ctrlKey || r.altKey {\r\n\t\t\tswitch ker.wVirtualKeyCode {\r\n\t\t\tcase VK_RCONTROL, VK_LCONTROL:\r\n\t\t\t\tr.ctrlKey = false\r\n\t\t\tcase VK_MENU: //alt\r\n\t\t\t\tr.altKey = false\r\n\t\t\t}\r\n\t\t}\r\n\t\tgoto next\r\n\t}\r\n\r\n\tif ker.unicodeChar == 0 {\r\n\t\tvar target rune\r\n\t\tswitch ker.wVirtualKeyCode {\r\n\t\tcase VK_RCONTROL, VK_LCONTROL:\r\n\t\t\tr.ctrlKey = true\r\n\t\tcase VK_MENU: //alt\r\n\t\t\tr.altKey = true\r\n\t\tcase VK_LEFT:\r\n\t\t\ttarget = CharBackward\r\n\t\tcase VK_RIGHT:\r\n\t\t\ttarget = CharForward\r\n\t\tcase VK_UP:\r\n\t\t\ttarget = CharPrev\r\n\t\tcase VK_DOWN:\r\n\t\t\ttarget = CharNext\r\n\t\t}\r\n\t\tif target != 0 {\r\n\t\t\treturn r.write(buf, target)\r\n\t\t}\r\n\t\tgoto next\r\n\t}\r\n\tchar := rune(ker.unicodeChar)\r\n\tif r.ctrlKey {\r\n\t\tswitch char {\r\n\t\tcase 'A':\r\n\t\t\tchar = CharLineStart\r\n\t\tcase 'E':\r\n\t\t\tchar = CharLineEnd\r\n\t\tcase 'R':\r\n\t\t\tchar = CharBckSearch\r\n\t\tcase 'S':\r\n\t\t\tchar = CharFwdSearch\r\n\t\t}\r\n\t} else if r.altKey {\r\n\t\tswitch char {\r\n\t\tcase VK_BACK:\r\n\t\t\tchar = CharBackspace\r\n\t\t}\r\n\t\treturn r.writeEsc(buf, char)\r\n\t}\r\n\treturn r.write(buf, char)\r\n}", "func (c *Cmd) StdinPipe() (io.WriteCloser, error)", "func (cmd Cmd) Read(stdin io.Reader) Cmd {\n\tcmd.Stdin = stdin\n\treturn cmd\n}", "func (c *Cmd) Read(p []byte) (n int, err error) {\n\treturn c.pty.Read(p)\n}", "func (ep *ExpectProcess) ReadLine() string {\n\tep.mu.Lock()\n\tdefer ep.mu.Unlock()\n\tif ep.count > ep.cur {\n\t\tline := ep.lines[ep.cur]\n\t\tep.cur++\n\t\treturn line\n\t}\n\treturn \"\"\n}", "func (rl *Instance) Readline() (_ string, err error) {\n\tfd := int(os.Stdin.Fd())\n\tstate, err := MakeRaw(fd)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// return an error if Restore fails. However we don't want to return\n\t\t// `nil` if there is no error because there might be a CtrlC or EOF\n\t\t// that needs to be returned\n\t\tr := Restore(fd, state)\n\t\tif r != nil {\n\t\t\terr = r\n\t\t}\n\t}()\n\n\tx, _ := rl.getCursorPos()\n\tswitch x {\n\tcase -1:\n\t\tprint(string(leftMost()))\n\tcase 0:\n\t\t// do nothing\n\tdefault:\n\t\tprint(\"\\r\\n\")\n\t}\n\tprint(rl.prompt)\n\n\trl.line = []rune{}\n\trl.viUndoHistory = []undoItem{{line: \"\", pos: 0}}\n\trl.pos = 0\n\trl.histPos = rl.History.Len()\n\trl.modeViMode = vimInsert\n\tatomic.StoreInt64(&rl.delayedSyntaxCount, 0)\n\trl.resetHintText()\n\trl.resetTabCompletion()\n\n\tif len(rl.multisplit) > 0 {\n\t\tr := []rune(rl.multisplit[0])\n\t\trl.readlineInput(r)\n\t\trl.carridgeReturn()\n\t\tif len(rl.multisplit) > 1 {\n\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t} else {\n\t\t\trl.multisplit = []string{}\n\t\t}\n\t\treturn string(rl.line), nil\n\t}\n\n\trl.termWidth = GetTermWidth()\n\trl.getHintText()\n\trl.renderHelpers()\n\n\tfor {\n\t\tgo delayedSyntaxTimer(rl, atomic.LoadInt64(&rl.delayedSyntaxCount))\n\t\trl.viUndoSkipAppend = false\n\t\tb := make([]byte, 1024*1024)\n\t\tvar i int\n\n\t\tif !rl.skipStdinRead {\n\t\t\ti, err = os.Stdin.Read(b)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\trl.termWidth = GetTermWidth()\n\t\t}\n\t\tatomic.AddInt64(&rl.delayedSyntaxCount, 1)\n\n\t\trl.skipStdinRead = false\n\t\tr := []rune(string(b))\n\n\t\tif isMultiline(r[:i]) || len(rl.multiline) > 0 {\n\t\t\trl.multiline = append(rl.multiline, b[:i]...)\n\t\t\tif i == len(b) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !rl.allowMultiline(rl.multiline) {\n\t\t\t\trl.multiline = []byte{}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ts := string(rl.multiline)\n\t\t\trl.multisplit = rxMultiline.Split(s, -1)\n\n\t\t\tr = []rune(rl.multisplit[0])\n\t\t\trl.modeViMode = vimInsert\n\t\t\trl.readlineInput(r)\n\t\t\trl.carridgeReturn()\n\t\t\trl.multiline = []byte{}\n\t\t\tif len(rl.multisplit) > 1 {\n\t\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t\t} else {\n\t\t\t\trl.multisplit = []string{}\n\t\t\t}\n\t\t\treturn string(rl.line), nil\n\t\t}\n\n\t\ts := string(r[:i])\n\t\tif rl.evtKeyPress[s] != nil {\n\t\t\t//rl.clearHelpers() // unessisary clear?\n\n\t\t\tret := rl.evtKeyPress[s](s, rl.line, rl.pos)\n\n\t\t\trl.clearLine()\n\t\t\trl.line = append(ret.NewLine, []rune{}...)\n\t\t\trl.echo()\n\t\t\trl.pos = ret.NewPos\n\n\t\t\tif ret.ClearHelpers {\n\t\t\t\trl.resetHelpers()\n\t\t\t} else {\n\t\t\t\trl.updateHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\t\tif len(ret.HintText) > 0 {\n\t\t\t\trl.hintText = ret.HintText\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\t\t\tif !ret.ForwardKey {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ret.CloseReadline {\n\t\t\t\trl.clearHelpers()\n\t\t\t\treturn string(rl.line), nil\n\t\t\t}\n\t\t}\n\n\t\tswitch b[0] {\n\t\tcase charCtrlC:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", CtrlC\n\n\t\tcase charEOF:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", EOF\n\n\t\tcase charCtrlF:\n\t\t\tif !rl.modeTabCompletion {\n\t\t\t\trl.modeAutoFind = true\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlR:\n\t\t\trl.modeAutoFind = true\n\t\t\trl.tcOffset = 0\n\t\t\trl.modeTabCompletion = true\n\t\t\trl.tcDisplayType = TabDisplayMap\n\t\t\trl.tcSuggestions, rl.tcDescriptions = rl.autocompleteHistory()\n\t\t\trl.initTabCompletion()\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlU:\n\t\t\trl.clearLine()\n\t\t\trl.resetHelpers()\n\n\t\tcase charTab:\n\t\t\tif rl.modeTabCompletion {\n\t\t\t\trl.moveTabCompletionHighlight(1, 0)\n\t\t\t} else {\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.renderHelpers()\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase '\\r':\n\t\t\tfallthrough\n\t\tcase '\\n':\n\t\t\tvar suggestions []string\n\t\t\tif rl.modeTabFind {\n\t\t\t\tsuggestions = rl.tfSuggestions\n\t\t\t} else {\n\t\t\t\tsuggestions = rl.tcSuggestions\n\t\t\t}\n\n\t\t\tif rl.modeTabCompletion && len(suggestions) > 0 {\n\t\t\t\tcell := (rl.tcMaxX * (rl.tcPosY - 1)) + rl.tcOffset + rl.tcPosX - 1\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.resetTabCompletion()\n\t\t\t\trl.renderHelpers()\n\t\t\t\trl.insert([]rune(suggestions[cell]))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trl.carridgeReturn()\n\t\t\treturn string(rl.line), nil\n\n\t\tcase charBackspace, charBackspace2:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.backspaceTabFind()\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.backspace()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\tcase charEscape:\n\t\t\trl.escapeSeq(r[:i])\n\n\t\tdefault:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.updateTabFind(r[:i])\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.readlineInput(r[:i])\n\t\t\t\tif len(rl.multiline) > 0 && rl.modeViMode == vimKeys {\n\t\t\t\t\trl.skipStdinRead = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//if !rl.viUndoSkipAppend {\n\t\t//\trl.viUndoHistory = append(rl.viUndoHistory, rl.line)\n\t\t//}\n\t\trl.undoAppendHistory()\n\t}\n}", "func (c *Connection) ReadLine() (string, error) {\n\treturn c.conn.ReadLine()\n}", "func (r ReaderInput) ReadLine() (string, error) {\n\treturn (*r.reader).ReadString('\\n')\n}", "func readline() (value string, err error) {\n\tvar valb []byte\n\tvar n int\n\tb := make([]byte, 1)\n\tfor {\n\t\t// read one byte at a time so we don't accidentally read extra bytes\n\t\tn, err = os.Stdin.Read(b)\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif n == 0 || b[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tvalb = append(valb, b[0])\n\t}\n\n\treturn strings.TrimSuffix(string(valb), \"\\r\"), nil\n}", "func (c *Conn) readLine() (string, error) {\n\tif c.server.ReadTimeout != 0 {\n\t\tif err := c.conn.SetReadDeadline(time.Now().Add(c.server.ReadTimeout)); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn c.text.ReadLine()\n}", "func ReadLine(prompt string) (string, bool) {\n\tvar cprompt *C.char\n\tif len(prompt) != 0 {\n\t\tcprompt = C.CString(prompt)\n\t}\n\tcline := C.readline(cprompt)\n\tif cprompt != nil {\n\t\tC.free(unsafe.Pointer(cprompt))\n\t}\n\tif cline == nil {\n\t\treturn \"\", true\n\t}\n\tline := C.GoString(cline)\n\tC.free(unsafe.Pointer(cline))\n\treturn line, false\n}", "func (r *lineReader) readLine(ctx context.Context) ([]byte, error) {\n\tvar buf []byte\n\tfor ctx.Err() == nil {\n\t\tline, err := r.r.ReadSlice('\\n')\n\t\tline = utils.BytesCopy(line)\n\t\tif err == nil {\n\t\t\treturn concatBufs(buf, line), err\n\t\t}\n\n\t\tif err == io.EOF {\n\t\t\tbuf = concatBufs(buf, line)\n\t\t\tif len(buf) == 0 {\n\t\t\t\treturn nil, io.EOF\n\t\t\t}\n\t\t\tutils.Sleep(ctx, r.eofSleep)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err == bufio.ErrBufferFull {\n\t\t\treturn concatBufs(buf, line), nil\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn nil, io.ErrClosedPipe\n}", "func (r *textprotoReader) ReadLine() (string, error) {\n\tline, err := r.readLineSlice()\n\treturn string(line), err\n}", "func Readline(prompt string, interfaces ...interface{}) (string, error) {\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Printf(prompt, interfaces...)\n\tinput, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tinput = strings.Trim(input, \"\\n\\r\")\n\treturn input, nil\n}", "func (c *CmdReal) StdinPipe() (io.WriteCloser, error) {\n\treturn c.cmd.StdinPipe()\n}", "func ReadIO(in io.Reader) (l *Line, err error) {\n\n s := bufio.NewScanner(in)\n\n // scan once to get the first line\n if s.Scan() == false || s.Err() != nil {\n return nil, s.Err()\n }\n\n l = &Line{data: s.Text()}\n scanIO(l, s)\n\n return l, s.Err()\n}", "func (c *Client) ReadLine() (line string, err error) {\n\tb, _, err := c.r.ReadLine()\n\tif err == io.EOF {\n\t\treturn\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\tline = string(b)\n\treturn\n}", "func (client *Client) InputReader(c net.Conn) {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfmt.Print(\"> \")\n\tfor scanner.Scan() {\n\t\targs := strings.Split(scanner.Text(), \" \")\n\t\tif args[0] == \"exit\" {\n\t\t\tos.Exit(0)\n\t\t}\n\t\tresponse, err := client.processCommand(c, args[0], args[1:]...)\n\t\tparseResponse(response, err, defaultTag)\n\t\tif args[0] == \"subscribe\" {\n\t\t\tsubscribePattern(c, scanner)\n\t\t\tfmt.Printf(\"\\r%s\", defaultTag)\n\t\t}\n\t}\n\n\tif scanner.Err() != nil {\n\t\tfmt.Printf(\"%v\", scanner.Err())\n\t\tos.Exit(2)\n\t}\n}", "func (c *CmdReal) GetStdin() io.Reader {\n\treturn c.cmd.Stdin\n}", "func Read(pipes *plumbing.Pipes, stream io.Reader) {\n\tinput := &input{\n\t\treceive: pipes.FromInterpreter(),\n\t\tsend: pipes.ToInterpreter(),\n\t\tstream: stream,\n\t}\n\tinput.read()\n}", "func readLine(s *bufio.Scanner) (string, error) {\n\tif !s.Scan() {\n\t\tif err := s.Err(); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"error reading line: %s\", err)\n\t\t} else {\n\t\t\treturn \"\", fmt.Errorf(\"unexpected EOF\")\n\t\t}\n\t}\n\tline := s.Text()\n\tif err := checkLine(line); err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid line: %s\", err)\n\t}\n\treturn line, nil\n}", "func ReadLine(reader io.Reader) (line string, err error) {\n\tbuffer := bytes.NewBuffer(make([]byte, 0, 4096))\n\tp := make([]byte, 1)\n\tfor {\n\t\tvar n int\n\t\tn, err = reader.Read(p)\n\t\tif err != nil || p[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tif n > 0 {\n\t\t\tbuffer.WriteByte(p[0])\n\t\t}\n\t}\n\tdata := buffer.Bytes()\n\tif len(data) > 0 && data[len(data)-1] == '\\r' {\n\t\tdata = data[:len(data)-1]\n\t}\n\treturn string(data), err\n}", "func (l *Linenoise) readBasic() (string, error) {\n\tif l.scanner == nil {\n\t\tl.scanner = bufio.NewScanner(os.Stdin)\n\t}\n\t// scan a line\n\tif !l.scanner.Scan() {\n\t\t// EOF - return quit\n\t\treturn \"\", ErrQuit\n\t}\n\t// check for unexpected errors\n\terr := l.scanner.Err()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t// get the line string\n\treturn l.scanner.Text(), nil\n}", "func ReadLine(reader io.Reader) ([]byte, error) {\n\tvar line []byte\n\tvar buffer [1]byte\n\tfor {\n\t\tn, err := reader.Read(buffer[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tif n == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tc := buffer[0]\n\t\tif c == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tline = append(line, c)\n\t}\n\treturn bytes.TrimSuffix(line, []byte{'\\r'}), nil\n}", "func (pipe *slimPipe) Read(buffer []byte) (int, error) {\n\terrChannel := make(chan error)\n\tcountChannel := make(chan int)\n\tgo func() {\n\t\treadBytes, err := io.ReadAtLeast(pipe.reader, buffer, 1)\n\t\tif err != nil {\n\t\t\terrChannel <- err\n\t\t} else {\n\t\t\tcountChannel <- readBytes\n\t\t}\n\t\tclose(errChannel)\n\t\tclose(countChannel)\n\t}()\n\tselect {\n\tcase count := <-countChannel:\n\t\treturn count, nil\n\tcase err := <-errChannel:\n\t\treturn 0, err\n\tcase <-time.After(pipe.timeout):\n\t\treturn 0, fmt.Errorf(\"Timeout (%v)\", pipe.timeout)\n\t}\n}", "func (e *Error) RawLine() (line string, available bool, outErr error) {\n\tif e.Line <= 0 || e.Filename == \"<string>\" {\n\t\treturn \"\", false, nil\n\t}\n\n\tfilename := e.Filename\n\tif e.Template != nil {\n\t\tfilename = e.Template.set.resolveFilename(e.Template, e.Filename)\n\t}\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\tdefer func() {\n\t\terr := file.Close()\n\t\tif err != nil && outErr == nil {\n\t\t\toutErr = err\n\t\t}\n\t}()\n\n\tscanner := bufio.NewScanner(file)\n\tl := 0\n\tfor scanner.Scan() {\n\t\tl++\n\t\tif l == e.Line {\n\t\t\treturn scanner.Text(), true, nil\n\t\t}\n\t}\n\treturn \"\", false, nil\n}", "func readStdin(out chan<- []byte) {\n\t//* copies some data from Stdin into data. Note that File.Read blocks until it receives data\n\tfor {\n\t\tdata := make([]byte, 1024)\n\t\tl, _ := os.Stdin.Read(data)\n\t\tif l > 0 {\n\t\t\t//* sends the buffered data over the channel\n\t\t\tout <- data\n\t\t}\n\t}\n}", "func ReadPipedInput() ([]byte, error) {\n\tinfo, err := os.Stdin.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpipedInput := info.Mode()&os.ModeNamedPipe != 0\n\tif info.Size() == 0 && !pipedInput {\n\t\treturn []byte{}, nil\n\t}\n\treturn ioutil.ReadAll(os.Stdin)\n}", "func readInputLoop(dt *discordterm.Client) {\n\trd := bufio.NewReader(os.Stdin)\n\n\tl, err := readline.NewEx(&readline.Config{\n\t\tPrompt: prompt,\n\t\tAutoComplete: completer,\n\t\tHistoryFile: filepath.Join(os.TempDir(), historyFile),\n\t\tHistorySearchFold: true,\n\t})\n\tif err != nil {\n\t\tlog.Println(\"Error creating readline:\", err)\n\t\treturn\n\t}\n\n\tvar standardReader bool\n\n\tfor {\n\t\tvar line string\n\t\tvar err error\n\n\t\tl.SetPrompt(createPrompt(dt))\n\n\t\tif !standardReader {\n\t\t\tline, err = l.Readline()\n\t\t\tif err != nil {\n\t\t\t\tstandardReader = true\n\t\t\t\tlog.Println(\"Error using readline package: switching to bufio reader: \", err)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Print(prompt)\n\t\t\tline, err = rd.ReadString('\\n')\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t}\n\n\t\t// Read a line of input\n\n\t\t// Remove whitespace characters from line\n\t\tline = strings.TrimSpace(line)\n\n\t\terr = executeCommand(dt, line)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\t}\n}", "func (p *stdinParser) Read() ([]byte, error) {\n\tif p.size == p.start {\n\t\tbuf, err := p.ConsoleParser.Read()\n\t\tif err != nil {\n\t\t\treturn []byte{}, err\n\t\t}\n\t\tp.start = 0\n\t\tp.size = len(buf)\n\t\tp.buf = buf\n\t}\n\ti := p.start\nL:\n\tfor ; i < p.size; i++ {\n\t\tif remapped, ok := p.keyMap[prompt.GetKey(p.buf[i:])]; ok {\n\t\t\tp.start = p.size\n\t\t\treturn remapped, nil\n\t\t}\n\t\tswitch prompt.GetKey(p.buf[i : i+1]) {\n\t\tcase prompt.Enter, prompt.ControlJ, prompt.ControlM:\n\t\t\tbreak L\n\t\t}\n\t}\n\tif i == p.start {\n\t\tp.start++\n\t\treturn p.buf[i : i+1], nil\n\t}\n\tbuf := p.buf[p.start:i]\n\tp.start = i\n\treturn buf, nil\n}", "func ReadLine(msg string) (string, error) {\n\tvar s string\n\tPrintfInfo(msg)\n\t_, err := fmt.Scanf(\"%s\", &s)\n\treturn s, err\n}", "func (c *SSHCommand) StdinPipe() (io.WriteCloser, error) {\n\treturn c.cmd.StdinPipe()\n}", "func (r *Reader) Read() (Line, error) {\n\tvar empty Line\n\n\tfor {\n\t\traw, _, err := r.r.ReadLine()\n\t\tif err != nil {\n\t\t\treturn empty, err // including io.EOF\n\t\t}\n\t\traw = bytes.TrimSpace(raw)\n\t\tif len(raw) > 0 {\n\t\t\treturn Parse(raw)\n\t\t}\n\t}\n}", "func (console *testConsole) Read(p []byte) (int, error) {\n\n\tif console.isClosed() {\n\t\treturn 0, io.EOF\n\t}\n\n\tconsole.bufMx.RLock()\n\tn := copy(p, console.buf)\n\tconsole.bufMx.RUnlock()\n\n\treturn n, nil\n}", "func termraw(L *lua.LState) int {\n\t_, err := term.MakeRaw(int(os.Stdin.Fd()))\n\tif err != nil {\n\t\tL.RaiseError(err.Error())\n\t}\n\n\treturn 0\n}", "func ReadLine(bio *bufio.Reader) ([]byte, error) {\n\tline, isPrefix, err := bio.ReadLine()\n\tif !isPrefix {\n\t\treturn line, err\n\t}\n\n\t// line is too long, read till eol\n\tbuf := append([]byte(nil), line...)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = bio.ReadLine()\n\t\tbuf = append(buf, line...)\n\t}\n\treturn buf, err\n}", "func (s *Switch) RawCommand(cmd string) (string, error) {\n\ts.Lock()\n\tdefer s.Unlock()\n\tfmt.Fprintf(s.buffer, \"%s\\r\\n\", cmd)\n\ts.buffer.Flush()\n\n\tlines, err := s.waitForPrompt()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif err = asError(lines); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn lines, nil\n}", "func readLine(bytes []byte, rd io.Reader) ([]byte, []byte, error) {\n\tend, length := -1, len(bytes)\n\tfor i, b := range bytes {\n\t\tif b == '\\r' && i+1 < length && bytes[i+1] == '\\n' { //eof\n\t\t\tend = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif end > 0 {\n\t\tline, newBytes := bytes[:end], make([]byte, 0)\n\t\tif end+2 < length {\n\t\t\tnewBytes = bytes[end+2:]\n\t\t}\n\n\t\treturn line, newBytes, nil\n\t}\n\n\tif rd == nil {\n\t\treturn nil, nil, errors.New(\"reader is null\")\n\t}\n\n\tbuff := make([]byte, 1024)\n\treadN, err := rd.Read(buff)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn readLine(append(bytes, buff[0:readN]...), rd)\n}", "func (c *Cmd) StdinPipe() (io.WriteCloser, error) {\n\treturn c.Cmd.StdinPipe()\n}", "func readInput(conn net.Conn, qst string) (string, error) {\n\tconn.Write([]byte(qst))\n\ts, err := bufio.NewReader(conn).ReadString('\\n')\n\tif err != nil {\n\t\tlog.Printf(\"readinput: could not read input from stdin: %v from client %v\", err, conn.RemoteAddr().String())\n\t\treturn \"\", err\n\t}\n\ts = strings.Trim(s, \"\\r\\n\")\n\treturn s, nil\n}", "func ReadStdinWithTimeout(bufferSize int, timeoutSeconds time.Duration) []byte {\n\tc := make(chan []byte, 1)\n\n\t// Read in background to allow using a select for a timeout\n\tgo (func() {\n\t\tr := bufio.NewReader(os.Stdin)\n\t\tbuf := make([]byte, bufferSize)\n\n\t\tn, err := r.Read(buf)\n\t\tif err != nil && err != io.EOF {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tc <- buf[:n]\n\t})()\n\n\tselect {\n\tcase b := <-c:\n\t\treturn b\n\t// Timeout\n\tcase <-time.After(timeoutSeconds * time.Second):\n\t\tfmt.Println(\"No input received\")\n\t\tos.Exit(1)\n\t\treturn nil\n\t}\n}", "func (p *Esc) Read(b []byte) (n int, err error) {\n\tsizeMsg := fmt.Sprintln(\"e:buf too small, expecting\", defaultSize, \"bytes.\")\n\tif len(b) < len(sizeMsg) {\n\t\treturn\n\t}\n\tif len(b) < defaultSize {\n\t\tn = copy(b, sizeMsg)\n\t\treturn\n\t}\n\n\t// use b as intermediate read buffer to avoid allocation\n\tn, err = p.in.Read(b)\n\t// p.syncBuffer can contain unprocessed bytes from last call.\n\tp.syncBuffer = append(p.syncBuffer, b[:n]...) // merge with leftovers\n\tn = 0\n\tif nil != err && io.EOF != err {\n\t\tn = copy(b, fmt.Sprintln(\"error:internal reader error \", err))\n\t\treturn\n\t}\n\n\t// Even err could be io.EOF some valid data possibly in p.syncBuffer.\n\t// In case of file input (JLINK usage) a plug off is not detectable here.\n\n\tp.bc = len(p.syncBuffer) // intermediade assingment for better error tracking\n\tif p.bc < 4 {\n\t\treturn // wait\n\t}\n\tp.b = b\n\tif 0xec != p.syncBuffer[0] { // 0xec == 236\n\t\treturn p.outOfSync(\"start byte is not 0xEC\")\n\t}\n\tlengthCode := p.syncBuffer[1]\n\tif 0xde == lengthCode { // 0xde == 222\n\t\treturn p.outOfSync(\"0xEC is followed by 0xDE, so no start byte\")\n\t}\n\ttriceID := int(binary.BigEndian.Uint16(p.syncBuffer[2:4]))\n\tvar ok bool\n\tp.trice, ok = p.lut[triceID]\n\tif !ok { // unknown id\n\t\treturn p.outOfSync(fmt.Sprint(\"unknown ID \", triceID))\n\t}\n\tp.bc = p.bytesCount(lengthCode) // payload plus header\n\tif p.expectedByteCount() != p.bc {\n\t\treturn p.outOfSync(fmt.Sprint(\"trice.Type \", p.trice.Type, \" with not matching length code \", lengthCode))\n\t}\n\tif len(p.syncBuffer) < 4+p.bc { // header plus payload\n\t\treturn // wait\n\t}\n\t// ID and count are ok\n\treturn p.sprintTrice()\n}", "func readLine(reader *bufio.Reader, buffer *bytes.Buffer) (line string, size int, err error) {\n\tvar (\n\t\tsegment []byte\n\t\tnext bool\n\t)\n\t// if link file to stdin, can block forever here.\n\tfor {\n\t\tif segment, next, err = reader.ReadLine(); err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\terr = errors.New(\"read line failed\")\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif _, err = buffer.Write(segment); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif next {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tsize = buffer.Len()\n\t\t\tline = buffer.String()\n\t\t\t//fix delim\n\t\t\treader.UnreadByte()\n\t\t\treader.UnreadByte()\n\t\t\tvar b []byte\n\t\t\tb, err = reader.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif b[0] == '\\r' {\n\t\t\t\tsize++\n\t\t\t}\n\t\t\tsize++\n\t\t\t// clear buffer\n\t\t\tbuffer.Reset()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *Config) Stdin() io.ReadCloser {\n\treturn c.stdin\n}", "func (r Raw) Read(b []byte) (n int64, err error) {\r\n\tpanic(\"this value cannot be read. use WriteTo() instead\")\r\n}", "func (e *ExportReader) readLine() ([]byte, error) {\n\tline, err := e.buf.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// trim the trailing newline\n\treturn line[:len(line)-1], nil\n}", "func LineReader(r io.Reader) (<-chan string, error) {\n\treturn lineReader(func() (io.Reader, func(), error) { return r, nil, nil })\n}", "func ReadLine(L *lua.LState) int {\n\tn := checkLuaNetClient(L, 1)\n\n\tvar delim byte\n\tif L.GetTop() > 1 {\n\t\td := L.CheckString(2)\n\t\tif len(d) != 1 {\n\t\t\tL.ArgError(2, \"Delim must be string of length 1\")\n\t\t}\n\t\tdelim = byte(d[0])\n\t} else {\n\t\tdelim = '\\n'\n\t}\n\n\treader := bufio.NewReader(n.Conn)\n\tif n.readTimeout > 0 {\n\t\tn.SetReadDeadline(time.Now().Add(n.readTimeout))\n\t}\n\tdata, err := reader.ReadString(delim)\n\tif err != nil {\n\t\tL.Push(lua.LString(data))\n\t\tL.Push(lua.LString(err.Error()))\n\t\treturn 2\n\t}\n\tL.Push(lua.LString(data))\n\tL.Push(lua.LNil)\n\treturn 2\n}", "func (p *stdio) Read(b []byte) (n int, err error) {\n\tn, err = p.buf.Read(b)\n\tif err == io.EOF {\n\t\treturn n, nil\n\t}\n\treturn n, err\n}", "func parseRawInput(line string) (IncomingData, bool) {\n\tif len(line) == 0 {\n\t\treturn IncomingData{}, false\n\t}\n\n\tsegments := strings.Split(strings.TrimSpace(line), \" \")\n\tresponseCode, err := strconv.Atoi(segments[1])\n\tif err != nil {\n\t\treturn parseNonNumericReply(segments)\n\t}\n\n\treturn parseNumericReply(responseCode, segments)\n}", "func (p *pipe) readFrom(r io.Reader) (read int64, failure error) {\n\tfor {\n\t\t// Wait until some space frees up\n\t\tsafeFree, err := p.inputWait()\n\t\tif err != nil {\n\t\t\treturn read, err\n\t\t}\n\t\t// Try to fill the buffer either till the reader position, or the end\n\t\tlimit := p.inPos + safeFree\n\t\tif limit > p.size {\n\t\t\tlimit = p.size\n\t\t}\n\t\tnr, err := r.Read(p.buffer[p.inPos:limit])\n\t\tread += int64(nr)\n\n\t\t// Update the pipe input state and handle any occurred errors\n\t\tp.inputAdvance(nr)\n\t\tif err == io.EOF {\n\t\t\treturn read, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn read, err\n\t\t}\n\t}\n}", "func (s *Session) readLine() (line string, err error) {\n\tline, err = s.reader.ReadString('\\n')\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t} else if op, ok := err.(*net.OpError); ok && strings.Contains(\n\t\t\top.Err.Error(), \"use of closed network connection\") {\n\t\t} else {\n\t\t\tfmt.Printf(\"Stream reader error (is gpsd running?): %#v\\n\", err)\n\t\t}\n\t}\n\treturn\n}", "func (client *Client) ReadLine() string {\n\tline, err := client.connection.ReadLine()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"<= %v\\n\", line)\n\treturn line\n}", "func execmReaderReadLine(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret, ret1 := args[0].(*textproto.Reader).ReadLine()\n\tp.Ret(1, ret, ret1)\n}", "func (c *conn) ReadControlLine() (string, error) {\n\tline, partial, err := c.reader.ReadLine()\n\n\tif err != nil {\n\t\treturn string(line), err\n\t}\n\n\tfor partial {\n\t\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\t\treturn string(line), ErrProtocolOpTooBig\n\t\t}\n\n\t\tvar l []byte\n\t\tl, partial, err = c.reader.ReadLine()\n\t\tline = append(line, l...)\n\t\tif err != nil {\n\t\t\treturn string(line), err\n\t\t}\n\t}\n\n\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\treturn string(line), ErrProtocolOpTooBig\n\t}\n\n\treturn string(line), nil\n}", "func getLine(in *bufio.Reader, lineNo *int) (string, bool) {\n\t*lineNo++\n\tline, _, err := in.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\", true\n\t}\n\treturn string(line), false\n}", "func (alr *adjustableLimitedReader) Read(p []byte) (n int, err error) {\n\tn, err = alr.R.Read(p)\n\tif err == io.EOF && alr.R.N <= 0 {\n\t\t// return our custom error since io.Reader returns EOF\n\t\terr = LineLimitExceeded\n\t}\n\treturn\n}", "func Line(prompt string) (string, error) {\n\tins := getInstance()\n\tins.SetPrompt(prompt)\n\treturn ins.Readline()\n}", "func (reader *Reader) ReadLine() (line []byte, e error) {\n\tline, e = reader.bufRead.ReadBytes(DefEOL)\n\n\tif e == nil {\n\t\t// remove EOL\n\t\tline = line[:len(line)-1]\n\t}\n\n\treturn\n}", "func ReadStdin() <-chan string {\n\tc := make(chan string)\n\tif seenStdin {\n\t\tlog.Fatalf(\"Repeated - on command line; can't reread stdin.\")\n\t}\n\tseenStdin = true\n\tgo func() {\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tscanner.Split(bufio.ScanWords)\n\t\tfor scanner.Scan() {\n\t\t\ts := strings.TrimSpace(scanner.Text())\n\t\t\tif s != \"\" {\n\t\t\t\tc <- s\n\t\t\t}\n\t\t}\n\t\tif err := scanner.Err(); err != nil {\n\t\t\tlog.Fatalf(\"Error reading stdin: %s\", err)\n\t\t}\n\t\tclose(c)\n\t}()\n\treturn c\n}", "func New() (*RawRuneReader, error) {\n\n\tstate, err := terminal.MakeRaw(syscall.Stdin)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trcr := RawRuneReader{}\n\trcr.state = state\n\trcr.in = bufio.NewReader(os.Stdin)\n\n\treturn &rcr, nil\n}", "func (t *Target) Read(stream usm.Stream, s usm.String) usm.Value {\n\tif stream == nil {\n\t\treturn fmt.Sprintf(`r.Stdin(%v)`, s)\n\t}\n\tpanic(\"not implemented\")\n}", "func (t Terminal) Read(prompt string) (string, error) {\n\tif prompt != \"\" {\n\t\tfmt.Fprintf(t.Output, \"%s \", prompt)\n\t}\n\n\treader := bufio.NewReader(t.Input)\n\n\ttext, readErr := reader.ReadString('\\n')\n\tif readErr != nil {\n\t\treturn \"\", readErr\n\t}\n\n\ttext = strings.TrimSpace(text)\n\n\treturn text, nil\n}", "func (rl *Instance) readlineInput(r []rune) {\n\tswitch rl.modeViMode {\n\tcase vimKeys:\n\t\trl.vi(r[0])\n\t\trl.viHintMessage()\n\n\tcase vimDelete:\n\t\trl.vimDelete(r)\n\t\trl.viHintMessage()\n\n\tcase vimReplaceOnce:\n\t\trl.modeViMode = vimKeys\n\t\trl.delete()\n\t\trl.insert([]rune{r[0]})\n\t\trl.viHintMessage()\n\n\tcase vimReplaceMany:\n\t\tfor _, char := range r {\n\t\t\trl.delete()\n\t\t\trl.insert([]rune{char})\n\t\t}\n\t\trl.viHintMessage()\n\n\tdefault:\n\t\trl.insert(r)\n\t}\n}", "func execmReaderReadLineBytes(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret, ret1 := args[0].(*textproto.Reader).ReadLineBytes()\n\tp.Ret(1, ret, ret1)\n}", "func ReadLineClean(rstream *bufio.Reader) (string, error) { // {{{1\n\tline, err := rstream.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tcrIdx := len(line) - 2\n\tif crIdx >= 0 && line[crIdx] == '\\r' {\n\t\treturn line[:crIdx], nil\n\t} else {\n\t\treturn \"\", errors.New(\"Bad format\")\n\t}\n}", "func (r *MessageExecuteCommand) RawInput() string {\n\treturn r.rawInput\n}", "func (q *Question) Read(prompt string) (answer string, err error) {\n\tline := q.getLine(prompt, \"\", _DEFAULT_NO)\n\n\tfor {\n\t\tanswer, err = line.Read()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif answer != \"\" {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func LineReader(r io.Reader) chan string {\n\tch := make(chan string)\n\n\tgo func() {\n\t\tscanner := bufio.NewScanner(r)\n\n\t\tfor scanner.Scan() {\n\t\t\tl := scanner.Text()\n\t\t\tl = strings.TrimSpace(l)\n\t\t\tif len(l) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tch <- l\n\t\t}\n\n\t\tclose(ch)\n\t}()\n\n\treturn ch\n}", "func ReadLine(path string, handler LineHandler) error {\n\tf, err := os.OpenFile(path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = readLine(bufio.NewReader(f), handler)\n\tif err1 := f.Close(); err == nil {\n\t\terr = err1\n\t}\n\treturn err\n}", "func (c Command) lineReader(r io.Reader) {\n\tscanner := bufio.NewScanner(r)\n\n\tfor scanner.Scan() {\n\t\tc.Stdout(scanner.Text())\n\t}\n}", "func (r *PipeReader) Read(data []byte) (n int, err error) {\n\treturn r.p.read(data)\n}", "func (r *PipeReader) Read(data []byte) (n int, err error) {\n\treturn r.p.read(data)\n}", "func (r *PipeReader) Read(data []byte) (n int, err error) {\n\treturn r.p.read(data)\n}", "func (r *Client) ReadLine() (string, error) {\n\treader := bufio.NewReader(r)\n\ts, e := reader.ReadString('\\n')\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\treturn strings.TrimSuffix(s, \"\\n\"), nil\n}", "func (s secureReader) Read(b []byte) (int, error) {\n\t// parse header\n\tvar size uint16\n\terr := binary.Read(s.pipe, binary.LittleEndian, &size)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\t// parse body\n\tvar buf bytes.Buffer\n\t_, err = buf.ReadFrom(io.LimitReader(s.pipe, int64(size)))\n\tnonce := [24]byte{}\n\tcopy(nonce[:], buf.Next(24))\n\tcipherText := buf.Bytes()\n\n\t// decrypt body and copy to buffer\n\tmsg, success := box.OpenAfterPrecomputation(nil, cipherText, &nonce, s.shared)\n\tif !success {\n\t\treturn 0, errors.New(\"unable to decrypt cipher text. box.Open() returned false\")\n\t}\n\treturn copy(b, msg), nil\n}", "func (p *pipe) read(b []byte) (int, error) {\n\t// Short circuit if the output was already closed\n\tselect {\n\tcase <-p.outQuit:\n\t\treturn 0, ErrClosedPipe\n\tdefault:\n\t}\n\t// Wait until some data becomes available\n\tsafeFree, err := p.outputWait()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\t// Retrieve as much as available\n\tlimit := p.outPos + p.size - safeFree\n\tif limit > p.size {\n\t\tlimit = p.size\n\t}\n\tif limit > p.outPos+int32(len(b)) {\n\t\tlimit = p.outPos + int32(len(b))\n\t}\n\twritten := copy(b, p.buffer[p.outPos:limit])\n\n\t// Update the pipe output state and return\n\tp.outputAdvance(written)\n\treturn written, nil\n}", "func ReadInput(path string) ([]byte, error) {\n\tvar inputFile *os.File\n\tif path == \"\" {\n\t\tstdinFileInfo, _ := os.Stdin.Stat()\n\t\tif (stdinFileInfo.Mode() & os.ModeNamedPipe) != 0 {\n\t\t\tinputFile = os.Stdin\n\t\t} else {\n\t\t\treturn nil, NewErrExpectedStdin()\n\t\t}\n\t} else {\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer func() { _ = f.Close() }()\n\t\tinputFile = f\n\t}\n\tfileContent, err := ioutil.ReadAll(inputFile)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// golang adds a new line characters at the end of every line, not what we want here\n\t// note that we need to make sure the workaround is cross platform\n\tfileContent = bytes.TrimRight(fileContent, \"\\r\\n\")\n\treturn fileContent, nil\n}", "func makeInputRaw(fd windows.Handle, mode uint32) error {\n\t// See\n\t// -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx\n\t// -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms683462(v=vs.85).aspx\n\n\t// Disable these modes\n\tmode &^= windows.ENABLE_ECHO_INPUT\n\tmode &^= windows.ENABLE_LINE_INPUT\n\tmode &^= windows.ENABLE_MOUSE_INPUT\n\tmode &^= windows.ENABLE_WINDOW_INPUT\n\tmode &^= windows.ENABLE_PROCESSED_INPUT\n\n\t// Enable these modes\n\tmode |= windows.ENABLE_EXTENDED_FLAGS\n\tmode |= windows.ENABLE_INSERT_MODE\n\tmode |= windows.ENABLE_QUICK_EDIT_MODE\n\n\tif vtInputSupported {\n\t\tmode |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT\n\t}\n\n\tif err := windows.SetConsoleMode(fd, mode); err != nil {\n\t\treturn fmt.Errorf(\"unable to set console to raw mode: %w\", err)\n\t}\n\n\treturn nil\n}", "func (i *In) Read(p []byte) (int, error) {\n\treturn i.in.Read(p)\n}", "func GetStdin() io.Reader {\n\treturn GetConsoleIOChannel().Stdin\n}", "func (tr *terminalReader) Read(p []byte) (n int, err error) {\n\t//Implementations of Read are discouraged from returning a zero byte count\n\t// with a nil error, except when len(p) == 0.\n\tif len(p) == 0 {\n\t\treturn 0, nil\n\t}\n\tif nil == tr.emulator {\n\t\treturn tr.readFromWrappedReader(p)\n\t}\n\treturn tr.emulator.ReadChars(tr.fd, tr.wrappedReader, p)\n}", "func (t *tube) RecvLine() ([]byte, error) {\n\treturn t.RecvUntil([]byte{t.NewLine()}, true)\n}", "func (e *ObservableEditableBuffer) Read(q0 int, r []rune) (int, error) {\n\treturn e.f.Read(q0, r)\n}", "func (nc noClose) Read(p []byte) (n int, err error) {\n\treturn nc.in.Read(p)\n}", "func TtyIn() *os.File {\n\treturn os.Stdin\n}" ]
[ "0.7045951", "0.6221766", "0.612136", "0.61189127", "0.6105609", "0.6082193", "0.60020673", "0.5822638", "0.5813698", "0.5802452", "0.5756891", "0.5702212", "0.56775093", "0.5662662", "0.56328225", "0.5623556", "0.5589195", "0.55323553", "0.55314094", "0.55254173", "0.5520291", "0.5507699", "0.55004835", "0.5463981", "0.5440241", "0.5437084", "0.54284936", "0.5409532", "0.5402601", "0.5400595", "0.53826356", "0.5355802", "0.5330259", "0.53186727", "0.5315923", "0.53156996", "0.5297407", "0.528337", "0.5282336", "0.527604", "0.52686685", "0.5262884", "0.52585554", "0.52569735", "0.52511424", "0.52479285", "0.5242177", "0.52370286", "0.5234933", "0.521772", "0.5208008", "0.52042395", "0.5202974", "0.5195844", "0.51838607", "0.5183259", "0.5180854", "0.51720816", "0.5162261", "0.51439476", "0.5143616", "0.5143109", "0.5131014", "0.5128464", "0.51196", "0.5110773", "0.51076376", "0.509821", "0.509368", "0.5092777", "0.5089256", "0.5066647", "0.5066198", "0.5061234", "0.50595313", "0.50586545", "0.505748", "0.5055054", "0.5048094", "0.50385934", "0.5038427", "0.5035708", "0.5035486", "0.5034051", "0.5029788", "0.50191075", "0.50191075", "0.50191075", "0.5017681", "0.5004746", "0.50012904", "0.50008655", "0.49987695", "0.4993448", "0.49817362", "0.498135", "0.49782687", "0.4967548", "0.49666154", "0.4964167" ]
0.69025856
1
Read a line using basic buffered IO.
func (l *Linenoise) readBasic() (string, error) { if l.scanner == nil { l.scanner = bufio.NewScanner(os.Stdin) } // scan a line if !l.scanner.Scan() { // EOF - return quit return "", ErrQuit } // check for unexpected errors err := l.scanner.Err() if err != nil { return "", err } // get the line string return l.scanner.Text(), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *lineReader) readLine(ctx context.Context) ([]byte, error) {\n\tvar buf []byte\n\tfor ctx.Err() == nil {\n\t\tline, err := r.r.ReadSlice('\\n')\n\t\tline = utils.BytesCopy(line)\n\t\tif err == nil {\n\t\t\treturn concatBufs(buf, line), err\n\t\t}\n\n\t\tif err == io.EOF {\n\t\t\tbuf = concatBufs(buf, line)\n\t\t\tif len(buf) == 0 {\n\t\t\t\treturn nil, io.EOF\n\t\t\t}\n\t\t\tutils.Sleep(ctx, r.eofSleep)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err == bufio.ErrBufferFull {\n\t\t\treturn concatBufs(buf, line), nil\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn nil, io.ErrClosedPipe\n}", "func readLine(reader *bufio.Reader, buffer *bytes.Buffer) (line string, size int, err error) {\n\tvar (\n\t\tsegment []byte\n\t\tnext bool\n\t)\n\t// if link file to stdin, can block forever here.\n\tfor {\n\t\tif segment, next, err = reader.ReadLine(); err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\terr = errors.New(\"read line failed\")\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif _, err = buffer.Write(segment); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif next {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tsize = buffer.Len()\n\t\t\tline = buffer.String()\n\t\t\t//fix delim\n\t\t\treader.UnreadByte()\n\t\t\treader.UnreadByte()\n\t\t\tvar b []byte\n\t\t\tb, err = reader.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif b[0] == '\\r' {\n\t\t\t\tsize++\n\t\t\t}\n\t\t\tsize++\n\t\t\t// clear buffer\n\t\t\tbuffer.Reset()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (e *ExportReader) readLine() ([]byte, error) {\n\tline, err := e.buf.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// trim the trailing newline\n\treturn line[:len(line)-1], nil\n}", "func readLine(bytes []byte, rd io.Reader) ([]byte, []byte, error) {\n\tend, length := -1, len(bytes)\n\tfor i, b := range bytes {\n\t\tif b == '\\r' && i+1 < length && bytes[i+1] == '\\n' { //eof\n\t\t\tend = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif end > 0 {\n\t\tline, newBytes := bytes[:end], make([]byte, 0)\n\t\tif end+2 < length {\n\t\t\tnewBytes = bytes[end+2:]\n\t\t}\n\n\t\treturn line, newBytes, nil\n\t}\n\n\tif rd == nil {\n\t\treturn nil, nil, errors.New(\"reader is null\")\n\t}\n\n\tbuff := make([]byte, 1024)\n\treadN, err := rd.Read(buff)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn readLine(append(bytes, buff[0:readN]...), rd)\n}", "func (cc *Reader) ReadLine() ([]byte, error) {\n\tfor {\n\t\t// try to find a terminated line in the buffered data already read\n\t\tnlidx := bytes.IndexByte(cc.buf[cc.searchFrom:cc.end], '\\n')\n\t\tif nlidx != -1 {\n\t\t\t// got a complete line\n\t\t\tline := cc.buf[cc.start : cc.searchFrom+nlidx]\n\t\t\tcc.start = cc.searchFrom + nlidx + 1\n\t\t\tcc.searchFrom = cc.start\n\t\t\t// treat \\r\\n as the line terminator if it was present\n\t\t\tif 0 < len(line) && line[len(line)-1] == '\\r' {\n\t\t\t\tline = line[:len(line)-1]\n\t\t\t}\n\t\t\treturn line, nil\n\t\t}\n\n\t\t// are we out of space? we can read more if any of these are true:\n\t\t// 1. cc.start != 0, so we can slide the existing data back\n\t\t// 2. cc.end < len(cc.buf), so we can read data into the end of the buffer\n\t\t// 3. len(cc.buf) < cc.maxSize, so we can grow the buffer\n\t\tif cc.start == 0 && cc.end == len(cc.buf) && len(cc.buf) == cc.maxSize {\n\t\t\treturn nil, ErrReadQ\n\t\t}\n\n\t\tif cc.eof {\n\t\t\treturn nil, io.EOF\n\t\t}\n\n\t\tif len(cc.buf) < cc.maxSize && (len(cc.buf)-(cc.end-cc.start) < cc.initialSize/2) {\n\t\t\t// allocate a new buffer, copy any remaining data\n\t\t\tnewLen := roundUpToPowerOfTwo(len(cc.buf) + 1)\n\t\t\tif newLen > cc.maxSize {\n\t\t\t\tnewLen = cc.maxSize\n\t\t\t} else if newLen < cc.initialSize {\n\t\t\t\tnewLen = cc.initialSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newLen)\n\t\t\tcopy(newBuf, cc.buf[cc.start:cc.end])\n\t\t\tcc.buf = newBuf\n\t\t} else if cc.start != 0 {\n\t\t\t// slide remaining data back to the front of the buffer\n\t\t\tcopy(cc.buf, cc.buf[cc.start:cc.end])\n\t\t}\n\t\tcc.end = cc.end - cc.start\n\t\tcc.start = 0\n\n\t\tcc.searchFrom = cc.end\n\t\tn, err := cc.conn.Read(cc.buf[cc.end:])\n\t\tcc.end += n\n\t\tif n != 0 && err == io.EOF {\n\t\t\t// we may have received new \\n-terminated lines, try to parse them\n\t\t\tcc.eof = true\n\t\t} else if err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n}", "func (ep *ExpectProcess) ReadLine() string {\n\tep.mu.Lock()\n\tdefer ep.mu.Unlock()\n\tif ep.count > ep.cur {\n\t\tline := ep.lines[ep.cur]\n\t\tep.cur++\n\t\treturn line\n\t}\n\treturn \"\"\n}", "func readLine(br *bufio.Reader) ([]byte, error) {\n\tline := make([]byte, 0, 64)\n\n\tfor {\n\t\tpart, err := br.ReadSlice('\\n')\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif bytes.HasSuffix(part, crlf) {\n\t\t\tline = append(line, part[:len(part)-2]...)\n\t\t\tbreak\n\t\t}\n\t\tline = append(line, part...)\n\t}\n\n\treturn line, nil\n}", "func (c *Conn) readLine() (string, error) {\n\tif c.server.ReadTimeout != 0 {\n\t\tif err := c.conn.SetReadDeadline(time.Now().Add(c.server.ReadTimeout)); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn c.text.ReadLine()\n}", "func ReadLine(bio *bufio.Reader) ([]byte, error) {\n\tline, isPrefix, err := bio.ReadLine()\n\tif !isPrefix {\n\t\treturn line, err\n\t}\n\n\t// line is too long, read till eol\n\tbuf := append([]byte(nil), line...)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = bio.ReadLine()\n\t\tbuf = append(buf, line...)\n\t}\n\treturn buf, err\n}", "func ReadIO(in io.Reader) (l *Line, err error) {\n\n s := bufio.NewScanner(in)\n\n // scan once to get the first line\n if s.Scan() == false || s.Err() != nil {\n return nil, s.Err()\n }\n\n l = &Line{data: s.Text()}\n scanIO(l, s)\n\n return l, s.Err()\n}", "func ReadLineByLine(path string, output chan<- string) {\n\tfile, err := os.Open(path)\n\tdefer file.Close()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\toutput <- scanner.Text()\n\t}\n\n\tclose(output)\n}", "func ReadLine(reader io.Reader) ([]byte, error) {\n\tvar line []byte\n\tvar buffer [1]byte\n\tfor {\n\t\tn, err := reader.Read(buffer[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tif n == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tc := buffer[0]\n\t\tif c == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tline = append(line, c)\n\t}\n\treturn bytes.TrimSuffix(line, []byte{'\\r'}), nil\n}", "func (c *Client) ReadLine() (line string, err error) {\n\tb, _, err := c.r.ReadLine()\n\tif err == io.EOF {\n\t\treturn\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\tline = string(b)\n\treturn\n}", "func (obj *LineFile) readLine(r *bufio.Reader) ([]byte, error) {\n\tvar results []byte\n\thasMore := true\n\tbytes := []byte{}\n\tvar err error\n\tfor hasMore {\n\t\tbytes, hasMore, err = r.ReadLine()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tif len(bytes) > 0 {\n\t\t\tresults = append(results, bytes...)\n\t\t}\n\t}\n\treturn results, err\n}", "func (r *textprotoReader) ReadLine() (string, error) {\n\tline, err := r.readLineSlice()\n\treturn string(line), err\n}", "func ReadLine(reader io.Reader) (line string, err error) {\n\tbuffer := bytes.NewBuffer(make([]byte, 0, 4096))\n\tp := make([]byte, 1)\n\tfor {\n\t\tvar n int\n\t\tn, err = reader.Read(p)\n\t\tif err != nil || p[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tif n > 0 {\n\t\t\tbuffer.WriteByte(p[0])\n\t\t}\n\t}\n\tdata := buffer.Bytes()\n\tif len(data) > 0 && data[len(data)-1] == '\\r' {\n\t\tdata = data[:len(data)-1]\n\t}\n\treturn string(data), err\n}", "func (e *ObservableEditableBuffer) Read(q0 int, r []rune) (int, error) {\n\treturn e.f.Read(q0, r)\n}", "func (reader *Reader) ReadLine() (line []byte, e error) {\n\tline, e = reader.bufRead.ReadBytes(DefEOL)\n\n\tif e == nil {\n\t\t// remove EOL\n\t\tline = line[:len(line)-1]\n\t}\n\n\treturn\n}", "func readLine(bufferedReader *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = bufferedReader.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\n\treturn string(ln), err\n}", "func readLine(reader *bufio.Reader) (line string, err error) {\n\tvar part []byte\n\tvar prefix bool\n\n\tbuffer := bytes.NewBuffer(make([]byte, 0))\n\tfor {\n\t\tif part, prefix, err = reader.ReadLine(); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tbuffer.Write(part)\n\t\tif !prefix {\n\t\t\tline = buffer.String()\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (c *Connection) ReadLine() (string, error) {\n\treturn c.conn.ReadLine()\n}", "func (serial_reader *SerialReader) ReadLine() string {\n\tresult := make([]byte, 0)\n\tlastRead := make([]byte, 1)\n\n\t// read byte by byte until the Line Feed character\n\tfor lastRead[0] != LF_CHAR {\n\t\tn, err := serial_reader.Read(lastRead)\n\t\tif (err != nil) || (n != 1) {\n\t\t\tpanic(log.Critical(err))\n\t\t}\n\n\t\tresult = append(result, lastRead[0])\n\t}\n\n\treturn string(result)\n}", "func readLine(s *bufio.Scanner) (string, error) {\n\tif !s.Scan() {\n\t\tif err := s.Err(); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"error reading line: %s\", err)\n\t\t} else {\n\t\t\treturn \"\", fmt.Errorf(\"unexpected EOF\")\n\t\t}\n\t}\n\tline := s.Text()\n\tif err := checkLine(line); err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid line: %s\", err)\n\t}\n\treturn line, nil\n}", "func readLine(r io.ReaderAt, offset int64) (s string, err error) {\n\tsr := io.NewSectionReader(r, offset, bufio.MaxScanTokenSize)\n\tsc := bufio.NewScanner(sr)\n\n\tif sc.Scan() {\n\t\ts = sc.Text()\n\t}\n\tif sc.Err() != nil {\n\t\terr = sc.Err()\n\t\treturn\n\t}\n\n\treturn\n}", "func getLine(in *bufio.Reader, lineNo *int) (string, bool) {\n\t*lineNo++\n\tline, _, err := in.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\", true\n\t}\n\treturn string(line), false\n}", "func (client *Client) ReadLine() string {\n\tline, err := client.connection.ReadLine()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"<= %v\\n\", line)\n\treturn line\n}", "func ReadLine(path string, handler LineHandler) error {\n\tf, err := os.OpenFile(path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = readLine(bufio.NewReader(f), handler)\n\tif err1 := f.Close(); err == nil {\n\t\terr = err1\n\t}\n\treturn err\n}", "func UnpackLine(r *bufio.Reader) ([]byte, error) {\n\t// Fast path: a line is fully contained in the buffer.\n\tvar line, err = r.ReadSlice('\\n')\n\n\tif err == bufio.ErrBufferFull {\n\t\t// Slow path: the line spills across multiple buffer fills.\n\t\terr = nil\n\n\t\tline = append([]byte(nil), line...) // Copy as |line| references an internal buffer.\n\t\tvar rest []byte\n\n\t\tif rest, err = r.ReadBytes('\\n'); err == nil {\n\t\t\tline = append(line, rest...)\n\t\t}\n\t}\n\n\tif err == io.EOF && len(line) != 0 {\n\t\t// If we read at least one byte, then an EOF is unexpected (it should\n\t\t// occur only on whole-message boundaries).\n\t\terr = io.ErrUnexpectedEOF\n\t}\n\treturn line, err\n}", "func LineReader(file *os.File, bus ChannelBus) {\n\tr := openReader(file)\n\tfor line, err := r.ReadString('\\n'); err == nil; line, err = r.ReadString('\\n') {\n\t\tbus.CurrentLine <- line\n\t}\n\tfile.Close()\n\tclose(bus.CurrentLine)\n}", "func ReadLine(L *lua.LState) int {\n\tn := checkLuaNetClient(L, 1)\n\n\tvar delim byte\n\tif L.GetTop() > 1 {\n\t\td := L.CheckString(2)\n\t\tif len(d) != 1 {\n\t\t\tL.ArgError(2, \"Delim must be string of length 1\")\n\t\t}\n\t\tdelim = byte(d[0])\n\t} else {\n\t\tdelim = '\\n'\n\t}\n\n\treader := bufio.NewReader(n.Conn)\n\tif n.readTimeout > 0 {\n\t\tn.SetReadDeadline(time.Now().Add(n.readTimeout))\n\t}\n\tdata, err := reader.ReadString(delim)\n\tif err != nil {\n\t\tL.Push(lua.LString(data))\n\t\tL.Push(lua.LString(err.Error()))\n\t\treturn 2\n\t}\n\tL.Push(lua.LString(data))\n\tL.Push(lua.LNil)\n\treturn 2\n}", "func (r *trackingreader) Read(b []byte) (int, error) {\n\tn, err := r.Reader.Read(b)\n\tr.pos += int64(n)\n\treturn n, err\n}", "func (file *File) SeekLine(lines int64, whence int) (int64, error) {\n\n\t// return error on bad whence\n\tif whence < 0 || whence > 2 {\n\t\treturn file.Seek(0, whence)\n\t}\n\n\tposition, err := file.Seek(0, whence)\n\n\tbuf := make([]byte, BufferLength)\n\tbufLen := 0\n\tlineSep := byte('\\n')\n\tseekBack := lines < 1\n\tlines = int64(math.Abs(float64(lines)))\n\tmatchCount := int64(0)\n\n\t// seekBack ignores first match\n\t// allows 0 to go to begining of current line\n\tif seekBack {\n\t\tmatchCount = -1\n\t}\n\n\tleftPosition := position\n\toffset := int64(BufferLength * -1)\n\n\tfor b := 1; ; b++ {\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif seekBack {\n\n\t\t\t// on seekBack 2nd buffer onward needs to seek\n\t\t\t// past what was just read plus another buffer size\n\t\t\tif b == 2 {\n\t\t\t\toffset *= 2\n\t\t\t}\n\n\t\t\t// if next seekBack will pass beginning of file\n\t\t\t// buffer is 0 to unread position\n\t\t\tif position+int64(offset) <= 0 {\n\t\t\t\tbuf = make([]byte, leftPosition)\n\t\t\t\tposition, err = file.Seek(0, io.SeekStart)\n\t\t\t\tleftPosition = 0\n\t\t\t} else {\n\t\t\t\tposition, err = file.Seek(offset, io.SeekCurrent)\n\t\t\t\tleftPosition = leftPosition - BufferLength\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tbufLen, err = file.Read(buf)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t} else if seekBack && leftPosition == 0 {\n\t\t\terr = io.EOF\n\t\t}\n\n\t\tfor i := 0; i < bufLen; i++ {\n\t\t\tiToCheck := i\n\t\t\tif seekBack {\n\t\t\t\tiToCheck = bufLen - i - 1\n\t\t\t}\n\t\t\tbyteToCheck := buf[iToCheck]\n\n\t\t\tif byteToCheck == lineSep {\n\t\t\t\tmatchCount++\n\t\t\t}\n\n\t\t\tif matchCount == lines {\n\t\t\t\tif seekBack {\n\t\t\t\t\treturn file.Seek(int64(i)*-1, io.SeekCurrent)\n\t\t\t\t}\n\t\t\t\treturn file.Seek(int64(bufLen*-1+i+1), io.SeekCurrent)\n\t\t\t}\n\t\t}\n\t}\n\n\tif err == io.EOF && !seekBack {\n\t\tposition, _ = file.Seek(0, io.SeekEnd)\n\t} else if err == io.EOF && seekBack {\n\t\tposition, _ = file.Seek(0, io.SeekStart)\n\n\t\t// no io.EOF err on SeekLine(0,0)\n\t\tif lines == 0 {\n\t\t\terr = nil\n\t\t}\n\t}\n\n\treturn position, err\n}", "func readLine(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix = true\n\t\terr error\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}", "func readLine(reader *bufio.Reader) ([]byte, error) {\n\tline := []byte{}\n\tfor {\n\t\t_line, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\treturn line, err\n\t\t}\n\t\tline = append(line, _line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn line, nil\n}", "func (s *Session) readLine() (line string, err error) {\n\tline, err = s.reader.ReadString('\\n')\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t} else if op, ok := err.(*net.OpError); ok && strings.Contains(\n\t\t\top.Err.Error(), \"use of closed network connection\") {\n\t\t} else {\n\t\t\tfmt.Printf(\"Stream reader error (is gpsd running?): %#v\\n\", err)\n\t\t}\n\t}\n\treturn\n}", "func (console *testConsole) Read(p []byte) (int, error) {\n\n\tif console.isClosed() {\n\t\treturn 0, io.EOF\n\t}\n\n\tconsole.bufMx.RLock()\n\tn := copy(p, console.buf)\n\tconsole.bufMx.RUnlock()\n\n\treturn n, nil\n}", "func (br *BufferedReader) Read(v Decoder) (n int, err error) {\n\nRetry:\n\tif br.mustFill {\n\t\t// The buffer needs to be filled before trying to decode\n\t\t// another record.\n\t\tif br.mode == ModeManual {\n\t\t\treturn 0, ErrMustFill\n\t\t}\n\n\t\terr = br.Fill()\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t}\n\n\tif br.eof && br.offset == br.buffered {\n\t\t// We've reached EOF on a previous Fill attempt and the\n\t\t// buffered data has been fully consumed.\n\t\treturn 0, io.EOF\n\t}\n\n\tn, err = v.Decode(br.buffer[br.offset:br.buffered])\n\n\tif err == ErrShortBuffer {\n\t\t// Unable to decode a full record.\n\n\t\tif br.offset == 0 && br.buffered == len(br.buffer) {\n\t\t\t// We've tried to decode from the start of a full\n\t\t\t// buffer, so it seems we won't be able to fit this\n\t\t\t// record in our buffer.\n\t\t\treturn 0, ErrTooLarge\n\t\t}\n\n\t\tif br.eof {\n\t\t\t// We won't be able to read more bytes yet there's\n\t\t\t// a partial record left to decode.\n\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t}\n\n\t\tbr.mustFill = true\n\n\t\tgoto Retry\n\t}\n\n\tbr.offset += n\n\n\tif err != nil {\n\t\treturn n, err\n\t}\n\n\treturn n, nil\n}", "func ReadLines(r io.Reader) Stream {\n c, _ := r.(io.Closer)\n return &lineStream{bufio: bufio.NewReader(r), maybeCloser: maybeCloser{c: c}}\n}", "func ReadLine(c <-chan []byte) Summary {\n\tres := Summary{}\n\tfor line := range c {\n\t\tres.Counter.TotalLines++\n\t\tres.Counter.TotalBytes += int64(len(line) + 1)\n\t\tres.Counter.TotalWords += countWords(line)\n\t}\n\treturn res\n}", "func TestReadLine(t *testing.T) {\n\tvar buf bytes.Buffer\n\ts := &session{}\n\ts.srv = &Server{}\n\ts.br = bufio.NewReader(&buf)\n\n\t// Ensure readLine() returns an EOF error on an empty buffer.\n\t_, err := s.readLine()\n\tif err != io.EOF {\n\t\tt.Errorf(\"readLine() on empty buffer returned err: %v, want EOF\", err)\n\t}\n\n\t// Ensure trailing <CRLF> is stripped.\n\tline := \"FOO BAR BAZ\\r\\n\"\n\tcmd := \"FOO BAR BAZ\"\n\tbuf.Write([]byte(line))\n\toutput, err := s.readLine()\n\tif err != nil {\n\t\tt.Errorf(\"readLine(%v) returned err: %v\", line, err)\n\t} else if output != cmd {\n\t\tt.Errorf(\"readLine(%v) returned %v, want %v\", line, output, cmd)\n\t}\n}", "func (b *Buffer) Read(reader io.Reader) (error) {\n\tif b.isCompacted {\n\t\tb.isCompacted = false\n\n\t\t// we want to read into the buffer from where it last was,\n\t\tvar slice = b.internal[b.index:]\n\t\tvar length, err = reader.Read(slice)\n\t\tb.index = 0 // start the index over, so reading starts from beginning again\n\t\tb.length += uint32(length) // increment the number of bytes read\n\t\treturn err\n\t}\n\tvar length, err = reader.Read(b.internal)\n\tb.index = 0\n\tb.length = uint32(length)\n\treturn err\n}", "func Read(b []byte) { Reader.Read(b) }", "func (this *reader) ioRead(buffer []byte) (n int, err error) {\n\tn, err = this.ioReader.Read(buffer)\n\tif err != nil {\n\t\treturn\n\t}\n\tif n != len(buffer) {\n\t\terr = fmt.Errorf(\"Reading failed. Expected %v bytes but %v was read\",\n\t\t\tlen(buffer), n)\n\t}\n\treturn\n}", "func ReadLine(msg string) (string, error) {\n\tvar s string\n\tPrintfInfo(msg)\n\t_, err := fmt.Scanf(\"%s\", &s)\n\treturn s, err\n}", "func LineReader(r io.Reader) (<-chan string, error) {\n\treturn lineReader(func() (io.Reader, func(), error) { return r, nil, nil })\n}", "func (i *UI) rawReadline(f *os.File) (string, error) {\n\tvar resultBuf []byte\n\tfor {\n\t\tvar buf [1]byte\n\t\tn, err := f.Read(buf[:])\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\n\t\tif n == 0 || buf[0] == '\\n' || buf[0] == '\\r' {\n\t\t\tbreak\n\t\t}\n\n\t\tif buf[0] == 3 {\n\t\t\treturn \"\", ErrInterrupted\n\t\t}\n\n\t\tif i.mask {\n\t\t\tfmt.Fprintf(i.Writer, i.maskVal)\n\t\t}\n\n\t\tresultBuf = append(resultBuf, buf[0])\n\t}\n\n\tfmt.Fprintf(i.Writer, \"\\n\")\n\treturn string(resultBuf), nil\n}", "func (r *Client) ReadLine() (string, error) {\n\treader := bufio.NewReader(r)\n\ts, e := reader.ReadString('\\n')\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\treturn strings.TrimSuffix(s, \"\\n\"), nil\n}", "func (x *Reader) ReadCompleteLine() (string, error) {\n\tline, err := x.Reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn line, nil\n}", "func (b *Buffer) Line(n int) string {\n\tif n >= len(b.lines) {\n\t\treturn \"\"\n\t}\n\treturn string(b.lines[n].data)\n}", "func (s *scanner) readline() []byte {\n\tln, err := s.r.ReadBytes('\\n')\n\tif err == io.EOF {\n\t\treturn []byte{'E', 'O', 'F'}\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"ReadBytes failed with %v\", err)\n\t\treturn []byte{}\n\t}\n\treturn ln\n}", "func (alr *adjustableLimitedReader) Read(p []byte) (n int, err error) {\n\tn, err = alr.R.Read(p)\n\tif err == io.EOF && alr.R.N <= 0 {\n\t\t// return our custom error since io.Reader returns EOF\n\t\terr = LineLimitExceeded\n\t}\n\treturn\n}", "func (p *pipe) readFrom(r io.Reader) (read int64, failure error) {\n\tfor {\n\t\t// Wait until some space frees up\n\t\tsafeFree, err := p.inputWait()\n\t\tif err != nil {\n\t\t\treturn read, err\n\t\t}\n\t\t// Try to fill the buffer either till the reader position, or the end\n\t\tlimit := p.inPos + safeFree\n\t\tif limit > p.size {\n\t\t\tlimit = p.size\n\t\t}\n\t\tnr, err := r.Read(p.buffer[p.inPos:limit])\n\t\tread += int64(nr)\n\n\t\t// Update the pipe input state and handle any occurred errors\n\t\tp.inputAdvance(nr)\n\t\tif err == io.EOF {\n\t\t\treturn read, nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn read, err\n\t\t}\n\t}\n}", "func (r ReaderInput) ReadLine() (string, error) {\n\treturn (*r.reader).ReadString('\\n')\n}", "func (r reader) Read(p []byte) (n int, err error) {\n\tn, err = r.r.Read(p)\n\tbn, err := r.r.Peek(1)\n\tfor i, b := range p {\n\t\t// if the current byte is a CR and the next byte is NOT a LF then replace the current byte with a LF\n\t\tif j := i + 1; b == rByte && ((j < len(p) && p[j] != nByte) || (len(bn) > 0 && bn[0] != nByte)) {\n\t\t\tp[i] = nByte\n\t\t}\n\t}\n\treturn\n}", "func Readline(ireader Reader) chan string {\n\treadline := make(chan string, 1)\n\tgo func() {\n\t\tdefer close(readline)\n\t\tfor {\n\t\t\tline, err := ireader.ReadString('\\n')\n\t\t\tif err != nil && line == \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treadline <- line\n\t\t}\n\t}()\n\treturn readline\n}", "func LineReader(r io.Reader) chan string {\n\tch := make(chan string)\n\n\tgo func() {\n\t\tscanner := bufio.NewScanner(r)\n\n\t\tfor scanner.Scan() {\n\t\t\tl := scanner.Text()\n\t\t\tl = strings.TrimSpace(l)\n\t\t\tif len(l) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tch <- l\n\t\t}\n\n\t\tclose(ch)\n\t}()\n\n\treturn ch\n}", "func readFile(path string, lineCh chan string) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\tlog.Fatalf(\"%s => %s\", errorMsgWriteOut, err)\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tlineCh <- scanner.Text()\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tclose(lineCh)\n}", "func (r *bytesReader) Read(b []byte) (n int, err error) {\n\tif r.index >= int64(len(r.bs)) {\n\t\treturn 0, io.EOF\n\t}\n\tn = copy(b, r.bs[r.index:])\n\tr.index += int64(n)\n\treturn\n}", "func readLine(reader *bufio.Reader) (string, error) {\n\tvar line, b []byte\n\tvar err error\n\tisPrefix := true\n\tfor isPrefix {\n\t\tb, isPrefix, err = reader.ReadLine()\n\t\tline = append(line, b...)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\treturn string(line), nil\n}", "func (p *pipe) read(b []byte) (int, error) {\n\t// Short circuit if the output was already closed\n\tselect {\n\tcase <-p.outQuit:\n\t\treturn 0, ErrClosedPipe\n\tdefault:\n\t}\n\t// Wait until some data becomes available\n\tsafeFree, err := p.outputWait()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\t// Retrieve as much as available\n\tlimit := p.outPos + p.size - safeFree\n\tif limit > p.size {\n\t\tlimit = p.size\n\t}\n\tif limit > p.outPos+int32(len(b)) {\n\t\tlimit = p.outPos + int32(len(b))\n\t}\n\twritten := copy(b, p.buffer[p.outPos:limit])\n\n\t// Update the pipe output state and return\n\tp.outputAdvance(written)\n\treturn written, nil\n}", "func (f *firstLineReader) getLine(timeout time.Duration) (string, error) {\n\tselect {\n\tcase s := <-f.sch:\n\t\treturn s, nil\n\tcase err := <-f.ech:\n\t\treturn err.Error(), err\n\tcase <-time.After(timeout):\n\t\terr := errors.New(\"read timed out\")\n\t\treturn err.Error(), err\n\t}\n}", "func (yp *YamlParser) readLineBytes() error {\n\tvar c uint\n\n\t// Clear read\n\typ.readCursor = 0\n\typ.readBytes = yp.readBytes[:0]\n\n\tfor {\n\t\tb, err := yp.reader.ReadByte()\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif b == '\\n' {\n\t\t\tc = uint(len(yp.readBytes))\n\n\t\t\t// Handle Windows' Line Endings\n\t\t\tif c > 1 && yp.readBytes[c-1] == '\\r' {\n\t\t\t\typ.readBytes = yp.readBytes[0 : c-1]\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\typ.readBytes = append(yp.readBytes, b)\n\t}\n\n\treturn nil\n}", "func (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}", "func (r *Reader) Read(b []byte) (n int, err error) {\n\tif r.i >= int64(len(r.s)) {\n\t\treturn 0, io.EOF\n\t}\n\tr.prevRune = -1\n\tn = copy(b, r.s[r.i:])\n\tr.i += int64(n)\n\treturn\n}", "func TestLineBufferSequential(t *testing.T) {\n\tsrc := &sourceTailer{lines: make(chan string)}\n\tbuffered := BufferedTailerWithMetrics(src)\n\tfor i := 0; i < 10000; i++ {\n\t\tsrc.lines <- fmt.Sprintf(\"This is line number %v.\", i)\n\t}\n\tfor i := 0; i < 10000; i++ {\n\t\tline := <-buffered.Lines()\n\t\tif line != fmt.Sprintf(\"This is line number %v.\", i) {\n\t\t\tt.Errorf(\"Expected 'This is line number %v', but got '%v'.\", i, line)\n\t\t}\n\t}\n\tbuffered.Close()\n\t_, stillOpen := <-buffered.Lines()\n\tif stillOpen {\n\t\tt.Error(\"Buffered tailer was not closed.\")\n\t}\n\t_, stillOpen = <-src.Lines()\n\tif stillOpen {\n\t\tt.Error(\"Source tailer was not closed.\")\n\t}\n}", "func (r *bytesReader) ReadAt(b []byte, offset int64) (n int, err error) {\n\tif offset < 0 {\n\t\treturn 0, errors.New(\"buffer.bytesReader.ReadAt: negative offset\")\n\t}\n\tif offset >= int64(len(r.bs)) {\n\t\treturn 0, io.EOF\n\t}\n\tn = copy(b, r.bs[offset:])\n\tif n < len(b) {\n\t\terr = io.EOF\n\t}\n\treturn\n}", "func (bb *BytesBuffer) Read(p []byte) (n int, err error) {\n\treturn bb.reader.Read(p)\n}", "func BenchmarkBufioReaderLineSmall(b *testing.B) {\n\tfor n := 0; n < b.N; n++ {\n\t\treaderReadLine(fnSmall)\n\t}\n}", "func (p *stdio) Read(b []byte) (n int, err error) {\n\tn, err = p.buf.Read(b)\n\tif err == io.EOF {\n\t\treturn n, nil\n\t}\n\treturn n, err\n}", "func (sb *SeekableBuffer) Read(p []byte) (n int, err error) {\n\tdefer func() {\n\t\tif state := recover(); state != nil {\n\t\t\terr = state.(error)\n\t\t}\n\t}()\n\n\tif sb.position >= len64(sb.data) {\n\t\treturn 0, io.EOF\n\t}\n\n\tn = copy(p, sb.data[sb.position:])\n\tsb.position += int64(n)\n\n\treturn n, nil\n\n}", "func readToCRLF(reader *bufio.Reader) (buffer []byte, err os.Error) {\n\t//\treader := bufio.NewReader(conn);\n\tvar buf []byte\n\tbuf, err = reader.ReadBytes(CR_BYTE)\n\tif err == nil {\n\t\tvar b byte\n\t\tb, err = reader.ReadByte()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif b != LF_BYTE {\n\t\t\terr = os.NewError(\"<BUG> Expecting a Linefeed byte here!\")\n\t\t}\n\t\t//\t\tlog.Println(\"readToCRLF: \", buf);\n\t\tbuffer = buf[0 : len(buf)-1]\n\t}\n\treturn\n}", "func (v *Reader) Read(b []byte) (int, error) {\n\tif v.br == nil {\n\t\tv.br = &buf.BufferedReader{Reader: buf.NewReader(v.Reader)}\n\t}\n\n\tp := b[:0]\n\tfor len(p) < len(b)-2 {\n\t\tx, err := v.br.ReadByte()\n\t\tif err != nil {\n\t\t\tif len(p) == 0 {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t\treturn len(p), nil\n\t\t}\n\t\tswitch v.state {\n\t\tcase StateContent:\n\t\t\tswitch x {\n\t\t\tcase '\"':\n\t\t\t\tv.state = StateDoubleQuote\n\t\t\t\tp = append(p, x)\n\t\t\tcase '\\'':\n\t\t\t\tv.state = StateSingleQuote\n\t\t\t\tp = append(p, x)\n\t\t\tcase '\\\\':\n\t\t\t\tv.state = StateEscape\n\t\t\tcase '#':\n\t\t\t\tv.state = StateComment\n\t\t\tcase '/':\n\t\t\t\tv.state = StateSlash\n\t\t\tdefault:\n\t\t\t\tp = append(p, x)\n\t\t\t}\n\t\tcase StateEscape:\n\t\t\tp = append(p, '\\\\', x)\n\t\t\tv.state = StateContent\n\t\tcase StateDoubleQuote:\n\t\t\tswitch x {\n\t\t\tcase '\"':\n\t\t\t\tv.state = StateContent\n\t\t\t\tp = append(p, x)\n\t\t\tcase '\\\\':\n\t\t\t\tv.state = StateDoubleQuoteEscape\n\t\t\tdefault:\n\t\t\t\tp = append(p, x)\n\t\t\t}\n\t\tcase StateDoubleQuoteEscape:\n\t\t\tp = append(p, '\\\\', x)\n\t\t\tv.state = StateDoubleQuote\n\t\tcase StateSingleQuote:\n\t\t\tswitch x {\n\t\t\tcase '\\'':\n\t\t\t\tv.state = StateContent\n\t\t\t\tp = append(p, x)\n\t\t\tcase '\\\\':\n\t\t\t\tv.state = StateSingleQuoteEscape\n\t\t\tdefault:\n\t\t\t\tp = append(p, x)\n\t\t\t}\n\t\tcase StateSingleQuoteEscape:\n\t\t\tp = append(p, '\\\\', x)\n\t\t\tv.state = StateSingleQuote\n\t\tcase StateComment:\n\t\t\tif x == '\\n' {\n\t\t\t\tv.state = StateContent\n\t\t\t\tp = append(p, '\\n')\n\t\t\t}\n\t\tcase StateSlash:\n\t\t\tswitch x {\n\t\t\tcase '/':\n\t\t\t\tv.state = StateComment\n\t\t\tcase '*':\n\t\t\t\tv.state = StateMultilineComment\n\t\t\tdefault:\n\t\t\t\tp = append(p, '/', x)\n\t\t\t}\n\t\tcase StateMultilineComment:\n\t\t\tswitch x {\n\t\t\tcase '*':\n\t\t\t\tv.state = StateMultilineCommentStar\n\t\t\tcase '\\n':\n\t\t\t\tp = append(p, '\\n')\n\t\t\t}\n\t\tcase StateMultilineCommentStar:\n\t\t\tswitch x {\n\t\t\tcase '/':\n\t\t\t\tv.state = StateContent\n\t\t\tcase '*':\n\t\t\t\t// Stay\n\t\t\tcase '\\n':\n\t\t\t\tp = append(p, '\\n')\n\t\t\tdefault:\n\t\t\t\tv.state = StateMultilineComment\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"Unknown state.\")\n\t\t}\n\t}\n\treturn len(p), nil\n}", "func (r *ChannelReader) Read(b []byte) (sz int, err error) {\n\tif len(b) == 0 {\n\t\treturn 0, io.ErrShortBuffer\n\t}\n\n\tfor {\n\t\tif len(r.buf) > 0 {\n\t\t\tif len(r.buf) <= len(b) {\n\t\t\t\tsz = len(r.buf)\n\t\t\t\tcopy(b, r.buf)\n\t\t\t\tr.buf = nil\n\t\t\t} else {\n\t\t\t\tcopy(b, r.buf)\n\t\t\t\tr.buf = r.buf[len(b):]\n\t\t\t\tsz = len(b)\n\t\t\t}\n\t\t\treturn sz, nil\n\t\t}\n\n\t\tvar ok bool\n\t\tif r.deadline.IsZero() {\n\t\t\tr.buf, ok = <-r.c\n\t\t} else {\n\t\t\ttimer := time.NewTimer(r.deadline.Sub(time.Now()))\n\t\t\tdefer timer.Stop()\n\n\t\t\tselect {\n\t\t\tcase r.buf, ok = <-r.c:\n\t\t\tcase <-timer.C:\n\t\t\t\treturn 0, context.DeadlineExceeded\n\t\t\t}\n\t\t}\n\t\tif len(r.buf) == 0 && !ok {\n\t\t\treturn 0, io.EOF\n\t\t}\n\t}\n}", "func readline() (value string, err error) {\n\tvar valb []byte\n\tvar n int\n\tb := make([]byte, 1)\n\tfor {\n\t\t// read one byte at a time so we don't accidentally read extra bytes\n\t\tn, err = os.Stdin.Read(b)\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif n == 0 || b[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tvalb = append(valb, b[0])\n\t}\n\n\treturn strings.TrimSuffix(string(valb), \"\\r\"), nil\n}", "func (pipe *slimPipe) Read(buffer []byte) (int, error) {\n\terrChannel := make(chan error)\n\tcountChannel := make(chan int)\n\tgo func() {\n\t\treadBytes, err := io.ReadAtLeast(pipe.reader, buffer, 1)\n\t\tif err != nil {\n\t\t\terrChannel <- err\n\t\t} else {\n\t\t\tcountChannel <- readBytes\n\t\t}\n\t\tclose(errChannel)\n\t\tclose(countChannel)\n\t}()\n\tselect {\n\tcase count := <-countChannel:\n\t\treturn count, nil\n\tcase err := <-errChannel:\n\t\treturn 0, err\n\tcase <-time.After(pipe.timeout):\n\t\treturn 0, fmt.Errorf(\"Timeout (%v)\", pipe.timeout)\n\t}\n}", "func readLine() string {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.Replace(text, \"\\n\", \"\", -1)\n\treturn text\n}", "func (l *LineReader) ReadOne() ([]string, error) {\n\tDebug(\"LineReader: start with %v\", l)\n\tfor {\n\t\tvar b [1]byte\n\t\tn, err := l.R.Read(b[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tln := l.Line.String()\n\t\t\t\tif ln == \"\" {\n\t\t\t\t\treturn []string{}, nil\n\t\t\t\t}\n\t\t\t\treturn l.C.Complete(ln)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tDebug(\"LineReader.ReadOne: got %s, %v, %v\", b, n, err)\n\t\tif n == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tswitch b[0] {\n\t\tdefault:\n\t\t\tDebug(\"LineReader.Just add it to line and pipe\")\n\t\t\tl.Line.Write(b[:])\n\t\t\tl.W.Write(b[:])\n\t\tcase 8, 127:\n\t\t\t// We may have found a use for the io stuff, we'll see.\n\t\t\ts := l.Line.String()\n\t\t\tif len(s) > 0 {\n\t\t\t\ts = s[:len(s)-1]\n\t\t\t\tl.Line = bytes.NewBufferString(s)\n\t\t\t\tl.W.Write(b[:])\n\t\t\t}\n\t\tcase '\\n', '\\r':\n\t\t\terr = ErrEOL\n\t\t\tfallthrough\n\t\tcase ' ':\n\t\t\tif b[0] == ' ' {\n\t\t\t\tl.W.Write(b[:])\n\t\t\t}\n\t\t\tln := l.Line.String()\n\t\t\tif ln == \"\" {\n\t\t\t\treturn []string{}, err\n\t\t\t}\n\t\t\ts, _ := l.C.Complete(ln)\n\t\t\t// If there is no match or too many matches,\n\t\t\t// return what is typed so far.\n\t\t\tDebug(\"LineReader ln %v, err %v, s %v\", ln, err, s)\n\t\t\tif len(s) != 1 {\n\t\t\t\ts = []string{ln}\n\t\t\t}\n\t\t\treturn s, err\n\t\tcase '\\t':\n\t\t\tDebug(\"LineReader.Try complete with %s\", l.Line.String())\n\t\t\ts, err := l.C.Complete(l.Line.String())\n\t\t\tDebug(\"LineReader.Complete returns %v, %v\", s, err)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif len(s) < 2 {\n\t\t\t\tDebug(\"Return is %v\", s)\n\t\t\t\treturn s, nil\n\t\t\t}\n\t\t\tif _, err := l.W.Write([]byte(fmt.Sprintf(\"\\n\\r%v\\n\\r%v\", s, l.Line.String()))); err != nil {\n\t\t\t\tlog.Printf(\"Write %v: %v\", s, err)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func BlockingRead(r *bufio.Reader) *[]byte {\n\tbyteChan := make(chan []byte)\n\tb := make([]byte, 4096) // buffer is 4k- we should never be exceeding this!\n\tgo func() {\n\t\tfor {\n\t\t\tn, _ := r.ReadBytes('\\n')\n\t\t\tif len(n) > 0 {\n\t\t\t\tbyteChan <- n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\tfor {\n\t\tselect {\n\t\tcase b = <-byteChan:\n\t\t\treturn &b\n\t\tdefault:\n\t\t\tcontinue\n\t\t}\n\t}\n}", "func (parser *PdfParser) readTextLine() (string, error) {\n\tvar r bytes.Buffer\n\tfor {\n\t\tbb, err := parser.reader.Peek(1)\n\t\tif err != nil {\n\t\t\tcommon.Log.Debug(\"Error %s\", err.Error())\n\t\t\treturn r.String(), err\n\t\t}\n\t\tif (bb[0] != '\\r') && (bb[0] != '\\n') {\n\t\t\tb, _ := parser.reader.ReadByte()\n\t\t\tr.WriteByte(b)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn r.String(), nil\n}", "func (b *buffer) read(rd io.Reader) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"panic reading: %v\", r)\n\t\t\tb.err = err\n\t\t}\n\t}()\n\n\tvar n int\n\tbuf := b.buf[0:b.size]\n\tfor n < b.size {\n\t\tn2, err := rd.Read(buf)\n\t\tn += n2\n\t\tif err != nil {\n\t\t\tb.err = err\n\t\t\tbreak\n\t\t}\n\t\tbuf = buf[n2:]\n\t}\n\tb.buf = b.buf[0:n]\n\tb.offset = 0\n\treturn b.err\n}", "func LineReaderFrom(path string) (<-chan string, error) {\n\treturn lineReader(func() (io.Reader, func(), error) {\n\t\tif !FileExists(path) {\n\t\t\treturn nil, nil, nil\n\t\t}\n\t\tf, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\treturn f, func() { f.Close() }, nil\n\t})\n}", "func (std *LineReaderService) Read() (<-chan []byte, error) {\n\tmc := make(chan []byte, 0)\n\n\tstd.pub.Subscribe(mc)\n\n\treturn mc, nil\n}", "func (f stdioFileHandle) Read(b []byte) (n int, err error) {\n\tif len(b) == 0 {\n\t\treturn 0, nil\n\t}\n\n\tsize := buffered()\n\tfor size == 0 {\n\t\tgosched()\n\t\tsize = buffered()\n\t}\n\n\tif size > len(b) {\n\t\tsize = len(b)\n\t}\n\tfor i := 0; i < size; i++ {\n\t\tb[i] = getchar()\n\t}\n\treturn size, nil\n}", "func (c *poolConn) ReadBuffer(size int) ([]byte, error) {\n\tif c.mustRead == true {\n\t\terr := c.ReadTcpBlock()\n\t\tif err != nil {\n\t\t\tc.err = err\n\t\t\treturn nil, err\n\t\t}\n\t\tc.buffer.index = 0\n\t\tc.mustRead = false\n\t}\n\n\t//if size < c.buffer.size-c.buffer.index, normal stitching\n\t//if c.buffer.size-c.buffer.index < size < c.buffer.capacity-c.buffer.size+c.buffer.index, move usable data in buffer to front\n\t//if size > c.buffer.capacity, directly read the specified size\n\tif size+2 <= c.buffer.size-c.buffer.index {\n\n\t\tif c.buffer.realBuffer[c.buffer.index+size] == '\\r' && c.buffer.realBuffer[c.buffer.index+size+1] == '\\n' {\n\t\t\tcpy_index := c.buffer.index\n\t\t\tc.buffer.index = c.buffer.index + size + 2\n\t\t\tif c.buffer.index >= c.buffer.size {\n\t\t\t\tc.mustRead = true\n\t\t\t}\n\t\t\treturn c.buffer.realBuffer[cpy_index: cpy_index+size], nil\n\t\t} else {\n\t\t\treturn nil, errors.New(\"ReadBuffer is read wrong!\")\n\t\t}\n\t} else if size+2 <= c.buffer.capacity-c.buffer.size+c.buffer.index {\n\t\tc.ReadUnsafeBuffer()\n\t\tif c.buffer.realBuffer[c.buffer.index+size] == '\\r' && c.buffer.realBuffer[c.buffer.index+size+1] == '\\n' {\n\t\t\tc.buffer.index = c.buffer.index + size + 2\n\t\t\tif c.buffer.index >= c.buffer.size {\n\t\t\t\tc.mustRead = true\n\t\t\t}\n\t\t\treturn c.buffer.realBuffer[0:size], nil\n\t\t} else {\n\t\t\treturn nil, errors.New(\"ReadBuffer is read wrong!\")\n\t\t}\n\n\t} else {\n\t\tvar err error\n\t\tbigBuffer := make([]byte, size+2)\n\t\tcopy(bigBuffer, c.buffer.realBuffer[c.buffer.index:])\n\n\t\t//Make the results right , when the BigSize < buffer.capacity\n\t\tif len(bigBuffer) > c.buffer.size-c.buffer.index {\n\t\t\tbigBuffer, err = c.ReadTcpBigBlockLink(bigBuffer)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\t//judge weather the bigBuffer is right\n\t\tif bigBuffer[size] == '\\r' && bigBuffer[size+1] == '\\n' {\n\t\t\tc.buffer.index = c.buffer.index + size + 2\n\t\t\tif c.buffer.index >= c.buffer.size {\n\t\t\t\tc.mustRead = true\n\t\t\t}\n\t\t\treturn bigBuffer[:size], nil\n\t\t} else {\n\t\t\treturn nil, errors.New(\"bigBuffer is read wrong!\")\n\t\t}\n\t}\n}", "func (tr *Reader) Read(b []byte) (n int, err error) {\n\tif tr.nb == 0 {\n\t\t// file consumed\n\t\treturn 0, io.EOF\n\t}\n\n\tif int64(len(b)) > tr.nb {\n\t\tb = b[0:tr.nb]\n\t}\n\tn, err = tr.r.Read(b)\n\ttr.nb -= int64(n)\n\n\tif err == io.EOF && tr.nb > 0 {\n\t\terr = io.ErrUnexpectedEOF\n\t}\n\ttr.err = err\n\treturn\n}", "func (b *Buffer) Read(out []byte) (n int, err error) {\n\tif b.readCursor >= b.Size() {\n\t\t// we read the entire buffer, let's loop back to the beginning\n\t\tb.readCursor = 0\n\t} else if b.readCursor+int64(len(out)) > b.Size() {\n\t\t// we don't have enough data in our buffer to fill the passed buffer\n\t\t// we need to do multiple passes\n\t\tn := copy(out, b.data[b.offset+b.readCursor:])\n\t\tb.readCursor += int64(n)\n\t\t// TMP check, should remove\n\t\tif b.readCursor != b.Size() {\n\t\t\tpanic(fmt.Sprintf(\"off by one much? %d - %d\", b.readCursor, b.Size()))\n\t\t}\n\t\tn2, _ := b.Read(out[n:])\n\t\tb.readCursor += int64(n2)\n\t\treturn int(n + n2), nil\n\t}\n\tn = copy(out, b.data[b.offset+b.readCursor:])\n\treturn\n}", "func readLn(path string) (<-chan string, <-chan error, chan<- int) {\n\tout, err, sig, sigv := make(chan string, 64), make(chan error, 1), make(chan int), 0\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif e := recover(); e != nil {\n\t\t\t\terr <- e.(error)\n\t\t\t}\n\t\t\tclose(err)\n\t\t\tclose(out)\n\t\t}()\n\t\tfile, e := os.Open(path)\n\t\tif e != nil {\n\t\t\tpanic(fmt.Errorf(\"can't access %q (%v)\", path, e))\n\t\t}\n\t\tdefer file.Close()\n\t\thandleSig(sig, &sigv)\n\n\t\tln := bufio.NewScanner(file)\n\t\tfor ; sigv == 0 && ln.Scan(); out <- ln.Text() {\n\t\t}\n\t\tif e := ln.Err(); e != nil {\n\t\t\tpanic(fmt.Errorf(\"problem reading %q (%v)\", path, e))\n\t\t}\n\t}()\n\treturn out, err, sig\n}", "func (e *Env) GetLine() (string, error) {\n\t//fmt.Println(\"GetLine\")\n\tif e.fileInfo.curFileScanner == nil {\n\t\t//fmt.Println(\"Getline openNextFile\")\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\tfor !(e.fileInfo.curFileScanner).Scan() {\n\t\t//fmt.Printf(\"Getline scan finished -> openNextFile: Scanner.Err=%v\\n\", e.fileInfo.curFileScanner.Err())\n\t\tif err := e.fileInfo.curFileScanner.Err(); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif len(e.fileInfo.files) == 0 {\n\t\t\t// when read from Stdin\n\t\t\treturn \"\", io.EOF\n\t\t}\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\te.IncFNR()\n\te.IncNR()\n\treturn e.fileInfo.curFileScanner.Text(), nil\n}", "func execmReaderReadLineBytes(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret, ret1 := args[0].(*textproto.Reader).ReadLineBytes()\n\tp.Ret(1, ret, ret1)\n}", "func (e *ObservableEditableBuffer) Reader(q0 int, q1 int) io.Reader {\n\treturn e.f.Reader(q0, q1)\n}", "func (r *Reader) Read(p []byte) (n int, err error) {\n\tr.ResetBuf(p)\n\tn, err = r.srcR.Read(r.buf)\n\treturn\n}", "func (r *Reader) Read() (Line, error) {\n\tvar empty Line\n\n\tfor {\n\t\traw, _, err := r.r.ReadLine()\n\t\tif err != nil {\n\t\t\treturn empty, err // including io.EOF\n\t\t}\n\t\traw = bytes.TrimSpace(raw)\n\t\tif len(raw) > 0 {\n\t\t\treturn Parse(raw)\n\t\t}\n\t}\n}", "func Buffer() string {\n\treturn C.GoString(C.rl_line_buffer)\n}", "func ReadLine(filePth string, hookfn func([]byte)) error {\n\tf, err := os.Open(filePth)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tbfRd := bufio.NewReader(f)\n\tfor {\n\t\tline, err := bfRd.ReadBytes('\\n')\n\t\thookfn(line) //放在错误处理前面,即使发生错误,也会处理已经读取到的数据。\n\t\tif err != nil { //遇到任何错误立即返回,并忽略 EOF 错误信息\n\t\t\tif err == io.EOF {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *conn) ReadControlLine() (string, error) {\n\tline, partial, err := c.reader.ReadLine()\n\n\tif err != nil {\n\t\treturn string(line), err\n\t}\n\n\tfor partial {\n\t\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\t\treturn string(line), ErrProtocolOpTooBig\n\t\t}\n\n\t\tvar l []byte\n\t\tl, partial, err = c.reader.ReadLine()\n\t\tline = append(line, l...)\n\t\tif err != nil {\n\t\t\treturn string(line), err\n\t\t}\n\t}\n\n\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\treturn string(line), ErrProtocolOpTooBig\n\t}\n\n\treturn string(line), nil\n}", "func (t *tube) RecvLine() ([]byte, error) {\n\treturn t.RecvUntil([]byte{t.NewLine()}, true)\n}", "func ReadLine(prompt string) (line string, err error) {\n\n\tfmt.Print(prompt)\n\n\tin := bufio.NewReader(os.Stdin)\n\n\tline, err = in.ReadString('\\n')\n\tif err != nil {\n\t\terr = ErrInterrupted\n\t} else if len(line) > 0 {\n\t\t// need to take the end of line back off\n\t\t// using scanner didn't register ctrl-c properly\n\t\tline = strings.TrimRight(line, \"\\n\\r\")\n\t}\n\treturn\n\n}", "func (c Command) lineReader(r io.Reader) {\n\tscanner := bufio.NewScanner(r)\n\n\tfor scanner.Scan() {\n\t\tc.Stdout(scanner.Text())\n\t}\n}", "func (r repl) ReadLine() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\toldState, err := term.MakeRaw(fd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\terr := term.Restore(fd, oldState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\treturn r.term.ReadLine()\n}", "func ReadFileWithBuffers(path string, currentLine int, beforeLinesAmount int, afterLinesAmount int) (Line, error) {\n\tlastLine := currentLine + afterLinesAmount\n\tfirstLine := currentLine - beforeLinesAmount\n\tif firstLine < 0 {\n\t\tfirstLine = 1\n\t}\n\n\tlines := Line{FirstLine: firstLine}\n\tfile, err := os.Open(path)\n\tdefer file.Close()\n\n\tif err != nil {\n\t\treturn lines, err\n\t}\n\n\tscanner := NewScanner(file)\n\tlineIndex := 1\n\n\tfor scanner.Next() {\n\t\tline := scanner.Get()\n\n\t\tif scanner.Error() != nil {\n\t\t\treturn lines, scanner.Error()\n\t\t}\n\n\t\tif lineIndex >= firstLine && lineIndex < currentLine {\n\t\t\tlines.Before = append(lines.Before, line)\n\t\t}\n\t\tif lineIndex == currentLine {\n\t\t\tlines.Exact = line\n\t\t}\n\t\tif lineIndex > currentLine && lineIndex <= lastLine {\n\t\t\tlines.After = append(lines.After, line)\n\t\t}\n\n\t\tlineIndex++\n\t}\n\n\treturn lines, nil\n}", "func (c *conn) Read(b []byte) (int, error) {\n\tc.ronce.Do(c.sleepLatency)\n\n\tn, err := c.rb.FillThrottle(func(remaining int64) (int64, error) {\n\t\tmax := remaining\n\t\tif l := int64(len(b)); max > l {\n\t\t\tmax = l\n\t\t}\n\n\t\tn, err := c.Conn.Read(b[:max])\n\t\treturn int64(n), err\n\t})\n\tif err != nil && err != io.EOF {\n\t\tlog.Errorf(\"trafficshape: error on throttled read: %v\", err)\n\t}\n\n\treturn int(n), err\n}" ]
[ "0.6840311", "0.68149805", "0.67247534", "0.66606617", "0.66584694", "0.6630793", "0.6623467", "0.64705783", "0.6389367", "0.6387104", "0.6332178", "0.63149166", "0.62792665", "0.62560844", "0.6244909", "0.6233652", "0.6214558", "0.6213266", "0.6182509", "0.6165949", "0.6141132", "0.6110228", "0.60973215", "0.6082099", "0.6061757", "0.6041638", "0.59853315", "0.5914971", "0.591188", "0.5893922", "0.58836424", "0.5873741", "0.58665776", "0.58553404", "0.58071256", "0.5788397", "0.5786785", "0.57866806", "0.57811356", "0.5774407", "0.576376", "0.576167", "0.5747857", "0.57084763", "0.57077545", "0.57033753", "0.5692981", "0.5681745", "0.567106", "0.56578535", "0.56576455", "0.5641454", "0.56320715", "0.56119514", "0.55969054", "0.5595924", "0.5590422", "0.5589981", "0.55785304", "0.55774903", "0.55718935", "0.5561032", "0.555704", "0.5551847", "0.55381763", "0.552267", "0.5516554", "0.5502267", "0.549818", "0.5496867", "0.54934716", "0.5491457", "0.5464798", "0.5463828", "0.5462634", "0.54619884", "0.5460676", "0.54606456", "0.54509985", "0.5449219", "0.5447148", "0.54438156", "0.5443441", "0.5441313", "0.54394215", "0.5436824", "0.54248166", "0.54161257", "0.5415955", "0.540513", "0.5403938", "0.53973126", "0.53855246", "0.5380334", "0.5367822", "0.53664094", "0.5365152", "0.53486824", "0.5341717", "0.5341598", "0.5332587" ]
0.0
-1
Read a line. Return nil on EOF/quit.
func (l *Linenoise) Read(prompt, init string) (string, error) { if !isatty.IsTerminal(uintptr(syscall.Stdin)) { // Not a tty, read from a file or pipe. return l.readBasic() } else if unsupportedTerm() { // Not a terminal we know about, so basic line reading. fmt.Printf(prompt) s, err := l.readBasic() if err == ErrQuit { fmt.Printf("\n") } return s, err } else { // A command line on stdin, our raison d'etre. return l.readRaw(prompt, init) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func readLine(s *bufio.Scanner) (string, error) {\n\tif !s.Scan() {\n\t\tif err := s.Err(); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"error reading line: %s\", err)\n\t\t} else {\n\t\t\treturn \"\", fmt.Errorf(\"unexpected EOF\")\n\t\t}\n\t}\n\tline := s.Text()\n\tif err := checkLine(line); err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid line: %s\", err)\n\t}\n\treturn line, nil\n}", "func (ep *ExpectProcess) ReadLine() string {\n\tep.mu.Lock()\n\tdefer ep.mu.Unlock()\n\tif ep.count > ep.cur {\n\t\tline := ep.lines[ep.cur]\n\t\tep.cur++\n\t\treturn line\n\t}\n\treturn \"\"\n}", "func ReadLine(prompt string) (string, bool) {\n\tvar cprompt *C.char\n\tif len(prompt) != 0 {\n\t\tcprompt = C.CString(prompt)\n\t}\n\tcline := C.readline(cprompt)\n\tif cprompt != nil {\n\t\tC.free(unsafe.Pointer(cprompt))\n\t}\n\tif cline == nil {\n\t\treturn \"\", true\n\t}\n\tline := C.GoString(cline)\n\tC.free(unsafe.Pointer(cline))\n\treturn line, false\n}", "func getLine(in *bufio.Reader, lineNo *int) (string, bool) {\n\t*lineNo++\n\tline, _, err := in.ReadLine()\n\tif err == io.EOF {\n\t\treturn \"\", true\n\t}\n\treturn string(line), false\n}", "func (c *Connection) ReadLine() (string, error) {\n\treturn c.conn.ReadLine()\n}", "func ReadLine(L *lua.LState) int {\n\tn := checkLuaNetClient(L, 1)\n\n\tvar delim byte\n\tif L.GetTop() > 1 {\n\t\td := L.CheckString(2)\n\t\tif len(d) != 1 {\n\t\t\tL.ArgError(2, \"Delim must be string of length 1\")\n\t\t}\n\t\tdelim = byte(d[0])\n\t} else {\n\t\tdelim = '\\n'\n\t}\n\n\treader := bufio.NewReader(n.Conn)\n\tif n.readTimeout > 0 {\n\t\tn.SetReadDeadline(time.Now().Add(n.readTimeout))\n\t}\n\tdata, err := reader.ReadString(delim)\n\tif err != nil {\n\t\tL.Push(lua.LString(data))\n\t\tL.Push(lua.LString(err.Error()))\n\t\treturn 2\n\t}\n\tL.Push(lua.LString(data))\n\tL.Push(lua.LNil)\n\treturn 2\n}", "func (reader *Reader) ReadLine() (line []byte, e error) {\n\tline, e = reader.bufRead.ReadBytes(DefEOL)\n\n\tif e == nil {\n\t\t// remove EOL\n\t\tline = line[:len(line)-1]\n\t}\n\n\treturn\n}", "func (c *Conn) readLine() (string, error) {\n\tif c.server.ReadTimeout != 0 {\n\t\tif err := c.conn.SetReadDeadline(time.Now().Add(c.server.ReadTimeout)); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\treturn c.text.ReadLine()\n}", "func (f *firstLineReader) getLine(timeout time.Duration) (string, error) {\n\tselect {\n\tcase s := <-f.sch:\n\t\treturn s, nil\n\tcase err := <-f.ech:\n\t\treturn err.Error(), err\n\tcase <-time.After(timeout):\n\t\terr := errors.New(\"read timed out\")\n\t\treturn err.Error(), err\n\t}\n}", "func ReadLine(prompt string) (line string, err error) {\n\n\tfmt.Print(prompt)\n\n\tin := bufio.NewReader(os.Stdin)\n\n\tline, err = in.ReadString('\\n')\n\tif err != nil {\n\t\terr = ErrInterrupted\n\t} else if len(line) > 0 {\n\t\t// need to take the end of line back off\n\t\t// using scanner didn't register ctrl-c properly\n\t\tline = strings.TrimRight(line, \"\\n\\r\")\n\t}\n\treturn\n\n}", "func (r *textprotoReader) ReadLine() (string, error) {\n\tline, err := r.readLineSlice()\n\treturn string(line), err\n}", "func (s *Session) readLine() (line string, err error) {\n\tline, err = s.reader.ReadString('\\n')\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t} else if op, ok := err.(*net.OpError); ok && strings.Contains(\n\t\t\top.Err.Error(), \"use of closed network connection\") {\n\t\t} else {\n\t\t\tfmt.Printf(\"Stream reader error (is gpsd running?): %#v\\n\", err)\n\t\t}\n\t}\n\treturn\n}", "func ReadLine(bio *bufio.Reader) ([]byte, error) {\n\tline, isPrefix, err := bio.ReadLine()\n\tif !isPrefix {\n\t\treturn line, err\n\t}\n\n\t// line is too long, read till eol\n\tbuf := append([]byte(nil), line...)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = bio.ReadLine()\n\t\tbuf = append(buf, line...)\n\t}\n\treturn buf, err\n}", "func (c *Client) ReadLine() (line string, err error) {\n\tb, _, err := c.r.ReadLine()\n\tif err == io.EOF {\n\t\treturn\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\tline = string(b)\n\treturn\n}", "func readLine(r io.ReaderAt, offset int64) (s string, err error) {\n\tsr := io.NewSectionReader(r, offset, bufio.MaxScanTokenSize)\n\tsc := bufio.NewScanner(sr)\n\n\tif sc.Scan() {\n\t\ts = sc.Text()\n\t}\n\tif sc.Err() != nil {\n\t\terr = sc.Err()\n\t\treturn\n\t}\n\n\treturn\n}", "func (tb *TextBuf) Line(ln int) []rune {\n\ttb.LinesMu.RLock()\n\tdefer tb.LinesMu.RUnlock()\n\tif ln >= tb.NLines || ln < 0 {\n\t\treturn nil\n\t}\n\treturn tb.Lines[ln]\n}", "func (e *ExportReader) readLine() ([]byte, error) {\n\tline, err := e.buf.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// trim the trailing newline\n\treturn line[:len(line)-1], nil\n}", "func (r *Reader) GetLine(lineNumberOneBased int) *string {\n\tr.lock.Lock()\n\tdefer r.lock.Unlock()\n\n\tif lineNumberOneBased < 1 {\n\t\treturn nil\n\t}\n\tif lineNumberOneBased > len(r.lines) {\n\t\treturn nil\n\t}\n\treturn &r.lines[lineNumberOneBased-1]\n}", "func ReadLine(msg string) (string, error) {\n\tvar s string\n\tPrintfInfo(msg)\n\t_, err := fmt.Scanf(\"%s\", &s)\n\treturn s, err\n}", "func (e *Env) GetLine() (string, error) {\n\t//fmt.Println(\"GetLine\")\n\tif e.fileInfo.curFileScanner == nil {\n\t\t//fmt.Println(\"Getline openNextFile\")\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\tfor !(e.fileInfo.curFileScanner).Scan() {\n\t\t//fmt.Printf(\"Getline scan finished -> openNextFile: Scanner.Err=%v\\n\", e.fileInfo.curFileScanner.Err())\n\t\tif err := e.fileInfo.curFileScanner.Err(); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif len(e.fileInfo.files) == 0 {\n\t\t\t// when read from Stdin\n\t\t\treturn \"\", io.EOF\n\t\t}\n\t\terr := openNextFile(e)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\te.IncFNR()\n\te.IncNR()\n\treturn e.fileInfo.curFileScanner.Text(), nil\n}", "func ReadLine(filePth string, hookfn func([]byte)) error {\n\tf, err := os.Open(filePth)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tbfRd := bufio.NewReader(f)\n\tfor {\n\t\tline, err := bfRd.ReadBytes('\\n')\n\t\thookfn(line) //放在错误处理前面,即使发生错误,也会处理已经读取到的数据。\n\t\tif err != nil { //遇到任何错误立即返回,并忽略 EOF 错误信息\n\t\t\tif err == io.EOF {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (r ReaderInput) ReadLine() (string, error) {\n\treturn (*r.reader).ReadString('\\n')\n}", "func (tr *testTalker) getLine() string {\n\tif len(tr.input) < 1 {\n\t\tpanic(\"getLine(): unexpected call to getLine, got no more input data.\")\n\t}\n\tinput := tr.input[0]\n\ttr.input = tr.input[1:]\n\treturn input\n}", "func (r *lineReader) readLine(ctx context.Context) ([]byte, error) {\n\tvar buf []byte\n\tfor ctx.Err() == nil {\n\t\tline, err := r.r.ReadSlice('\\n')\n\t\tline = utils.BytesCopy(line)\n\t\tif err == nil {\n\t\t\treturn concatBufs(buf, line), err\n\t\t}\n\n\t\tif err == io.EOF {\n\t\t\tbuf = concatBufs(buf, line)\n\t\t\tif len(buf) == 0 {\n\t\t\t\treturn nil, io.EOF\n\t\t\t}\n\t\t\tutils.Sleep(ctx, r.eofSleep)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err == bufio.ErrBufferFull {\n\t\t\treturn concatBufs(buf, line), nil\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn nil, io.ErrClosedPipe\n}", "func ReadIO(in io.Reader) (l *Line, err error) {\n\n s := bufio.NewScanner(in)\n\n // scan once to get the first line\n if s.Scan() == false || s.Err() != nil {\n return nil, s.Err()\n }\n\n l = &Line{data: s.Text()}\n scanIO(l, s)\n\n return l, s.Err()\n}", "func (r repl) ReadLine() (string, error) {\n\tfd := int(os.Stdin.Fd())\n\toldState, err := term.MakeRaw(fd)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer func() {\n\t\terr := term.Restore(fd, oldState)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\treturn r.term.ReadLine()\n}", "func ReadLine(reader io.Reader) ([]byte, error) {\n\tvar line []byte\n\tvar buffer [1]byte\n\tfor {\n\t\tn, err := reader.Read(buffer[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tif n == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tc := buffer[0]\n\t\tif c == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tline = append(line, c)\n\t}\n\treturn bytes.TrimSuffix(line, []byte{'\\r'}), nil\n}", "func (cc *Reader) ReadLine() ([]byte, error) {\n\tfor {\n\t\t// try to find a terminated line in the buffered data already read\n\t\tnlidx := bytes.IndexByte(cc.buf[cc.searchFrom:cc.end], '\\n')\n\t\tif nlidx != -1 {\n\t\t\t// got a complete line\n\t\t\tline := cc.buf[cc.start : cc.searchFrom+nlidx]\n\t\t\tcc.start = cc.searchFrom + nlidx + 1\n\t\t\tcc.searchFrom = cc.start\n\t\t\t// treat \\r\\n as the line terminator if it was present\n\t\t\tif 0 < len(line) && line[len(line)-1] == '\\r' {\n\t\t\t\tline = line[:len(line)-1]\n\t\t\t}\n\t\t\treturn line, nil\n\t\t}\n\n\t\t// are we out of space? we can read more if any of these are true:\n\t\t// 1. cc.start != 0, so we can slide the existing data back\n\t\t// 2. cc.end < len(cc.buf), so we can read data into the end of the buffer\n\t\t// 3. len(cc.buf) < cc.maxSize, so we can grow the buffer\n\t\tif cc.start == 0 && cc.end == len(cc.buf) && len(cc.buf) == cc.maxSize {\n\t\t\treturn nil, ErrReadQ\n\t\t}\n\n\t\tif cc.eof {\n\t\t\treturn nil, io.EOF\n\t\t}\n\n\t\tif len(cc.buf) < cc.maxSize && (len(cc.buf)-(cc.end-cc.start) < cc.initialSize/2) {\n\t\t\t// allocate a new buffer, copy any remaining data\n\t\t\tnewLen := roundUpToPowerOfTwo(len(cc.buf) + 1)\n\t\t\tif newLen > cc.maxSize {\n\t\t\t\tnewLen = cc.maxSize\n\t\t\t} else if newLen < cc.initialSize {\n\t\t\t\tnewLen = cc.initialSize\n\t\t\t}\n\t\t\tnewBuf := make([]byte, newLen)\n\t\t\tcopy(newBuf, cc.buf[cc.start:cc.end])\n\t\t\tcc.buf = newBuf\n\t\t} else if cc.start != 0 {\n\t\t\t// slide remaining data back to the front of the buffer\n\t\t\tcopy(cc.buf, cc.buf[cc.start:cc.end])\n\t\t}\n\t\tcc.end = cc.end - cc.start\n\t\tcc.start = 0\n\n\t\tcc.searchFrom = cc.end\n\t\tn, err := cc.conn.Read(cc.buf[cc.end:])\n\t\tcc.end += n\n\t\tif n != 0 && err == io.EOF {\n\t\t\t// we may have received new \\n-terminated lines, try to parse them\n\t\t\tcc.eof = true\n\t\t} else if err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n}", "func ReadLine(reader io.Reader) (line string, err error) {\n\tbuffer := bytes.NewBuffer(make([]byte, 0, 4096))\n\tp := make([]byte, 1)\n\tfor {\n\t\tvar n int\n\t\tn, err = reader.Read(p)\n\t\tif err != nil || p[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tif n > 0 {\n\t\t\tbuffer.WriteByte(p[0])\n\t\t}\n\t}\n\tdata := buffer.Bytes()\n\tif len(data) > 0 && data[len(data)-1] == '\\r' {\n\t\tdata = data[:len(data)-1]\n\t}\n\treturn string(data), err\n}", "func readLine(bytes []byte, rd io.Reader) ([]byte, []byte, error) {\n\tend, length := -1, len(bytes)\n\tfor i, b := range bytes {\n\t\tif b == '\\r' && i+1 < length && bytes[i+1] == '\\n' { //eof\n\t\t\tend = i\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif end > 0 {\n\t\tline, newBytes := bytes[:end], make([]byte, 0)\n\t\tif end+2 < length {\n\t\t\tnewBytes = bytes[end+2:]\n\t\t}\n\n\t\treturn line, newBytes, nil\n\t}\n\n\tif rd == nil {\n\t\treturn nil, nil, errors.New(\"reader is null\")\n\t}\n\n\tbuff := make([]byte, 1024)\n\treadN, err := rd.Read(buff)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn readLine(append(bytes, buff[0:readN]...), rd)\n}", "func readline() (value string, err error) {\n\tvar valb []byte\n\tvar n int\n\tb := make([]byte, 1)\n\tfor {\n\t\t// read one byte at a time so we don't accidentally read extra bytes\n\t\tn, err = os.Stdin.Read(b)\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif n == 0 || b[0] == '\\n' {\n\t\t\tbreak\n\t\t}\n\t\tvalb = append(valb, b[0])\n\t}\n\n\treturn strings.TrimSuffix(string(valb), \"\\r\"), nil\n}", "func (s *scanner) readline() []byte {\n\tln, err := s.r.ReadBytes('\\n')\n\tif err == io.EOF {\n\t\treturn []byte{'E', 'O', 'F'}\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"ReadBytes failed with %v\", err)\n\t\treturn []byte{}\n\t}\n\treturn ln\n}", "func (t *tube) RecvLine() ([]byte, error) {\n\treturn t.RecvUntil([]byte{t.NewLine()}, true)\n}", "func (r *Reader) Read() (Line, error) {\n\tvar empty Line\n\n\tfor {\n\t\traw, _, err := r.r.ReadLine()\n\t\tif err != nil {\n\t\t\treturn empty, err // including io.EOF\n\t\t}\n\t\traw = bytes.TrimSpace(raw)\n\t\tif len(raw) > 0 {\n\t\t\treturn Parse(raw)\n\t\t}\n\t}\n}", "func readLine(reader *bufio.Reader, buffer *bytes.Buffer) (line string, size int, err error) {\n\tvar (\n\t\tsegment []byte\n\t\tnext bool\n\t)\n\t// if link file to stdin, can block forever here.\n\tfor {\n\t\tif segment, next, err = reader.ReadLine(); err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\terr = errors.New(\"read line failed\")\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif _, err = buffer.Write(segment); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif next {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tsize = buffer.Len()\n\t\t\tline = buffer.String()\n\t\t\t//fix delim\n\t\t\treader.UnreadByte()\n\t\t\treader.UnreadByte()\n\t\t\tvar b []byte\n\t\t\tb, err = reader.ReadBytes('\\n')\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif b[0] == '\\r' {\n\t\t\t\tsize++\n\t\t\t}\n\t\t\tsize++\n\t\t\t// clear buffer\n\t\t\tbuffer.Reset()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (r *Client) ReadLine() (string, error) {\n\treader := bufio.NewReader(r)\n\ts, e := reader.ReadString('\\n')\n\tif e != nil {\n\t\treturn \"\", e\n\t}\n\treturn strings.TrimSuffix(s, \"\\n\"), nil\n}", "func readLine() string {\n\treader := bufio.NewReader(os.Stdin)\n\ttext, _ := reader.ReadString('\\n')\n\ttext = strings.Replace(text, \"\\n\", \"\", -1)\n\treturn text\n}", "func (client *Client) ReadLine() string {\n\tline, err := client.connection.ReadLine()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"<= %v\\n\", line)\n\treturn line\n}", "func (serial_reader *SerialReader) ReadLine() string {\n\tresult := make([]byte, 0)\n\tlastRead := make([]byte, 1)\n\n\t// read byte by byte until the Line Feed character\n\tfor lastRead[0] != LF_CHAR {\n\t\tn, err := serial_reader.Read(lastRead)\n\t\tif (err != nil) || (n != 1) {\n\t\t\tpanic(log.Critical(err))\n\t\t}\n\n\t\tresult = append(result, lastRead[0])\n\t}\n\n\treturn string(result)\n}", "func ReadLine(path string, handler LineHandler) error {\n\tf, err := os.OpenFile(path, os.O_RDONLY, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = readLine(bufio.NewReader(f), handler)\n\tif err1 := f.Close(); err == nil {\n\t\terr = err1\n\t}\n\treturn err\n}", "func GetLine(s string, index int) (string, error) {\n\tlines := GetLines(s)\n\tif index < 0 || index >= len(lines) {\n\t\treturn \"\", errors.New(\"line index out of bounds\")\n\t}\n\treturn lines[index], nil\n}", "func ReadLineClean(rstream *bufio.Reader) (string, error) { // {{{1\n\tline, err := rstream.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tcrIdx := len(line) - 2\n\tif crIdx >= 0 && line[crIdx] == '\\r' {\n\t\treturn line[:crIdx], nil\n\t} else {\n\t\treturn \"\", errors.New(\"Bad format\")\n\t}\n}", "func (d *Decoder) consumeLine() {\n\td.take(notNewline)\n\tif d.at(0) == '\\n' {\n\t\td.advance(1)\n\t\td.line++\n\t}\n\td.reset()\n\td.section = endSection\n}", "func (np NullParser) ParseLine(_ string, _ *location.L) error {\n\treturn nil\n}", "func (c *Chat) ReadChatLine() *LogLineParsed {\n\tif c.logger.readCursor == c.logger.writeCursor {\n\t\treturn nil\n\t}\n\n\tl := &c.logger.ChatLines[c.logger.readCursor]\n\tc.logger.readCursor++\n\tif c.logger.readCursor > numInteralLogLines {\n\t\tc.logger.readCursor -= numInteralLogLines\n\t}\n\n\treturn l\n}", "func Readline(ireader Reader) chan string {\n\treadline := make(chan string, 1)\n\tgo func() {\n\t\tdefer close(readline)\n\t\tfor {\n\t\t\tline, err := ireader.ReadString('\\n')\n\t\t\tif err != nil && line == \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treadline <- line\n\t\t}\n\t}()\n\treturn readline\n}", "func (x *Reader) ReadCompleteLine() (string, error) {\n\tline, err := x.Reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn line, nil\n}", "func Line(prompt string) (string, error) {\n\tins := getInstance()\n\tins.SetPrompt(prompt)\n\treturn ins.Readline()\n}", "func readLine(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix = true\n\t\terr error\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}", "func readLine(bufferedReader *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = bufferedReader.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\n\treturn string(ln), err\n}", "func (rl *Instance) Readline() (_ string, err error) {\n\tfd := int(os.Stdin.Fd())\n\tstate, err := MakeRaw(fd)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// return an error if Restore fails. However we don't want to return\n\t\t// `nil` if there is no error because there might be a CtrlC or EOF\n\t\t// that needs to be returned\n\t\tr := Restore(fd, state)\n\t\tif r != nil {\n\t\t\terr = r\n\t\t}\n\t}()\n\n\tx, _ := rl.getCursorPos()\n\tswitch x {\n\tcase -1:\n\t\tprint(string(leftMost()))\n\tcase 0:\n\t\t// do nothing\n\tdefault:\n\t\tprint(\"\\r\\n\")\n\t}\n\tprint(rl.prompt)\n\n\trl.line = []rune{}\n\trl.viUndoHistory = []undoItem{{line: \"\", pos: 0}}\n\trl.pos = 0\n\trl.histPos = rl.History.Len()\n\trl.modeViMode = vimInsert\n\tatomic.StoreInt64(&rl.delayedSyntaxCount, 0)\n\trl.resetHintText()\n\trl.resetTabCompletion()\n\n\tif len(rl.multisplit) > 0 {\n\t\tr := []rune(rl.multisplit[0])\n\t\trl.readlineInput(r)\n\t\trl.carridgeReturn()\n\t\tif len(rl.multisplit) > 1 {\n\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t} else {\n\t\t\trl.multisplit = []string{}\n\t\t}\n\t\treturn string(rl.line), nil\n\t}\n\n\trl.termWidth = GetTermWidth()\n\trl.getHintText()\n\trl.renderHelpers()\n\n\tfor {\n\t\tgo delayedSyntaxTimer(rl, atomic.LoadInt64(&rl.delayedSyntaxCount))\n\t\trl.viUndoSkipAppend = false\n\t\tb := make([]byte, 1024*1024)\n\t\tvar i int\n\n\t\tif !rl.skipStdinRead {\n\t\t\ti, err = os.Stdin.Read(b)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\trl.termWidth = GetTermWidth()\n\t\t}\n\t\tatomic.AddInt64(&rl.delayedSyntaxCount, 1)\n\n\t\trl.skipStdinRead = false\n\t\tr := []rune(string(b))\n\n\t\tif isMultiline(r[:i]) || len(rl.multiline) > 0 {\n\t\t\trl.multiline = append(rl.multiline, b[:i]...)\n\t\t\tif i == len(b) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !rl.allowMultiline(rl.multiline) {\n\t\t\t\trl.multiline = []byte{}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ts := string(rl.multiline)\n\t\t\trl.multisplit = rxMultiline.Split(s, -1)\n\n\t\t\tr = []rune(rl.multisplit[0])\n\t\t\trl.modeViMode = vimInsert\n\t\t\trl.readlineInput(r)\n\t\t\trl.carridgeReturn()\n\t\t\trl.multiline = []byte{}\n\t\t\tif len(rl.multisplit) > 1 {\n\t\t\t\trl.multisplit = rl.multisplit[1:]\n\t\t\t} else {\n\t\t\t\trl.multisplit = []string{}\n\t\t\t}\n\t\t\treturn string(rl.line), nil\n\t\t}\n\n\t\ts := string(r[:i])\n\t\tif rl.evtKeyPress[s] != nil {\n\t\t\t//rl.clearHelpers() // unessisary clear?\n\n\t\t\tret := rl.evtKeyPress[s](s, rl.line, rl.pos)\n\n\t\t\trl.clearLine()\n\t\t\trl.line = append(ret.NewLine, []rune{}...)\n\t\t\trl.echo()\n\t\t\trl.pos = ret.NewPos\n\n\t\t\tif ret.ClearHelpers {\n\t\t\t\trl.resetHelpers()\n\t\t\t} else {\n\t\t\t\trl.updateHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\t\tif len(ret.HintText) > 0 {\n\t\t\t\trl.hintText = ret.HintText\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\t\t\tif !ret.ForwardKey {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ret.CloseReadline {\n\t\t\t\trl.clearHelpers()\n\t\t\t\treturn string(rl.line), nil\n\t\t\t}\n\t\t}\n\n\t\tswitch b[0] {\n\t\tcase charCtrlC:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", CtrlC\n\n\t\tcase charEOF:\n\t\t\trl.clearHelpers()\n\t\t\treturn \"\", EOF\n\n\t\tcase charCtrlF:\n\t\t\tif !rl.modeTabCompletion {\n\t\t\t\trl.modeAutoFind = true\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlR:\n\t\t\trl.modeAutoFind = true\n\t\t\trl.tcOffset = 0\n\t\t\trl.modeTabCompletion = true\n\t\t\trl.tcDisplayType = TabDisplayMap\n\t\t\trl.tcSuggestions, rl.tcDescriptions = rl.autocompleteHistory()\n\t\t\trl.initTabCompletion()\n\n\t\t\trl.modeTabFind = true\n\t\t\trl.updateTabFind([]rune{})\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase charCtrlU:\n\t\t\trl.clearLine()\n\t\t\trl.resetHelpers()\n\n\t\tcase charTab:\n\t\t\tif rl.modeTabCompletion {\n\t\t\t\trl.moveTabCompletionHighlight(1, 0)\n\t\t\t} else {\n\t\t\t\trl.getTabCompletion()\n\t\t\t}\n\n\t\t\trl.renderHelpers()\n\t\t\trl.viUndoSkipAppend = true\n\n\t\tcase '\\r':\n\t\t\tfallthrough\n\t\tcase '\\n':\n\t\t\tvar suggestions []string\n\t\t\tif rl.modeTabFind {\n\t\t\t\tsuggestions = rl.tfSuggestions\n\t\t\t} else {\n\t\t\t\tsuggestions = rl.tcSuggestions\n\t\t\t}\n\n\t\t\tif rl.modeTabCompletion && len(suggestions) > 0 {\n\t\t\t\tcell := (rl.tcMaxX * (rl.tcPosY - 1)) + rl.tcOffset + rl.tcPosX - 1\n\t\t\t\trl.clearHelpers()\n\t\t\t\trl.resetTabCompletion()\n\t\t\t\trl.renderHelpers()\n\t\t\t\trl.insert([]rune(suggestions[cell]))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trl.carridgeReturn()\n\t\t\treturn string(rl.line), nil\n\n\t\tcase charBackspace, charBackspace2:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.backspaceTabFind()\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.backspace()\n\t\t\t\trl.renderHelpers()\n\t\t\t}\n\n\t\tcase charEscape:\n\t\t\trl.escapeSeq(r[:i])\n\n\t\tdefault:\n\t\t\tif rl.modeTabFind {\n\t\t\t\trl.updateTabFind(r[:i])\n\t\t\t\trl.viUndoSkipAppend = true\n\t\t\t} else {\n\t\t\t\trl.readlineInput(r[:i])\n\t\t\t\tif len(rl.multiline) > 0 && rl.modeViMode == vimKeys {\n\t\t\t\t\trl.skipStdinRead = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//if !rl.viUndoSkipAppend {\n\t\t//\trl.viUndoHistory = append(rl.viUndoHistory, rl.line)\n\t\t//}\n\t\trl.undoAppendHistory()\n\t}\n}", "func UnpackLine(r *bufio.Reader) ([]byte, error) {\n\t// Fast path: a line is fully contained in the buffer.\n\tvar line, err = r.ReadSlice('\\n')\n\n\tif err == bufio.ErrBufferFull {\n\t\t// Slow path: the line spills across multiple buffer fills.\n\t\terr = nil\n\n\t\tline = append([]byte(nil), line...) // Copy as |line| references an internal buffer.\n\t\tvar rest []byte\n\n\t\tif rest, err = r.ReadBytes('\\n'); err == nil {\n\t\t\tline = append(line, rest...)\n\t\t}\n\t}\n\n\tif err == io.EOF && len(line) != 0 {\n\t\t// If we read at least one byte, then an EOF is unexpected (it should\n\t\t// occur only on whole-message boundaries).\n\t\terr = io.ErrUnexpectedEOF\n\t}\n\treturn line, err\n}", "func (q *Question) getLine(prompt, defaultAnswer string, def hasDefault) *Line {\n\tvar ansiLen int\n\n\t// The values by default are set to bold.\n\tif def != _DEFAULT_NO {\n\t\tansiLen = len(setBold) + len(setOff)\n\t}\n\n\tprompt = QuestionPrefix + prompt\n\n\t// Add the value by default\n\tif def == _DEFAULT_SIMPLE {\n\t\tprompt = fmt.Sprintf(\"%s [%s%s%s]\", prompt, setBold, defaultAnswer, setOff)\n\t} else if def == _DEFAULT_MULTIPLE {\n\t\tprompt = fmt.Sprintf(\"%s [%s]\", prompt, defaultAnswer)\n\t}\n\n\t// Add spaces\n\tif strings.HasSuffix(prompt, \"?\") {\n\t\tprompt += \" \"\n\t} else {\n\t\tprompt += \": \"\n\t}\n\n\treturn NewLinePrompt(prompt, ansiLen, nil) // No history.\n}", "func (b *RFCTextReader) ReadLine() (v string, lineType int, err error) {\n\tif b.lastLine {\n\t\terr = io.EOF\n\t\treturn\n\t}\n\tfor !b.lastLine {\n\t\tif v, err = b.reader.ReadString('\\n'); nil != err {\n\t\t\tif err == io.EOF {\n\t\t\t\tb.lastLine = true\n\t\t\t\terr = nil\n\t\t\t} else {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tb.lineno++\n\t\tv = strings.TrimRightFunc(v, unicode.IsSpace)\n\t\tswitch b.mode {\n\t\tcase readModeNormal:\n\t\t\tif spaceCount := isSchemaStart(v); (spaceCount > 3) && (spaceCount < 12) {\n\t\t\t\tv = strings.TrimLeftFunc(v, unicode.IsSpace)\n\t\t\t\tif isSchemaEnd(v) {\n\t\t\t\t\treturn v, LineTypeSchema, nil\n\t\t\t\t}\n\t\t\t\tb.schemaTextSpaceCount = spaceCount\n\t\t\t\tb.mode = readModeSchema\n\t\t\t\tb.schemaTextBuffer = v\n\t\t\t} else {\n\t\t\t\tif chapterText := trapChapter.FindString(v); chapterText != \"\" {\n\t\t\t\t\tb.CurrentChapter = strings.TrimRightFunc(chapterText, unicode.IsSpace)\n\t\t\t\t\tlineType = LineTypeChapter\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\tcase readModeSchema:\n\t\t\tif 0 == len(v) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif trapPageHeader1.MatchString(v) && trapPageHeader2.MatchString(v) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif trapPageFooter.MatchString(v) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tspaceCount := countLeadingSpace(v)\n\t\t\tif spaceCount < b.schemaTextSpaceCount {\n\t\t\t\tlog.Printf(\"WARN: indent ot enough for schema: %v, line=%d\", v, b.lineno)\n\t\t\t}\n\t\t\tv = strings.TrimLeftFunc(v, unicode.IsSpace)\n\t\t\tb.schemaTextBuffer = b.schemaTextBuffer + \" \" + v\n\t\t\tif isSchemaEnd(b.schemaTextBuffer) {\n\t\t\t\tb.mode = readModeNormal\n\t\t\t\tv = b.schemaTextBuffer\n\t\t\t\tlineType = LineTypeSchema\n\t\t\t\treturn\n\t\t\t}\n\t\tdefault:\n\t\t\tlog.Printf(\"ERR: unknown mode: %v\", b.mode)\n\t\t}\n\t}\n\treturn\n}", "func readLine(reader *bufio.Reader) (line string, err error) {\n\tvar part []byte\n\tvar prefix bool\n\n\tbuffer := bytes.NewBuffer(make([]byte, 0))\n\tfor {\n\t\tif part, prefix, err = reader.ReadLine(); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tbuffer.Write(part)\n\t\tif !prefix {\n\t\t\tline = buffer.String()\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func readLine(br *bufio.Reader) ([]byte, error) {\n\tline := make([]byte, 0, 64)\n\n\tfor {\n\t\tpart, err := br.ReadSlice('\\n')\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif bytes.HasSuffix(part, crlf) {\n\t\t\tline = append(line, part[:len(part)-2]...)\n\t\t\tbreak\n\t\t}\n\t\tline = append(line, part...)\n\t}\n\n\treturn line, nil\n}", "func (q *Question) Read(prompt string) (answer string, err error) {\n\tline := q.getLine(prompt, \"\", _DEFAULT_NO)\n\n\tfor {\n\t\tanswer, err = line.Read()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif answer != \"\" {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (socket *Socket) Read() (string, error) {\n\tif socket.IsClosed() {\n\t\treturn \"\", io.EOF\n\t}\n\n\tlineBytes, isPrefix, err := socket.reader.ReadLine()\n\tif isPrefix {\n\t\treturn \"\", errReadQ\n\t}\n\n\t// convert bytes to string\n\tline := string(lineBytes)\n\n\t// read last message properly (such as ERROR/QUIT/etc), just fail next reads/writes\n\tif err == io.EOF {\n\t\tsocket.Close()\n\t}\n\n\tif err == io.EOF && strings.TrimSpace(line) != \"\" {\n\t\t// don't do anything\n\t} else if err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn line, nil\n}", "func execmReaderReadLine(_ int, p *gop.Context) {\n\targs := p.GetArgs(1)\n\tret, ret1 := args[0].(*textproto.Reader).ReadLine()\n\tp.Ret(1, ret, ret1)\n}", "func readLine(reader *bufio.Reader) ([]byte, error) {\n\tline := []byte{}\n\tfor {\n\t\t_line, isPrefix, err := reader.ReadLine()\n\t\tif err != nil {\n\t\t\treturn line, err\n\t\t}\n\t\tline = append(line, _line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn line, nil\n}", "func (o *SearchLine) GetLine() int32 {\n\tif o == nil || o.Line == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Line\n}", "func (t *ReaderTokeniser) ReadLine() ([]string, error) {\n\tfor {\n\t\tif line, lineok := t.tokeniseUntilLine(); lineok {\n\t\t\treturn line, nil\n\t\t}\n\t\tif err := t.fillFromReader(); err != nil {\n\t\t\treturn []string{}, err\n\t\t}\n\t}\n}", "func (e *Error) RawLine() (line string, available bool, outErr error) {\n\tif e.Line <= 0 || e.Filename == \"<string>\" {\n\t\treturn \"\", false, nil\n\t}\n\n\tfilename := e.Filename\n\tif e.Template != nil {\n\t\tfilename = e.Template.set.resolveFilename(e.Template, e.Filename)\n\t}\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\tdefer func() {\n\t\terr := file.Close()\n\t\tif err != nil && outErr == nil {\n\t\t\toutErr = err\n\t\t}\n\t}()\n\n\tscanner := bufio.NewScanner(file)\n\tl := 0\n\tfor scanner.Scan() {\n\t\tl++\n\t\tif l == e.Line {\n\t\t\treturn scanner.Text(), true, nil\n\t\t}\n\t}\n\treturn \"\", false, nil\n}", "func LineReader(r io.Reader) chan string {\n\tch := make(chan string)\n\n\tgo func() {\n\t\tscanner := bufio.NewScanner(r)\n\n\t\tfor scanner.Scan() {\n\t\t\tl := scanner.Text()\n\t\t\tl = strings.TrimSpace(l)\n\t\t\tif len(l) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tch <- l\n\t\t}\n\n\t\tclose(ch)\n\t}()\n\n\treturn ch\n}", "func (in *interp) readLine(line string) ([]interface{}, error) {\n\tif !in.pendingLine.ready() {\n\t\treturn in.readExprLine(line, nil)\n\t}\n\n\tvar s scanner.Scanner\n\tfset := token.NewFileSet()\n\tfile := fset.AddFile(\"\", fset.Base(), len(line))\n\ts.Init(file, []byte(line), nil, 0)\n\n\t_, tok, lit := s.Scan()\n\tswitch tok {\n\tcase token.EOF:\n\t\treturn nil, nil\n\n\tcase token.IMPORT:\n\t\t_, tok, lit = s.Scan()\n\t\tif tok != token.STRING {\n\t\t\treturn nil, errors.New(\"expected string literal\")\n\t\t}\n\t\tpkgpath, err := strconv.Unquote(lit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpkg, err := in.loadPackage(pkgpath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tin.imports = append(in.imports, pkg)\n\t\treturn nil, nil\n\n\tcase token.IDENT:\n\t\tok, err := in.maybeReadAssignment(line, &s, lit, file.Base())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif ok {\n\t\t\treturn nil, nil\n\t\t}\n\t\tfallthrough\n\n\tdefault:\n\t\treturn in.readExprLine(line, nil)\n\t}\n}", "func SimpleReadLine(prompt string, add_history ... bool) (string, error) {\n\tfmt.Printf(prompt)\n\tline, err := Input.ReadString('\\n')\n\tif err == nil {\n\t\tline = strings.TrimRight(line, \"\\r\\n\")\n\t}\n\treturn line, err\n}", "func SimpleReadLine(prompt string, add_history ... bool) (string, error) {\n\tfmt.Printf(prompt)\n\tline, err := Input.ReadString('\\n')\n\tif err == nil {\n\t\tline = strings.TrimRight(line, \"\\r\\n\")\n\t}\n\treturn line, err\n}", "func TestReadLine(t *testing.T) {\n\tvar buf bytes.Buffer\n\ts := &session{}\n\ts.srv = &Server{}\n\ts.br = bufio.NewReader(&buf)\n\n\t// Ensure readLine() returns an EOF error on an empty buffer.\n\t_, err := s.readLine()\n\tif err != io.EOF {\n\t\tt.Errorf(\"readLine() on empty buffer returned err: %v, want EOF\", err)\n\t}\n\n\t// Ensure trailing <CRLF> is stripped.\n\tline := \"FOO BAR BAZ\\r\\n\"\n\tcmd := \"FOO BAR BAZ\"\n\tbuf.Write([]byte(line))\n\toutput, err := s.readLine()\n\tif err != nil {\n\t\tt.Errorf(\"readLine(%v) returned err: %v\", line, err)\n\t} else if output != cmd {\n\t\tt.Errorf(\"readLine(%v) returned %v, want %v\", line, output, cmd)\n\t}\n}", "func ReadFromLine(line string) (ent hosts.Entry, err error) {\n\ttrimmedLine := TrimWhitespace(line)\n\tif isEmptyOrComment(trimmedLine) {\n\t\treturn nil, emptyLineError\n\t}\n\n\tcommentFreeLine := extractCommentFreeLine(trimmedLine)\n\tif isEmptyOrComment(commentFreeLine) {\n\t\treturn nil, emptyLineError\n\t}\n\n\tlineItems := spaceRegexp.Split(commentFreeLine, -1)\n\tif len(lineItems) <= 1 {\n\t\treturn nil, InvalidLineError\n\t}\n\n\tip := net.ParseIP(lineItems[0])\n\tif ip == nil {\n\t\treturn nil, hosts.ErrorInvalidIp\n\t}\n\treturn hosts.NewEntry(ip, lineItems[1:])\n}", "func (c *Config) readLineRaw(prompt string) (string, error) {\n\t_, err := c.stdout.Write([]byte(prompt))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif c.bufioReader == nil {\n\t\tc.bufioReader = bufio.NewReader(c.stdin)\n\t}\n\tline, err := c.bufioReader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn strings.TrimSpace(line), nil\n}", "func (lc *LineCache) GetLine(filePath string, index1 int) (string, error) {\n\tif index1 == 0 { // some linters, e.g. gosec can do it: it really means first line\n\t\tindex1 = 1\n\t}\n\n\tconst index1To0Offset = -1\n\trawLine, err := lc.getRawLine(filePath, index1+index1To0Offset)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(bytes.Trim(rawLine, \"\\r\")), nil\n}", "func (obj *LineFile) readLine(r *bufio.Reader) ([]byte, error) {\n\tvar results []byte\n\thasMore := true\n\tbytes := []byte{}\n\tvar err error\n\tfor hasMore {\n\t\tbytes, hasMore, err = r.ReadLine()\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tif len(bytes) > 0 {\n\t\t\tresults = append(results, bytes...)\n\t\t}\n\t}\n\treturn results, err\n}", "func (tr *terminalReader) Read(p []byte) (n int, err error) {\n\t//Implementations of Read are discouraged from returning a zero byte count\n\t// with a nil error, except when len(p) == 0.\n\tif len(p) == 0 {\n\t\treturn 0, nil\n\t}\n\tif nil == tr.emulator {\n\t\treturn tr.readFromWrappedReader(p)\n\t}\n\treturn tr.emulator.ReadChars(tr.fd, tr.wrappedReader, p)\n}", "func readLine(in *bufio.Reader) ([]string, error) {\n\tfor {\n\t\tline, err := in.ReadString('\\n')\n\t\tif err != nil {\n\t\t\tif len(line) == 0 {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\targs := strings.Fields(line)\n\t\t// skip empty lines and comments\n\t\tif (len(args) == 0) || (args[0][0] == '#') || (args[0][0] == ';') {\n\t\t\tcontinue\n\t\t}\n\t\treturn args, nil\n\t}\n}", "func (v *MailView) GetLine(lineNumber int) (string, error) {\n\treturn v.lines[lineNumber], nil\n}", "func (file *File) SeekLine(lines int64, whence int) (int64, error) {\n\n\t// return error on bad whence\n\tif whence < 0 || whence > 2 {\n\t\treturn file.Seek(0, whence)\n\t}\n\n\tposition, err := file.Seek(0, whence)\n\n\tbuf := make([]byte, BufferLength)\n\tbufLen := 0\n\tlineSep := byte('\\n')\n\tseekBack := lines < 1\n\tlines = int64(math.Abs(float64(lines)))\n\tmatchCount := int64(0)\n\n\t// seekBack ignores first match\n\t// allows 0 to go to begining of current line\n\tif seekBack {\n\t\tmatchCount = -1\n\t}\n\n\tleftPosition := position\n\toffset := int64(BufferLength * -1)\n\n\tfor b := 1; ; b++ {\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif seekBack {\n\n\t\t\t// on seekBack 2nd buffer onward needs to seek\n\t\t\t// past what was just read plus another buffer size\n\t\t\tif b == 2 {\n\t\t\t\toffset *= 2\n\t\t\t}\n\n\t\t\t// if next seekBack will pass beginning of file\n\t\t\t// buffer is 0 to unread position\n\t\t\tif position+int64(offset) <= 0 {\n\t\t\t\tbuf = make([]byte, leftPosition)\n\t\t\t\tposition, err = file.Seek(0, io.SeekStart)\n\t\t\t\tleftPosition = 0\n\t\t\t} else {\n\t\t\t\tposition, err = file.Seek(offset, io.SeekCurrent)\n\t\t\t\tleftPosition = leftPosition - BufferLength\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tbufLen, err = file.Read(buf)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t} else if seekBack && leftPosition == 0 {\n\t\t\terr = io.EOF\n\t\t}\n\n\t\tfor i := 0; i < bufLen; i++ {\n\t\t\tiToCheck := i\n\t\t\tif seekBack {\n\t\t\t\tiToCheck = bufLen - i - 1\n\t\t\t}\n\t\t\tbyteToCheck := buf[iToCheck]\n\n\t\t\tif byteToCheck == lineSep {\n\t\t\t\tmatchCount++\n\t\t\t}\n\n\t\t\tif matchCount == lines {\n\t\t\t\tif seekBack {\n\t\t\t\t\treturn file.Seek(int64(i)*-1, io.SeekCurrent)\n\t\t\t\t}\n\t\t\t\treturn file.Seek(int64(bufLen*-1+i+1), io.SeekCurrent)\n\t\t\t}\n\t\t}\n\t}\n\n\tif err == io.EOF && !seekBack {\n\t\tposition, _ = file.Seek(0, io.SeekEnd)\n\t} else if err == io.EOF && seekBack {\n\t\tposition, _ = file.Seek(0, io.SeekStart)\n\n\t\t// no io.EOF err on SeekLine(0,0)\n\t\tif lines == 0 {\n\t\t\terr = nil\n\t\t}\n\t}\n\n\treturn position, err\n}", "func readLn(path string) (<-chan string, <-chan error, chan<- int) {\n\tout, err, sig, sigv := make(chan string, 64), make(chan error, 1), make(chan int), 0\n\tgo func() {\n\t\tdefer func() {\n\t\t\tif e := recover(); e != nil {\n\t\t\t\terr <- e.(error)\n\t\t\t}\n\t\t\tclose(err)\n\t\t\tclose(out)\n\t\t}()\n\t\tfile, e := os.Open(path)\n\t\tif e != nil {\n\t\t\tpanic(fmt.Errorf(\"can't access %q (%v)\", path, e))\n\t\t}\n\t\tdefer file.Close()\n\t\thandleSig(sig, &sigv)\n\n\t\tln := bufio.NewScanner(file)\n\t\tfor ; sigv == 0 && ln.Scan(); out <- ln.Text() {\n\t\t}\n\t\tif e := ln.Err(); e != nil {\n\t\t\tpanic(fmt.Errorf(\"problem reading %q (%v)\", path, e))\n\t\t}\n\t}()\n\treturn out, err, sig\n}", "func LineReader(r io.Reader) (<-chan string, error) {\n\treturn lineReader(func() (io.Reader, func(), error) { return r, nil, nil })\n}", "func (io *Io) NextLine() string {\n\tvar buffer []byte\n\tfor {\n\t\tline, isPrefix, err := io.reader.ReadLine()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tbuffer = append(buffer, line...)\n\t\tif !isPrefix {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn string(buffer)\n}", "func (p *parser) line() string {\n\tif !p.valid() {\n\t\treturn \"\"\n\t}\n\tl := p.lines[p.idx]\n\tp.idx++\n\treturn l\n}", "func (console *testConsole) Read(p []byte) (int, error) {\n\n\tif console.isClosed() {\n\t\treturn 0, io.EOF\n\t}\n\n\tconsole.bufMx.RLock()\n\tn := copy(p, console.buf)\n\tconsole.bufMx.RUnlock()\n\n\treturn n, nil\n}", "func Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix = true\n\t\terr error\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}", "func (alr *adjustableLimitedReader) Read(p []byte) (n int, err error) {\n\tn, err = alr.R.Read(p)\n\tif err == io.EOF && alr.R.N <= 0 {\n\t\t// return our custom error since io.Reader returns EOF\n\t\terr = LineLimitExceeded\n\t}\n\treturn\n}", "func (std *LineReaderService) Read() (<-chan []byte, error) {\n\tmc := make(chan []byte, 0)\n\n\tstd.pub.Subscribe(mc)\n\n\treturn mc, nil\n}", "func (c *conn) ReadControlLine() (string, error) {\n\tline, partial, err := c.reader.ReadLine()\n\n\tif err != nil {\n\t\treturn string(line), err\n\t}\n\n\tfor partial {\n\t\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\t\treturn string(line), ErrProtocolOpTooBig\n\t\t}\n\n\t\tvar l []byte\n\t\tl, partial, err = c.reader.ReadLine()\n\t\tline = append(line, l...)\n\t\tif err != nil {\n\t\t\treturn string(line), err\n\t\t}\n\t}\n\n\tif len(line) > c.server.Config().Limits.ControlLine {\n\t\treturn string(line), ErrProtocolOpTooBig\n\t}\n\n\treturn string(line), nil\n}", "func (reader *Reader) FetchNextLine(lastline []byte) (line []byte, e error) {\n\tline, e = reader.ReadLine()\n\n\tlastline = append(lastline, DefEOL)\n\tlastline = append(lastline, line...)\n\n\treturn lastline, e\n}", "func (parser *PdfParser) readTextLine() (string, error) {\n\tvar r bytes.Buffer\n\tfor {\n\t\tbb, err := parser.reader.Peek(1)\n\t\tif err != nil {\n\t\t\tcommon.Log.Debug(\"Error %s\", err.Error())\n\t\t\treturn r.String(), err\n\t\t}\n\t\tif (bb[0] != '\\r') && (bb[0] != '\\n') {\n\t\t\tb, _ := parser.reader.ReadByte()\n\t\t\tr.WriteByte(b)\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn r.String(), nil\n}", "func Readln(r *bufio.Reader) (string, error) {\n\tvar (\n\t\tisPrefix bool = true\n\t\terr error = nil\n\t\tline, ln []byte\n\t)\n\tfor isPrefix && err == nil {\n\t\tline, isPrefix, err = r.ReadLine()\n\t\tln = append(ln, line...)\n\t}\n\treturn string(ln), err\n}", "func (l *Linenoise) readBasic() (string, error) {\n\tif l.scanner == nil {\n\t\tl.scanner = bufio.NewScanner(os.Stdin)\n\t}\n\t// scan a line\n\tif !l.scanner.Scan() {\n\t\t// EOF - return quit\n\t\treturn \"\", ErrQuit\n\t}\n\t// check for unexpected errors\n\terr := l.scanner.Err()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\t// get the line string\n\treturn l.scanner.Text(), nil\n}", "func (n *Node) receiveLine(line *mmn.Line) {\n\tswitch true {\n\n\t\tcase line.VersionList != nil:\n\t\t\tn.receiveVersionList(line.VersionList.Versions)\n\n\t\tcase line.Version != nil:\n\t\t\tn.receiveVersion(*line.Version)\n\n\t\tcase line.Cap != nil:\n\t\t\tn.receiveCap(line.Cap.Capabilities)\n\n\t\tcase line.Degraded != nil:\n\t\t\tn.receiveDegraded(*line.Degraded)\n\t}\n}", "func (l *LineReader) ReadOne() ([]string, error) {\n\tDebug(\"LineReader: start with %v\", l)\n\tfor {\n\t\tvar b [1]byte\n\t\tn, err := l.R.Read(b[:])\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tln := l.Line.String()\n\t\t\t\tif ln == \"\" {\n\t\t\t\t\treturn []string{}, nil\n\t\t\t\t}\n\t\t\t\treturn l.C.Complete(ln)\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tDebug(\"LineReader.ReadOne: got %s, %v, %v\", b, n, err)\n\t\tif n == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tswitch b[0] {\n\t\tdefault:\n\t\t\tDebug(\"LineReader.Just add it to line and pipe\")\n\t\t\tl.Line.Write(b[:])\n\t\t\tl.W.Write(b[:])\n\t\tcase 8, 127:\n\t\t\t// We may have found a use for the io stuff, we'll see.\n\t\t\ts := l.Line.String()\n\t\t\tif len(s) > 0 {\n\t\t\t\ts = s[:len(s)-1]\n\t\t\t\tl.Line = bytes.NewBufferString(s)\n\t\t\t\tl.W.Write(b[:])\n\t\t\t}\n\t\tcase '\\n', '\\r':\n\t\t\terr = ErrEOL\n\t\t\tfallthrough\n\t\tcase ' ':\n\t\t\tif b[0] == ' ' {\n\t\t\t\tl.W.Write(b[:])\n\t\t\t}\n\t\t\tln := l.Line.String()\n\t\t\tif ln == \"\" {\n\t\t\t\treturn []string{}, err\n\t\t\t}\n\t\t\ts, _ := l.C.Complete(ln)\n\t\t\t// If there is no match or too many matches,\n\t\t\t// return what is typed so far.\n\t\t\tDebug(\"LineReader ln %v, err %v, s %v\", ln, err, s)\n\t\t\tif len(s) != 1 {\n\t\t\t\ts = []string{ln}\n\t\t\t}\n\t\t\treturn s, err\n\t\tcase '\\t':\n\t\t\tDebug(\"LineReader.Try complete with %s\", l.Line.String())\n\t\t\ts, err := l.C.Complete(l.Line.String())\n\t\t\tDebug(\"LineReader.Complete returns %v, %v\", s, err)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif len(s) < 2 {\n\t\t\t\tDebug(\"Return is %v\", s)\n\t\t\t\treturn s, nil\n\t\t\t}\n\t\t\tif _, err := l.W.Write([]byte(fmt.Sprintf(\"\\n\\r%v\\n\\r%v\", s, l.Line.String()))); err != nil {\n\t\t\t\tlog.Printf(\"Write %v: %v\", s, err)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func ReadLines(r io.Reader) Stream {\n c, _ := r.(io.Closer)\n return &lineStream{bufio: bufio.NewReader(r), maybeCloser: maybeCloser{c: c}}\n}", "func (tb *TextBuf) BytesLine(ln int) []byte {\n\ttb.LinesMu.RLock()\n\tdefer tb.LinesMu.RUnlock()\n\tif ln >= tb.NLines || ln < 0 {\n\t\treturn nil\n\t}\n\treturn tb.LineBytes[ln]\n}", "func GetReadLineFn() ReadLineFnType {\n\treturn readLineFn\n}", "func readString(line string, pos int, quoted bool) (data string, off int, err error) {\n\tinput := line[pos:] // narrow the input to the current position\n\tif quoted {\n\t\tdata, off, err = extractFromQuotes(input)\n\t\toff++ // go after the \"\n\t} else {\n\t\tif off = strings.IndexAny(input, \" \\n\"); off == -1 {\n\t\t\t// Should never happen since line is expected to have a trailing \\n.\n\t\t\tdata = input\n\t\t\toff = len(input)\n\t\t} else {\n\t\t\tdata = input[:off]\n\t\t}\n\t}\n\treturn\n}", "func ReadLineByLine(path string, output chan<- string) {\n\tfile, err := os.Open(path)\n\tdefer file.Close()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\toutput <- scanner.Text()\n\t}\n\n\tclose(output)\n}", "func (b *Buffer) Line(n int) string {\n\tif n >= len(b.lines) {\n\t\treturn \"\"\n\t}\n\treturn string(b.lines[n].data)\n}", "func Readline(prompt string, interfaces ...interface{}) (string, error) {\n\treader := bufio.NewReader(os.Stdin)\n\tfmt.Printf(prompt, interfaces...)\n\tinput, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tinput = strings.Trim(input, \"\\n\\r\")\n\treturn input, nil\n}", "func (o *SearchLine) GetLineOk() (*int32, bool) {\n\tif o == nil || o.Line == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Line, true\n}", "func NextLine() string {\n\tsc.Scan()\n\treturn sc.Text()\n}" ]
[ "0.6570686", "0.6451235", "0.638333", "0.628676", "0.6238831", "0.6168656", "0.61130947", "0.60420555", "0.60133535", "0.5990853", "0.5951626", "0.59446377", "0.59429616", "0.5906366", "0.58516145", "0.5850762", "0.5813327", "0.5811245", "0.577608", "0.57625437", "0.5760141", "0.57471186", "0.57216686", "0.5680117", "0.56779647", "0.56605244", "0.5609335", "0.55975145", "0.55877775", "0.5536015", "0.5531435", "0.5482185", "0.54522157", "0.54182804", "0.5395213", "0.5388264", "0.5369727", "0.5364256", "0.53429615", "0.5340645", "0.53309876", "0.5328593", "0.5306276", "0.53053004", "0.5284564", "0.52257997", "0.52107066", "0.5208666", "0.5201684", "0.51802915", "0.51764035", "0.5162886", "0.5151615", "0.51501", "0.5131137", "0.5119083", "0.50907093", "0.508696", "0.5081648", "0.5080956", "0.50741893", "0.5061085", "0.5054897", "0.5042879", "0.5015996", "0.5015662", "0.5015662", "0.5005057", "0.4968689", "0.4941289", "0.4935175", "0.48997873", "0.48856676", "0.48813775", "0.48543423", "0.4843577", "0.48422474", "0.4820988", "0.4819403", "0.48126242", "0.4806132", "0.4794776", "0.47915363", "0.4785982", "0.47845596", "0.47587526", "0.4753512", "0.47531545", "0.47510138", "0.47431636", "0.4738952", "0.4723547", "0.4703361", "0.46958435", "0.46863934", "0.46829474", "0.46749598", "0.4667792", "0.46629483", "0.46569583" ]
0.5112507
56
Loop calls the provided function in a loop. Exit when the function returns true or when the exit key is pressed. Returns true when the loop function completes, false for early exit.
func (l *Linenoise) Loop(fn func() bool, exitKey rune) bool { // set rawmode for stdin err := l.enableRawMode(syscall.Stdin) if err != nil { log.Printf("enable rawmode error %s\n", err) return false } u := utf8{} rc := false looping := true for looping { // get a rune r := u.getRune(syscall.Stdin, &timeoutZero) if r == exitKey { // the loop has been cancelled rc = false looping = false } else { if fn() { // the loop function has completed rc = true looping = false } } } // restore the terminal mode for stdin l.disableRawMode(syscall.Stdin) return rc }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func loop() bool {\n\tfmt.Printf(\"loop index %d/%d\\r\\n\", loopIndex, maxLoops)\n\ttime.Sleep(500 * time.Millisecond)\n\tloopIndex++\n\treturn loopIndex > maxLoops\n}", "func (c *Coordinator) loop(fn loopFunc, interval time.Duration, reason string) chan struct{} {\n\tdone := make(chan struct{})\n\tgo func() {\n\t\tticker := c.ticker(interval)\n\t\tdefer close(done)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\t// taker or renew old leases\n\t\t\tcase <-ticker():\n\t\t\t\tif err := fn(); err != nil {\n\t\t\t\t\tc.Logger.WithError(err).Errorf(\"Worker %s failed to %s\", c.WorkerId, reason)\n\t\t\t\t}\n\t\t\t// someone called stop and we need to exit.\n\t\t\tcase <-done:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn done\n}", "func Loop(interval time.Duration, f func()) {\n\tsigChan := make(chan os.Signal, 1)\n\tsignal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)\n\n\ttk := time.NewTicker(interval)\n\tdefer tk.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-tk.C:\n\t\t\tf()\n\t\tcase <-sigChan:\n\t\t\tlog.Println(\"shutdown received, stopping loop\")\n\t\t\treturn\n\t\t}\n\t}\n}", "func (r *Repl) Loop() error {\n\tdefer func() {\n\t\tif recover() != nil {\n\t\t\t// interpreter signal or other badness, just abort.\n\t\t\tos.Exit(0)\n\t\t}\n\t}()\n\n\tvar line string\n\tfor {\n\t\ttmp, err := r.readline.Readline()\n\t\tif err == io.EOF {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err != nil && err.Error() == \"Interrupt\" {\n\t\t\tfmt.Println(\"You can press ^D or type \\\"quit\\\", \\\"exit\\\" to exit the shell\")\n\t\t\tline = \"\"\n\t\t\tcontinue\n\t\t}\n\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"+++ Error %#v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tline += tmp\n\n\t\tswitch strings.TrimSpace(line) {\n\t\tcase \"quit\":\n\t\t\tfallthrough\n\t\tcase \"exit\":\n\t\t\tos.Exit(0)\n\t\t}\n\n\t\tval, err := r.builder.Run(line)\n\t\tline = \"\"\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"+++ Error: %v\\n\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tfmt.Println(val)\n\t}\n}", "func Loop(job floc.Job) floc.Job {\n\treturn func(ctx floc.Context, ctrl floc.Control) error {\n\t\tfor {\n\t\t\t// Do not start the job if the execution is finished\n\t\t\tif ctrl.IsFinished() {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// Do the job\n\t\t\terr := job(ctx, ctrl)\n\t\t\tif handledErr := handleResult(ctrl, err); handledErr != nil {\n\t\t\t\treturn handledErr\n\t\t\t}\n\t\t}\n\t}\n}", "func (this *RpcObject) Loop() {\n\tfor this.IsRun {\n\t\tstart := time.Now()\n\t\tthis.ExecuteEvent()\n\t\tdelta := MAX_SLEEP_TIME - time.Now().Sub(start)\n\t\tif delta > 0 {\n\t\t\ttime.Sleep(delta)\n\t\t} else {\n\t\t\truntime.Gosched()\n\t\t}\n\t}\n}", "func (ui *ReplApp) loop() {\n\tsig := make(chan os.Signal)\n\tsignal.Notify(sig, os.Interrupt, syscall.SIGTERM)\n\n\tfor {\n\t\t// get first input from sig, console, or bot\n\t\tvar line string\n\t\tselect {\n\t\tcase <-sig:\n\t\t\treturn\n\n\t\tcase line = <-ui.console.Read():\n\t\t\tif ui.evalLine(line) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\t}\n}", "func Timerloop() bool {\n\tticker := time.NewTicker(5 * time.Second)\n\tc := make(chan struct{})\n\tfor {\n\t\tselect {\n\t\tcase <-c:\n\t\t\treturn false\n\t\tcase t := <-ticker.C:\n\t\t\tfmt.Println(\"tick\", t)\n\t\t\t//timer is on\n\t\t\treturn true\n\t\t}\n\t}\n\n\ttime.Sleep(3 * time.Millisecond)\n\tticker.Stop()\n\t// fmt.Println(\"Ticker stopped\")\n\treturn false\n}", "func (r *REPL) Loop(ctx context.Context) {\n\n\t// Initialize the liner library.\n\tline := liner.NewLiner()\n\tdefer line.Close()\n\tline.SetCtrlCAborts(true)\n\tline.SetMultiLineMode(true)\n\tr.loadHistory(line)\n\n\tif len(r.banner) > 0 {\n\t\tfmt.Fprintln(r.output, r.banner)\n\t}\n\n\tline.SetCompleter(r.complete)\n\nloop:\n\tfor {\n\n\t\tinput, err := line.Prompt(r.getPrompt())\n\n\t\t// prompt on ctrl+d\n\t\tif err == io.EOF {\n\t\t\tgoto exitPrompt\n\t\t}\n\n\t\t// reset on ctrl+c\n\t\tif err == liner.ErrPromptAborted {\n\t\t\tcontinue\n\t\t}\n\n\t\t// exit on unknown error\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(r.output, \"error (fatal):\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tif err := r.OneShot(ctx, input); err != nil {\n\t\t\tswitch err := err.(type) {\n\t\t\tcase stop:\n\t\t\t\tgoto exit\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintln(r.output, err)\n\t\t\t}\n\t\t}\n\n\t\tline.AppendHistory(input)\n\t}\n\nexitPrompt:\n\tfmt.Fprintln(r.output)\n\n\tfor {\n\t\tinput, err := line.Prompt(exitPromptMessage)\n\n\t\t// exit on ctrl+d\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\n\t\t// reset on ctrl+c\n\t\tif err == liner.ErrPromptAborted {\n\t\t\tgoto loop\n\t\t}\n\n\t\t// exit on unknown error\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(r.output, \"error (fatal):\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tswitch strings.ToLower(input) {\n\t\tcase \"\", \"y\", \"yes\":\n\t\t\tgoto exit\n\t\tcase \"n\", \"no\":\n\t\t\tgoto loop\n\t\t}\n\t}\n\nexit:\n\tr.saveHistory(line)\n}", "func (c *Canvas) Run(f func(e interface{}) bool) {\n\tif f == nil {\n\t\tf = func(e interface{}) bool {\n\t\t\tswitch e := e.(type) {\n\t\t\tcase paint.Event:\n\t\t\t\tc.Paint()\n\t\t\tcase key.Event:\n\t\t\t\tswitch e.Code {\n\t\t\t\tcase key.CodeEscape, key.CodeQ:\n\t\t\t\t\tif e.Direction == key.DirPress {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\n\t\t}\n\t}\n\tfor {\n\t\te := c.win.NextEvent()\n\t\tif !f(e) {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (spi *SPI) Loop() bool {\n\treturn spi.mode&THREE_WIRE != 0\n}", "func RepeatFnBool(\n\tctx context.Context,\n\tfn func() bool,\n) <-chan bool {\n\tch := make(chan bool)\n\n\tgo func() {\n\t\tdefer close(ch)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase ch <- fn():\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn ch\n}", "func LoopSync(tk *time.Ticker, f func()) {\n\tsigChan := make(chan os.Signal, 1)\n\tsignal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)\n\n\tfor {\n\t\tselect {\n\t\tcase <-tk.C:\n\t\t\tf()\n\t\tcase <-sigChan:\n\t\t\tlog.Println(\"shutdown received, stopping loop\")\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *Consumer) loop() {\n\tvar stop bool\n\tfor !stop {\n\t\tselect {\n\t\tcase <-c.status: // ...\n\t\tcase <-c.pause: // ...\n\t\tcase <-c.resume: // ...\n\t\tcase <-c.stop: // ...\n\t\tcase resp := <-c.pausedQuery: // ...\n\t\tcase <-c.exit:\n\t\t\tstop = true\n\t\t}\n\t}\n}", "func (a *App) Loop() {\n\tif err := a.gui.MainLoop(); err != nil && err != gocui.ErrQuit {\n\t\tlog.Panicln(err)\n\t}\n}", "func (r *Repl) Loop() error {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tpanic(fmt.Errorf(\"repl.Loop: %v\", err))\n\t\t}\n\t}()\n\n\tvar line string\n\tvar stackKeep int\n\t//var val *mruby.MrbValue\n\n\tparser := mruby.NewParser(r.rubykube.Mrb())\n\tcontext := mruby.NewCompileContext(r.rubykube.Mrb())\n\tcontext.CaptureErrors(true)\n\n\tfor {\n\t\ttmp, err := r.readline.Readline()\n\t\tif err == io.EOF {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err != nil && err.Error() == \"Interrupt\" {\n\t\t\tif line != \"\" {\n\t\t\t\tr.rubykube.NormalPrompt()\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"You can press ^D or type \\\"quit\\\", \\\"exit\\\" to exit the shell\")\n\t\t\t}\n\n\t\t\tline = \"\"\n\t\t\tcontinue\n\t\t}\n\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"+++ Error %#v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tline += tmp + \"\\n\"\n\n\t\tswitch strings.TrimSpace(line) {\n\t\tcase \"quit\":\n\t\t\tfallthrough\n\t\tcase \"exit\":\n\t\t\tos.Exit(0)\n\t\tcase \"help\":\n\t\t\tfmt.Println(\"Please take a look at usage examples\\n\\t\\thttps://github.com/errordeveloper/kubeplay/blob/master/README.md\")\n\t\t}\n\n\t\tif _, err := parser.Parse(line, context); err != nil {\n\t\t\tr.rubykube.MultiLinePrompt()\n\t\t\tcontinue\n\t\t}\n\n\t\t_, stackKeep, err = r.rubykube.RunCode(parser.GenerateCode(), stackKeep)\n\t\tline = \"\"\n\t\tr.rubykube.NormalPrompt()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"+++ Error: %v\\n\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\t//if val.String() != \"\" {\n\t\t//\tfmt.Println(val)\n\t\t//}\n\t}\n}", "func (h *Handler) loop() {\n\tfor {\n\t\tselect {\n\t\tcase reset := <-h.reset:\n\t\t\treset.state\n\t\tcase stop := <-h.loopStop:\n\t\t\tendState := h.stateHandler.Stop()\n\t\t\tstop.resp <- endState\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (w *watcher) checkLoop(ctx context.Context) {\n\tfor atomic.LoadInt32(&w.state) == isRunning {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tw.Close()\n\t\t\tw.dispose()\n\t\t\treturn\n\t\tdefault:\n\t\t\tw.check(ctx)\n\t\t\ttime.Sleep(w.interval)\n\t\t}\n\t}\n}", "func (wd *Watchdog) loop() {\n\tvar t0 int64\nidle:\n\tt0 = <-wd.resets\n\tt0 = wd.pump(t0)\nloop:\n\tt0 = t0 - time.Now().UnixNano()\n\ttime.Sleep(time.Duration(t0))\n\tnow := time.Now().UnixNano()\n\tt0 = wd.pump(now)\n\tif t0 == now {\n\t\twd.timeouts <- true\n\t\tgoto idle\n\t}\n\tgoto loop\n}", "func remoteCmdLoop(ctx *context.T, stdin io.Reader) func() {\n\tdone := make(chan struct{})\n\tgo func() {\n\t\tscanner := bufio.NewScanner(stdin)\n\t\tfor scanner.Scan() {\n\t\t\tif scanner.Text() == \"close\" {\n\t\t\t\tclose(done)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\treturn func() { <-done }\n}", "func winLoop(cfg pixelgl.WindowConfig) {\n\twin, err := pixelgl.NewWindow(cfg)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor !win.Closed() {\n\t\t// For the test, just set the background to black\n\t\twin.Clear(colornames.Black)\n\n\t\t// check if the esc key has been pressed\n\t\tif win.JustPressed(pixelgl.KeyEscape) {\n\t\t\t// exit out of the win.Closed() loop\n\t\t\tbreak\n\t\t}\n\t\twin.Update()\n\t}\n\n\t// When the win.Closed() loop exists, close the `quit` channel\n\tclose(quit)\n}", "func (i *Client) loop() {\n\tfor m := range i.events {\n\t\tgo i.handleEvent(m)\n\t}\n\n\tfmt.Println(\"Done reading events\")\n}", "func (conn *Conn) runLoop() {\n\tfor {\n\t\tselect {\n\t\tcase line := <-conn.in:\n\t\t\tconn.ED.Dispatch(line.Cmd, conn, line)\n\t\tcase <-conn.cLoop:\n\t\t\t// strobe on control channel, bail out\n\t\t\treturn\n\t\t}\n\t}\n}", "func doLoop(ctxCancel context.CancelFunc, begin int, end int, f ForLoop) {\n\n\twg := sync.WaitGroup{}\n\twg.Add(end - begin)\n\n\tfor i := begin; i < end; i++ {\n\t\tgo func(it int) {\n\t\t\tdefer wg.Done()\n\t\t\tdefer defaultRecover()\n\n\t\t\t//function call\n\t\t\tf(it)\n\t\t}(i)\n\t}\n\n\twg.Wait()\n\tctxCancel()\n}", "func Loop(gm Game) (Game, again, error) {\n\tif !gm.isReady() {\n\t\treturn DeadGame(), false, ErrCouldNotStart()\n\t}\n\tgame, more := turn(gm, gm.player1)\n\tif !more {\n\t\treturn game, false, nil\n\t}\n\tg, more := turn(game, game.player2)\n\treturn g, more, nil\n}", "func LevelLoop() bool {\n\treturn !levelComplete\n}", "func LoopContext(ctx context.Context, interval time.Duration, loopFn, cleanupFn func()) {\n\tdefer cleanupFn()\n\n\tfor !ContextDone(ctx) {\n\t\tloopFn()\n\t\tif !DelayContext(ctx, interval) {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (s *Sound) Loop() bool {\n\treturn s.snd.Get(\"loop\").Bool()\n}", "func (v *V2RayPoint) RunLoop() {\n\tgo v.pointloop()\n}", "func Loop(){\n\tfor {\n\t\t\t <-ElectionTimer.C\n\t\t\tif r.Id == r.LeaderId { \n\t\t\t\t\t//r.ResetTimer()\n\t\t\t\t}else{\n\t\t\t\t\tr.CallElection()\t\t\t\t\t\t\t\n\t\t\t\t}\n\t\t}//end of for\t\n}", "func main() {\n\t//forLoop(1)\n\t//forWhile(1)\n\tloop2()\n}", "func forever() {\n\tfor {\n\t\tbreak\n\t}\n}", "func (v *Viewer) MainLoop() error {\n\tif err := v.display(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := keyboard.Open(); err != nil {\n\t\treturn err\n\t}\n\tdefer keyboard.Close()\n\n\tfor {\n\t\tchar, key, err := keyboard.GetKey()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif key == keyboard.KeyEsc || char == 'q' {\n\t\t\tfmt.Print(\"\\033[2J\")\n\t\t\tfmt.Print(\"\\033[0;0H\")\n\t\t\tif v.autoclose {\n\t\t\t\texec.Command(\"osascript\", \"-e\", `tell application \"iTerm\" to tell current tab of current window to close`).Start()\n\t\t\t}\n\t\t\tbreak\n\t\t} else if char == 'n' {\n\t\t\tv.nextDisplay()\n\t\t} else if char == 'p' {\n\t\t\tv.prevDisplay()\n\t\t} else {\n\t\t\tfmt.Printf(\"You pressed: %q\\r\\n\", char)\n\t\t\tfmt.Println(key)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (r *RunloopShortCircuiter) Run() {\n\tfor !r.complated {\n\t\tnextEvent := app.NSApplication_nextEventMatchingMask_untilDate_inMode_dequeue(app.NSApp(),\n\t\t\tevent.NSAnyEventMask, // mask\n\t\t\tdate.NSDate_distantFuture(), // expiration.\n\t\t\trunloop.NSDefaultRunLoopMode, // mode.\n\t\t\ttrue, // flag\n\t\t)\n\t\tif nextEvent == 0 {\n\t\t\tbreak\n\t\t}\n\t\tapp.NSApplication_sendEvent(app.NSApp(), nextEvent)\n\t}\n\tr.complated = false\n}", "func Loop() (err error) {\n\tif commands.Has(INFO_COMMAND) {\n\t\tif err = commands.Execute(INFO_COMMAND); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"%s command not found\", INFO_COMMAND))\n\t\t}\n\t}\n\n\tfmt.Println(\"Type .help for more information\")\n\tfmt.Println()\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfmt.Printf(PROMPT)\n\tfor scanner.Scan() {\n\t\tt := strings.TrimSpace(scanner.Text())\n\t\tif len(t) > 0 {\n\t\t\tif commands.Has(t) {\n\t\t\t\terr = commands.Execute(t)\n\t\t\t} else {\n\t\t\t\terr = eval(t)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tfmt.Println(\"error:\", err)\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(PROMPT)\n\t}\n\n\treturn nil\n}", "func (t *tracer) loop() {\n\tfor {\n\t\tselect {\n\t\tcase <-t.done:\n\t\t\treturn\n\t\tdefault:\n\t\t\tif t.ready() {\n\t\t\t\tt.flush()\n\t\t\t}\n\t\t\ttime.Sleep(time.Second)\n\t\t}\n\t}\n}", "func Loop(args []string, onReady func(*App)) error {\n\tlog.Println(\"=== gallium.Loop ===\")\n\tcerr := newCerr()\n\tdefer cerr.free()\n\n\tapp := App{\n\t\tready: make(chan struct{}),\n\t}\n\n\tgo func() {\n\t\tselect {\n\t\tcase <-app.ready:\n\t\t\tonReady(&app)\n\t\tcase <-time.After(3 * time.Second):\n\t\t\tlog.Fatal(\"Waited for 3 seconds without ready signal\")\n\t\t}\n\t}()\n\n\tappId := apps.add(&app)\n\tC.helper_GalliumLoop(C.int(appId), C.CString(args[0]), &cerr.c)\n\treturn cerr.err()\n}", "func goLooping() {\n\tfmt.Println(\"Standard ForLoop\")\n\tfor index := 0; index < 5; index++ {\n\t\tfmt.Print(index)\n\t}\n\tfmt.Println(\"\")\n\tfmt.Println(\"ForLoop that acts like a while loop\")\n\tcanContinue := true\n\ti := 0\n\tfor canContinue {\n\t\tif i == 4 {\n\t\t\tcanContinue = false\n\t\t}\n\t\tfmt.Print(i)\n\t\ti++\n\t}\n\n\tfmt.Println(\"\")\n\tfmt.Println(\"For break on condition\")\n\tj := 0\n\tfor {\n\t\tif j == 5 {\n\t\t\tbreak\n\t\t}\n\t\tfmt.Print(j)\n\t\tj++\n\t}\n}", "func loop2() {\n\ti := 10\n\tfor {\n\t\tif i < 0 { // check the condition\n\t\t\tbreak\n\t\t}\n\t\tfmt.Print(i, \" \") // do the work()\n\t\ti--\n\t}\n}", "func GameLoop(gs *GameService, c config.Configuration, seed int64) {\n\tsleep, err := time.ParseDuration(c.SleepBetween)\n\tif err != nil {\n\t\treturn\n\t}\n\tfor {\n\t\ttime.Sleep(sleep)\n\t\tif c.MinimumPlayer <= len(gs.players) {\n\t\t\tlog.Print(\"New game started with \", len(gs.players), \" players\")\n\t\t\tboard, winner, err := gs.startGame(c, seed)\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(\"StartGame\", err)\n\t\t\t}\n\t\t\tlog.Print(\"Game ended without errors, winner: \", board.Winner().Name)\n\t\t\tgs.total = scoreboard.Join(gs.total, *board)\n\t\t\tif winner == nil {\n\t\t\t\twinner = board.Winner()\n\t\t\t}\n\t\t\tgs.announceResult(board, winner)\n\t\t\tgs.Clean()\n\t\t}\n\t\tgs.PingPlayers()\n\t}\n}", "func (r *reaper) runLoop() {\n\tfor {\n\t\tselect {\n\t\tcase <-r.sigs:\n\t\t\tprocs, err := ps.Processes()\n\t\t\tif err != nil {\n\t\t\t\tklog.Warningf(\"reaper: failed to get all procs: %v\", err)\n\t\t\t} else {\n\t\t\t\tfor _, p := range procs {\n\t\t\t\t\treaped := waitIfZombieStunnel(p)\n\t\t\t\t\tif reaped {\n\t\t\t\t\t\t// wait for only one process per SIGCHLD received over channel. It\n\t\t\t\t\t\t// doesn't have to be the same process that triggered the\n\t\t\t\t\t\t// particular SIGCHLD (there's no way to tell anyway), the\n\t\t\t\t\t\t// intention is to reap zombies as they come.\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase <-r.stopCh:\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (w *TimedWriter) loop() {\n\tfor {\n\t\tselect {\n\t\tcase <-w.ticker.C:\n\t\t\t// TODO(jsternberg): Add some way to perform logging.\n\t\t\tw.Flush()\n\t\tcase <-w.done:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (p *Probe) loop() {\n\tdefer close(p.stopped)\n\n\t// Do a first probe right away, so that the prober immediately exports results for everything.\n\tp.run()\n\tfor {\n\t\tselect {\n\t\tcase <-p.tick.Chan():\n\t\t\tp.run()\n\t\tcase <-p.ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "func (ad *AWSData) loop() {\n\tad.getAWSInfo()\n\n\tfor ad.running {\n\t\tstart := time.Now()\n\t\tdelayTimer := time.NewTimer(ad.delay)\n\t\tlog.Trace(\"Loop Start\")\n\t\tselect {\n\t\tcase ac := <-ad.hostChange:\n\t\t\tlog.Trace(\"Loop:Changing Host\")\n\t\t\terr := ad.doSetAddress(ac)\n\t\t\tif err != nil {\n\t\t\t\tlog.Warn(\"got error setting DNS:{}, {}\", ac, err)\n\t\t\t}\n\t\tcase <-ad.forceUpdate:\n\t\t\tlog.Trace(\"Loop:AWS force Update\")\n\t\t\tad.getAWSInfo()\n\t\tcase <-delayTimer.C:\n\t\t\tlog.Trace(\"Loop:Hit AWS update timeout\")\n\t\t\terr := ad.getAWSInfo()\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(\"Problems talking to AWS:{}\", err)\n\t\t\t}\n\t\t}\n\t\tdelayTimer.Stop()\n\t\tloopTime := time.Since(start).Seconds()\n\t\tdnsLoopLatency.Observe(loopTime)\n\t\tlog.Trace(\"Loop End: {}s\", fmt.Sprintf(\"%.4f\", loopTime))\n\t}\n\tif ad.running {\n\t\tlog.Warn(\"Exited main loop w/o shuttdown!\")\n\t}\n}", "func (c *Controller) loop() {\n\tdefer c.looper.Done()\n\tfor {\n\t\tselect {\n\t\tcase <-c.finish:\n\t\t\treturn\n\t\tcase noti := <-c.parser.Listen():\n\t\t\tif !noti.OK {\n\t\t\t\tc.fail(noti.JobID, noti.Msg)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc.downloader.DispatchDownloads(noti.JobID)\n\t\tcase noti := <-c.downloader.Listen():\n\t\t\tif !noti.OK {\n\t\t\t\tc.fail(noti.JobID, noti.Msg)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc.boruter.Request(noti.JobID)\n\t\tcase noti := <-c.boruter.Listen():\n\t\t\tif !noti.OK {\n\t\t\t\tc.fail(noti.JobID, noti.Msg)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc.dryader.StartJob(noti.JobID)\n\t\tcase noti := <-c.dryader.Listen():\n\t\t\tif !noti.OK {\n\t\t\t\tc.fail(noti.JobID, noti.Msg)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc.succeed(noti.JobID)\n\t\t}\n\t}\n}", "func mainLoop(ch chan int) {\n\tfmt.Println(\"Looping\")\n\n\tfor {\n\t\tfmt.Println(\"Updating world...\")\n\t\tupdate()\n\t\ttime.Sleep(updateInterval)\n\t}\n\tch <- 0\n}", "func (s *server) loop() {\n\tfor {\n\t\tselect {\n\t\tcase op := <-s.ops:\n\t\t\top()\n\t\t}\n\t}\n}", "func (w *windowImpl) winLoop() {\n\twinShow := time.NewTimer(time.Second)\nouter:\n\tfor {\n\t\tlog.Println(\"mobile window loop iteration\")\n\t\tselect {\n\t\tcase <-w.winClose:\n\t\t\tbreak outer\n\t\tcase f := <-w.runQueue:\n\t\t\tif w.app.gpu == nil {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tf.f()\n\t\t\tif f.done != nil {\n\t\t\t\tf.done <- true\n\t\t\t}\n\t\tcase <-winShow.C:\n\t\t\tif w.app.gpu == nil {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tw.sendWindowEvent(window.Show)\n\t\t}\n\t}\n}", "func main() {\n\tloop:\n\t\tfor {\n\t\t\tswitch {\n\t\t\tcase true:\n\t\t\t\tfmt.Println(\"breaking out...\")\n\t\t\t\tbreak loop\n\t\t\t}\n\t\t}\n\n\tfmt.Println(\"out!\")\n}", "func FuncLoop(name string, tick time.Duration, target func(xray.Ray) error) romeo.Service {\n\treturn &Reloader{Reloadable: loopFuncAdapter{name: name, target: target, tick: tick}}\n}", "func (s *BaseBrainfuckListener) ExitLoop(ctx *LoopContext) {}", "func (module *ScreensaverModule) Loop(srv *Server) {\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(5 * time.Second):\n\t\t\tmodule.Tick(srv)\n\t\t}\n\t}\n}", "func (h *EventHandler) Run() {\n\tticker := time.NewTicker(2 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tif !h.needHandle || h.isDoing {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\th.needHandle = false\n\t\t\th.isDoing = true\n\t\t\t// if has error\n\t\t\tif h.doHandle() {\n\t\t\t\th.needHandle = true\n\t\t\t\ttime.Sleep(2 * time.Second)\n\t\t\t}\n\t\t\th.isDoing = false\n\t\tcase <-h.ctx.Done():\n\t\t\tblog.Infof(\"EventHandler for %s run loop exit\", h.lbID)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (scholten *Scholten) loop() {\n\n\terr := scholten.serv.startListening()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif scholten.root {\n\t\tgo scholten.doWork()\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase basic := <-scholten.basicChan:\n\t\t\t// ALUNO\n\n\t\tcase control := <-scholten.controlChan:\n\t\t\t// ALUNO\n\n\t\tcase termination := <- scholten.terminationChan:\n\t\t\t// ALUNO\n\t\t}\n\t}\n}", "func DrainFn(c <-chan interface{}) {\n\tfor {\n\t\tselect {\n\t\tcase _, ok := <-c:\n\t\t\tif ok == false {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (conn *Conn) runLoop(ctx context.Context) {\n\tfor {\n\t\tselect {\n\t\tcase line := <-conn.in:\n\t\t\tconn.dispatch(line)\n\t\tcase <-ctx.Done():\n\t\t\t// control channel closed, trigger Cancel() to clean\n\t\t\t// things up properly and bail out\n\n\t\t\t// We can't defer this, because Close() waits for it.\n\t\t\tconn.wg.Done()\n\t\t\tconn.Close()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (self *AltaActor) runLoop() {\n\tfor {\n\t\tselect {\n\t\tcase event := <-self.EventChan:\n\t\t\tself.Model.Fsm.FsmEvent(event)\n\n\t\t\t// Save state after each transition\n\t\t\tself.saveModel()\n\t\tcase <-self.ticker.C:\n\t\t\t// FIXME: Use this timer to perform retries when things fail\n\t\t\tlog.Debugf(\"Alta: %s, FSM state: %s, state: %#v\", self.Model.Spec.AltaName,\n\t\t\t\tself.Model.Fsm.FsmState, self)\n\n\t\t\t// If we are stuck in created state, retry it periodically\n\t\t\tif self.Model.Fsm.FsmState == \"created\" {\n\t\t\t\tself.AltaEvent(\"schedule\")\n\t\t\t}\n\t\t}\n\t}\n}", "func (cm *Docker) LoopService() {\n\tvar id string\n\tdefer close(cm.needsRefreshServices)\n\tdefer close(cm.doneService)\n\tfor {\n\t\tselect {\n\t\tcase id = <-cm.needsRefreshServices:\n\t\t\tcm.refreshService(cm.MustGetService(id))\n\t\tcase <-cm.doneService:\n\t\t\treturn\n\t\t}\n\t\truntime.Gosched()\n\t}\n}", "func (b *Builder) loop(ctx context.Context) {\n\terr := b.loadChallenge()\n\tif err != nil {\n\t\tlog.Info(\"challenge not loaded: %s\", err)\n\t}\n\tif err := b.waitOrStop(ctx, b.initDone); err != nil {\n\t\treturn\n\t}\n\t// ensure layer 1 has arrived\n\tif err := b.waitOrStop(ctx, b.layerClock.AwaitLayer(1)); err != nil {\n\t\treturn\n\t}\n\tb.run(ctx)\n}", "func LoopScene() bool {\n\treturn loopDemo\n}", "func (cm *Docker) LoopNode() {\n\tvar id string\n\tdefer close(cm.needsRefreshNodes)\n\tdefer close(cm.doneNode)\n\tfor {\n\t\tselect {\n\t\tcase id = <-cm.needsRefreshNodes:\n\t\t\tcm.refreshNode(cm.MustGetNode(id))\n\t\t\tbreak\n\t\tcase <-cm.doneNode:\n\t\t\treturn\n\t\t}\n\t\truntime.Gosched()\n\t}\n}", "func gameLoop(grid *game.Grid, controls *panel.Controls, status *panel.Status) {\n\tfor {\n\t\tif !paused {\n\t\t\tgrid.NextGeneration()\n\t\t}\n\n\t\t// Clear terminal window before rendering if needed.\n\t\tif clearUI {\n\t\t\tui.Clear()\n\t\t\tclearUI = false\n\t\t}\n\t\tui.Render(grid, controls, status)\n\n\t\t// Limit framerate if needed.\n\t\tif speed != game.Unlimited && !paused {\n\t\t\ttime.Sleep(time.Duration(speed) * time.Millisecond)\n\t\t}\n\t}\n}", "func (s *Sim) Run(stop func(s *Sim) bool) {\n\tfor s.CurrentTick() != math.MaxInt64 && !stop(s) {\n\t\ts.runOneStep()\n\t}\n}", "func Loop(action Action, strategies ...Strategy) error {\n\tfor i := uint(1); ; i++ {\n\t\terr := action()\n\t\tif err == nil {\n\t\t\ti = 0\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, s := range strategies {\n\t\t\tif shouldRetry := s(i, err); !shouldRetry {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n}", "func loop(ch chan int) {\n\n fmt.Println(\"start infinit loop in this go routine\\n\")\n for {\n time.Sleep(time.Second)\n\t}\n\n}", "func (lm *LMutex) lockLoop(timeout time.Duration) bool {\n\tdoneCh, start := make(chan struct{}), time.Now().UTC()\n\tdefer close(doneCh)\n\n\t// We timed out on the previous lock, incrementally wait\n\t// for a longer back-off time and try again afterwards.\n\tfor range newRetryTimerSimple(doneCh) {\n\n\t\t// Try to acquire the lock.\n\t\tif atomic.CompareAndSwapInt64(&lm.state, NOLOCKS, WRITELOCK) {\n\t\t\treturn true\n\t\t} else if time.Now().UTC().Sub(start) >= timeout { // Are we past the timeout?\n\t\t\tbreak\n\t\t}\n\t\t// We timed out on the previous lock, incrementally wait\n\t\t// for a longer back-off time and try again afterwards.\n\t}\n\treturn false\n}", "func (l *Loop) Go(sleep time.Duration) {\n\t// Use an endless event loop\n\tfor {\n\t\t// For each possible event\n\t\tfor _, e := range *l {\n\t\t\t// Check if the event should trigger\n\t\t\tif e.ShouldTrigger() {\n\t\t\t\t// When triggering an event, run it in the background\n\t\t\t\tgo e.Trigger()\n\t\t\t}\n\t\t\t// If the window for an event is in the past, remove it,\n\t\t\t// unless it is a clock-event.\n\t\t}\n\t\t// How long to sleep before checking again\n\t\ttime.Sleep(sleep)\n\t}\n}", "func main() {\n\tfor i:=0;i<10;i++ {\n\t\tgo myfunc(i) //this will call myfunc() as a goroutine\n\t}\n\tvar input string\n\tfmt.Scanln(&input) //waiting on user input so the goroutine finishes and program does not exit as this is the last line of the program.\n\t\n}", "func MainIteration() bool {\n\treturn gobool(C.gtk_main_iteration())\n}", "func mainloop(ticker time.Ticker) {\n\texitSignal := make(chan os.Signal)\n\tsignal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM)\n\t<-exitSignal\n\n\tticker.Stop()\n\tfmt.Println(\"Program Exit\")\n\tos.Exit(0)\n}", "func (self Sound) GetLoop() bool {\n\treturn C.sfSound_getLoop(self.Cref) == 1\n}", "func loop3() {\n\ti := 0\n\tanExpression := true\n\tfor ok := true; ok; ok = anExpression { // checking the condition\n\t\tif i > 10 {\n\t\t\tanExpression = false // change the condition (the loop still working after unfulfilled condition created)\n\t\t}\n\n\t\tfmt.Print(i, \" \") // do the work\n\t\ti++\n\t}\n}", "func (w *windowImpl) winLoop() {\nouter:\n\tfor {\n\t\tselect {\n\t\tcase <-w.winClose:\n\t\t\tbreak outer\n\t\tcase f := <-w.runQueue:\n\t\t\tif w.glw == nil {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tf.f()\n\t\t\tif f.done != nil {\n\t\t\t\tf.done <- true\n\t\t\t}\n\t\tcase <-w.publish:\n\t\t\tif w.glw == nil {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tif !theApp.noScreens {\n\t\t\t\ttheApp.RunOnMain(func() {\n\t\t\t\t\tif !w.Activate() {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tw.glw.SwapBuffers() // note: implicitly does a flush\n\t\t\t\t\t// note: generally don't need this:\n\t\t\t\t\t// gpu.Draw.Clear(true, true)\n\t\t\t\t})\n\t\t\t\tw.publishDone <- struct{}{}\n\t\t\t}\n\t\t}\n\t}\n}", "func main() {\n\tquit := make(chan bool)\n\n\tgo func() {\n\t\ti := 1\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-quit:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tfmt.Printf(\"Running routine - iter %d\\n\", i)\n\t\t\t\ti = i + 1\n\t\t\t\ttime.Sleep(3 * time.Second)\n\t\t\t}\n\t\t}\n\t}()\n\t// something happens ...\n\ttime.Sleep(9 * time.Second)\n\tfmt.Println(\"Ticker Stop - quit <- true\")\n\tquit <- true\n}", "func (c *Controller) Loop() error {\n\ttimer.Delay(500)\n\tserial.Println(\" Write PIN 2 -> HIGH\")\n\tdigital.Write(2, digital.High)\n\ttimer.Delay(500)\n\tdigital.Write(2, digital.Low)\n\tserial.Println(\" Write PIN 2 -> LOW\")\n\treturn nil\n}", "func MainIterationDo(blocking bool) bool {\n\treturn gobool(C.gtk_main_iteration_do(gbool(blocking)))\n}", "func outerloop(screen *ebiten.Image) error {\r\n\r\n //screen.Fill(color.NRGBA{0xff, 0xff, 128, 0xff}) // \r\n screen.Fill(color.NRGBA{154, 158, 5, 0xff}) \r\n\r\n if ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) &&\r\n mouseReleased {\r\n mx, my := ebiten.CursorPosition()\r\n mouseReleased = false\r\n if Button_Click(mx,my) == startButtonCode {\r\n fmt.Printf(\"click button\\n\")\r\n //mode = modeGameScreen\r\n //MG_Init()\r\n buttonRunTimer.set(buttonRunTimer.kButtonStart,30) // 60 is 1 seconds\\\r\n \r\n } else if Button_Click(mx,my) == quitButtonCode {\r\n buttonQuitTimer.set(buttonRunTimer.kButtonStart,30)\r\n }\r\n } else if ! ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {\r\n mouseReleased = true\r\n }\r\n\r\n\r\n if ebiten.IsKeyPressed(ebiten.KeyQ) {\r\n \texitProgram()\r\n }\r\n \r\n Button_Draw(screen)\r\n\r\n // timers are to allow the user to see the button press animation\r\n buttonRunTimer.inc()\r\n if buttonRunTimer.check() {\r\n fmt.Printf(\"buttonRunTimer execcute!\\n\")\r\n buttonRunTimer.reset()\r\n mode = modeGameScreen\r\n MG_Init()\r\n \r\n }\r\n\r\n buttonQuitTimer.inc()\r\n if buttonQuitTimer.check() {\r\n fmt.Printf(\"quit execcute!\\n\")\r\n buttonQuitTimer.reset() // unnecessary but for consistency\r\n exitProgram()\r\n }\r\n\r\n\t//digitsDraw(screen)\r\n\r\n if ebiten.IsKeyPressed(ebiten.KeyJ) && PushKeyOnce(\"J\") {\r\n fmt.Print(\"key J\\n\")\r\n //PushKeyOnce(\"J\")\r\n }\r\n if ebiten.IsKeyPressed(ebiten.KeyU) && PushKeyOnce(\"U\") {\r\n fmt.Print(\"key U\\n\")\r\n //PushKeyOnce(\"U\")\r\n }\r\n ebitenutil.DebugPrint(screen, \"Memory Game \\nin Ebiten\\n\")\r\n return nil\r\n}", "func runWhileFilesystemLives(f func() error, label string, filesystemId string, errorBackoff, successBackoff time.Duration) {\n\tdeathChan := make(chan interface{})\n\tdeathObserver.Subscribe(filesystemId, deathChan)\n\tstillAlive := true\n\tfor stillAlive {\n\t\tselect {\n\t\tcase _ = <-deathChan:\n\t\t\tstillAlive = false\n\t\tdefault:\n\t\t\terr := f()\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\n\t\t\t\t\t\"Error in runWhileFilesystemLives(%s@%s), retrying in %s: %s\",\n\t\t\t\t\tlabel, filesystemId, errorBackoff, err)\n\t\t\t\ttime.Sleep(errorBackoff)\n\t\t\t} else {\n\t\t\t\ttime.Sleep(successBackoff)\n\t\t\t}\n\t\t}\n\t}\n\tdeathObserver.Unsubscribe(filesystemId, deathChan)\n}", "func (w *Watcher) Loop(ctx context.Context) chan *client.Response {\n\tresultChannel := make(chan *client.Response)\n\n\tgo watchLoop(w.EtcdWatcher, ctx, resultChannel)\n\treturn resultChannel\n}", "func (s *Server) loopRun(pc *PeerConn, handler Handler) error {\n\tfor {\n\t\tmsg, err := pc.ReadMsg()\n\t\tswitch err {\n\t\tcase nil:\n\t\tcase io.EOF:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\ts := err.Error()\n\t\t\tif strings.Contains(s, \"closed\") {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"fail to decode the message from '%s': %s\",\n\t\t\t\tpc.RemoteAddr().String(), s)\n\t\t}\n\n\t\tif err = s.Config.HandleMessage(pc, msg, handler); err != nil {\n\t\t\treturn fmt.Errorf(\"fail to handle peer message from '%s': %s\",\n\t\t\t\tpc.RemoteAddr().String(), err)\n\t\t}\n\t}\n}", "func (s *WhileStmt) isDone(env *Env) (done bool) { //todo\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tswitch e.(type) { // error type case\n\t\t\tcase ContinueErr:\n\t\t\t\tdone = false\n\t\t\t\treturn\n\t\t\tcase BreakErr:\n\t\t\t\tdone = true\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tpanic(e)\n\t\t\t}\n\t\t}\n\t}()\n\tfor isTruthy(s.condition.eval(env)) {\n\t\ts.body.execute(env)\n\t}\n\treturn true\n}", "func (n *Peer) Loop() error {\n\tfuncs := map[string]func(io.Reader, <-chan *packet) error{\n\t\t\"ping\": n.pongAfterReadPing,\n\t\t\"pong\": n.readPong,\n\t\t\"inv\": n.readInv,\n\t\t\"headers\": n.readHeaders,\n\t\t\"merkleblock\": n.readMerkle,\n\t\t\"addr\": n.readAddr,\n\t}\n\tpch := n.goReadMessage()\n\tt := time.NewTimer(3 * time.Minute)\n\tfor {\n\t\tdefer func() {\n\t\t\tselect {\n\t\t\tcase <-pch:\n\t\t\tdefault:\n\t\t\t}\n\t\t}()\n\t\tif err := n.resetDeadline(); err != nil {\n\t\t\treturn n.errClose(err)\n\t\t}\n\t\tselect {\n\t\tcase p := <-pch:\n\t\t\tif p.err != nil {\n\t\t\t\treturn n.errClose(p.err)\n\t\t\t}\n\t\t\tlog.Println(p.cmd + \" from \" + n.conn.RemoteAddr().String())\n\t\t\tn.timeout = 0\n\t\t\tf, exist := funcs[p.cmd]\n\t\t\tif !exist {\n\t\t\t\tlog.Printf(\"%s:unknown or unsupported command\", p.cmd)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := f(p.payload, pch); err != nil {\n\t\t\t\tlog.Print(err)\n\t\t\t}\n\t\tcase w := <-wch:\n\t\t\terr := n.writeMessage(w.cmd, w.data)\n\t\t\tw.err <- err\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t\tlog.Print(\"sended \", w.cmd)\n\t\tcase <-t.C:\n\t\t\tif n.timeout++; n.timeout > timeout {\n\t\t\t\treturn errors.New(\"timeout\")\n\t\t\t}\n\t\t\tif err := n.writePing(); err != nil {\n\t\t\t\treturn n.errClose(err)\n\t\t\t}\n\t\t}\n\t\tif !t.Stop() {\n\t\t\t<-t.C\n\t\t}\n\t\tt.Reset(3 * time.Minute)\n\t}\n}", "func (loop *mainLoop) Run() {\n\tloop.running = true\n\n\tfor loop.running {\n\t\tselect {\n\t\t// Send a value over the channel in order to\n\t\t// signal that the loop started.\n\t\tcase loop.initialized <- 1:\n\n\t\t\t// A request to pause the loop is received.\n\t\tcase <-loop.PauseCh:\n\t\t\t// do something or simply send-back a value to\n\t\t\t// the pause channel.\n\t\t\tloop.PauseCh <- 0\n\n\t\t\t// A request to terminate the loop is received.\n\t\tcase <-loop.TerminateCh:\n\t\t\tloop.running = false\n\t\t\tloop.TerminateCh <- 0\n\n\t\t\t// Receive a tick from the ticker.\n\t\tcase <-loop.ticker.C:\n\t\t\t// Initiate the exit procedure.\n\t\t\tapplication.Exit()\n\n\t\t\t// Receive a duration string and create a proper\n\t\t\t// ticker from it.\n\t\tcase durationStr := <-loop.durationCh:\n\t\t\tduration, err := time.ParseDuration(durationStr)\n\t\t\tif err != nil {\n\t\t\t\tpanic(\"Error parsing a duration string.\")\n\t\t\t}\n\t\t\tloop.ticker = time.NewTicker(duration)\n\t\t\tapplication.Logf(\"A new duration received. Running for %s...\", durationStr)\n\t\t}\n\t}\n}", "func RepeatFunc(ctx context.Context, fn func() interface{}) <-chan interface{} {\n\tstream := make(chan interface{})\n\n\tgo func() {\n\t\tdefer close(stream)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase stream <- fn():\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn stream\n}", "func SceneLoop() bool {\n\treturn true\n}", "func (lp *loop) Run() (buffer string, err error) {\n\tfor {\n\t\tvar flag redrawFlag\n\t\tif lp.extractRedrawFull() {\n\t\t\tflag |= fullRedraw\n\t\t}\n\t\tlp.redrawCb(flag)\n\t\tselect {\n\t\tcase event := <-lp.inputCh:\n\t\t\t// Consume all events in the channel to minimize redraws.\n\t\tconsumeAllEvents:\n\t\t\tfor {\n\t\t\t\tlp.handleCb(event)\n\t\t\t\tselect {\n\t\t\t\tcase ret := <-lp.returnCh:\n\t\t\t\t\tlp.redrawCb(finalRedraw)\n\t\t\t\t\treturn ret.buffer, ret.err\n\t\t\t\tdefault:\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase event = <-lp.inputCh:\n\t\t\t\t\t// Continue the loop of consuming all events.\n\t\t\t\tdefault:\n\t\t\t\t\tbreak consumeAllEvents\n\t\t\t\t}\n\t\t\t}\n\t\tcase ret := <-lp.returnCh:\n\t\t\tlp.redrawCb(finalRedraw)\n\t\t\treturn ret.buffer, ret.err\n\t\tcase <-lp.redrawCh:\n\t\t}\n\t}\n}", "func WaitSomething(nRetry int, waitTime time.Duration, fn func() bool) bool {\n\tfor i := 0; i < nRetry-1; i++ {\n\t\tif fn() {\n\t\t\treturn true\n\t\t}\n\n\t\ttime.Sleep(waitTime)\n\t}\n\treturn fn()\n}", "func (cm *Docker) LoopTask() {\n\tvar id string\n\tdefer close(cm.needsRefreshTasks)\n\tdefer close(cm.doneTask)\n\tfor {\n\t\tselect {\n\t\tcase id = <-cm.needsRefreshTasks:\n\t\t\tcm.refreshTask(cm.MustGetTask(id))\n\t\tcase <-cm.doneTask:\n\t\t\treturn\n\t\t}\n\t\truntime.Gosched()\n\t}\n}", "func repeatFn(done <-chan interface{}, fn func() interface{}) <-chan interface{} {\n\tvalueStream := make(chan interface{})\n\tgo func(){\n\t\tdefer close(valueStream)\n\t\t// defer log.Println(\"broek loop\")\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\treturn\n\t\t\tcase valueStream<-fn():\n\t\t\t}\n\t\t}\n\n\t}()\n\treturn valueStream\n}", "func loop(loopbackDevice, image *os.File) error {\n\t_, _, err := syscall.Syscall(\n\t\tsyscall.SYS_IOCTL,\n\t\tloopbackDevice.Fd(),\n\t\tloopSetFd,\n\t\timage.Fd(),\n\t)\n\treturn errnoIsErr(err)\n}", "func (o *KinesisOutput) RunOutputLoop() {\n\tdt := &Dnstap{}\n\tfor frame := range o.outputChannel {\n\t\tif err := proto.Unmarshal(frame, dt); err != nil {\n\t\t\tlog.Fatalf(\"dnstap.TextOutput: proto.Unmarshal() failed: %s\\n\", err)\n\t\t\tcontinue\n\t\t}\n\t\tbuf, ok := o.format(dt)\n\t\tif !ok {\n\t\t\tlog.Fatalf(\"dnstap.TextOutput: text format function failed\\n\")\n\t\t\tcontinue\n\t\t}\n\t\t//Send buf to kinesis\n\t\t_, err := o.client.PutRecord(&kinesis.PutRecordInput{\n\t\t\tData: buf,\n\t\t\tStreamName: aws.String(o.streamname),\n\t\t\tPartitionKey: aws.String(o.PartitionKey),\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"aws client PutRecord() failed: %s\\n\", err)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tclose(o.wait)\n}", "func loop_check(head, tail, term *ListNode) bool {\n\tvar t *ListNode\n\n\tt = head\n\tfor t != tail {\n\t\tif t == term {\n\t\t\treturn true\n\t\t}\n\t\tt = t.Next\n\t}\n\treturn false\n}", "func (b *Bus) eventLoop() {\n\tfor {\n\t\tselect {\n\t\tcase <-b.stop:\n\t\t\treturn\n\t\tcase msg := <-b.recvQueue:\n\t\t\tb.dispatchMessage(msg)\n\t\tcase event := <-b.eventQueue:\n\t\t\tb.dispatchEvent(event)\n\t\t}\n\t}\n}", "func (s *BaseBrainfuckListener) EnterLoop(ctx *LoopContext) {}", "func (u *Ui) Loop() error {\n\t// snake ticker\n\t// channel dec is sent every 5 carrots collected and it decreases interval time\n\tstartInterval := float64(1500)\n\tdec := make(chan bool)\n\treset := make(chan bool)\n\tticker := time.NewTicker(time.Duration(startInterval) * time.Millisecond)\n\tgo func() {\n\t\tdecCounter := 1.0\n\t\tfor {\n\t\t\tselect {\n\t\t\t// accelerate interval frequency / decrease interval time\n\t\t\tcase <-dec:\n\t\t\t\tticker.Stop()\n\t\t\t\tdecCounter += 0.25\n\t\t\t\tticker = time.NewTicker(time.Duration(startInterval/decCounter) * time.Millisecond)\n\t\t\t// send reset every new game. reset sets decCounter back to start\n\t\t\tcase <-reset:\n\t\t\t\tticker.Stop()\n\t\t\t\tdecCounter = 1.0\n\t\t\t\tticker = time.NewTicker(time.Duration(startInterval/decCounter) * time.Millisecond)\n\t\t\t}\n\t\t}\n\t}()\n\t// main loop\n\tvar ops op.Ops\n\tvar tickerSwitch bool\n\tfor {\n\t\tselect {\n\t\tcase e := <-u.w.Events():\n\t\t\tswitch e := e.(type) {\n\t\t\tcase system.DestroyEvent:\n\t\t\t\treturn e.Err\n\t\t\tcase system.FrameEvent:\n\t\t\t\tu.gtx = layout.NewContext(&ops, e)\n\t\t\t\t// had the option to only update the squares that were changed,\n\t\t\t\t// as returned by Update(), but have to redraw everything anyways\n\t\t\t\t// between frame events and caching an image of the lawn and updating\n\t\t\t\t// upon that image would end up being less efficient than simply\n\t\t\t\t// redrawing all of the squares each time\n\t\t\t\tif u.ga.Dead {\n\t\t\t\t\tif u.continueBtn.pressed {\n\t\t\t\t\t\tu.menuBtn.pressed = true\n\t\t\t\t\t\tu.continueBtn.pressed = false\n\t\t\t\t\t\t// locally save name and score data when continue button pressed\n\t\t\t\t\t\tu.updateHs()\n\t\t\t\t\t\t// reset name data\n\t\t\t\t\t\tu.name = \"\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif u.backhighscoresBtn.pressed {\n\t\t\t\t\tu.highscoresBtn.pressed = false\n\t\t\t\t\tu.backhighscoresBtn.pressed = false\n\t\t\t\t}\n\t\t\t\tif u.menuBtn.pressed && !u.highscoresBtn.pressed {\n\t\t\t\t\tif u.backmenuBtn.pressed {\n\t\t\t\t\t\tif !u.titleScreen {\n\t\t\t\t\t\t\tu.menuBtn.pressed = false\n\t\t\t\t\t\t}\n\t\t\t\t\t\tu.backmenuBtn.pressed = false\n\t\t\t\t\t}\n\t\t\t\t\tif u.newgameBtn.pressed {\n\t\t\t\t\t\t// dont start newgame until name is entered\n\t\t\t\t\t\tif u.name != \"\" {\n\t\t\t\t\t\t\tu.ga = engine.NewGame()\n\t\t\t\t\t\t\t// reset snake ticker on newgame\n\t\t\t\t\t\t\treset <- true\n\t\t\t\t\t\t\tu.menuBtn.pressed = false\n\t\t\t\t\t\t\tu.newgameBtn.pressed = false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif u.exitBtn.pressed {\n\t\t\t\t\t\tprint(\"Exiting.\\n\")\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tu.ga.Update()\n\t\t\t\t}\n\t\t\t\tu.full()\n\t\t\t\te.Frame(u.gtx.Ops)\n\t\t\t\tif u.ga.Score%5 != 0 {\n\t\t\t\t\ttickerSwitch = true\n\t\t\t\t}\n\t\t\t\t// update ticker if 5th carrot eaten\n\t\t\t\tif u.ga.Score%5 == 0 && u.ga.Score != 0 && tickerSwitch {\n\t\t\t\t\tdec <- true\n\t\t\t\t\ttickerSwitch = false\n\t\t\t\t}\n\t\t\tcase key.Event:\n\t\t\t\tif !u.ga.Dead && !u.menuBtn.pressed {\n\t\t\t\t\tif ok := u.ga.HandleKey(e.Name); ok {\n\t\t\t\t\t\tu.w.Invalidate()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase system.ClipboardEvent:\n\t\t\t\tu.nameEditor.SetText(e.Text)\n\t\t\t}\n\t\tcase <-ticker.C:\n\t\t\tif !u.menuBtn.pressed {\n\t\t\t\tu.ga.MoveSnakes()\n\t\t\t\tu.w.Invalidate()\n\t\t\t}\n\t\t}\n\t}\n}", "func (v *ViewView) Loop() os.Error {\n\n\tvar player_id string\n\tvar opponent_move string\n\tfor {\n\t\t\n\t\treq := <- v.Request\n\n\t\tswitch req.Command {\n\t\tcase Enable:\n\t\t\t// unfreeze user input/output\n\t\t\t// allow player to give input\n\t\t\tplayer_id = req.Args[0]\n\t\t\tv.enable(player_id)\n\n\t\tcase Get:\n\t\t\tv.Response <- []string{v.get()} // the player's move\n\t\t\t// freeze user input/output\n\n\t\tcase Set:\n\t\t\t// save the other player's move\n\t\t\topponent_move = req.Args[0]\n\n\t\tcase Show:\n\t\t\t// display the updated board\n\t\t\tplayer_id = req.Args[0]\n\t\t\tv.show(player_id, opponent_move)\n\n\t\tcase Done:\n\t\t\toutcome := Outcome(req.Args[0])\n\t\t\tswitch outcome {\n\t\t\tcase Draw:\n\t\t\t\t// show that the game is a tie\n\t\t\t\tv.writeln(\"It's a \" + string(outcome))\n\n\t\t\tdefault:\n\t\t\t\t// show that the other player won\n\t\t\t\tv.writeln(\"Player \" + player_id + \" \" + string(outcome) + \"s\")\n\t\t\t}\n\t\t}\n\n\t}\n\n\treturn nil\n}", "func (fe *FeServiceImpl) StatefulLoop() {\n\tlog.Println(\"Starting stateful loop\")\n\tvar targetState *ControllerCommand\n\tlatestState := make(map[uint64]api.BiosphereState)\n\tinfTicks := time.Tick(10 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase cmd := <-fe.cmdQueue:\n\t\t\tif cmd == nil {\n\t\t\t\tlog.Printf(\"Received nil command\")\n\t\t\t\ttargetState = nil\n\t\t\t\tlatestState = make(map[uint64]api.BiosphereState)\n\t\t\t} else if cmd.getBiosphereStates != nil {\n\t\t\t\tlog.Printf(\"Received getBiosphereStates\")\n\t\t\t\tfrozenState := make(map[uint64]api.BiosphereState)\n\t\t\t\tfor k, v := range latestState {\n\t\t\t\t\tfrozenState[k] = v\n\t\t\t\t}\n\t\t\t\tcmd.getBiosphereStates <- frozenState\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"Received controller command: %v\", cmd)\n\t\t\t\ttargetState = cmd\n\t\t\t\tlatestState[cmd.bsId] = api.BiosphereState_T_RUN\n\t\t\t}\n\t\tcase <-infTicks:\n\t\t\tctx := context.Background()\n\t\t\tfe.applyDelta(ctx, latestState, targetState)\n\t\t}\n\t}\n}", "func (t *Target) Loop(condition usm.Number, body usm.Block) {\n\tif condition == nil {\n\t\tt.WriteStatement(\"for {\\n\")\n\t} else {\n\t\tt.WriteStatement(\"for %v {\\n\", condition)\n\t}\n\tt.Indent(body)\n\tt.WriteStatement(\"}\\n\")\n}", "func loop() {\n\n\tdelta := 0 * time.Nanosecond\n\n\tlast := time.Now()\n\n\tfor true {\n\t\tcur := time.Now()\n\t\tdelta += cur.Sub(last)\n\t\tlast = cur\n\n\t\tfor delta >= 15*time.Millisecond {\n\t\t\tdelta -= time.Millisecond\n\t\t\t//fmt.Println(\"Up\")\n\t\t}\n\t\t//fmt.Println(\"Re\")\n\t}\n\n}", "func do_you_wanna_continue() {\n\tvar input string\n\tfor {\n\t\tfmt.Println(\"Do you wanna exit. (yes|no):\\n\\n\")\n\n\t\tfmt.Scanf(\"%s\", &input)\n\n\t\tif input == \"yes\" || input == \"y\" {\n\t\t\tbreak\n\t\t}\n\t}\n}" ]
[ "0.6949295", "0.6442794", "0.62186843", "0.6109389", "0.6025708", "0.5983033", "0.59712213", "0.59504193", "0.58755404", "0.5874324", "0.5786895", "0.57853717", "0.57385105", "0.5727201", "0.5709851", "0.5637353", "0.56257826", "0.55741024", "0.5458363", "0.5448975", "0.5423755", "0.5372211", "0.5354896", "0.5344653", "0.53417075", "0.5335693", "0.5329481", "0.532223", "0.53153265", "0.5284541", "0.52778476", "0.5267423", "0.52647775", "0.5253104", "0.524274", "0.5241332", "0.5202155", "0.5156393", "0.5153038", "0.5118378", "0.5101752", "0.5096475", "0.5072426", "0.5067664", "0.50570875", "0.5052664", "0.5050355", "0.5047221", "0.5040989", "0.5020541", "0.50071794", "0.49979448", "0.49908477", "0.49887323", "0.49865234", "0.49860016", "0.49788412", "0.49566072", "0.49417627", "0.49381295", "0.49192268", "0.49087074", "0.48954147", "0.48859227", "0.48803106", "0.4879141", "0.4876581", "0.48597765", "0.4858489", "0.48571455", "0.48546124", "0.48526368", "0.48438162", "0.48218715", "0.48017496", "0.47951397", "0.4780676", "0.4777574", "0.47708562", "0.47703117", "0.47617346", "0.47590432", "0.47560334", "0.4753988", "0.47433823", "0.47286472", "0.47219875", "0.47200036", "0.47196528", "0.4718275", "0.47174522", "0.47128245", "0.47035763", "0.47002104", "0.46965048", "0.46960506", "0.46824262", "0.46820742", "0.46794277", "0.46655208" ]
0.80397373
0
Key Code Debugging PrintKeycodes prints scan codes on the screen for debugging/development purposes.
func (l *Linenoise) PrintKeycodes() { fmt.Printf("Linenoise key codes debugging mode.\n") fmt.Printf("Press keys to see scan codes. Type 'quit' at any time to exit.\n") // set rawmode for stdin err := l.enableRawMode(syscall.Stdin) if err != nil { log.Printf("enable rawmode error %s\n", err) return } u := utf8{} var cmd [4]rune running := true for running { // get a rune r := u.getRune(syscall.Stdin, nil) if r == KeycodeNull { continue } // display the character var s string if unicode.IsPrint(r) { s = string(r) } else { switch r { case KeycodeCR: s = "\\r" case KeycodeTAB: s = "\\t" case KeycodeESC: s = "ESC" case KeycodeLF: s = "\\n" case KeycodeBS: s = "BS" default: s = "?" } } fmt.Printf("'%s' 0x%x (%d)\r\n", s, int32(r), int32(r)) // check for quit copy(cmd[:], cmd[1:]) cmd[3] = r if string(cmd[:]) == "quit" { running = false } } // restore the terminal mode for stdin l.disableRawMode(syscall.Stdin) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (scode Scancode) Code() Code {\n\treturn Code(C.SDL_GetKeyFromScancode(C.SDL_Scancode(scode)))\n}", "func wdekeyFromCode(e *sdl.KeyboardEvent) string {\n\t//TODO Implement this\n\treturn \"\"\n}", "func loadPrintable(keys map[rune]kb.Key, keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte, scanCodeMap map[string][]int64) error {\n\tbuf := extract(layoutBuf, \"kPrintableCodeMap\")\n\n\tmatches := printableKeyRE.FindAllStringSubmatch(string(buf), -1)\n\tfor _, m := range matches {\n\t\tdomCode := m[1]\n\n\t\t// ignore domCodes that are duplicates of other unicode characters\n\t\tif domCode == \"INTL_BACKSLASH\" || domCode == \"INTL_HASH\" || strings.HasPrefix(domCode, \"NUMPAD\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tkc, ok := keycodeConverterMap[domCode]\n\t\tif !ok {\n\t\t\tpanic(fmt.Sprintf(\"could not find key %s in keycode map\", domCode))\n\t\t}\n\n\t\tcode := getCode(kc[5])\n\t\tr1, r2 := decodeRune(m[2]), decodeRune(m[3])\n\t\taddKey(keys, r1, kb.Key{\n\t\t\tCode: code,\n\t\t\tKey: string(r1),\n\t\t\tText: string(r1),\n\t\t\tUnmodified: string(r1),\n\t\t\tPrint: true,\n\t\t}, scanCodeMap, true)\n\n\t\t// shifted value is same as non-shifted, so skip\n\t\tif r2 == r1 {\n\t\t\tcontinue\n\t\t}\n\t\t// skip for duplicate keys\n\t\tif r2 == '|' && domCode != \"BACKSLASH\" {\n\t\t\tcontinue\n\t\t}\n\n\t\taddKey(keys, r2, kb.Key{\n\t\t\tCode: code,\n\t\t\tKey: string(r2),\n\t\t\tText: string(r2),\n\t\t\tUnmodified: string(r1),\n\t\t\tShift: true,\n\t\t\tPrint: true,\n\t\t}, scanCodeMap, true)\n\t}\n\n\treturn nil\n}", "func (code Scancode) String() string {\n\treturn C.GoString(C.SDL_GetScancodeName(C.SDL_Scancode(code)))\n}", "func (l* Lexer) Print() {\n fmt.Printf(\"position = %d readPosition = %d ch = %c\", l.position, l.readPosition, l.ch)\n}", "func (key KeyCode) String() string {\n\treturn key.Name()\n}", "func show(keyStr string) {\n\tkeys, err := keybinding.ParseAll(keyStr)\n\tif err != nil {\n\t\tfmt.Println(\"Error parsing\", keyStr, \":\", err)\n\t} else {\n\t\tfmt.Println(\"Key: \", keyStr, \"=\", keys)\n\t}\n}", "func (kl Keylogger) ParseKeycode(keyCode int, keyState uint16) Key {\n\tkey := Key{Empty: false, Keycode: keyCode}\n\n\t// Only one rune has to fit in\n\toutBuf := make([]uint16, 1)\n\n\t// Buffer to store the keyboard state in\n\tkbState := make([]uint8, 256)\n\n\t// Get keyboard layout for this process (0)\n\tkbLayout, _, _ := procGetKeyboardLayout.Call(uintptr(0))\n\n\t// Check if the SHIFT key is pressed\n\tif w32.GetAsyncKeyState(w32.VK_SHIFT)&(1<<15) != 0 {\n\t\tkbState[w32.VK_SHIFT] = 0xFF\n\t}\n\n\t//Check if the CAPS LOCK key is pressed\n\tcapitalState, _, _ := procGetKeyState.Call(uintptr(w32.VK_CAPITAL))\n\tif capitalState != 0 {\n\t\tkbState[w32.VK_CAPITAL] = 0xFF\n\t}\n\n\t//Check if the CTRL key is pressed\n\tif w32.GetAsyncKeyState(w32.VK_CONTROL)&(1<<15) != 0 {\n\t\tkbState[w32.VK_CONTROL] = 0xFF\n\t}\n\n\t//Check if the ALT key is pressed\n\tif w32.GetAsyncKeyState(w32.VK_MENU)&(1<<15) != 0 {\n\t\tkbState[w32.VK_MENU] = 0xFF\n\t}\n\n\t//execute function procToUnicodeEx\n\t//Params: The virtual-key code to be translated, The hardware scan code of the key to be translated,\n\t//A pointer to a 256-byte array that contains the current keyboard state,\n\t//The buffer that receives the translated Unicode character or characters.\n\t//The size, in characters, of the buffer pointed to by the pwszBuff parameter,\n\t//The behavior of the function,\n\t//The input locale identifier used to translate the specified code.\n\t_, _, _ = procToUnicodeEx.Call(\n\t\tuintptr(keyCode),\n\t\tuintptr(0),\n\t\tuintptr(unsafe.Pointer(&kbState[0])),\n\t\tuintptr(unsafe.Pointer(&outBuf[0])),\n\t\tuintptr(1),\n\t\tuintptr(1),\n\t\tuintptr(kbLayout))\n\n\t//from the buffer of the translated Unicode character, it is transformed to Rune\n\tkey.Rune, _ = utf8.DecodeRuneInString(syscall.UTF16ToString(outBuf))\n\n\treturn key\n}", "func Code(w http.ResponseWriter, r *http.Request) {\n\tfilter, queryErr := getFilter(r)\n\tvar response string\n\tif queryErr != nil {\n\t\tresponse = `QUERY ERROR\\n` + queryErr.Error()\n\t} else {\n\t\tdumpcapOut, dumpcapErr := callDumpcap(filter)\n\t\tif dumpcapErr != nil {\n\t\t\tresponse = dumpcapErr.Error()\n\t\t} else {\n\t\t\tresponse = \"(000)\" + strings.SplitN(string(dumpcapOut), \"(000)\", 2)[1]\n\t\t}\n\t}\n\tw.Write([]byte(response + \"\\n\"))\n}", "func (c RekeyClient) DebugShowRekeyStatus(ctx context.Context, sessionID int) (err error) {\n\t__arg := DebugShowRekeyStatusArg{SessionID: sessionID}\n\terr = c.Cli.Call(ctx, \"keybase.1.rekey.debugShowRekeyStatus\", []interface{}{__arg}, nil, 0*time.Millisecond)\n\treturn\n}", "func debugPrint(text string) {\n\tif (debugon) {\n\t\tfmt.Println(text)\n\t}\n}", "func keyHelp(myWin fyne.Window) {\n\tstep1 := \"1.chrome F12\"\n\tstep2 := \"2.source\"\n\tstep3 := \"3.theoplayer.d.js\"\n\tstep4 := \"4.break: \" + services.JSConsole[0]\n\tstep5 := \"5.copy code to console\"\n\tstep6 := \"6.copy to key\"\n\tuiKeyTip := fmt.Sprintf(\"%-28s\\n%-33s\\n%-28s\\n%-25s\\n%-6s\\n%-30s\", step1, step2, step3, step4, step5, step6)\n\tuiKeyDialog := dialog.NewConfirm(\"Get Key\", uiKeyTip, func(res bool) {\n\t\tif res {\n\t\t\tmyWin.Clipboard().SetContent(services.JSConsole[1])\n\t\t}\n\t}, myWin)\n\n\tuiKeyDialog.SetDismissText(\"Cancel\")\n\tuiKeyDialog.SetConfirmText(\"Copy\")\n\tuiKeyDialog.Show()\n}", "func ShowLanguageCodes() {\n\tstr := \"\"\n\tfor _, code := range langCodeSortSeq {\n\t\tnewstr := code + \" | \" + languageDic[code] + \"\\n\"\n\t\tstr += newstr\n\t}\n\tfmt.Println(str)\n}", "func Display(m charset.Decoder) {\n\tspecials := map[rune]string{\n\t\t'\\n': \"LF\",\n\t\t'\\r': \"CR\",\n\t\t'\\f': \"FF\",\n\t\t' ': \"SP\",\n\t\t0x1b: \"ESC\",\n\t\t0x20ac: \" €\",\n\t}\n\tfmt.Printf(\" \")\n\tfor c := 0; c < 8; c++ {\n\t\tfmt.Printf(\"0x%d_ \", c)\n\t}\n\tfmt.Println(\"\")\n\tfor r := 0; r < 0x10; r++ {\n\t\tfmt.Printf(\"0x_%x: \", r)\n\t\tfor c := 0; c < 8; c++ {\n\t\t\tk := byte(c*0x10 + r)\n\t\t\tif v, ok := m[k]; ok {\n\t\t\t\tif s, ok := specials[v]; ok {\n\t\t\t\t\tfmt.Printf(\"%3s \", s)\n\t\t\t\t} else if v >= 0x400 {\n\t\t\t\t\tfmt.Printf(\"%04x \", v)\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Printf(\" %c \", v)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\" \")\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t}\n}", "func dsaKeyPrinter(name string, val *big.Int, buf *bytes.Buffer) {\n buf.WriteString(fmt.Sprintf(\"%16s%s:\", \"\", name))\n for i, b := range val.Bytes() {\n if (i % 15) == 0 {\n buf.WriteString(fmt.Sprintf(\"\\n%20s\", \"\"))\n }\n buf.WriteString(fmt.Sprintf(\"%02x\", b)\n if i != len(val.Bytes())-1 { \n buf.WriteString(\":\")\n }\n }", "func printInPlace(s string) {\n\tfmt.Printf(\"\\033[2K\\r%s\", s)\n}", "func printMap(c map[string]string) {\n\tfor color, hex := range c {\n\t\tfmt.Println(\"Hex code for\", color, \"is\", hex)\n\t}\n}", "func (e *Escp) BarCode(k BarType) *Escp {\n\te.buffer.Write([]byte{0x1B, 0x28, 0x42, byte(k)})\n\treturn e\n}", "func EnumerateDebugRenderableKeys() []string {\n\tkeys := []string{}\n\tdebugMap.Range(func(k, v interface{}) bool {\n\t\tkey, ok := k.(string)\n\t\tif ok {\n\t\t\tkeys = append(keys, key)\n\t\t}\n\t\treturn true\n\t})\n\treturn keys\n}", "func (instanceKey *InstanceKey) StringCode() string {\n\treturn fmt.Sprintf(\"%s:%d\", instanceKey.Hostname, instanceKey.Port)\n}", "func printDebugPage(ctx context.Context) error {\n\ts, err := retrieveDebugPage(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(s)\n\treturn nil\n}", "func (bst *BST) KeyPrinter(v interface{}) string {\n\treturn fmt.Sprintf(\"%v\", v)\n}", "func printMap(c map[string]string) {\n\t// Iterate over a map\n\tfor color, hex := range c {\n\t\tfmt.Println(\"Hex code for\", color, \"is\", hex)\n\t}\n}", "func keyFunc(m sparta.Widget, e interface{}) bool {\n\tev := e.(sparta.KeyEvent)\n\tpress := \"press\"\n\tif ev.Key < 0 {\n\t\tpress = \"release\"\n\t}\n\tr := \"\"\n\tif (ev.Key > 0) && ((ev.Key & sparta.KeyNoChar) == 0) {\n\t\tr = string([]rune{rune(ev.Key)})\n\t}\n\tif len(r) > 0 {\n\t\tfmt.Fprintf(os.Stdout, \"Ev:%s\\t%s\\tVal:%s\\tSt:%d\\tX:%d\\tY:%d\\n\", sparta.KeyEv, press, r, ev.State, ev.Loc.X, ev.Loc.Y)\n\t} else {\n\t\tfmt.Fprintf(os.Stdout, \"Ev:%s\\t%s\\tVal:%d\\tSt:%d\\tX:%d\\tY:%d\\n\", sparta.KeyEv, press, ev.Key, ev.State, ev.Loc.X, ev.Loc.Y)\n\t}\n\treturn false\n}", "func (consensus *Consensus) DebugPrintPublicKeys() {\n\tfor _, k := range consensus.PublicKeys {\n\t\tstr := fmt.Sprintf(\"%s\", k)\n\t\tutils.GetLogInstance().Debug(\"pk:\", \"string\", str)\n\t}\n\n\tutils.GetLogInstance().Debug(\"PublicKeys:\", \"#\", len(consensus.PublicKeys))\n}", "func (k Key) String() string {\n\tswitch k {\n\tcase KeyA:\n\t\treturn \"A\"\n\tcase KeyB:\n\t\treturn \"B\"\n\tcase KeyC:\n\t\treturn \"C\"\n\tcase KeyD:\n\t\treturn \"D\"\n\tcase KeyE:\n\t\treturn \"E\"\n\tcase KeyF:\n\t\treturn \"F\"\n\tcase KeyG:\n\t\treturn \"G\"\n\tcase KeyH:\n\t\treturn \"H\"\n\tcase KeyI:\n\t\treturn \"I\"\n\tcase KeyJ:\n\t\treturn \"J\"\n\tcase KeyK:\n\t\treturn \"K\"\n\tcase KeyL:\n\t\treturn \"L\"\n\tcase KeyM:\n\t\treturn \"M\"\n\tcase KeyN:\n\t\treturn \"N\"\n\tcase KeyO:\n\t\treturn \"O\"\n\tcase KeyP:\n\t\treturn \"P\"\n\tcase KeyQ:\n\t\treturn \"Q\"\n\tcase KeyR:\n\t\treturn \"R\"\n\tcase KeyS:\n\t\treturn \"S\"\n\tcase KeyT:\n\t\treturn \"T\"\n\tcase KeyU:\n\t\treturn \"U\"\n\tcase KeyV:\n\t\treturn \"V\"\n\tcase KeyW:\n\t\treturn \"W\"\n\tcase KeyX:\n\t\treturn \"X\"\n\tcase KeyY:\n\t\treturn \"Y\"\n\tcase KeyZ:\n\t\treturn \"Z\"\n\tcase KeyAlt:\n\t\treturn \"Alt\"\n\tcase KeyAltLeft:\n\t\treturn \"AltLeft\"\n\tcase KeyAltRight:\n\t\treturn \"AltRight\"\n\tcase KeyArrowDown:\n\t\treturn \"ArrowDown\"\n\tcase KeyArrowLeft:\n\t\treturn \"ArrowLeft\"\n\tcase KeyArrowRight:\n\t\treturn \"ArrowRight\"\n\tcase KeyArrowUp:\n\t\treturn \"ArrowUp\"\n\tcase KeyBackquote:\n\t\treturn \"Backquote\"\n\tcase KeyBackslash:\n\t\treturn \"Backslash\"\n\tcase KeyBackspace:\n\t\treturn \"Backspace\"\n\tcase KeyBracketLeft:\n\t\treturn \"BracketLeft\"\n\tcase KeyBracketRight:\n\t\treturn \"BracketRight\"\n\tcase KeyCapsLock:\n\t\treturn \"CapsLock\"\n\tcase KeyComma:\n\t\treturn \"Comma\"\n\tcase KeyContextMenu:\n\t\treturn \"ContextMenu\"\n\tcase KeyControl:\n\t\treturn \"Control\"\n\tcase KeyControlLeft:\n\t\treturn \"ControlLeft\"\n\tcase KeyControlRight:\n\t\treturn \"ControlRight\"\n\tcase KeyDelete:\n\t\treturn \"Delete\"\n\tcase KeyDigit0:\n\t\treturn \"Digit0\"\n\tcase KeyDigit1:\n\t\treturn \"Digit1\"\n\tcase KeyDigit2:\n\t\treturn \"Digit2\"\n\tcase KeyDigit3:\n\t\treturn \"Digit3\"\n\tcase KeyDigit4:\n\t\treturn \"Digit4\"\n\tcase KeyDigit5:\n\t\treturn \"Digit5\"\n\tcase KeyDigit6:\n\t\treturn \"Digit6\"\n\tcase KeyDigit7:\n\t\treturn \"Digit7\"\n\tcase KeyDigit8:\n\t\treturn \"Digit8\"\n\tcase KeyDigit9:\n\t\treturn \"Digit9\"\n\tcase KeyEnd:\n\t\treturn \"End\"\n\tcase KeyEnter:\n\t\treturn \"Enter\"\n\tcase KeyEqual:\n\t\treturn \"Equal\"\n\tcase KeyEscape:\n\t\treturn \"Escape\"\n\tcase KeyF1:\n\t\treturn \"F1\"\n\tcase KeyF2:\n\t\treturn \"F2\"\n\tcase KeyF3:\n\t\treturn \"F3\"\n\tcase KeyF4:\n\t\treturn \"F4\"\n\tcase KeyF5:\n\t\treturn \"F5\"\n\tcase KeyF6:\n\t\treturn \"F6\"\n\tcase KeyF7:\n\t\treturn \"F7\"\n\tcase KeyF8:\n\t\treturn \"F8\"\n\tcase KeyF9:\n\t\treturn \"F9\"\n\tcase KeyF10:\n\t\treturn \"F10\"\n\tcase KeyF11:\n\t\treturn \"F11\"\n\tcase KeyF12:\n\t\treturn \"F12\"\n\tcase KeyHome:\n\t\treturn \"Home\"\n\tcase KeyInsert:\n\t\treturn \"Insert\"\n\tcase KeyMeta:\n\t\treturn \"Meta\"\n\tcase KeyMetaLeft:\n\t\treturn \"MetaLeft\"\n\tcase KeyMetaRight:\n\t\treturn \"MetaRight\"\n\tcase KeyMinus:\n\t\treturn \"Minus\"\n\tcase KeyNumLock:\n\t\treturn \"NumLock\"\n\tcase KeyNumpad0:\n\t\treturn \"Numpad0\"\n\tcase KeyNumpad1:\n\t\treturn \"Numpad1\"\n\tcase KeyNumpad2:\n\t\treturn \"Numpad2\"\n\tcase KeyNumpad3:\n\t\treturn \"Numpad3\"\n\tcase KeyNumpad4:\n\t\treturn \"Numpad4\"\n\tcase KeyNumpad5:\n\t\treturn \"Numpad5\"\n\tcase KeyNumpad6:\n\t\treturn \"Numpad6\"\n\tcase KeyNumpad7:\n\t\treturn \"Numpad7\"\n\tcase KeyNumpad8:\n\t\treturn \"Numpad8\"\n\tcase KeyNumpad9:\n\t\treturn \"Numpad9\"\n\tcase KeyNumpadAdd:\n\t\treturn \"NumpadAdd\"\n\tcase KeyNumpadDecimal:\n\t\treturn \"NumpadDecimal\"\n\tcase KeyNumpadDivide:\n\t\treturn \"NumpadDivide\"\n\tcase KeyNumpadEnter:\n\t\treturn \"NumpadEnter\"\n\tcase KeyNumpadEqual:\n\t\treturn \"NumpadEqual\"\n\tcase KeyNumpadMultiply:\n\t\treturn \"NumpadMultiply\"\n\tcase KeyNumpadSubtract:\n\t\treturn \"NumpadSubtract\"\n\tcase KeyPageDown:\n\t\treturn \"PageDown\"\n\tcase KeyPageUp:\n\t\treturn \"PageUp\"\n\tcase KeyPause:\n\t\treturn \"Pause\"\n\tcase KeyPeriod:\n\t\treturn \"Period\"\n\tcase KeyPrintScreen:\n\t\treturn \"PrintScreen\"\n\tcase KeyQuote:\n\t\treturn \"Quote\"\n\tcase KeyScrollLock:\n\t\treturn \"ScrollLock\"\n\tcase KeySemicolon:\n\t\treturn \"Semicolon\"\n\tcase KeyShift:\n\t\treturn \"Shift\"\n\tcase KeyShiftLeft:\n\t\treturn \"ShiftLeft\"\n\tcase KeyShiftRight:\n\t\treturn \"ShiftRight\"\n\tcase KeySlash:\n\t\treturn \"Slash\"\n\tcase KeySpace:\n\t\treturn \"Space\"\n\tcase KeyTab:\n\t\treturn \"Tab\"\n\t}\n\treturn \"\"\n}", "func loadNonPrintable(keys map[rune]kb.Key, keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte, scanCodeMap map[string][]int64) error {\n\tbuf := extract(layoutBuf, \"kNonPrintableCodeMap\")\n\tmatches := nonPrintableKeyRE.FindAllStringSubmatch(string(buf), -1)\n\tfor _, m := range matches {\n\t\tcode, key := m[1], m[2]\n\n\t\t// get code, key definitions\n\t\tdc, ok := keycodeConverterMap[code]\n\t\tif !ok {\n\t\t\tpanic(fmt.Sprintf(\"no dom code definition for %s\", code))\n\t\t}\n\t\tdk, ok := domKeyMap[key]\n\t\tif !ok {\n\t\t\tpanic(fmt.Sprintf(\"no dom key definition for %s\", key))\n\t\t}\n\n\t\t// some scan codes do not have names defined, so use key name\n\t\tc := dk[0]\n\t\tif dc[5] != \"NULL\" {\n\t\t\tc = getCode(dc[5])\n\t\t}\n\n\t\t// convert rune\n\t\tr, err := strconv.ParseInt(dk[2], 0, 32)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\taddKey(keys, rune(r), kb.Key{\n\t\t\tCode: c,\n\t\t\tKey: dk[0],\n\t\t}, scanCodeMap, false)\n\t}\n\n\treturn nil\n}", "func downKey(key rune) error {\n\tvar vkey rune\n\tscanCode, ok := Scan[key]\n\tif ok {\n\t\tkey = rune(scanCode.Virtual)\n\t\tvkey = rune(scanCode.Scan)\n\t\t// log.Printf(\"Key: %s, Virtual: %v, Scan:%v\\n\", scanCode.Name, key, vkey)\n\t\tif scanCode.Name == \".\" {\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t}\n\t} else {\n\t\tvkey = key + 0x80\n\t}\n\t// for some reason applications miss periods, pause before entering\n\n\t_, _, err := keyEventDLL.Call(uintptr(key), uintptr(vkey), 0, 0)\n\t// error return needs to be corrected before here because its always filled\n\t// even if there is no error\n\treturn err\n}", "func printMap(m map[string]string) {\n\tfor color, hex := range m { //key, value\n\t\tfmt.Println(\"Hex code for\", color, \"is\", hex)\n\t}\n}", "func skp(context *Context) {\n x := context.opcode & 0x0F00 >> 8\n if context.window.IsKeyPressed(HexKey(context.cpu.v[x])) {\n context.cpu.pc += 2\n }\n context.cpu.pc += 2\n}", "func Printable(i int) bool { return i >= 32 && i <= 126 }", "func printCodeSnippet(issue *issue.Issue) string {\n\tstart, end := parseLine(issue.Line)\n\tscanner := bufio.NewScanner(strings.NewReader(issue.Code))\n\tvar buf bytes.Buffer\n\tline := start\n\tfor scanner.Scan() {\n\t\tcodeLine := scanner.Text()\n\t\tif strings.HasPrefix(codeLine, strconv.Itoa(line)) && line <= end {\n\t\t\tcodeLine = \" > \" + codeLine + \"\\n\"\n\t\t\tline++\n\t\t} else {\n\t\t\tcodeLine = \" \" + codeLine + \"\\n\"\n\t\t}\n\t\tbuf.WriteString(codeLine)\n\t}\n\treturn buf.String()\n}", "func PrintLicenseInfo(key string) error {\n\tl, err := GetLicenseInfo(strings.ToLower(key))\n\n\t// TODO:: err type\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"key: %s\\n\", l.Key)\n\tfmt.Printf(\"id: %s\\n\", l.SpdxID)\n\tfmt.Printf(\"url: %s\\n\", l.LicenseURL)\n\n\tfmt.Printf(\"\\ndescription:\\n%s\\n\", l.Description)\n\n\tfmt.Printf(\"\\nimplementation:\\n%s\\n\", l.Implementation)\n\n\tprint(\"\\npermissions:\\n\")\n\tfor _, c := range l.Permissions {\n\t\tfmt.Printf(\n\t\t\t\" %s %s\\n\",\n\t\t\tcolor.NewAtt(text_color.HiGreen).ColorString(string(IconCheck)),\n\t\t\tc,\n\t\t)\n\t}\n\n\tprint(\"\\nlimitations:\\n\")\n\tfor _, c := range l.Limitations {\n\t\tfmt.Printf(\n\t\t\t\" %s %s\\n\",\n\t\t\tcolor.NewAtt(text_color.HiRed).ColorString(string(IconCross)),\n\t\t\tc,\n\t\t)\n\t}\n\n\tprint(\"\\nconditions:\\n\")\n\tfor _, c := range l.Conditions {\n\t\tfmt.Printf(\n\t\t\t\" %s %s\\n\",\n\t\t\tcolor.NewAtt(text_color.HiBlue).ColorString(string(IconInfo)),\n\t\t\tc,\n\t\t)\n\t}\n\n\tprint(\"\\n\")\n\treturn nil\n}", "func (c testCEEwriter) Debug(m string) error { return nil }", "func DebugPrint(image *ebiten.Image, str string) error {\n\tdefaultDebugPrintState.DebugPrint(image, str)\n\treturn nil\n}", "func loadKeyboardCodes(vkeyCodeMap map[string][]int64, lookup map[string]string, path string, pos int) error {\n\tbuf, err := grab(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbuf = extract(buf, \"KeyboardCode\")\n\n\tmatches := keyboardCodeRE.FindAllStringSubmatch(string(buf), -1)\n\tfor _, m := range matches {\n\t\tv := m[2]\n\t\tswitch {\n\t\tcase strings.HasPrefix(m[2], \"'\"):\n\t\t\tv = fmt.Sprintf(\"0x%04x\", m[2][1])\n\n\t\tcase !strings.HasPrefix(m[2], \"0x\") && m[2] != \"0\":\n\t\t\tz, ok := lookup[v]\n\t\t\tif !ok {\n\t\t\t\tpanic(fmt.Sprintf(\"could not find %s in lookup\", v))\n\t\t\t}\n\t\t\tv = z\n\t\t}\n\n\t\t// load the value\n\t\ti, err := strconv.ParseInt(v, 0, 32)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"could not parse %s // %s // %s\", m[1], m[2], v))\n\t\t}\n\n\t\tvkey, ok := vkeyCodeMap[m[1]]\n\t\tif !ok {\n\t\t\tvkey = make([]int64, 2)\n\t\t}\n\t\tvkey[pos] = i\n\t\tvkeyCodeMap[m[1]] = vkey\n\t}\n\n\treturn nil\n}", "func Debug(s string) {\n\tif os.Getenv(\"DEBUG\") == \"Y\" {\n\t\tfmt.Print(\"\\u001b[33m\")\n\t\tfmt.Println(\"DEBUG:\", s, \"\\u001b[0m\")\n\t}\t\n}", "func sknp(context *Context) {\n x := context.opcode & 0x0F00 >> 8\n if !context.window.IsKeyPressed(HexKey(context.cpu.v[x])) {\n context.cpu.pc += 2\n }\n context.cpu.pc += 2\n}", "func Debug(text string) {\n\tprintLog(\"debug\", text)\n}", "func (s *SkipList) DebugPrint() []string {\n\tdebugData := make([]string, s.currentLevel+1)\n\tfor i := 0; i <= s.currentLevel; i++ {\n\t\tstrBuilder := strings.Builder{}\n\t\tstrBuilder.WriteString(strconv.Itoa(i) + \":\")\n\t\tcurrent := s.header.Next[i]\n\t\tfor current != nil {\n\t\t\tstrBuilder.WriteString(strconv.Itoa(current.Key) + \",\")\n\t\t\tcurrent = current.Next[i]\n\t\t}\n\t\tdebugData[i] = strBuilder.String()\n\t}\n\treturn debugData\n}", "func printScanKey(ch <-chan []string) {\n\tfor {\n\t\tfor _, v := range <-ch {\n\t\t\tfmt.Println(v)\n\t\t}\n\t}\n}", "func (vk vKeyboard) KeyDown(key int) error {\n\tif !keyCodeInRange(key) {\n\t\treturn fmt.Errorf(\"failed to perform KeyDown. Code %d is not in range\", key)\n\t}\n\treturn sendBtnEvent(vk.deviceFile, []int{key}, btnStatePressed)\n}", "func rcPrint(p *TCompiler, code *TCode) (*value.Value, error) {\n\tprintln(\"[PRINT]\", p.regGet(code.A).ToString())\n\tp.moveNext()\n\treturn nil, nil\n}", "func (c ConsoleOutput) Debug(msg string, a ...interface{}) {\n\tif c.Verbose {\n\t\tswitch {\n\t\tcase c.Emoji && c.Color:\n\t\t\tfmt.Printf(debug+orange+msg+reset+\"\\n\", a...)\n\t\tcase c.Emoji:\n\t\t\tfmt.Printf(debug+msg+\"\\n\", a...)\n\t\tcase c.Color:\n\t\t\tfmt.Printf(\"[\"+orange+\"d\"+reset+\"] \"+orange+msg+reset+\"\\n\", a...)\n\t\tdefault:\n\t\t\tfmt.Printf(\"[d] \"+msg+\"\\n\", a...)\n\t\t}\n\t}\n}", "func PrintCommand(command string) {\n\tcolor.Printf(\"c\", \"%s\", command)\n}", "func displayInstructions(s tcell.Screen) {\n emitStr(s, 2, 2, tcell.StyleDefault, \"Press f/b to go to next/previous stretches\")\n emitStr(s, 2, 3, tcell.StyleDefault, \"Press p to toggle pause\")\n emitStr(s, 2, 4, tcell.StyleDefault, \"Press ESC exit\")\n return\n}", "func dumpPC(x, oldx uint16) string {\n\ts := make([]string, 2)\n\ts[0] = fmt.Sprintf(\"PC %04x\", x)\n\tif x != oldx {\n\t\ts[1] = \"*\"\n\t}\n\treturn strings.Join(s, \" \")\n}", "func (s Seed) PrintMnemonic(wordsPerLine int) {\n\tif wordsPerLine <= 0 {\n\t\tpanic(\"wordsPerLine must be >= 1\")\n\t}\n\n\tfor i, w := range s.EncodeWords() {\n\t\tfmt.Printf(\"%s\", w)\n\t\tif (i+wordsPerLine+1)%wordsPerLine == 0 {\n\t\t\tfmt.Printf(\"\\n\")\n\t\t} else {\n\t\t\tfmt.Print(\" \")\n\t\t}\n\t}\n}", "func PrintFlags(input *string, output *string, mode *string, key *string, length *string) {\n\t// Preserve the (null) display behavior of stock zcryp.\n\tprintableinput := \"(null)\"\n\tprintableoutput := \"(null)\"\n\tprintablemode := \"(null)\"\n\tprintablekey := \"(null)\"\n\tprintablelength := \"(null)\"\n\n\tif input != nil {\n\t\tprintableinput = *input\n\t}\n\n\tif output != nil {\n\t\tprintableoutput = *output\n\t}\n\n\tif mode != nil {\n\t\tprintablemode = *mode\n\t}\n\n\tif key != nil {\n\t\tprintablekey = *key\n\t}\n\t\n\tif length != nil {\n\t\tprintablelength = *length\n\t}\n\n\tfmt.Fprintln(os.Stderr, fmt.Sprintf(\"input->%s , output->%s , mode->%s , key->%s, len->%s\", printableinput, printableoutput, printablemode, printablekey, printablelength))\n}", "func keycodeFromName(name string) key.Code {\n\tswitch strings.ToLower(name) {\n\tcase \"a\":\n\t\treturn key.CODE_A\n\tcase \"b\":\n\t\treturn key.CODE_B\n\tcase \"c\":\n\t\treturn key.CODE_C\n\tcase \"d\":\n\t\treturn key.CODE_D\n\tcase \"e\":\n\t\treturn key.CODE_E\n\tcase \"f\":\n\t\treturn key.CODE_F\n\tcase \"g\":\n\t\treturn key.CODE_G\n\tcase \"h\":\n\t\treturn key.CODE_H\n\tcase \"i\":\n\t\treturn key.CODE_I\n\tcase \"j\":\n\t\treturn key.CODE_J\n\tcase \"k\":\n\t\treturn key.CODE_K\n\tcase \"l\":\n\t\treturn key.CODE_L\n\tcase \"m\":\n\t\treturn key.CODE_M\n\tcase \"n\":\n\t\treturn key.CODE_N\n\tcase \"o\":\n\t\treturn key.CODE_O\n\tcase \"p\":\n\t\treturn key.CODE_P\n\tcase \"q\":\n\t\treturn key.CODE_Q\n\tcase \"r\":\n\t\treturn key.CODE_R\n\tcase \"s\":\n\t\treturn key.CODE_S\n\tcase \"t\":\n\t\treturn key.CODE_T\n\tcase \"u\":\n\t\treturn key.CODE_U\n\tcase \"v\":\n\t\treturn key.CODE_V\n\tcase \"w\":\n\t\treturn key.CODE_W\n\tcase \"x\":\n\t\treturn key.CODE_X\n\tcase \"y\":\n\t\treturn key.CODE_Y\n\tcase \"z\":\n\t\treturn key.CODE_Z\n\tcase \"0\":\n\t\treturn key.CODE_0\n\tcase \"1\":\n\t\treturn key.CODE_1\n\tcase \"2\":\n\t\treturn key.CODE_2\n\tcase \"3\":\n\t\treturn key.CODE_3\n\tcase \"4\":\n\t\treturn key.CODE_4\n\tcase \"5\":\n\t\treturn key.CODE_5\n\tcase \"6\":\n\t\treturn key.CODE_6\n\tcase \"7\":\n\t\treturn key.CODE_7\n\tcase \"8\":\n\t\treturn key.CODE_8\n\tcase \"9\":\n\t\treturn key.CODE_9\n\tcase \" \", \"space\":\n\t\treturn key.CODE_SPACE\n\tcase \"-\":\n\t\treturn key.CODE_MINUS\n\tcase \"=\":\n\t\treturn key.CODE_EQUAL\n\tcase \"[\":\n\t\treturn key.CODE_LEFTBRACE\n\tcase \"]\":\n\t\treturn key.CODE_RIGHTBRACE\n\tcase \"(\":\n\t\treturn key.CODE_KPLEFTPAREN\n\tcase \")\":\n\t\treturn key.CODE_KPRIGHTPAREN\n\tcase \";\":\n\t\treturn key.CODE_SEMICOLON\n\tcase \"'\":\n\t\treturn key.CODE_APOSTROPHE\n\tcase \"`\":\n\t\treturn key.CODE_GRAVE\n\tcase \"\\\\\":\n\t\treturn key.CODE_BACKSLASH\n\tcase \",\":\n\t\treturn key.CODE_COMMA\n\tcase \".\":\n\t\treturn key.CODE_DOT\n\tcase \"/\":\n\t\treturn key.CODE_SLASH\n\tcase \"*\":\n\t\treturn key.CODE_KPASTERISK //hmm\n\tcase \"+\":\n\t\treturn key.CODE_KPPLUS //hmm\n\t/*case \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_\n\tcase \"\": return key.CODE_*/\n\t// TODO - fwd del, rightshift\n\tcase \"backspace\", \"delete\":\n\t\treturn key.CODE_BACKSPACE\n\tcase \"ctrl\", \"control\":\n\t\treturn key.CODE_LEFTCTRL\n\tcase \"shift\":\n\t\treturn key.CODE_LEFTSHIFT\n\tcase \"alt\", \"option\":\n\t\treturn key.CODE_LEFTALT\n\tcase \"tab\", \"\\t\":\n\t\treturn key.CODE_TAB\n\tcase \"arrowup\", \"up\":\n\t\treturn key.CODE_UP\n\tcase \"arrowleft\", \"left\":\n\t\treturn key.CODE_LEFT\n\tcase \"arrowright\", \"right\":\n\t\treturn key.CODE_RIGHT\n\tcase \"arrowdown\", \"down\":\n\t\treturn key.CODE_DOWN\n\tcase \"esc\", \"escape\":\n\t\treturn key.CODE_ESC\n\tcase \"enter\":\n\t\treturn key.CODE_ENTER\n\tcase \"linefeed\":\n\t\treturn key.CODE_LINEFEED //like shift+enter?\n\tcase \"sysrq\":\n\t\treturn key.CODE_SYSRQ //nice if works?\n\tcase \"home\":\n\t\treturn key.CODE_HOME\n\tcase \"end\":\n\t\treturn key.CODE_END\n\tcase \"pgup\", \"pageup\":\n\t\treturn key.CODE_PAGEUP\n\tcase \"pgdn\", \"pagedown\":\n\t\treturn key.CODE_PAGEDOWN\n\tcase \"compose\":\n\t\treturn key.CODE_COMPOSE\n\tcase \"f1\":\n\t\treturn key.CODE_F1\n\tcase \"f2\":\n\t\treturn key.CODE_F2\n\tcase \"f3\":\n\t\treturn key.CODE_F3\n\tcase \"f4\":\n\t\treturn key.CODE_F4\n\tcase \"f5\":\n\t\treturn key.CODE_F5\n\tcase \"f6\":\n\t\treturn key.CODE_F6\n\tcase \"f7\":\n\t\treturn key.CODE_F7\n\tcase \"f8\":\n\t\treturn key.CODE_F8\n\tcase \"f9\":\n\t\treturn key.CODE_F9\n\tcase \"f10\":\n\t\treturn key.CODE_F10\n\tcase \"f11\":\n\t\treturn key.CODE_F11\n\tcase \"f12\":\n\t\treturn key.CODE_F12\n\t// rarer keys\n\t// doesn't seem to work--let's try shift-insert instead:\n\t// case \"paste\": return key.CODE_PASTE\n\t// CODE_UNDO doesn't work. Ctrl-Z could. For redo, apps\n\t// are evenly tied between Ctrl-Shift-Z and Ctrl-Y,\n\t// so are we stuck?\n\t// case \"undo\": return key.CODE_UNDO\n\tcase \"back\":\n\t\treturn key.CODE_BACK\n\tcase \"forward\":\n\t\treturn key.CODE_FORWARD\n\tcase \"reload\":\n\t\treturn key.CODE_REFRESH\n\tcase \"click\":\n\t\treturn key.CODE_BTN_LEFT\n\tcase \"r.click\":\n\t\treturn key.CODE_BTN_RIGHT\n\tcase \"m.click\":\n\t\treturn key.CODE_BTN_MIDDLE\n\n\t\t//\tcase \"\": return key.CODE_\n\t\t//\tcase \"\": return key.CODE_\n\tdefault:\n\t\treturn key.CODE_RESERVED\n\t\t// TODO- ATK; shifted ones, and undoing shift for nonshifted ones if relevant\n\t}\n}", "func (game Game) Print() {\n\tfor i := 0; i < 8; i++ {\n\t\tif i == 0 {\n\t\t\tfmt.Printf(\"\\u001b[40m\\u001b[37m A B C D E F G H \")\n\t\t\tfmt.Printf(\"\\u001b[0m\")\n\t\t\tfmt.Println()\n\t\t}\n\t\tfmt.Printf(\"\\u001b[40m\\u001b[37m %s \", strconv.Itoa(i+1))\n\t\tfmt.Printf(\"\\u001b[0m\")\n\n\t\tfor j := 0; j < 8; j++ {\n\n\t\t\tif game.board[i][j] == -1 {\n\t\t\t\tfmt.Printf(\"\\u001b[42m\\u001b[30m %s \", \"●\")\n\t\t\t\tfmt.Printf(\"\\u001b[0m\")\n\t\t\t} else if game.board[i][j] == 1 {\n\t\t\t\tfmt.Printf(\"\\u001b[42m\\u001b[37m %s \", \"●\")\n\t\t\t\tfmt.Printf(\"\\u001b[0m\")\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"\\u001b[42m\\u001b[90m . \")\n\t\t\t\tfmt.Printf(\"\\u001b[0m\")\n\t\t\t}\n\t\t}\n\t\tfmt.Println()\n\t}\n}", "func (kl Keylogger) ParseKeycode(keyCode int, keyState uint16) Key {\n\tkey := Key{Empty: false, Keycode: keyCode}\n\n\t// Only one rune has to fit in\n\toutBuf := make([]uint16, 1)\n\n\t// Buffer to store the keyboard state in\n\tkbState := make([]uint8, 256)\n\n\t// Get keyboard layout for this process (0)\n\tkbLayout, _, _ := procGetKeyboardLayout.Call(uintptr(0))\n\n\t// Put all key modifier keys inside the kbState list\n\tif w32.GetAsyncKeyState(w32.VK_SHIFT)&(1<<15) != 0 {\n\t\tkbState[w32.VK_SHIFT] = 0xFF\n\t}\n\n\tcapitalState, _, _ := procGetKeyState.Call(uintptr(w32.VK_CAPITAL))\n\tif capitalState != 0 {\n\t\tkbState[w32.VK_CAPITAL] = 0xFF\n\t}\n\n\tif w32.GetAsyncKeyState(w32.VK_CONTROL)&(1<<15) != 0 {\n\t\tkbState[w32.VK_CONTROL] = 0xFF\n\t}\n\n\tif w32.GetAsyncKeyState(w32.VK_MENU)&(1<<15) != 0 {\n\t\tkbState[w32.VK_MENU] = 0xFF\n\t}\n\n\t_, _, _ = procToUnicodeEx.Call(\n\t\tuintptr(keyCode),\n\t\tuintptr(0),\n\t\tuintptr(unsafe.Pointer(&kbState[0])),\n\t\tuintptr(unsafe.Pointer(&outBuf[0])),\n\t\tuintptr(1),\n\t\tuintptr(1),\n\t\tuintptr(kbLayout))\n\n\tkey.Rune, _ = utf8.DecodeRuneInString(syscall.UTF16ToString(outBuf))\n\n\treturn key\n}", "func Debug(g *types.Cmd) {\n\tg.Debug = true\n}", "func (c Cursor) Sprint() string {\n\treturn fmt.Sprintf(\"%s%c\", EscapeStart, c)\n}", "func (s *LoginServer) printServerKeys(w http.ResponseWriter) {\n\n\tfmt.Fprintf(w, \"List of server keys\\n\")\n\tfmt.Fprintf(w, \"-------------------\\n\")\n\tfmt.Fprintf(w, \"Index\\tValue\\n\")\n\tfor _, key := range s.Keys.ServiceKeys() {\n\t\tfmt.Fprintf(w, \"%v\\t%v\\n\", key.Index, hex.EncodeToString(key.Value[:]))\n\t}\n}", "func IsPrint(b byte) bool { return lookup[b]&printMask != 0 }", "func (s *BasemumpsListener) EnterCode(ctx *CodeContext) {}", "func printDebug(msg string) {\n\tif Debug {\n\t\tfmt.Println(fmt.Sprintf(\"DEBUG %s: %s\", getFormattedTime(), msg))\n\t}\n}", "func printDebug(msg string) {\n\tif Debug {\n\t\tfmt.Println(fmt.Sprintf(\"DEBUG %s: %s\", getFormattedTime(), msg))\n\t}\n}", "func (l *MemoryLogger) Debug(msg string, keyvals ...interface{}) {\n\tl.println(\"DEBUG\", msg, keyvals)\n}", "func Pause(msg string) {\n\tfmt.Print(msg, \"[Press Enter to Continue]: \")\n\tvar s string\n\t_, err := fmt.Scan(&s)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (gw *GameWorld) PrintDebug() {\n\tfmt.Println(\"Gameworld debug information!\")\n\tfmt.Printf(\"Game Map: rows=%d\\n\", len(gw.gameArea))\n\tfor i := 0; i < len(gw.gameArea); i++ {\n\t\tfmt.Printf(\"row %d \", i)\n\t\tfor j := 0; j < len(gw.gameArea[i]); j++ {\n\t\t\tgw.gameArea[i][j].PrintDebug()\n\t\t}\n\t\tfmt.Println()\n\t}\n}", "func Debug(data []byte) {\n\tlog.Print(\"DEBUG: \", string(data))\n}", "func printDebug(format string, a ...interface{}) {\n\tif fetchConfig().verbosity < Debug {\n\t\treturn\n\t}\n\tif fetchConfig().color {\n\t\tformat = color.FgGray.Render(format)\n\t}\n\tfmt.Fprintf(os.Stdout, format+\"\\n\", a...)\n\n}", "func (e *Engine) PrintDebug(startTime time.Time, version string) string {\n\te.write(fmt.Sprintf(\"\\n%s %s\\n\", log.Text(\"Version:\").Green().Bold().Plain(), version))\n\tsh := e.Env.Shell()\n\tshellVersion := e.Env.Getenv(\"POSH_SHELL_VERSION\")\n\tif len(shellVersion) != 0 {\n\t\tsh += fmt.Sprintf(\" (%s)\", shellVersion)\n\t}\n\te.write(fmt.Sprintf(\"\\n%s %s\\n\", log.Text(\"Shell:\").Green().Bold().Plain(), sh))\n\n\t// console title timing\n\ttitleStartTime := time.Now()\n\te.Env.Debug(\"Segment: Title\")\n\ttitle := e.getTitleTemplateText()\n\tconsoleTitle := &Segment{\n\t\tname: \"ConsoleTitle\",\n\t\tnameLength: 12,\n\t\tEnabled: len(e.Config.ConsoleTitleTemplate) > 0,\n\t\ttext: title,\n\t\tduration: time.Since(titleStartTime),\n\t}\n\tlargestSegmentNameLength := consoleTitle.nameLength\n\n\t// render prompt\n\te.write(log.Text(\"\\nPrompt:\\n\\n\").Green().Bold().Plain().String())\n\te.write(e.Primary())\n\n\te.write(log.Text(\"\\n\\nSegments:\\n\\n\").Green().Bold().Plain().String())\n\n\tvar segments []*Segment\n\tsegments = append(segments, consoleTitle)\n\n\tfor _, block := range e.Config.Blocks {\n\t\tfor _, segment := range block.Segments {\n\t\t\tsegments = append(segments, segment)\n\t\t\tif segment.nameLength > largestSegmentNameLength {\n\t\t\t\tlargestSegmentNameLength = segment.nameLength\n\t\t\t}\n\t\t}\n\t}\n\n\t// 22 is the color for false/true and 7 is the reset color\n\tlargestSegmentNameLength += 22 + 7\n\tfor _, segment := range segments {\n\t\tduration := segment.duration.Milliseconds()\n\t\tvar active log.Text\n\t\tif segment.Enabled {\n\t\t\tactive = log.Text(\"true\").Yellow()\n\t\t} else {\n\t\t\tactive = log.Text(\"false\").Purple()\n\t\t}\n\t\tsegmentName := fmt.Sprintf(\"%s(%s)\", segment.Name(), active.Plain())\n\t\te.write(fmt.Sprintf(\"%-*s - %3d ms\\n\", largestSegmentNameLength, segmentName, duration))\n\t}\n\n\te.write(fmt.Sprintf(\"\\n%s %s\\n\", log.Text(\"Run duration:\").Green().Bold().Plain(), time.Since(startTime)))\n\te.write(fmt.Sprintf(\"\\n%s %s\\n\", log.Text(\"Cache path:\").Green().Bold().Plain(), e.Env.CachePath()))\n\n\tconfig := e.Env.Flags().Config\n\tif len(config) == 0 {\n\t\tconfig = \"no --config set, using default built-in configuration\"\n\t}\n\te.write(fmt.Sprintf(\"\\n%s %s\\n\", log.Text(\"Config path:\").Green().Bold().Plain(), config))\n\n\te.write(log.Text(\"\\nLogs:\\n\\n\").Green().Bold().Plain().String())\n\te.write(e.Env.Logs())\n\treturn e.string()\n}", "func PrintUncolored() {\r\n\tif len(uncolored) == 0 {\r\n\t\treturn\r\n\t}\r\n\r\n\tfmt.Println(\"\\nDebug Info:\")\r\n\tfor block, freq := range uncolored {\r\n\t\tansi.Print(ansi.Yellow, block)\r\n\t\tfmt.Print(\" \")\r\n\t\tansi.Println(ansi.BrightBlue, fmt.Sprint(freq))\r\n\t}\r\n}", "func Sprint(a ...interface{}) string {\n\ta = append(a, ResetCode)\n\tcompileValues(&a)\n\treturn fmt.Sprint(a...)\n}", "func KeyDown(keyCode allegro.KeyCode) bool {\n return _pressedKeys[keyCode]\n}", "func TokenDebugPrint(tokens []Token) {\n\tfor _, token := range tokens {\n\t\tfmt.Printf(\" L%03d,C%03d-%03d %11s: [%s]\\n\", token.line, token.colStart, token.colEnd, token.tokType.toString(), token.value)\n\t}\n}", "func (md *MockDisplay) KeyDown(key uint8) bool { return md.keysDown[key] }", "func ShowCursor() {\n\tfmt.Printf(CSI + ShowCursorSeq)\n}", "func StartGocKeyboard() {\n\n\tC.InitKeyboard()\n\n\tfmt.Printf(\"\\nEnter: (Press 'q' to quit)\")\n\tfor {\n\t\tkey := C.GetCharacter()\n\t\tfmt.Printf(\"%c\", key)\n\n\t\tif key == 'q' {\n\t\t\tfmt.Printf(\"Bye!\")\n\t\t\tbreak\n\t\t}\n\t}\n\n\tC.CloseKeyboard()\n}", "func Debug(fn func()) {\n\n\tSetDumpCode(\"1\")\n\tdefer SetDumpCode(\"0\")\n\tfn()\n}", "func KeyLog(rw io.ReadWriter) (err error) {\r\n\t// Query key mapped to integer `0x00` to `0xFF` if it's pressed.\r\n\tfor i := 0; i < 0xFF; i++ {\r\n\t\tasynch, _, _ := syscall.Syscall(procGetAsyncKeyState.Addr(), 1, uintptr(i), 0, 0)\r\n\r\n\t\t// If the least significant bit is set ignore it.\r\n\t\t//\r\n\t\t// As it's written in the documentation:\r\n\t\t// `if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState.`\r\n\t\t// Which we don't care about :)\r\n\t\tif asynch&0x1 == 0 {\r\n\t\t\tcontinue\r\n\t\t}\r\n\r\n\t\t// Write i to rw.\r\n\t\terr = writeKey(i, rw)\r\n\r\n\t\tif err != nil {\r\n\t\t\treturn err\r\n\t\t}\r\n\t}\r\n\r\n\treturn nil\r\n}", "func showCursor() {\n\tfmt.Printf(\"\\033[?25h\")\n}", "func (e *Escpos) PrintImage(img image.Image) {\n\te.SetLineSpace(1)\n\twidth, height := img.Bounds().Dx(), img.Bounds().Dy()\n\tbCommand := []byte(fmt.Sprintf(\"\\x1B*%c00\", 33))\n\tbCommand[3] = byte(height % 256)\n\tbCommand[4] = byte(height / 256)\n\tdata := []byte{0, 0, 0}\n\tfor i := 0; i < (height/24 + 1); i++ {\n\t\traw := bCommand\n\t\tfor j := 0; j < width; j++ {\n\t\t\tfor k := 0; k < 24; k++ {\n\t\t\t\tif i*24+k < height {\n\t\t\t\t\tr, g, b, _ := img.At(j, i*24+k).RGBA()\n\t\t\t\t\tif (r+g+b)/3/255 < 128 {\n\t\t\t\t\t\tdata[k/8] += byte(128 >> uint(k%8))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\traw = append(raw, data...)\n\t\t\tdata = []byte{0, 0, 0}\n\t\t}\n\t\te.WriteRaw(raw)\n\t\te.Linefeed()\n\n\t}\n\te.SetLineSpace(0)\n}", "func ScrSave() {\n PrintCtrOnErr(ESC_SAVE_SCREEN)\n PrintCtrOnErr(ESC_SAVE_CURSOR)\n PrintCtrOnErr(ESC_CURSOR_OFF)\n PrintCtrOnErr(ESC_CLEAR_SCREEN)\n}", "func (a *App) KeyListener(e *vecty.Event) {\n\tkey := e.Get(\"key\").String()\n\tswitch key {\n\tcase \" \":\n\t\tfmt.Println(\"Space\")\n\t}\n}", "func PrintBoard(revealed map[int]struct{}, lastRevealed int) {\n\tpace := 0\n\theaders := [10]int{1, 2, 16, 17, 31, 32, 46, 47, 61, 62}\n\tfmt.Println(\"B I N G O\")\n\tfor x := 0; x < 8; x++ {\n\t\tfor y := 0; y < 10; y++ {\n\t\t\t// skip 16, 31, 46, 61 and 76\n\t\t\tif x == 7 && (headers[y]+pace)%15 == 1 {\n\t\t\t\tfmt.Print(\" \")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t_, ok := revealed[headers[y]+pace]\n\t\t\tif !ok {\n\t\t\t\tfmt.Print(headers[y]+pace, \"\\t\")\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Printf(sortedColor, strconv.Itoa(headers[y]+pace))\n\t\t}\n\t\tfmt.Println()\n\t\tpace += 2\n\t}\n\tfmt.Printf(\"Ultimo numero sorteado: %d\\n\", lastRevealed)\n}", "func CodeToSymbol(key string) (string, error) {\n\ti, err := strconv.Atoi(key)\n\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"couldn't parse string %s to int\", key)\n\t}\n\n\thex := xlib.KeyCodeToHex(i)\n\tname, ok := xlib.KeySyms[hex]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"keycode %s not in keysymdef.h\", key)\n\t}\n\n\treturn name, nil\n}", "func PrintLicenseList() error {\n\tkeys, err := GetLicenseKeys()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprintln(\"key : id : name\")\n\tfor _, key := range keys {\n\t\tfmt.Printf(\"%s : %s : %s\\n\", key.Key, key.SpdxID, key.Name)\n\t}\n\treturn nil\n}", "func Print(key Type) {\n\tmutex.RLock()\n\tdefer mutex.RUnlock()\n\n\tklog.Infof(\"%s: %s\", key, GlobalStats[key])\n}", "func ldk(context *Context) {\n x := context.opcode & 0x0F00 >> 8\n before := time.Now()\n key := context.window.WaitForKeyPress()\n // Don't count blocking time against delay\n context.cpu.delay -= time.Since(before).Nanoseconds() / 1000000\n context.cpu.v[x] = byte(key)\n}", "func (d *debugPrintState) DebugPrint(r *ebiten.Image, str string) {\n\tif d.textImage == nil {\n\t\timg := assets.TextImage()\n\t\td.textImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterNearest)\n\t}\n\tif d.debugPrintRenderTarget == nil {\n\t\twidth, height := 256, 256\n\t\td.debugPrintRenderTarget, _ = ebiten.NewImage(width, height, ebiten.FilterNearest)\n\t}\n\td.drawText(r, str, 1, 1, color.NRGBA{0x00, 0x00, 0x00, 0x80})\n\td.drawText(r, str, 0, 0, color.NRGBA{0xff, 0xff, 0xff, 0xff})\n}", "func (key Key) String() string {\n\tdisplayTokens := make([]string, 0)\n\tprefix := \"\"\n\tfor _, token := range key.Tokens {\n\t\tif token == \"Ctrl\" {\n\t\t\tprefix = \"^\"\n\t\t\tcontinue\n\t\t}\n\t\tif value, exists := display[token]; exists {\n\t\t\ttoken = value\n\t\t}\n\t\tdisplayTokens = append(displayTokens, token)\n\t}\n\treturn prefix + strings.Join(displayTokens, \"+\")\n}", "func DebugKVs(ctx context.Context, msg string, args ...interface{}) {\n\tglobal.DebugKVs(ctx, msg, args...)\n}", "func (c Code) String() string {\n\treturn codeString[c]\n}", "func PressKey(p string, refresh func(int, int), keys ...string) string {\n\tvar plen int\n\tpm := p + \" (\"\n\tfor i, key := range keys {\n\t\tif i != 0 {\n\t\t\tpm += \"/\"\n\t\t}\n\t\tpm += key\n\t}\n\tpm += \")\"\n\tplen = utf8.RuneCountInString(pm) + 1\n\tx, y := termbox.Size()\n\tif refresh != nil {\n\t\trefresh(x, y)\n\t}\n\tClearLine(x, y-1)\n\tPrintstring(pm, 0, y-1)\n\ttermbox.SetCursor(plen, y-1)\n\ttermbox.Flush()\n\tfor {\n\t\tev := termbox.PollEvent()\n\t\tif ev.Type == termbox.EventResize {\n\t\t\tx, y = termbox.Size()\n\t\t\tif refresh != nil {\n\t\t\t\trefresh(x, y)\n\t\t\t}\n\t\t\tClearLine(x, y-1)\n\t\t\tPrintstring(pm, 0, y-1)\n\t\t\ttermbox.SetCursor(plen, y-1)\n\t\t\ttermbox.Flush()\n\t\t} else if ev.Type == termbox.EventKey {\n\t\t\tpressedkey := ParseTermboxEvent(ev)\n\t\t\tfor _, key := range keys {\n\t\t\t\tif key == pressedkey {\n\t\t\t\t\treturn key\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func Print(key Type) {\n\tmutex.RLock()\n\tdefer mutex.RUnlock()\n\n\tklog.Infof(\"%s: %s\", key, globalStats[key])\n}", "func (op Print) OpCode() int { return OpPrint }", "func PrintComb() {\n\tvar i rune = 0\n\tvar j rune = 0\n\tvar k rune = 0\n\tvar count rune = 0\n\tfor i < 10 {\n\t\tj = 0\n\t\tfor j < 10 {\n\t\t\tk = 0\n\t\t\tfor k < 10 {\n\t\t\t\tif i != j && j != k && i != k {\n\t\t\t\t\tif i < j && j < k {\n\t\t\t\t\t\tif count == 119 {\n\t\t\t\t\t\t\tz01.PrintRune(i + 48)\n\t\t\t\t\t\t\tz01.PrintRune(j + 48)\n\t\t\t\t\t\t\tz01.PrintRune(k + 48)\n\t\t\t\t\t\t\tz01.PrintRune(10)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tz01.PrintRune(i + 48)\n\t\t\t\t\t\t\tz01.PrintRune(j + 48)\n\t\t\t\t\t\t\tz01.PrintRune(k + 48)\n\t\t\t\t\t\t\tz01.PrintRune(44)\n\t\t\t\t\t\t\tz01.PrintRune(32)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcount++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tk++\n\t\t\t}\n\t\t\tj++\n\t\t}\n\t\ti++\n\t}\n}", "func (view *DetailsView) KeyHelp() string {\n\treturn \"TBD\"\n}", "func debug(g *gocui.Gui, output interface{}) {\n\tv, err := g.View(\"debug\")\n\tif err == nil {\n\t\tt := time.Now()\n\t\ttf := t.Format(\"2006-01-02 15:04:05\")\n\t\toutput = tf + \" > \" + output.(string)\n\t\tfmt.Fprintln(v, output)\n\t}\n}", "func upKey(key rune) error {\n\tvar vkey rune\n\tscanCode, ok := Scan[key]\n\tif ok {\n\t\tkey = rune(scanCode.Virtual)\n\t\tvkey = rune(scanCode.Scan)\n\n\t} else {\n\t\tvkey = key + 0x80\n\t}\n\n\t// defining keyUp to be more \"verbose\"\n\tvar keyUp uintptr = 0x0002\n\t_, _, err := keyEventDLL.Call(uintptr(key), uintptr(vkey), keyUp, 0)\n\treturn err\n}", "func PrintKeyTW(k *key) {\n\tPrintKeysTW([]KeyAPI{k})\n}", "func KeySortPrint(m interface{}) {\n\tre := regexp.MustCompile(`^[+-]?[0-9]*\\.?[0-9]+:`)\n\tmapstr := fSp(m)\n\tmapstr = mapstr[4 : len(mapstr)-1]\n\t// fPln(mapstr)\n\tI := 0\n\trmIdxList := []interface{}{}\n\tss := sSplit(mapstr, \" \")\n\tfor i, s := range ss {\n\t\tif re.MatchString(s) {\n\t\t\tI = i\n\t\t} else {\n\t\t\tss[I] += \" \" + s\n\t\t\trmIdxList = append(rmIdxList, i) // to be deleted (i)\n\t\t}\n\t}\n\tfor i, s := range ss {\n\t\tif !exist(i, rmIdxList...) {\n\t\t\tfPln(s)\n\t\t}\n\t}\n}", "func CatchDebug() {\r\n\tsigchan := make(chan os.Signal, 1)\r\n\t//signal.Notify(sigchan, syscall.SIGUSR1)\r\n\tsignal.Notify(sigchan, syscall.Signal(0xa)) // SIGUSR1 = Signal(0xa)\r\n\tfor range sigchan {\r\n\t\tPrintProgramStatus()\r\n\t}\r\n}", "func HandleUpPress() {\n\tlog.Println(\"Key up pressed\")\n}", "func keyCodeToInput(code int, time bool) {\n\tcorrectTiming := 1.0\n\tif time {\n\t\tcorrectTiming = engine.TimeElapsed * 40\n\t}\n\tcWalkSpeed := walkSpeed * correctTiming\n\tcRotateSpeed := rotateSpeed * correctTiming\n\n\tswitch code {\n\tcase 119: // \"W\" - forward\n\t\tengine.StrafePlayerV(cWalkSpeed)\n\tcase 97: // \"A\" - strafe left\n\t\tengine.StrafePlayerH(-cWalkSpeed)\n\tcase 115: // \"S\" - backward\n\t\tengine.StrafePlayerV(-cWalkSpeed)\n\tcase 100: // \"D\" - strafe right\n\t\tengine.StrafePlayerH(cWalkSpeed)\n\tcase 101: // \"E\" - turn right\n\t\tengine.TurnPlayer(cRotateSpeed)\n\tcase 113: // \"Q\" - turn left\n\t\tengine.TurnPlayer(-cRotateSpeed)\n\t}\n}", "func catchDebug() {\n\tsigchan := make(chan os.Signal, 1)\n\t//signal.Notify(sigchan, syscall.SIGUSR1)\n\tsignal.Notify(sigchan, syscall.Signal(0xa)) // SIGUSR1 = Signal(0xa)\n\n\tfor {\n\t\tselect {\n\t\tcase <-sigchan:\n\t\t\tprintProgramStatus()\n\t\t}\n\t}\n}" ]
[ "0.5734756", "0.5661743", "0.5619345", "0.55390036", "0.5255597", "0.52267355", "0.5218144", "0.52071184", "0.5201189", "0.51946056", "0.5191891", "0.51840925", "0.51568466", "0.5144059", "0.51070255", "0.5100881", "0.5098705", "0.50601155", "0.5047249", "0.50467867", "0.50427204", "0.50281507", "0.5026279", "0.5021067", "0.49598095", "0.49409914", "0.48810053", "0.4874005", "0.48570818", "0.48568594", "0.48494187", "0.48481032", "0.48431936", "0.4838371", "0.48380348", "0.48368782", "0.48289797", "0.48259118", "0.48179734", "0.48160967", "0.48020366", "0.47735903", "0.47649693", "0.47633842", "0.475589", "0.47528335", "0.47488192", "0.474761", "0.47448412", "0.47447106", "0.47353527", "0.47321782", "0.47302544", "0.47250068", "0.47094", "0.47034776", "0.46989542", "0.46631297", "0.46631297", "0.46581772", "0.46580693", "0.46541727", "0.46476918", "0.46379367", "0.4634783", "0.46308625", "0.46237472", "0.46188357", "0.46184325", "0.46141315", "0.46024176", "0.46009892", "0.45998695", "0.45978495", "0.45958352", "0.45952678", "0.45867503", "0.45800018", "0.4575538", "0.45717365", "0.45715377", "0.45584524", "0.4558377", "0.4554509", "0.45519534", "0.454194", "0.4539532", "0.45360008", "0.45345256", "0.45312166", "0.45254213", "0.4507423", "0.44954157", "0.44943184", "0.4493143", "0.44839597", "0.4477175", "0.44664314", "0.4465734", "0.44623724" ]
0.8194317
0
SetCompletionCallback sets the completion callback function.
func (l *Linenoise) SetCompletionCallback(fn func(string) []string) { l.completionCallback = fn }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *SyncClient) SetCompletionListener(callback syncCompletionListener) error {\n\tif callback == nil {\n\t\tC.obx_sync_listener_complete(client.cClient, nil, nil)\n\t\tcCallbackUnregister(client.cCallbacks[cCallbackIndexCompletion])\n\t} else {\n\t\tif cbId, err := cCallbackRegister(cVoidCallback(func() {\n\t\t\tcallback()\n\t\t})); err != nil {\n\t\t\treturn err\n\t\t} else {\n\t\t\tC.obx_sync_listener_complete(client.cClient, (*C.OBX_sync_listener_complete)(cVoidCallbackDispatchPtr), cbId.cPtr())\n\t\t\tclient.swapCallbackId(cCallbackIndexCompletion, cbId)\n\t\t}\n\t}\n\treturn nil\n}", "func SetCompletionHandler(c CompletionHandler) {\n\tcomplHandler = c\n}", "func (q *Queue) SetCallback(cb Callback) error {\n\tq.cb = cb\n\treturn nil\n}", "func (t *StreamTransport) SetCallBack(cb StreamTransportCallbacker) {\n\tt.cb = cb\n}", "func (mb *MenuButton) SetCallBack(callback Callback) {\n\tmb.callback = callback\n}", "func (req *Request) SetCallback(parserName string) *Request {\n\treq.Callback = parserName\n\treturn req\n}", "func (s *Session) SetCloseCallback(callback func(*Session)) {\n\ts.closeCallback = callback\n}", "func (s *Strava) SetCallbackHandler(\n\tsuccess func(auth *strava.AuthorizationResponse, w http.ResponseWriter, r *http.Request),\n\tfailure func(err error, w http.ResponseWriter, r *http.Request)) {\n\tpath, _ := s.authenticator.CallbackPath()\n\thttp.HandleFunc(path, s.authenticator.HandlerFunc(success, failure))\n}", "func SetLicenseCallback(callbackFunction func(int)) int {\n\tstatus := C.SetLicenseCallback((C.CallbackType)(unsafe.Pointer(C.licenseCallbackCgoGateway)))\n\tlicenseCallbackFuncion = callbackFunction\n\treturn int(status)\n}", "func (v *Vox) SetCb(cb audio.OnDataCb) {\n\tv.Lock()\n\tdefer v.Unlock()\n\tv.cb = cb\n}", "func (d *Doorman) SetCb(cb audio.OnDataCb) {\n\td.Lock()\n\tdefer d.Unlock()\n\td.onDataCb = cb\n}", "func (o *ReaderOptions) SetPasswordCallback(cb func() string) {\n\to.cb = cb\n}", "func SetOutputCallback(fn OutNextCallbackFunc) {\n\toutNextCallback = fn\n}", "func (s *PipelineExecutionStepMetadata) SetCallback(v *CallbackStepMetadata) *PipelineExecutionStepMetadata {\n\ts.Callback = v\n\treturn s\n}", "func (win *Window) SetCloseCallback(callback WindowCloseCallback) WindowCloseCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CloseCallback\n\tcallbacks.CloseCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowCloseCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowCloseCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCloseCallback(callback WindowCloseCallback) WindowCloseCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CloseCallback\n\tcallbacks.CloseCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowCloseCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowCloseCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (s *Module) SetUpdateValidatorsCallback(f func(uint32, keys.PublicKeys)) {\n\ts.mtx.Lock()\n\tdefer s.mtx.Unlock()\n\ts.updateValidatorsCb = f\n}", "func (tb *TextBuf) SetCompleter(data interface{}, matchFun complete.MatchFunc, editFun complete.EditFunc,\n\tlookupFun complete.LookupFunc) {\n\tif matchFun == nil || editFun == nil {\n\t\tif tb.Complete != nil {\n\t\t\ttb.Complete.CompleteSig.Disconnect(tb.This())\n\t\t}\n\t\ttb.Complete.Destroy()\n\t\ttb.Complete = nil\n\t\treturn\n\t}\n\tif tb.Complete != nil {\n\t\tif tb.Complete.Context == data {\n\t\t\ttb.Complete.MatchFunc = matchFun\n\t\t\ttb.Complete.EditFunc = editFun\n\t\t\ttb.Complete.LookupFunc = lookupFun\n\t\t\treturn\n\t\t}\n\t}\n\ttb.Complete = &gi.Complete{}\n\ttb.Complete.InitName(tb.Complete, \"tb-completion\") // needed for standalone Ki's\n\ttb.Complete.Context = data\n\ttb.Complete.MatchFunc = matchFun\n\ttb.Complete.EditFunc = editFun\n\ttb.Complete.LookupFunc = lookupFun\n\t// note: only need to connect once..\n\ttb.Complete.CompleteSig.ConnectOnly(tb.This(), func(recv, send ki.Ki, sig int64, data interface{}) {\n\t\ttbf, _ := recv.Embed(KiT_TextBuf).(*TextBuf)\n\t\tif sig == int64(gi.CompleteSelect) {\n\t\t\ttbf.CompleteText(data.(string)) // always use data\n\t\t} else if sig == int64(gi.CompleteExtend) {\n\t\t\ttbf.CompleteExtend(data.(string)) // always use data\n\t\t}\n\t})\n}", "func (win *Window) SetDropCallback(callback DropCallback) DropCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.DropCallback\n\tcallbacks.DropCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetDropCallback(win.c())\n\t} else {\n\t\tC.goRemoveDropCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetDropCallback(callback DropCallback) DropCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.DropCallback\n\tcallbacks.DropCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetDropCallback(win.c())\n\t} else {\n\t\tC.goRemoveDropCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func SetKeyCallback(f KeyHandler) {\n\tkey = append(key, f)\n\tC.glfwSetKeyCB()\n}", "func (win *Window) SetFocusCallback(callback WindowFocusCallback) WindowFocusCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FocusCallback\n\tcallbacks.FocusCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowFocusCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowFocusCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetFocusCallback(callback WindowFocusCallback) WindowFocusCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FocusCallback\n\tcallbacks.FocusCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowFocusCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowFocusCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (b *ExperimentBuilder) SetCallbacks(callbacks model.ExperimentCallbacks) {\n\tb.callbacks = callbacks\n}", "func (r *TransferRecord) SetCompletionTime() {\n\tr.mutex.Lock()\n\tr.CompletionTime = time.Now()\n\tr.mutex.Unlock()\n}", "func (s *SSL) SetVerifyCallback(verify_cb VerifyCallback) {\n\ts.SetVerify(s.VerifyMode(), verify_cb)\n}", "func SetMouseButtonCallback(f MouseButtonHandler) {\n\tmouseButton = append(mouseButton, f)\n\tC.glfwSetMouseButtonCB()\n}", "func (l *List) SetDoneFn(fn func()) *List {\n\tl.doneFn = fn\n\treturn l\n}", "func (c *Context) SetMonitorCallback(callback MonitorCallback) MonitorCallback {\n\tpreviousCallback := monitorCallback\n\tmonitorCallback = callback\n\tif callback != nil {\n\t\tC.goSetMonitorCallback()\n\t} else {\n\t\tC.goRemoveMonitorCallback()\n\t}\n\treturn previousCallback\n}", "func (c *Context) SetMonitorCallback(callback MonitorCallback) MonitorCallback {\n\tpreviousCallback := monitorCallback\n\tmonitorCallback = callback\n\tif callback != nil {\n\t\tC.goSetMonitorCallback()\n\t} else {\n\t\tC.goRemoveMonitorCallback()\n\t}\n\treturn previousCallback\n}", "func (m *ModalAreaList) SetDoneFunc(handler func(buttonIndex int)) *ModalAreaList {\n\tm.done = handler\n\treturn m\n}", "func SetCharCallback(f CharHandler) {\n\tchar = append(char, f)\n\tC.glfwSetCharCB()\n}", "func (f *FileDialog) SetOnClosed(closed func()) {\n\tif f.dialog == nil {\n\t\treturn\n\t}\n\t// If there is already a callback set, remember it and call both.\n\toriginalCallback := f.onClosedCallback\n\n\tf.onClosedCallback = func(response bool) {\n\t\tclosed()\n\t\tif originalCallback != nil {\n\t\t\toriginalCallback(response)\n\t\t}\n\t}\n}", "func SetWindowCloseCallback(f WindowCloseHandler) {\n\twindowClose = f\n\tC.glfwSetWindowCloseCB()\n}", "func (arg1 *UConverter) SetToUCallBack(arg2 func(bool, UConverter, []byte, []uint16, []int32, UConverterCallbackReason, *UErrorCode), arg3 *UErrorCode)", "func (l *Linenoise) SetHintsCallback(fn func(string) *Hint) {\n\tl.hintsCallback = fn\n}", "func (b *bpfHandle) SetHeaderComplete(flag bool) error {\n\tnum := 0\n\tif flag {\n\t\tnum = 1\n\t}\n\tif ok, err := b.ioctlWithInt(ioctlBIOCSHDRCMPLT, num); ok {\n\t\treturn nil\n\t} else {\n\t\treturn err\n\t}\n}", "func (device *Device) SetVideoCallback(callback VideoCallback) {\n\n\tif _, ok := devices[device.device]; !ok {\n\t\tdevices[device.device] = device\n\t}\n\n\tC.freenect_set_video_callback(device.device, (*[0]byte)(C.videoCallback))\n\tdevice.videoCallback = callback\n}", "func (_this *FontFaceSet) SetOnLoadingDone(listener func(event *FontFaceSetLoadEvent, currentTarget *FontFaceSet)) js.Func {\n\tcb := eventFuncFontFaceSet_FontFaceSetLoadEvent(listener)\n\t_this.Value_JS.Set(\"onloadingdone\", cb)\n\treturn cb\n}", "func (v *Value) SetRefreshCallback(fn RefreshCb) *Value {\n\tv.refreshWith = fn\n\treturn v\n}", "func (filterdev *NetworkTap) SetHeaderComplete(f int) error {\n\t_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(filterdev.device.Fd()), syscall.BIOCSHDRCMPLT, uintptr(unsafe.Pointer(&f)))\n\tif err != 0 {\n\t\treturn syscall.Errno(err)\n\t}\n\treturn nil\n}", "func (device *LaserRangeFinderBricklet) SetDistanceCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, option)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetDistanceCallbackThreshold), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (cs mouseCallbacks) SetMouseCallback(e MouseEvent, c Callback) {\n\tif c == nil {\n\t\tdelete(cs, e)\n\t} else {\n\t\tcs[e] = c\n\t}\n}", "func (win *Window) SetMaximizeCallback(callback WindowMaximizeCallback) WindowMaximizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MaximizeCallback\n\tcallbacks.MaximizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowMaximizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowMaximizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (c *ThreeScaleClient) SetHook(cb AfterResponseCB) {\n\tc.afterResponse = cb\n}", "func (s *DefaultSelector) SetOnDataCb(cb OnDataCb) {\n\ts.Lock()\n\tdefer s.Unlock()\n\ts.onDataCb = cb\n}", "func OnComplete(onComplete FnOnComplete) SubscriberOption {\n\treturn func(s *subscriber) {\n\t\ts.fnOnComplete = onComplete\n\t}\n}", "func (win *Window) SetScrollCallback(callback ScrollCallback) ScrollCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ScrollCallback\n\tcallbacks.ScrollCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetScrollCallback(win.c())\n\t} else {\n\t\tC.goRemoveScrollCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetScrollCallback(callback ScrollCallback) ScrollCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ScrollCallback\n\tcallbacks.ScrollCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetScrollCallback(win.c())\n\t} else {\n\t\tC.goRemoveScrollCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetKeyCallback(callback KeyCallback) KeyCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.KeyCallback\n\tcallbacks.KeyCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetKeyCallback(win.c())\n\t} else {\n\t\tC.goRemoveKeyCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetKeyCallback(callback KeyCallback) KeyCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.KeyCallback\n\tcallbacks.KeyCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetKeyCallback(win.c())\n\t} else {\n\t\tC.goRemoveKeyCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func SetAutoComplete(completer AutoCompleter) {\n\tins := getInstance()\n\tcfg := ins.Config.Clone()\n\tcfg.AutoComplete = completer\n\tins.SetConfig(cfg)\n}", "func (win *Window) SetMouseButtonCallback(callback MouseButtonCallback) MouseButtonCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MouseButtonCallback\n\tcallbacks.MouseButtonCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetMouseButtonCallback(win.c())\n\t} else {\n\t\tC.goRemoveMouseButtonCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetMouseButtonCallback(callback MouseButtonCallback) MouseButtonCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MouseButtonCallback\n\tcallbacks.MouseButtonCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetMouseButtonCallback(win.c())\n\t} else {\n\t\tC.goRemoveMouseButtonCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func TestCallbackInvokedWhenSetLate(t *testing.T) {\n\twg := &sync.WaitGroup{}\n\twg.Add(1)\n\tapp := blockedABCIApplication{\n\t\twg: wg,\n\t}\n\t_, c := setupClientServer(t, app)\n\treqRes := c.CheckTxAsync(types.RequestCheckTx{})\n\n\tdone := make(chan struct{})\n\tcb := func(_ *types.Response) {\n\t\tclose(done)\n\t}\n\treqRes.SetCallback(cb)\n\tapp.wg.Done()\n\t<-done\n\n\tvar called bool\n\tcb = func(_ *types.Response) {\n\t\tcalled = true\n\t}\n\treqRes.SetCallback(cb)\n\trequire.True(t, called)\n}", "func (s *Session) SetSendCallback(callback func(*Session, interface{})) {\n\ts.sendCallback = callback\n}", "func (item *CacheItem) SetAboutToExpireCallback(f func(interface{})) {\n\tif len(item.aboutToExpire) > 0 {\n\t\titem.RemoveAboutToExpireCallbacks()\n\t}\n\titem.Lock()\n\tdefer item.Unlock()\n\titem.aboutToExpire = append(item.aboutToExpire, f)\n}", "func (req *Request) SetErrback(errbackName string) *Request {\n\treq.Callback = errbackName\n\treturn req\n}", "func setCallbackContract(name string) {\n\tstate.WriteString(CALLBACK_CONTRACT, name)\n}", "func SetRefreshAuthTokenCallback(f func() string) func(*AviSession) error {\n\treturn func(sess *AviSession) error {\n\t\treturn sess.setRefreshAuthTokenCallback(f)\n\t}\n}", "func SetMouseWheelCallback(f MouseWheelHandler) {\n\tmouseWheel = append(mouseWheel, f)\n\tC.glfwSetMouseWheelCB()\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetRefreshCallback(callback WindowRefreshCallback) WindowRefreshCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.RefreshCallback\n\tcallbacks.RefreshCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowRefreshCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowRefreshCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetRefreshCallback(callback WindowRefreshCallback) WindowRefreshCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.RefreshCallback\n\tcallbacks.RefreshCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowRefreshCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowRefreshCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (l *label) SetFinishedFunc(handler func(key tcell.Key)) tview.FormItem {\n\tl.finished = handler\n\treturn l\n}", "func (win *Window) SetFramebufferSizeCallback(callback FramebufferSizeCallback) FramebufferSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FramebufferSizeCallback\n\tcallbacks.FramebufferSizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetFramebufferSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveFramebufferSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetFramebufferSizeCallback(callback FramebufferSizeCallback) FramebufferSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FramebufferSizeCallback\n\tcallbacks.FramebufferSizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetFramebufferSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveFramebufferSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetSizeCallback(callback WindowSizeCallback) WindowSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.SizeCallback\n\tcallbacks.SizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetSizeCallback(callback WindowSizeCallback) WindowSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.SizeCallback\n\tcallbacks.SizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (o *UcsdBackupInfoAllOf) SetPercentageCompletion(v int64) {\n\to.PercentageCompletion = &v\n}", "func Completion(cmd *cobra.Command, args []string) {\n\terr := cmd.Root().GenBashCompletionFile(completionTarget)\n\tcompletion(err, args...)\n}", "func (_m *MockCompletableFuture[T]) Complete(value T) {\n\t_m.Called(value)\n}", "func (client *Client) SetMessageCallback(request *SetMessageCallbackRequest) (_result *SetMessageCallbackResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &SetMessageCallbackResponse{}\n\t_body, _err := client.SetMessageCallbackWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func TestCallbackInvokedWhenSetEarly(t *testing.T) {\n\twg := &sync.WaitGroup{}\n\twg.Add(1)\n\tapp := blockedABCIApplication{\n\t\twg: wg,\n\t}\n\t_, c := setupClientServer(t, app)\n\treqRes := c.CheckTxAsync(types.RequestCheckTx{})\n\n\tdone := make(chan struct{})\n\tcb := func(_ *types.Response) {\n\t\tclose(done)\n\t}\n\treqRes.SetCallback(cb)\n\tapp.wg.Done()\n\n\tcalled := func() bool {\n\t\tselect {\n\t\tcase <-done:\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t}\n\trequire.Eventually(t, called, time.Second, time.Millisecond*25)\n}", "func (s *server) SetNewClientCB(callback func(c *Client)) {\n\ts.onNewClientCallback = callback\n}", "func (o *GetV0AuthCallbackDefault) SetStatusCode(code int) {\n\to._statusCode = code\n}", "func (c *Prometheus) SetHTTPMetricCallback(callback bucket.HTTPMetricNameAlterCallback) Client {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tc.httpMetricCallback = callback\n\treturn c\n}", "func (t *SelfTester) SetOnNewPoliciesReadyCb(cb func()) {\n}", "func (device *BarometerBricklet) SetAltitudeCallbackThreshold(option ThresholdOption, min int32, max int32) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, option)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetAltitudeCallbackThreshold), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (arg1 *UConverter) SetFromUCallBack(arg2 func(bool, UConverter, []uint16, []byte, []int32, UConverterCallbackReason, *UErrorCode), arg3 *UErrorCode)", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func SetTimeout(callback func(), delay time.Duration) (cancel func()) {\n\treturn SetTimeoutWithContext(context.Background(), callback, delay)\n}", "func (o *InlineResponse20033Milestones) SetCompleterLastname(v string) {\n\to.CompleterLastname = &v\n}", "func (device *LaserRangeFinderBricklet) SetVelocityCallbackThreshold(option ThresholdOption, min int16, max int16) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, option)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetVelocityCallbackThreshold), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func Callback(onFire func() error) *CB {\n\treturn &CB{\n\t\tonFire: onFire,\n\t}\n}", "func (s *TabularJobConfig) SetCompletionCriteria(v *AutoMLJobCompletionCriteria) *TabularJobConfig {\n\ts.CompletionCriteria = v\n\treturn s\n}", "func (c *SearchCall) Callback(callback string) *SearchCall {\n\tc.urlParams_.Set(\"callback\", callback)\n\treturn c\n}", "func (win *Window) SetCursorEnterCallback(callback CursorEnterCallback) CursorEnterCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorEnterCallback\n\tcallbacks.CursorEnterCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorEnterCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorEnterCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCursorEnterCallback(callback CursorEnterCallback) CursorEnterCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorEnterCallback\n\tcallbacks.CursorEnterCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorEnterCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorEnterCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCursorPosCallback(callback CursorPosCallback) CursorPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorPosCallback\n\tcallbacks.CursorPosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorPosCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCursorPosCallback(callback CursorPosCallback) CursorPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorPosCallback\n\tcallbacks.CursorPosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorPosCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (s *TimeSeriesForecastingJobConfig) SetCompletionCriteria(v *AutoMLJobCompletionCriteria) *TimeSeriesForecastingJobConfig {\n\ts.CompletionCriteria = v\n\treturn s\n}", "func SetWindowRefreshCallback(f WindowRefreshHandler) {\n\twindowRefresh = f\n\tC.glfwSetWindowRefreshCB()\n}", "func (self *Tween) SetOnCompleteA(member *Signal) {\n self.Object.Set(\"onComplete\", member)\n}", "func (i *Ime) SetCandidates(parameters Object, callback func(success bool)) {\n\ti.o.Call(\"setCandidates\", parameters, callback)\n}", "func (c *Stats) FlushCallback(f func(metricSeries []*client.DDMetric)) {\n\tc.flushCallback = f\n}", "func (c *Context) SetJoystickCallback(callback JoystickCallback) JoystickCallback {\n\tpreviousCallback := joystickCallback\n\tjoystickCallback = callback\n\tif callback != nil {\n\t\tC.goSetJoystickCallback()\n\t} else {\n\t\tC.goRemoveJoystickCallback()\n\t}\n\treturn previousCallback\n}", "func (c *Context) SetJoystickCallback(callback JoystickCallback) JoystickCallback {\n\tpreviousCallback := joystickCallback\n\tjoystickCallback = callback\n\tif callback != nil {\n\t\tC.goSetJoystickCallback()\n\t} else {\n\t\tC.goRemoveJoystickCallback()\n\t}\n\treturn previousCallback\n}" ]
[ "0.7559254", "0.68985003", "0.6753321", "0.6613184", "0.64593345", "0.611201", "0.6071126", "0.59966904", "0.5947144", "0.590608", "0.5787208", "0.5714929", "0.5710185", "0.56814975", "0.56087536", "0.56087536", "0.55971366", "0.5591729", "0.55124784", "0.55124784", "0.540154", "0.5374355", "0.5374355", "0.52947634", "0.5282134", "0.5267603", "0.5247907", "0.5234132", "0.5223576", "0.5223576", "0.5200483", "0.51956636", "0.5172468", "0.51537323", "0.5135751", "0.5122596", "0.5101519", "0.5039487", "0.50383383", "0.5016339", "0.50068015", "0.5005664", "0.50024444", "0.4991537", "0.49912405", "0.4988781", "0.49887124", "0.49863398", "0.49863398", "0.49839416", "0.49839416", "0.49751514", "0.4969367", "0.4969367", "0.4967623", "0.49212828", "0.49170563", "0.49158624", "0.4911396", "0.4876612", "0.4855465", "0.4839774", "0.4839774", "0.483928", "0.483928", "0.4828361", "0.48091912", "0.48091912", "0.4779748", "0.4779748", "0.47742954", "0.47670254", "0.47601154", "0.47577706", "0.4752885", "0.47359258", "0.47278458", "0.47194216", "0.47162953", "0.47095102", "0.47078776", "0.47040284", "0.47040284", "0.4678937", "0.46727306", "0.4666388", "0.46658155", "0.46619824", "0.46612707", "0.46551397", "0.46551397", "0.4647265", "0.4647265", "0.46421012", "0.46368304", "0.46359053", "0.46326578", "0.46316305", "0.46295998", "0.46295998" ]
0.8331443
0
SetHintsCallback sets the hints callback function.
func (l *Linenoise) SetHintsCallback(fn func(string) *Hint) { l.hintsCallback = fn }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Window) SetHints(hints hints) {\n\tw.hints |= hints\n}", "func (v *TextView) SetInputHints(hints InputHints) {\n\tC.gtk_text_view_set_input_hints(v.native(), C.GtkInputHints(hints))\n}", "func (f *Font) SetHinting(hinting int) {\n\tC.TTF_SetFontHinting(f.f, C.int(hinting))\n}", "func InitHint(hint Hint, value HintValue) {\n\tC.glfwInitHint(C.int(hint), C.int(value))\n}", "func (jbobject *ClientConfiguration) SetSocketBufferSizeHints(a int, b int) {\n\t_, err := jbobject.CallMethod(javabind.GetEnv(), \"setSocketBufferSizeHints\", javabind.Void, a, b)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n}", "func (o *FontOptions) SetHintStyle(hintStyle HintStyle) {\n\tC.cairo_font_options_set_hint_style(o.native, C.cairo_hint_style_t(hintStyle))\n}", "func (l *Linenoise) SetCompletionCallback(fn func(string) []string) {\n\tl.completionCallback = fn\n}", "func InitHint(hint Hint, value int) {\n\tC.glfwInitHint(C.int(hint), C.int(value))\n}", "func (o *ReaderOptions) SetPasswordCallback(cb func() string) {\n\to.cb = cb\n}", "func WithCursorHints(hints ...CursorHint) CursorOption {\n\treturn func(c *CursorConfig) {\n\t\tfor _, hint := range hints {\n\t\t\thint(&c.Hints)\n\t\t}\n\t}\n}", "func (device *LaserRangeFinderBricklet) SetDistanceCallbackThreshold(option ThresholdOption, min uint16, max uint16) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, option)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetDistanceCallbackThreshold), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (ao *AggregateOptions) SetHint(h interface{}) *AggregateOptions {\n\tao.Hint = h\n\treturn ao\n}", "func WithCursorHintPredicate(f CursorPredicateFunc) CursorHint {\n\treturn func(o *CursorHints) {\n\t\to.PredicateFn = f\n\t}\n}", "func (o *FontOptions) SetHintMetrics(hintMetrics HintMetrics) {\n\tC.cairo_font_options_set_hint_metrics(o.native, C.cairo_hint_metrics_t(hintMetrics))\n}", "func (mn *MockNetwork) SetConnectCallback(network.ConnectCallback) {\n\n}", "func SetMouseWheelCallback(f MouseWheelHandler) {\n\tmouseWheel = append(mouseWheel, f)\n\tC.glfwSetMouseWheelCB()\n}", "func WithHintf(err error, format string, args ...interface{}) error {\n\treturn hintdetail.WithHintf(err, format, args...)\n}", "func (req *Request) SetCallback(parserName string) *Request {\n\treq.Callback = parserName\n\treturn req\n}", "func (device *BarometerBricklet) SetAltitudeCallbackThreshold(option ThresholdOption, min int32, max int32) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, option)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetAltitudeCallbackThreshold), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (win *Window) SetTypeHint(hint gdk.WindowTypeHint) {\n\twin.Candy().Guify(\"gtk_window_set_type_hint\", win, hint)\n}", "func (s *Module) SetUpdateValidatorsCallback(f func(uint32, keys.PublicKeys)) {\n\ts.mtx.Lock()\n\tdefer s.mtx.Unlock()\n\ts.updateValidatorsCb = f\n}", "func (f *Session) SetHint(hint interface{}) *Session {\n\tf.findOneAndUpdateOpts = append(f.findOneAndUpdateOpts,\n\t\toptions.FindOneAndUpdate().SetHint(hint))\n\tf.findOneAndReplaceOpts = append(f.findOneAndReplaceOpts,\n\t\toptions.FindOneAndReplace().SetHint(hint))\n\tf.findOneAndDeleteOpts = append(f.findOneAndDeleteOpts, options.FindOneAndDelete().SetHint(hint))\n\tf.updateOpts = append(f.updateOpts, options.Update().SetHint(hint))\n\treturn f\n}", "func (win *Window) SetSizeCallback(callback WindowSizeCallback) WindowSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.SizeCallback\n\tcallbacks.SizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetSizeCallback(callback WindowSizeCallback) WindowSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.SizeCallback\n\tcallbacks.SizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (c *Context) SetMonitorCallback(callback MonitorCallback) MonitorCallback {\n\tpreviousCallback := monitorCallback\n\tmonitorCallback = callback\n\tif callback != nil {\n\t\tC.goSetMonitorCallback()\n\t} else {\n\t\tC.goRemoveMonitorCallback()\n\t}\n\treturn previousCallback\n}", "func (c *Context) SetMonitorCallback(callback MonitorCallback) MonitorCallback {\n\tpreviousCallback := monitorCallback\n\tmonitorCallback = callback\n\tif callback != nil {\n\t\tC.goSetMonitorCallback()\n\t} else {\n\t\tC.goRemoveMonitorCallback()\n\t}\n\treturn previousCallback\n}", "func (s *RuntimeHints) SetSlotHints(v map[string]map[string]*RuntimeHintDetails) *RuntimeHints {\n\ts.SlotHints = v\n\treturn s\n}", "func (win *Window) SetMaximizeCallback(callback WindowMaximizeCallback) WindowMaximizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MaximizeCallback\n\tcallbacks.MaximizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowMaximizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowMaximizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (c *Client) SetWrappingLookupFunc(lookupFunc WrappingLookupFunc) {\n\tc.modifyLock.Lock()\n\tdefer c.modifyLock.Unlock()\n\tc.wrappingLookupFunc = lookupFunc\n}", "func (win *Window) SetFocusCallback(callback WindowFocusCallback) WindowFocusCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FocusCallback\n\tcallbacks.FocusCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowFocusCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowFocusCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetFocusCallback(callback WindowFocusCallback) WindowFocusCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FocusCallback\n\tcallbacks.FocusCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowFocusCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowFocusCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetFramebufferSizeCallback(callback FramebufferSizeCallback) FramebufferSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FramebufferSizeCallback\n\tcallbacks.FramebufferSizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetFramebufferSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveFramebufferSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetFramebufferSizeCallback(callback FramebufferSizeCallback) FramebufferSizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.FramebufferSizeCallback\n\tcallbacks.FramebufferSizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetFramebufferSizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveFramebufferSizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (c *Context) WindowHint(hint Hint, value HintValue) {\n\tC.glfwWindowHint(C.int(hint), C.int(value))\n}", "func (c *Context) WindowHint(hint Hint, value HintValue) {\n\tC.glfwWindowHint(C.int(hint), C.int(value))\n}", "func (q *Queue) SetCallback(cb Callback) error {\n\tq.cb = cb\n\treturn nil\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetScrollCallback(callback ScrollCallback) ScrollCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ScrollCallback\n\tcallbacks.ScrollCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetScrollCallback(win.c())\n\t} else {\n\t\tC.goRemoveScrollCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetScrollCallback(callback ScrollCallback) ScrollCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ScrollCallback\n\tcallbacks.ScrollCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetScrollCallback(win.c())\n\t} else {\n\t\tC.goRemoveScrollCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (item *CacheItem) SetAboutToExpireCallback(f func(interface{})) {\n\tif len(item.aboutToExpire) > 0 {\n\t\titem.RemoveAboutToExpireCallbacks()\n\t}\n\titem.Lock()\n\tdefer item.Unlock()\n\titem.aboutToExpire = append(item.aboutToExpire, f)\n}", "func SetOutputCallback(fn OutNextCallbackFunc) {\n\toutNextCallback = fn\n}", "func (c *Context) SetHinting(hinting font.Hinting) {\n\tc.hinting = hinting\n\tfor i := range c.cache {\n\t\tc.cache[i] = cacheEntry{}\n\t}\n}", "func (ps *PeerState) SetRoundCallback(height uint32, round uint16, f func()) {\n\tps.mtx.Lock()\n\tdefer ps.mtx.Unlock()\n\tif ps.height < height {\n\t\tps.cbHeight = height\n\t\tps.cbRound = round\n\t\tps.cbFunc = f\n\t\t// Wait until the height of the peerState changes.\n\t\t// We'll call cbFunc then.\n\t\treturn\n\t} else if ps.height == height {\n\t\tpeerRound := calcRound(ps.startTime)\n\t\tif peerRound < round {\n\t\t\t// Set a timer to call the cbFunc when the time comes.\n\t\t\tgo func() {\n\t\t\t\troundStart := calcRoundStartTime(round, ps.startTime)\n\t\t\t\ttime.Sleep(roundStart.Sub(time.Now()))\n\t\t\t\t// If peer height is still good\n\t\t\t\tps.mtx.Lock()\n\t\t\t\tpeerHeight := ps.height\n\t\t\t\tps.mtx.Unlock()\n\t\t\t\tif peerHeight == height {\n\t\t\t\t\tf()\n\t\t\t\t}\n\t\t\t}()\n\t\t} else if peerRound == round {\n\t\t\tgo f()\n\t\t} else {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\treturn\n\t}\n}", "func (ls *linestate) refreshShowHints() []string {\n\t// do we have a hints callback?\n\tif ls.ts.hintsCallback == nil {\n\t\t// no hints\n\t\treturn nil\n\t}\n\t// How many columns do we have for the hint?\n\thintCols := ls.cols - ls.promptWidth - runewidth.StringWidth(string(ls.buf))\n\tif hintCols <= 0 {\n\t\t// no space to display hints\n\t\treturn nil\n\t}\n\t// get the hint\n\th := ls.ts.hintsCallback(string(ls.buf))\n\tif h == nil || len(h.Hint) == 0 {\n\t\t// no hints\n\t\treturn nil\n\t}\n\t// trim the hint until it fits\n\thEnd := len(h.Hint)\n\tfor runewidth.StringWidth(h.Hint[:hEnd]) > hintCols {\n\t\thEnd--\n\t}\n\t// color fixup\n\tif h.Bold && h.Color < 0 {\n\t\th.Color = 37\n\t}\n\t// build the output string\n\tseq := make([]string, 0, 3)\n\tif h.Color >= 0 || h.Bold {\n\t\tseq = append(seq, fmt.Sprintf(\"\\033[%d;%d;49m\", btoi(h.Bold), h.Color))\n\t}\n\tseq = append(seq, h.Hint[:hEnd])\n\tif h.Color >= 0 || h.Bold {\n\t\tseq = append(seq, \"\\033[0m\")\n\t}\n\treturn seq\n}", "func SetWindowSizeCallback(f WindowSizeHandler) {\n\twindowSize = f\n\tC.glfwSetWindowSizeCB()\n}", "func Hint(target, mode Enum) {\n\tgl.Hint(uint32(target), uint32(mode))\n}", "func (b *ExperimentBuilder) SetCallbacks(callbacks model.ExperimentCallbacks) {\n\tb.callbacks = callbacks\n}", "func (c *Client) SetMsgCallback(cb adapter.MsgCallback) {\n\tlog.Debug(\"SetMsgCallback\")\n\tc.msgCallback = cb\n}", "func (s *Strava) SetCallbackHandler(\n\tsuccess func(auth *strava.AuthorizationResponse, w http.ResponseWriter, r *http.Request),\n\tfailure func(err error, w http.ResponseWriter, r *http.Request)) {\n\tpath, _ := s.authenticator.CallbackPath()\n\thttp.HandleFunc(path, s.authenticator.HandlerFunc(success, failure))\n}", "func LogHint(reason string) {\n\t// no-op when hints not enabled\n}", "func (s *SourceProperties) SetIdentificationHints(v *IdentificationHints) *SourceProperties {\n\ts.IdentificationHints = v\n\treturn s\n}", "func (g *Gui) SetManagerFunc(manager func(*Gui) error) {\n\tg.SetManager(ManagerFunc(manager))\n}", "func WithCallback(callback EnableCallback) ProviderOpt {\n\treturn func(opts *providerOpts) {\n\t\topts.callback = callback\n\t}\n}", "func hints(s string) *cli.Hint {\n\tif s == \"hello\" {\n\t\t// string, color, bold\n\t\treturn &cli.Hint{\" World\", 35, false}\n\t}\n\treturn nil\n}", "func (wrapper *HTTPServerConnectionChainWrapper) AddCallback(callback ConnectionCallback) {\n\twrapper.callbacks = append(wrapper.callbacks, callback)\n}", "func (win *Window) SetPosCallback(callback WindowPosCallback) WindowPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.PosCallback\n\tcallbacks.PosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowPosCallback(win.c())\n\t}\n\treturn previousCallback\n}", "func (win *Window) SetPosCallback(callback WindowPosCallback) WindowPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.PosCallback\n\tcallbacks.PosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowPosCallback(win.c())\n\t}\n\treturn previousCallback\n}", "func (mb *MenuButton) SetCallBack(callback Callback) {\n\tmb.callback = callback\n}", "func SetTemperatureCallbackThreshold(id string, uid uint32, t *device.Threshold16, handler func(device.Resulter, error)) *device.Device {\n\treturn device.Generator{\n\t\tId: device.FallbackId(id, \"SetTemperatureCallbackThreshold\"),\n\t\tFid: function_set_temperature_callback_threshold,\n\t\tUid: uid,\n\t\tData: t,\n\t\tHandler: handler,\n\t\tWithPacket: true}.CreateDevice()\n}", "func (jbobject *ClientConfiguration) WithSocketBufferSizeHints(a int, b int) *ClientConfiguration {\n\tjret, err := jbobject.CallMethod(javabind.GetEnv(), \"withSocketBufferSizeHints\", \"com/amazonaws/ClientConfiguration\", a, b)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tretconv := javabind.NewJavaToGoCallable()\n\tdst := &javabind.Callable{}\n\tretconv.Dest(dst)\n\tif err := retconv.Convert(javabind.ObjectRef(jret)); err != nil {\n\t\tpanic(err)\n\t}\n\tretconv.CleanUp()\n\tunique_x := &ClientConfiguration{}\n\tunique_x.Callable = dst\n\treturn unique_x\n}", "func setCallback(a *apl.Apl, L, R apl.Value) (apl.Value, error) {\n\tw, ok := toWidget(L)\n\tif ok == false {\n\t\treturn nil, fmt.Errorf(\"u f: left argument must be a widget\")\n\t}\n\n\tlst, ok := R.(apl.List)\n\tif ok == false {\n\t\treturn nil, fmt.Errorf(\"u f: right argument must be a list\")\n\t}\n\tif len(lst) == 1 {\n\t\tif fn, ok := lst[0].(apl.Function); ok {\n\t\t\treturn setcb(a, w, fn)\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"u f: argument must be a list containing a single function\")\n}", "func (win *Window) SetCloseCallback(callback WindowCloseCallback) WindowCloseCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CloseCallback\n\tcallbacks.CloseCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowCloseCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowCloseCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCloseCallback(callback WindowCloseCallback) WindowCloseCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CloseCallback\n\tcallbacks.CloseCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowCloseCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowCloseCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (builder *TsListKeysCommandBuilder) WithCallback(callback func([][]TsCell) error) *TsListKeysCommandBuilder {\n\tbuilder.callback = callback\n\treturn builder\n}", "func InitHintBool(hint Hint, value bool) {\n\tif value {\n\t\tInitHint(hint, True)\n\t} else {\n\t\tInitHint(hint, False)\n\t}\n}", "func (s *PipelineExecutionStepMetadata) SetCallback(v *CallbackStepMetadata) *PipelineExecutionStepMetadata {\n\ts.Callback = v\n\treturn s\n}", "func (g *goMetrics) AddCallback(f func(stats *runtime.MemStats)) {\n\tg.mu.Lock()\n\tg.cb = append(g.cb, f)\n\tg.mu.Unlock()\n}", "func (lvs *ValueStore) setHintsForReachable(v Value, r hash.Hash, toPending bool) {\n\tv.WalkRefs(func(reachable Ref) {\n\t\thash := reachable.TargetHash()\n\t\tif cur := lvs.check(hash); cur == nil || cur.Hint().IsEmpty() || cur.Hint() == hash {\n\t\t\tlvs.set(hash, hintedChunk{getTargetType(reachable), r}, toPending)\n\t\t}\n\t})\n}", "func (w *TextWidget) SetPrompt(g *gocui.Gui, prefix, content string, callback func(bool, string)) error {\n\tif w.view == nil {\n\t\treturn nil\n\t}\n\n\tgx := New(g)\n\n\toldfocus := g.CurrentView()\n\tg.Cursor = true\n\tgx.Focus(w.view)\n\n\tw.SetText(prefix)\n\tfmt.Fprintf(w.view, content)\n\n\teditor := PromptEditor(g, len(prefix), func(success bool, response string) {\n\t\tw.setEditor(nil)\n\t\tgx.Focus(oldfocus)\n\t\tg.Cursor = false\n\t\tcallback(success, response)\n\t})\n\n\tw.setEditor(editor)\n\n\treturn w.view.SetCursor(len(prefix)+len(content), 0)\n}", "func GetAllHints(err error) []string { return hintdetail.GetAllHints(err) }", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (q *Query) Hint(hint interface{}) QueryI {\n\tnewQ := q\n\tnewQ.hint = hint\n\treturn newQ\n}", "func (c *Stats) FlushCallback(f func(metricSeries []*client.DDMetric)) {\n\tc.flushCallback = f\n}", "func (i *Ime) SetCandidates(parameters Object, callback func(success bool)) {\n\ti.o.Call(\"setCandidates\", parameters, callback)\n}", "func (client *SyncClient) SetCompletionListener(callback syncCompletionListener) error {\n\tif callback == nil {\n\t\tC.obx_sync_listener_complete(client.cClient, nil, nil)\n\t\tcCallbackUnregister(client.cCallbacks[cCallbackIndexCompletion])\n\t} else {\n\t\tif cbId, err := cCallbackRegister(cVoidCallback(func() {\n\t\t\tcallback()\n\t\t})); err != nil {\n\t\t\treturn err\n\t\t} else {\n\t\t\tC.obx_sync_listener_complete(client.cClient, (*C.OBX_sync_listener_complete)(cVoidCallbackDispatchPtr), cbId.cPtr())\n\t\t\tclient.swapCallbackId(cCallbackIndexCompletion, cbId)\n\t\t}\n\t}\n\treturn nil\n}", "func (c *Context) DefaultWindowHints() {\n\tC.glfwDefaultWindowHints()\n}", "func (c *Context) DefaultWindowHints() {\n\tC.glfwDefaultWindowHints()\n}", "func (builder *TsQueryCommandBuilder) WithCallback(callback func([][]TsCell) error) *TsQueryCommandBuilder {\n\tbuilder.callback = callback\n\treturn builder\n}", "func (win *Window) SetRefreshCallback(callback WindowRefreshCallback) WindowRefreshCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.RefreshCallback\n\tcallbacks.RefreshCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowRefreshCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowRefreshCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetRefreshCallback(callback WindowRefreshCallback) WindowRefreshCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.RefreshCallback\n\tcallbacks.RefreshCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowRefreshCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowRefreshCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (self *SinglePad) SetOnConnectCallbackA(member interface{}) {\n self.Object.Set(\"onConnectCallback\", member)\n}", "func (l *Loader) SetLookupFn(fn func(string) (string, bool)) {\n\tl.lock.Lock()\n\tdefer l.lock.Unlock()\n\n\tl.lookUp = fn\n}", "func Hint(target GLenum, mode GLenum) {\n\tC.glHint(C.GLenum(target), C.GLenum(mode))\n}", "func (t *SelfTester) SetOnNewPoliciesReadyCb(cb func()) {\n}", "func (t *StreamTransport) SetCallBack(cb StreamTransportCallbacker) {\n\tt.cb = cb\n}", "func (win *Window) SetDropCallback(callback DropCallback) DropCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.DropCallback\n\tcallbacks.DropCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetDropCallback(win.c())\n\t} else {\n\t\tC.goRemoveDropCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetDropCallback(callback DropCallback) DropCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.DropCallback\n\tcallbacks.DropCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetDropCallback(win.c())\n\t} else {\n\t\tC.goRemoveDropCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func SetKeyCallback(f KeyHandler) {\n\tkey = append(key, f)\n\tC.glfwSetKeyCB()\n}", "func (v *TextView) GetInputHints() InputHints {\n\tc := C.gtk_text_view_get_input_hints(v.native())\n\treturn InputHints(c)\n}", "func (client *Client) SetCasterConfigWithCallback(request *SetCasterConfigRequest, callback func(response *SetCasterConfigResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *SetCasterConfigResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.SetCasterConfig(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func (c *Context) SetJoystickCallback(callback JoystickCallback) JoystickCallback {\n\tpreviousCallback := joystickCallback\n\tjoystickCallback = callback\n\tif callback != nil {\n\t\tC.goSetJoystickCallback()\n\t} else {\n\t\tC.goRemoveJoystickCallback()\n\t}\n\treturn previousCallback\n}", "func (c *Context) SetJoystickCallback(callback JoystickCallback) JoystickCallback {\n\tpreviousCallback := joystickCallback\n\tjoystickCallback = callback\n\tif callback != nil {\n\t\tC.goSetJoystickCallback()\n\t} else {\n\t\tC.goRemoveJoystickCallback()\n\t}\n\treturn previousCallback\n}", "func Hint(target Enum, mode Enum) {\n\tctarget, _ := (C.GLenum)(target), cgoAllocsUnknown\n\tcmode, _ := (C.GLenum)(mode), cgoAllocsUnknown\n\tC.glHint(ctarget, cmode)\n}", "func (cs mouseCallbacks) SetMouseCallback(e MouseEvent, c Callback) {\n\tif c == nil {\n\t\tdelete(cs, e)\n\t} else {\n\t\tcs[e] = c\n\t}\n}", "func increaseMarkersIndexCallbackStrategy(markers.SequenceID, markers.Index) bool {\n\treturn true\n}", "func (arg1 *UConverter) SetToUCallBack(arg2 func(bool, UConverter, []byte, []uint16, []int32, UConverterCallbackReason, *UErrorCode), arg3 *UErrorCode)", "func (win *Window) SetCursorPosCallback(callback CursorPosCallback) CursorPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorPosCallback\n\tcallbacks.CursorPosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorPosCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCursorPosCallback(callback CursorPosCallback) CursorPosCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CursorPosCallback\n\tcallbacks.CursorPosCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCursorPosCallback(win.c())\n\t} else {\n\t\tC.goRemoveCursorPosCallback(win.c())\n\t}\n\n\treturn previousCallback\n}" ]
[ "0.6655771", "0.5874338", "0.5531722", "0.53638446", "0.5362723", "0.53541845", "0.52623695", "0.523914", "0.52245545", "0.52127707", "0.5178566", "0.51380336", "0.5067138", "0.504538", "0.50408465", "0.5038447", "0.49948537", "0.4993341", "0.4972689", "0.4966621", "0.49430433", "0.48598742", "0.48316455", "0.48316455", "0.48010433", "0.48010433", "0.47692224", "0.4749948", "0.47435993", "0.47360337", "0.47360337", "0.47309884", "0.47309884", "0.47251824", "0.47251824", "0.47009182", "0.46637183", "0.46637183", "0.4652923", "0.4652923", "0.46506032", "0.46433717", "0.45944464", "0.45332086", "0.45158768", "0.45055783", "0.45031118", "0.44796628", "0.44503883", "0.44351083", "0.44319668", "0.44162238", "0.4409221", "0.44083622", "0.4407135", "0.44066817", "0.44039458", "0.44039458", "0.4392523", "0.43653736", "0.43613118", "0.43551657", "0.43406585", "0.43406585", "0.43382004", "0.43222234", "0.43195298", "0.43150932", "0.43119192", "0.43018183", "0.42997065", "0.42987412", "0.42987412", "0.42912558", "0.42892775", "0.4275991", "0.42730337", "0.42665407", "0.42665407", "0.42587125", "0.42575875", "0.42575875", "0.4250653", "0.4245085", "0.4244204", "0.42398182", "0.42310956", "0.42308626", "0.42308626", "0.4225182", "0.4223597", "0.4214574", "0.42085642", "0.42085642", "0.42071107", "0.42046237", "0.41980803", "0.41932178", "0.41891026", "0.41891026" ]
0.8803182
0
SetMultiline sets multiline editing mode.
func (l *Linenoise) SetMultiline(mode bool) { l.mlmode = mode }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *Discord) SupportsMultiline() bool {\n\treturn true\n}", "func (d *Discord) SupportsMultiline() bool {\n\treturn true\n}", "func (f *StandardFormatter) SetAppendNewLine(appendNewLine bool) {\n\tf.mutex.Lock()\n\tdefer f.mutex.Unlock()\n\tf.appendNewLine = appendNewLine\n}", "func SetLines(l []string) {\n\tlines = l\n}", "func (b *Blueprint) MultiLineString(column string) *ColumnDefinition {\n\treturn b.addColumn(\"multilinestring\", column, nil)\n}", "func NewMultiLineParser(flushTimeout time.Duration, parser parser.Parser, lineHandler LineHandler, lineLimit int) *MultiLineParser {\n\treturn &MultiLineParser{\n\t\tinputChan: make(chan *DecodedInput),\n\t\tbuffer: bytes.NewBuffer(nil),\n\t\tflushTimeout: flushTimeout,\n\t\tlineHandler: lineHandler,\n\t\tlineLimit: lineLimit,\n\t\tparser: parser,\n\t}\n}", "func (s *VisvalingamSimplifier) MultiLineString(mls orb.MultiLineString) orb.MultiLineString {\n\treturn multiLineString(s, mls)\n}", "func (t *Textarea) SetHeight(val int) {\n\tt.Call(\"setAttribute\", \"style\", \"height:\"+strconv.Itoa(val)+\"px\")\n}", "func NewMultiLineEntry(text string, placeholder string, isReadOnly bool) (entry *widget.Entry) {\n\tentry = widget.NewMultiLineEntry()\n\tentry.SetText(text)\n\tentry.SetPlaceHolder(placeholder)\n\tentry.SetReadOnly(isReadOnly)\n\treturn\n}", "func (s *Set) SetMaxLineSize(i int) {\n\ts.MaxLineSize = i\n}", "func (v *TextView) SetEditable(editable bool) {\n\tC.gtk_text_view_set_editable(v.native(), gbool(editable))\n}", "func (s *Surface) SetLineMiterLimit(miter float64) {\n\ts.Ctx.Set(\"miterLimit\", miter)\n}", "func (v *Label) SetLines(lines int) {\n\tC.gtk_label_set_lines(v.native(), C.gint(lines))\n}", "func (l *Logger) SetNumLines(n int) {\n\t// Acquire lock\n\tl.mu.Lock()\n\t// Defer the release of our lock\n\tdefer l.mu.Unlock()\n\t// Set line number limit\n\tl.numLines = n\n}", "func (canvas *Canvas) SetLineWidth(w Unit) {\n\twriteCommand(canvas.contents, \"w\", w)\n}", "func (v *TextView) SetWrapMode(wrapMode WrapMode) {\n\tC.gtk_text_view_set_wrap_mode(v.native(), C.GtkWrapMode(wrapMode))\n}", "func (r *REPL) DisableMultiLineBuffering(yes bool) *REPL {\n\tr.bufferDisabled = yes\n\treturn r\n}", "func EscapeMultiLine(content string) string {\n\tcontent = strings.TrimSpace(content)\n\tcontent = strings.Replace(content, \"\\n\", `\\`+\"\\n\", -1)\n\n\tcontent = multipleNewLinesInLinkRegex.ReplaceAllString(content, \"\\n\\\\\")\n\n\treturn content\n}", "func (ed *Editor) SetSelection(start, end int) {\n\tif ed.getTextarea() == nil {\n\t\treturn\n\t}\n\ted.ta.SetSelectionStart(start)\n\ted.ta.SetSelectionEnd(end)\n}", "func (t *Tab) SetMargined(n int, margined bool) {\n\tC.uiTabSetMargined(t.t, C.int(n), frombool(margined))\n}", "func SetEscapeNewlines(en bool) {\n\tescapeNewlines = en\n}", "func (d *Doc) AddMultilineText(x, y float64, content string) {\n\tdata := strings.Split(content, \"\\n\")\n\tfor i := range data {\n\t\td.AddText(x, y, data[i])\n\t\ty += d.DefaultLineHeight()\n\t}\n}", "func SetDefaultLine(line Line) {\n\tdefaultLine = line\n}", "func (buf *CommandBuffer) SetLineWidth(lineWidth float32) {\n\tC.domVkCmdSetLineWidth(buf.fps[vkCmdSetLineWidth], buf.hnd, C.float(lineWidth))\n}", "func (s *Set) SetLineSize(i int) {\n\tif i > s.MaxLineSize {\n\t\ts.LineSize = s.MaxLineSize\n\t} else {\n\t\ts.LineSize = i\n\t}\n}", "func UseLiteralStyleIfMultiline(useLiteralStyleIfMultiline bool) EncodeOption {\n\treturn func(e *Encoder) error {\n\t\te.useLiteralStyleIfMultiline = useLiteralStyleIfMultiline\n\t\treturn nil\n\t}\n}", "func (w *IPWriter) SetCurrentLine(n uint) {\n\tw.currentLine = n\n}", "func NewLineEditor() *LineEditor {\n\treturn &LineEditor{\n\t\tCx: 0,\n\t\tRow: ERow{},\n\t}\n}", "func MultiLine(key, val string) zapcore.Field {\n\treturn zapcore.Field{Key: key, Type: zapcore.StringerType, Interface: multiLineString{val}}\n}", "func (r *AutoRoller) SetMode(m, user, message string) error {\n\tr.modeMtx.Lock()\n\tdefer r.modeMtx.Unlock()\n\tif err := r.modeHistory.Add(m, user, message); err != nil {\n\t\treturn err\n\t}\n\treturn r.doAutoRoll()\n}", "func (r *AutoRoller) SetMode(m, user, message string) error {\n\tif err := r.modeHistory.Add(m, user, message); err != nil {\n\t\treturn err\n\t}\n\treturn r.Tick()\n}", "func (m *MockSettings) SetMaxLineSize(arg0 int) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SetMaxLineSize\", arg0)\n}", "func SetConsoleMode(hConsoleHandle HANDLE, dwMode DWORD) bool {\n\tret1 := syscall3(setConsoleMode, 2,\n\t\tuintptr(hConsoleHandle),\n\t\tuintptr(dwMode),\n\t\t0)\n\treturn ret1 != 0\n}", "func (t *Table) SetRowLine(line bool) {\n\tt.rowLine = line\n}", "func (this *Tidy) Newline(val int) (bool, error) {\n\tswitch val {\n\tcase LF, CRLF, CR:\n\t\treturn this.optSetInt(C.TidyNewline, (C.ulong)(val))\n\t}\n\treturn false, errors.New(\"Argument val int is out of range (0,1,2)\")\n}", "func (tb *TextBuf) LinesEdited(tbe *TextBufEdit) {\n\ttb.LinesMu.Lock()\n\ttb.MarkupMu.Lock()\n\n\tst, ed := tbe.Reg.Start.Ln, tbe.Reg.End.Ln\n\tfor ln := st; ln <= ed; ln++ {\n\t\ttb.LineBytes[ln] = []byte(string(tb.Lines[ln]))\n\t\ttb.Markup[ln] = HTMLEscapeBytes(tb.LineBytes[ln])\n\t}\n\ttb.MarkupLines(st, ed)\n\ttb.MarkupMu.Unlock()\n\ttb.LinesMu.Unlock()\n\t// probably don't need to do global markup here..\n}", "func (s *SSAGenState) SetLineno(l int32)", "func (t *Textarea) SetSelectionEnd(val int) {\n\tt.Set(\"selectionEnd\", t.utf8ToUTF16Pos(val))\n}", "func (s *Surface) SetLineJoin(join LineJoin) {\n\ts.Ctx.Set(\"lineJoin\", string(join))\n}", "func (m *msg) SetMode(md mode) {\n\tm.LiVnMode = (m.LiVnMode & 0xf8) | byte(md)\n}", "func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter {\n\t//fmt.Fprintf(os.Stderr, \"FileLogWriter.SetRotateLines: %v\\n\", maxlines)\n\tw.maxlines = maxlines\n\treturn w\n}", "func (p *Page) SetLineWidth(w float64) {\n\tfmt.Fprint(p.contents, w, \" w \")\n}", "func (c *CursesConfig) SetCommandMode(mode tileslib.CommandModeType) {\n\tc.base.CommandMode = mode\n}", "func SetConsole() error {\n\treturn nil\n}", "func (v *TextView) SetAcceptsTab(acceptsTab bool) {\n\tC.gtk_text_view_set_accepts_tab(v.native(), gbool(acceptsTab))\n}", "func (d *Display) AutoLineWrapOff() error {\n\t_, err := d.port.Write([]byte(AutoLineWrapOff))\n\treturn err\n}", "func (p *LegoPort) SetMode(m string) *LegoPort {\n\tif p.err != nil {\n\t\treturn p\n\t}\n\tp.err = setAttributeOf(p, mode, m)\n\treturn p\n}", "func ConvertMultiLineText(s string, isTable bool, isHeader bool, showHTML bool) string {\n\tif isTable {\n\t\ts = strings.TrimSpace(s)\n\t}\n\n\t// Convert line-break on a non-empty line followed by another line\n\t// starting with \"alphanumeric\" word into space-space-newline\n\t// which is a know convention of Markdown for multi-lines paragprah.\n\t// This doesn't apply on a markdown list for example, because all the\n\t// consecutive lines start with hyphen which is a special character.\n\tif !isHeader {\n\t\ts = regexp.MustCompile(`(\\S*)(\\r?\\n)(\\s*)(\\w+)`).ReplaceAllString(s, \"$1 $2$3$4\")\n\t\ts = strings.ReplaceAll(s, \" \\n\", \" \\n\")\n\t\ts = strings.ReplaceAll(s, \" \\n\\n\", \"\\n\\n\")\n\t\ts = strings.ReplaceAll(s, \"\\n \\n\", \"\\n\\n\")\n\t}\n\n\tif !isTable {\n\t\treturn s\n\t}\n\n\t// representation of line break. <br> if showHTML is true, <space> if false.\n\tlinebreak := \" \"\n\n\tif showHTML {\n\t\tlinebreak = \"<br>\"\n\t}\n\n\t// Convert space-space-newline to 'linebreak'.\n\ts = strings.ReplaceAll(s, \" \\n\", linebreak)\n\n\t// Convert single newline to 'linebreak'.\n\treturn strings.ReplaceAll(s, \"\\n\", linebreak)\n}", "func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children))\n}", "func writeMultiline(log logging.Logger, s string) {\n\tif s == \"\" {\n\t\treturn\n\t}\n\tfor _, line := range strings.Split(strings.TrimSuffix(s, \"\\n\"), \"\\n\") {\n\t\tlog.Log(line)\n\t}\n}", "func (ls *linestate) editSet(s string) {\n\tls.buf = []rune(s)\n\tls.pos = len(ls.buf)\n\tls.refreshLine()\n}", "func (mr *MockSettingsMockRecorder) SetMaxLineSize(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetMaxLineSize\", reflect.TypeOf((*MockSettings)(nil).SetMaxLineSize), arg0)\n}", "func (s *BaseSyslParserListener) EnterMulti_line_docstring(ctx *Multi_line_docstringContext) {}", "func (d *Doc) AddFormattedMultilineText(x, y float64, content string, size int, style string) {\n\td.SetFontSize(size)\n\td.SetFontStyle(style)\n\tdata := strings.Split(content, \"\\n\")\n\tfor i := range data {\n\t\td.AddText(x, y, data[i])\n\t\ty += d.DefaultLineHeight()\n\t}\n\td.DefaultFontSize()\n\td.DefaultFontStyle()\n}", "func (s *Store) SetLineDelim(str string) {\n\ts.delim = str\n}", "func (xs *Sheet) SetDisplayGridlines(show int) {\n\txs.xb.lib.NewProc(\"xlSheetSetDisplayGridlinesW\").\n\t\tCall(xs.self, I(show))\n}", "func (dw *DrawingWand) SetStrokeLineCap(lineCap LineCap) {\n\tC.MagickDrawSetStrokeLineCap(dw.dw, C.LineCap(lineCap))\n}", "func (file *File) setNewline(bufferStr string) {\n\n\t// Default to line feed.\n\tfile.newline = \"\\n\"\n\tcount := strings.Count(bufferStr, \"\\n\")\n\n\t// Check if carriage return is more popular.\n\tc := strings.Count(bufferStr, \"\\r\")\n\tif c > count {\n\t\tcount = c\n\t\tfile.newline = \"\\r\"\n\t}\n\n\t// Check for CRLF or LFCR.\n\tfor _, newline := range []string{\"\\n\\r\", \"\\r\\n\"} {\n\t\tc := strings.Count(bufferStr, newline)\n\t\t// Factor of two to prevent overcounting.\n\t\tif c > count/2 {\n\t\t\tcount = c\n\t\t\tfile.newline = newline\n\t\t}\n\t}\n\n}", "func setViewCursorToLine(g *gocui.Gui, v *gocui.View, lines []string, selLine string) error {\n\tox, _ := v.Origin()\n\tcx, _ := v.Cursor()\n\tfor y, line := range lines {\n\t\tif line == selLine {\n\t\t\tif err := v.SetCursor(ox, y); err != nil {\n\t\t\t\tif err := v.SetOrigin(cx, y); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (dbm *DBManager) SetBatchMode(mode bool) {\n\tdbm.batchMode = mode\n\t//if the batch mode is turned off, close DB directly\n\tif !mode {\n\t\tdbm.closeDB()\n\t}\n}", "func (o *SearchLine) SetLine(v int32) {\n\to.Line = &v\n}", "func (s *BaseGraffleParserListener) EnterMult_line_stmnt(ctx *Mult_line_stmntContext) {}", "func (l *Selectable) SetCaret(start, end int) {\n\tl.initialize()\n\tl.text.SetCaret(start, end)\n}", "func (d *Display) AutoLineWrapOn() error {\n\t_, err := d.port.Write([]byte(AutoLineWrapOn))\n\treturn err\n}", "func (s *WidgetBase) SetBorder(enabled bool) {\n\ts.Block.Border = enabled\n}", "func (dw *DrawingWand) SetStrokeLineJoin(lineJoin LineJoin) {\n\tC.MagickDrawSetStrokeLineJoin(dw.dw, C.LineJoin(lineJoin))\n}", "func (b *AppendOnlyBufferedBatch) SetSelection(useSel bool) {\n\tb.batch.SetSelection(useSel)\n\tif useSel {\n\t\t// Make sure that selection vector is of the appropriate length.\n\t\tif cap(b.sel) < b.length {\n\t\t\tb.sel = make([]int, b.length)\n\t\t} else {\n\t\t\tb.sel = b.sel[:b.length]\n\t\t}\n\t}\n}", "func (self *TextView) SetAcceptsTab(acceptsTab bool) {\n\tb := gobject.GBool(acceptsTab)\n\tdefer b.Free()\n\tC.gtk_text_view_set_accepts_tab(self.object, *((*C.gboolean)(b.GetPtr())))\n}", "func (dw *DrawingWand) SetStrokeMiterLimit(miterLimit uint) {\n\tC.MagickDrawSetStrokeMiterLimit(dw.dw, C.ulong(miterLimit))\n}", "func (b *Button) SetOutline(outline bool) {\n\tif outline {\n\t\tb.outline = \"-outline\"\n\t} else {\n\t\tb.outline = \"\"\n\t}\n}", "func (f *File) SetLinesForContent(content []byte) {\n\tvar lines []index\n\tline := index(0)\n\tfor offset, b := range content {\n\t\tif line >= 0 {\n\t\t\tlines = append(lines, line)\n\t\t}\n\t\tline = -1\n\t\tif b == '\\n' {\n\t\t\tline = index(offset) + 1\n\t\t}\n\t}\n\n\t// set lines table\n\tf.mutex.Lock()\n\tf.lines = lines\n\tf.mutex.Unlock()\n}", "func Textarea(\n\tx, y, width, height int,\n\tfg, bg termbox.Attribute,\n\twrap bool,\n) *Editbox {\n\tebox := newEditbox(x, y, width, height, options{\n\t\tfg: fg,\n\t\tbg: bg,\n\t\twrap: wrap,\n\t\texitKeys: []termbox.Key{\n\t\t\ttermbox.KeyEsc,\n\t\t\ttermbox.KeyTab,\n\t\t},\n\t\tautoexpand: false,\n\t})\n\tebox.Render()\n\treturn ebox\n}", "func (o *WindowsMobileMsi) SetCommandLine(v string) {\n\to.CommandLine = &v\n}", "func TextViewScrollToLine(textView *gtk.TextView, line int, highLight ...bool) {\n\tvar doHighLight bool\n\tif len(highLight) > 0 {\n\t\tdoHighLight = highLight[0]\n\t}\n\tvar err error\n\tif line > 0 {\n\t\tif buf, err := textView.GetBuffer(); err == nil {\n\n\t\t\titerTxt0 := buf.GetIterAtLine(line)\n\t\t\titerTxt1 := buf.GetIterAtOffset(buf.GetIterAtLine(line).GetOffset() - 1)\n\n\t\t\tbuf.PlaceCursor(iterTxt0)\n\t\t\tfor gtk.EventsPending() {\n\t\t\t\tgtk.MainIterationDo(false)\n\t\t\t}\n\t\t\ttextView.ScrollToIter(iterTxt0, 0.0, true, 0.5, 0.5)\n\n\t\t\tif doHighLight {\n\t\t\t\tbuf.SelectRange(iterTxt0, iterTxt1) // HighLight current line.\n\t\t\t}\n\t\t}\n\t}\n\tif err != nil {\n\t\tlog.Fatalf(\"TextViewScrollToLine: %s\\n\", err.Error())\n\t}\n}", "func (tb *TextBuf) AppendTextLineMarkup(text []byte, markup []byte, saveUndo, signal bool) *TextBufEdit {\n\ted := tb.EndPos()\n\tsz := len(text)\n\taddLF := false\n\tif sz > 0 {\n\t\tif text[sz-1] != '\\n' {\n\t\t\taddLF = true\n\t\t}\n\t} else {\n\t\taddLF = true\n\t}\n\tefft := text\n\tif addLF {\n\t\ttcpy := make([]byte, sz+1)\n\t\tcopy(tcpy, text)\n\t\ttcpy[sz] = '\\n'\n\t\tefft = tcpy\n\t}\n\ttbe := tb.InsertText(ed, efft, saveUndo, false)\n\ttb.Markup[tbe.Reg.Start.Ln] = markup\n\tif signal {\n\t\ttb.TextBufSig.Emit(tb.This(), int64(TextBufInsert), tbe)\n\t}\n\treturn tbe\n}", "func (t *Text) SetBody(newBody string) error {\n\tt.body = newBody\n\treturn nil\n}", "func SetTextView(tv *gtk.TextView, in []string, removeEmpty ...bool) {\n\tvar re bool\n\tvar err error\n\tvar buff *gtk.TextBuffer\n\n\tif len(removeEmpty) > 0 {\n\t\tre = removeEmpty[0]\n\t}\n\tif buff, err = tv.GetBuffer(); err == nil {\n\t\tif re {\n\t\t\tfor idx, line := range in {\n\t\t\t\tif len(line) == 0 {\n\t\t\t\t\tin = append(in[:idx], in[idx+1:]...)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuff.SetText(strings.Join(in, glsg.GetOsLineEnd()))\n\t}\n\tif err != nil {\n\t\tfmt.Printf(\"SetTextView: %s\", err.Error())\n\t}\n\treturn\n}", "func (p *Parser) SetCommandType() error {\n\tif p.currentLine == \"\" {\n\t\treturn errors.New(\"Current line hasn't been set\")\n\t}\n\n\t//remove excess whitespace\n\t// matches leading/trailing whitespace\n\tre := regexp.MustCompile(`^[\\s\\p{Zs}]+|[\\s\\p{Zs}]+$`)\n\t// matches whitespace inbetween words\n\treInside := regexp.MustCompile(`[\\s\\p{Zs}]{2,}`)\n\tfinal := re.ReplaceAllString(p.currentLine, \"\")\n\tfinal = reInside.ReplaceAllString(final, \" \")\n\tp.splitLine = strings.Split(final, \" \")\n\n\tswitch strings.ToLower(p.splitLine[0]) {\n\tcase \"add\":\n\t\tfallthrough\n\tcase \"sub\":\n\t\tfallthrough\n\tcase \"neg\":\n\t\tfallthrough\n\tcase \"eq\":\n\t\tfallthrough\n\tcase \"gt\":\n\t\tfallthrough\n\tcase \"lt\":\n\t\tfallthrough\n\tcase \"and\":\n\t\tfallthrough\n\tcase \"or\":\n\t\tfallthrough\n\tcase \"not\":\n\t\tp.CurrentCommandType = CArithmetic\n\tcase \"push\":\n\t\tp.CurrentCommandType = CPush\n\tcase \"pop\":\n\t\tp.CurrentCommandType = CPop\n\t}\n\n\treturn nil\n}", "func SetReadLineFn(fn ReadLineFnType) {\n\treadLineFn = fn\n}", "func (s *Store) NewLine(ln int, st string) {\n\tif ln <= 0 {\n\t\ts.lines = append([]*line{newLine(st)}, s.lines...)\n\t\treturn\n\t}\n\tif ln >= len(s.lines) {\n\t\ts.lines = append(s.lines, newLine(st))\n\t\treturn\n\t}\n\ts.lines = append(s.lines[:ln], append([]*line{newLine(st)}, s.lines[ln:]...)...)\n\tcs := s.undoFac()\n\tcs.AddLine(ln)\n\tcs.ChangeLine(ln+1, \"\", st)\n\ts.AddUndoSet(cs)\n\treturn\n}", "func (tv *TextView) SetSize() bool {\n\tsty := &tv.Sty\n\tspc := sty.BoxSpace()\n\trndsz := tv.RenderSz\n\trndsz.X += tv.LineNoOff\n\tnetsz := mat32.Vec2{float32(tv.LinesSize.X) + tv.LineNoOff, float32(tv.LinesSize.Y)}\n\tcursz := tv.LayData.AllocSize.SubScalar(2 * spc)\n\tif cursz.X < 10 || cursz.Y < 10 {\n\t\tnwsz := netsz.Max(rndsz)\n\t\ttv.Size2DFromWH(nwsz.X, nwsz.Y)\n\t\ttv.LayData.Size.Need = tv.LayData.AllocSize\n\t\ttv.LayData.Size.Pref = tv.LayData.AllocSize\n\t\treturn true\n\t}\n\tnwsz := netsz.Max(rndsz)\n\talloc := tv.LayData.AllocSize\n\ttv.Size2DFromWH(nwsz.X, nwsz.Y)\n\tif alloc != tv.LayData.AllocSize {\n\t\ttv.LayData.Size.Need = tv.LayData.AllocSize\n\t\ttv.LayData.Size.Pref = tv.LayData.AllocSize\n\t\treturn true\n\t}\n\t// fmt.Printf(\"NO resize: netsz: %v cursz: %v rndsz: %v\\n\", netsz, cursz, rndsz)\n\treturn false\n}", "func (e *Edit) SetTextSelection(start, end int) {\n\te.SendMessage(win.EM_SETSEL, uintptr(start), uintptr(end))\n}", "func (o *BlockBasedTableOptions) SetBlockSize(blockSize int) {\n\tC.rocksdb_block_based_options_set_block_size(o.c, C.size_t(blockSize))\n}", "func (v *TextView) SetPixelsBelowLines(px int) {\n\tC.gtk_text_view_set_pixels_below_lines(v.native(), C.gint(px))\n}", "func (s *MonitoringJsonDatasetFormat) SetLine(v bool) *MonitoringJsonDatasetFormat {\n\ts.Line = &v\n\treturn s\n}", "func (c *Client) SetFullscreen(v bool) error {\n\treturn c.SetProperty(\"fullscreen\", v)\n}", "func SetInterspersed(interspersed bool) {\n\tCommandLine.SetInterspersed(interspersed)\n}", "func (f *Font) SetOutline(outline int) {\n\tC.TTF_SetFontOutline(f.f, C.int(outline))\n}", "func SetColor(mode bool) {\n\tColorize = mode\n}", "func (t *Textarea) SetState(val string, selStart, selEnd int) {\n\tt.Set(\"value\", val)\n\tt.SetSelectionStart(selStart)\n\tt.SetSelectionEnd(selEnd)\n}", "func (env *Environment) SetFocus(module *Module) {\n\tif env != module.env {\n\t\tpanic(\"SetFocus to module from another environment\")\n\t}\n\tC.EnvFocus(env.env, module.modptr)\n}", "func (s *Set) SetIdealLineSize() error {\n\twidth, _, err := TerminalSize(int(GetTerminal()))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tidealLength := width - len(s.Description) - len(s.RParen) - len(s.LParen) - NumberOfCharacters - NumberOfCharactersBuffer\n\ts.LineSize = idealLength\n\n\treturn nil\n}", "func (b *Bot) SetEditMessageHandler(fn editMessageHandlerFunc) {\n\tb.handlers.editMessageHandler = fn\n}", "func TestCommentsMultiline(t *testing.T) {\n\ttemplate := \"12345{{!\\n This is a\\n multi-line comment...\\n}}67890\\n\"\n\texpected := \"1234567890\\n\"\n\tactual := Render(template)\n\n\tif actual != expected {\n\t\tt.Errorf(\"returned %#v, expected %#v\", actual, expected)\n\t}\n}", "func (tv *TextView) LayoutLines(st, ed int, isDel bool) bool {\n\tif tv.Buf == nil || tv.Buf.NumLines() == 0 {\n\t\treturn false\n\t}\n\tsty := &tv.Sty\n\tfst := sty.Font\n\tfst.BgColor.SetColor(nil)\n\tmxwd := float32(tv.LinesSize.X)\n\trerend := false\n\n\ttv.Buf.MarkupMu.RLock()\n\tfor ln := st; ln <= ed; ln++ {\n\t\tcurspans := len(tv.Renders[ln].Spans)\n\t\ttv.Renders[ln].SetHTMLPre(tv.Buf.Markup[ln], &fst, &sty.Text, &sty.UnContext, tv.CSS)\n\t\ttv.Renders[ln].LayoutStdLR(&sty.Text, &sty.Font, &sty.UnContext, tv.RenderSz)\n\t\tif !tv.HasLinks && len(tv.Renders[ln].Links) > 0 {\n\t\t\ttv.HasLinks = true\n\t\t}\n\t\tnwspans := len(tv.Renders[ln].Spans)\n\t\tif nwspans != curspans && (nwspans > 1 || curspans > 1) {\n\t\t\trerend = true\n\t\t}\n\t\tmxwd = mat32.Max(mxwd, tv.Renders[ln].Size.X)\n\t}\n\ttv.Buf.MarkupMu.RUnlock()\n\n\t// update all offsets to end of text\n\tif rerend || isDel || st != ed {\n\t\tofst := st - 1\n\t\tif ofst < 0 {\n\t\t\tofst = 0\n\t\t}\n\t\toff := tv.Offs[ofst]\n\t\tfor ln := ofst; ln < tv.NLines; ln++ {\n\t\t\ttv.Offs[ln] = off\n\t\t\tlsz := mat32.Max(tv.Renders[ln].Size.Y, tv.LineHeight)\n\t\t\toff += lsz\n\t\t}\n\t\textraHalf := tv.LineHeight * 0.5 * float32(tv.VisSize.Y)\n\t\tnwSz := mat32.Vec2{mxwd, off + extraHalf}.ToPointCeil()\n\t\ttv.ResizeIfNeeded(nwSz)\n\t} else {\n\t\tnwSz := mat32.Vec2{mxwd, 0}.ToPointCeil()\n\t\tnwSz.Y = tv.LinesSize.Y\n\t\ttv.ResizeIfNeeded(nwSz)\n\t}\n\treturn rerend\n}", "func (b *Buffer) SetArea(r image.Rectangle) {\n\tb.Area.Max = r.Max\n\tb.Area.Min = r.Min\n}", "func SetMode(value string) {\n\trgin.SetMode(value)\n}", "func (v *ToggleButton) SetMode(drawIndicator bool) {\n\tC.gtk_toggle_button_set_mode(v.native(), gbool(drawIndicator))\n}", "func (mysqld *Mysqld) SetSemiSyncEnabled(primary, replica bool) error {\n\tlog.Infof(\"Setting semi-sync mode: primary=%v, replica=%v\", primary, replica)\n\n\t// Convert bool to int.\n\tvar p, s int\n\tif primary {\n\t\tp = 1\n\t}\n\tif replica {\n\t\ts = 1\n\t}\n\n\terr := mysqld.ExecuteSuperQuery(context.TODO(), fmt.Sprintf(\n\t\t\"SET GLOBAL rpl_semi_sync_master_enabled = %v, GLOBAL rpl_semi_sync_slave_enabled = %v\",\n\t\tp, s))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can't set semi-sync mode: %v; make sure plugins are loaded in my.cnf\", err)\n\t}\n\treturn nil\n}", "func (e *Editor) SetCaret(start, end int) {\n\te.makeValid()\n\t// Constrain start and end to [0, e.Len()].\n\tl := e.Len()\n\tstart = max(min(start, l), 0)\n\tend = max(min(end, l), 0)\n\te.caret.start.ofs, e.caret.end.ofs = start, end\n\te.makeValidCaret()\n\te.caret.scroll = true\n\te.scroller.Stop()\n}" ]
[ "0.5475919", "0.5475919", "0.5170859", "0.4870367", "0.4799137", "0.478739", "0.47782564", "0.47514302", "0.4702174", "0.46572047", "0.46277925", "0.46055743", "0.45961565", "0.45706195", "0.45657697", "0.4545953", "0.453209", "0.4527019", "0.44969025", "0.44902694", "0.4446595", "0.44386667", "0.44312978", "0.43943653", "0.43873376", "0.43706027", "0.43649316", "0.43302253", "0.4251327", "0.42479905", "0.4243656", "0.42369846", "0.4185764", "0.41803768", "0.4177793", "0.41694984", "0.4139322", "0.413565", "0.41198355", "0.41040215", "0.41020417", "0.409752", "0.407823", "0.4077381", "0.40768024", "0.40581882", "0.40551504", "0.40518203", "0.40482494", "0.40441418", "0.4033653", "0.40285414", "0.4007365", "0.40070516", "0.40033782", "0.39946145", "0.39473617", "0.39431718", "0.3931862", "0.3927295", "0.3924041", "0.39219108", "0.39152357", "0.39140254", "0.38990122", "0.38846773", "0.38834724", "0.38801363", "0.38739207", "0.38731968", "0.38695684", "0.3864894", "0.38644958", "0.3863914", "0.38626954", "0.38599965", "0.38583437", "0.38565266", "0.384785", "0.3847317", "0.38363606", "0.38321602", "0.3823771", "0.3821382", "0.3811639", "0.38004977", "0.3797005", "0.37925857", "0.3784637", "0.37837785", "0.3780884", "0.3773482", "0.3767278", "0.37635446", "0.37551844", "0.3754388", "0.37536186", "0.37509736", "0.37331307", "0.3727216" ]
0.79778475
0
SetHotkey sets the hotkey that causes line editing to exit. The hotkey will be appended to the line buffer but not displayed.
func (l *Linenoise) SetHotkey(key rune) { l.hotkey = key }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (g *Gui) SetKeybinding(viewname string, key tcell.Key, ch rune, mod tcell.ModMask, handler func(*Gui, *View) error) error {\n\t// var kb *eventBinding\n\n\t// k, ch, err := getKey(key)\n\t// if err != nil {\n\t// \treturn err\n\t// }\n\t// TODO: get rid of this ugly mess\n\t//switch key {\n\t//case termbox.MouseLeft:\n\t//\tkb = newMouseBinding(viewname, tcell.Button1, mod, handler)\n\t//case termbox.MouseMiddle:\n\t//\tkb = newMouseBinding(viewname, tcell.Button3, mod, handler)\n\t//case termbox.MouseRight:\n\t//\tkb = newMouseBinding(viewname, tcell.Button2, mod, handler)\n\t//case termbox.MouseWheelUp:\n\t//\tkb = newMouseBinding(viewname, tcell.WheelUp, mod, handler)\n\t//case termbox.MouseWheelDown:\n\t//\tkb = newMouseBinding(viewname, tcell.WheelDown, mod, handler)\n\t//default:\n\t//\tkb = newKeybinding(viewname, key, ch, mod, handler)\n\t//}\n\tkb := newKeybinding(viewname, key, ch, mod, handler)\n\tg.eventBindings = append(g.eventBindings, kb)\n\treturn nil\n}", "func (*XMLDocument) SetOnkeypress(onkeypress func(window.Event)) {\n\tmacro.Rewrite(\"$_.onkeypress = $1\", onkeypress)\n}", "func (env *Environment) SetFocus(module *Module) {\n\tif env != module.env {\n\t\tpanic(\"SetFocus to module from another environment\")\n\t}\n\tC.EnvFocus(env.env, module.modptr)\n}", "func (*XMLDocument) SetOnkeydown(onkeydown func(window.Event)) {\n\tmacro.Rewrite(\"$_.onkeydown = $1\", onkeydown)\n}", "func ClearLine() {\n\temitEscape(\"K\", 2)\n}", "func ClearLine() {\n\tfmt.Printf(\"\\033[2K\")\n}", "func ClearLine() {\n\tfmt.Printf(\"\\033[2K\")\n}", "func setCursorLoc(x, y int) {\n\tfmt.Printf(\"\\033[%v;%vH\", y, x)\n}", "func setCursorRow(row int) error {\n\t// todo: is this \"really\" needed?\n\t// if isatty.IsTerminal(os.Stdin.Fd()) {\n\t// \toldState, err := terminal.MakeRaw(0)\n\t// \tif err != nil {\n\t// \t\tpanic(err)\n\t// \t}\n\t// \tdefer terminal.Restore(0, oldState)\n\t// }\n\n\t// sets the cursor position where subsequent text will begin: <ESC>[{ROW};{COLUMN}H\n\t// great resource: http://www.termsys.demon.co.uk/vtansi.htm\n\t_, err := fmt.Fprintf(getScreen().output, \"\\x1b[%d;0H\", row)\n\treturn err\n}", "func setViewCursorToLine(g *gocui.Gui, v *gocui.View, lines []string, selLine string) error {\n\tox, _ := v.Origin()\n\tcx, _ := v.Cursor()\n\tfor y, line := range lines {\n\t\tif line == selLine {\n\t\t\tif err := v.SetCursor(ox, y); err != nil {\n\t\t\t\tif err := v.SetOrigin(cx, y); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func SetConsoleCtrlHandler(handlerRoutine func(DWORD) int32, add uint) (err error) {\n\t_, _, err = procSetConsoleCtrlHandler.Call(uintptr(unsafe.Pointer(&handlerRoutine)),\n\t\tuintptr(add))\n\tif err.Error() != ErrSuccess {\n\t\treturn\n\t}\n\terr = nil\n\treturn\n}", "func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {\n\tbaseHandler := binding.Handler\n\tnewHandler := func(opts gocui.ViewMouseBindingOpts) error {\n\t\t// we ignore click events on views that aren't popup panels, when a popup panel is focused\n\t\tif gui.helpers.Confirmation.IsPopupPanelFocused() && gui.currentViewName() != binding.ViewName {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn baseHandler(opts)\n\t}\n\tbinding.Handler = newHandler\n\n\treturn gui.g.SetViewClickBinding(binding)\n}", "func ClearLineStart() {\n\tfmt.Printf(\"\\033[1K\")\n}", "func ClearLineStart() {\n\tfmt.Printf(\"\\033[1K\")\n}", "func (d *Display) AutoLineWrapOff() error {\n\t_, err := d.port.Write([]byte(AutoLineWrapOff))\n\treturn err\n}", "func ClearLinePartialForward() {\n\temitEscape(\"K\")\n}", "func keybindings(g *gocui.Gui) error {\n\tif err := g.SetKeybinding(\"\", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (g *Gui) SetRune(x, y int, ch rune, style tcell.Style) error {\n\tif x < 0 || y < 0 || x >= g.maxX || y >= g.maxY {\n\t\treturn errors.New(\"invalid point\")\n\t}\n\t// temporary kludge for the pretty\n\t// st = g.prettyColor(x, y, st)\n\tg.screen.SetContent(x, y, ch, nil, style)\n\treturn nil\n}", "func (v *TextView) SetCursorVisible(visible bool) {\n\tC.gtk_text_view_set_cursor_visible(v.native(), gbool(visible))\n}", "func (d *Device) SetScroll(line int16) {\n\td.buf[0] = uint8(line >> 8)\n\td.buf[1] = uint8(line)\n\td.startWrite()\n\td.sendCommand(VSCRSADD, d.buf[:2])\n\td.endWrite()\n}", "func (scr *Screen) SetRune(x, y int, r rune) {\n\t//fmt.Printf(\"SetRune: x=%v, y=%v, rune=%q\\r\\n\", x, y, r)\n\tif x >= scr.Width || y >= scr.Height {\n\t\treturn\n\t}\n\n\tscr.buffer[y][x] = r\n}", "func (t *tui) keybindings(g *gotui.Gui) error {\n\tif err := g.SetKeybinding(\"\", gotui.KeyCtrlC, gotui.ModNone, t.quit); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyPgup, gotui.ModNone, t.scrollUp); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyPgdn, gotui.ModNone, t.scrollDown); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyCtrlL, gotui.ModNone, t.redraw); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyArrowRight, gotui.ModAlt, t.worldRight); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyArrowLeft, gotui.ModAlt, t.worldLeft); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyCtrlRsqBracket, gotui.ModNone, t.activeWorldRight); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"\", gotui.KeyCtrlLsqBracket, gotui.ModNone, t.activeWorldLeft); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyEnter, gotui.ModNone, t.send); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyEnter, gotui.ModAlt, t.forceNewline); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyArrowUp, gotui.ModNone, t.arrowUp); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyArrowDown, gotui.ModNone, t.arrowDown); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyHome, gotui.ModNone, t.home); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"send\", gotui.KeyEnd, gotui.ModNone, t.end); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"modal\", gotui.KeyEnter, gotui.ModNone, t.closeModal); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"modal\", gotui.KeyArrowUp, gotui.ModNone, t.scrollModalUp); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\tif err := g.SetKeybinding(\"modal\", gotui.KeyArrowDown, gotui.ModNone, t.scrollModalDown); err != nil {\n\t\treturn errgo.Mask(err)\n\t}\n\treturn nil\n}", "func SetKeyCallback(f KeyHandler) {\n\tkey = append(key, f)\n\tC.glfwSetKeyCB()\n}", "func (ls *linestate) editSet(s string) {\n\tls.buf = []rune(s)\n\tls.pos = len(ls.buf)\n\tls.refreshLine()\n}", "func ClearLine(conn io.Writer) {\n\tclearline := \"\\x1B[2K\"\n\tWrite(conn, clearline+\"\\r\", ColorModeNone)\n}", "func (this *Window) SetKeyRepeatEnabled(enabled bool) {\n\tC.sfWindow_setKeyRepeatEnabled(this.cptr, goBool2C(enabled))\n}", "func (ptr *terminalPrompter) SetWordCompleter(completer WordCompleter) {\n\tptr.State.SetWordCompleter(liner.WordCompleter(completer))\n}", "func (s *Screen) ClearLine() {\n\tfmt.Fprint(s.Terminal, \"\\u001b[2K\")\n}", "func (l *Linenoise) edit(ifd, ofd int, prompt, init string) (string, error) {\n\t// create the line state\n\tls := newLineState(ifd, ofd, prompt, l)\n\t// set and output the initial line\n\tls.editSet(init)\n\t// The latest history entry is always our current buffer\n\tl.HistoryAdd(ls.String())\n\n\tu := utf8{}\n\n\tfor {\n\t\tr := u.getRune(syscall.Stdin, nil)\n\t\tif r == KeycodeNull {\n\t\t\tcontinue\n\t\t}\n\t\t// Autocomplete when the callback is set.\n\t\t// It returns the character to be handled next.\n\t\tif r == KeycodeTAB && l.completionCallback != nil {\n\t\t\tr = ls.completeLine()\n\t\t\tif r == KeycodeNull {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif r == KeycodeCR || r == l.hotkey {\n\t\t\tl.historyPop(-1)\n\t\t\tif l.hintsCallback != nil {\n\t\t\t\t// Refresh the line without hints to leave the\n\t\t\t\t// line as the user typed it after the newline.\n\t\t\t\thcb := l.hintsCallback\n\t\t\t\tl.hintsCallback = nil\n\t\t\t\tls.refreshLine()\n\t\t\t\tl.hintsCallback = hcb\n\t\t\t}\n\t\t\ts := ls.String()\n\t\t\tif r == l.hotkey {\n\t\t\t\treturn s + string(l.hotkey), nil\n\t\t\t}\n\t\t\treturn s, nil\n\t\t} else if r == KeycodeBS {\n\t\t\t// backspace: remove the character to the left of the cursor\n\t\t\tls.editBackspace()\n\n\t\t} else if r == KeycodeESC {\n\t\t\tif wouldBlock(ifd, &timeout20ms) {\n\t\t\t\t// looks like a single escape- abandon the line\n\t\t\t\tl.historyPop(-1)\n\t\t\t\treturn \"\", nil\n\t\t\t}\n\t\t\t// escape sequence\n\t\t\ts0 := u.getRune(ifd, &timeout20ms)\n\t\t\ts1 := u.getRune(ifd, &timeout20ms)\n\t\t\tif s0 == '[' {\n\t\t\t\t// ESC [ sequence\n\t\t\t\tif s1 >= '0' && s1 <= '9' {\n\t\t\t\t\t// Extended escape, read additional byte.\n\t\t\t\t\ts2 := u.getRune(ifd, &timeout20ms)\n\t\t\t\t\tif s2 == '~' {\n\t\t\t\t\t\tif s1 == '3' {\n\t\t\t\t\t\t\t// delete\n\t\t\t\t\t\t\tls.editDelete()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif s1 == 'A' {\n\t\t\t\t\t\t// cursor up\n\t\t\t\t\t\tls.editSet(l.historyPrev(ls))\n\t\t\t\t\t} else if s1 == 'B' {\n\t\t\t\t\t\t// cursor down\n\t\t\t\t\t\tls.editSet(l.historyNext(ls))\n\t\t\t\t\t} else if s1 == 'C' {\n\t\t\t\t\t\t// cursor right\n\t\t\t\t\t\tls.editMoveRight()\n\t\t\t\t\t} else if s1 == 'D' {\n\t\t\t\t\t\t// cursor left\n\t\t\t\t\t\tls.editMoveLeft()\n\t\t\t\t\t} else if s1 == 'H' {\n\t\t\t\t\t\t// cursor home\n\t\t\t\t\t\tls.editMoveHome()\n\t\t\t\t\t} else if s1 == 'F' {\n\t\t\t\t\t\t// cursor end\n\t\t\t\t\t\tls.editMoveEnd()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if s0 == '0' {\n\t\t\t\t// ESC 0 sequence\n\t\t\t\tif s1 == 'H' {\n\t\t\t\t\t// cursor home\n\t\t\t\t\tls.editMoveHome()\n\t\t\t\t} else if s1 == 'F' {\n\t\t\t\t\t// cursor end\n\t\t\t\t\tls.editMoveEnd()\n\t\t\t\t}\n\t\t\t}\n\t\t} else if r == KeycodeCtrlA {\n\t\t\t// go to the start of the line\n\t\t\tls.editMoveHome()\n\t\t} else if r == KeycodeCtrlB {\n\t\t\t// cursor left\n\t\t\tls.editMoveLeft()\n\t\t} else if r == KeycodeCtrlC {\n\t\t\t// return QUIT\n\t\t\treturn \"\", ErrQuit\n\t\t} else if r == KeycodeCtrlD {\n\t\t\tif len(ls.buf) > 0 {\n\t\t\t\t// delete: remove the character to the right of the cursor.\n\t\t\t\tls.editDelete()\n\t\t\t} else {\n\t\t\t\t// nothing to delete - QUIT\n\t\t\t\tl.historyPop(-1)\n\t\t\t\treturn \"\", ErrQuit\n\t\t\t}\n\t\t} else if r == KeycodeCtrlE {\n\t\t\t// go to the end of the line\n\t\t\tls.editMoveEnd()\n\t\t} else if r == KeycodeCtrlF {\n\t\t\t// cursor right\n\t\t\tls.editMoveRight()\n\t\t} else if r == KeycodeCtrlH {\n\t\t\t// backspace: remove the character to the left of the cursor\n\t\t\tls.editBackspace()\n\t\t} else if r == KeycodeCtrlK {\n\t\t\t// delete to the end of the line\n\t\t\tls.deleteToEnd()\n\t\t} else if r == KeycodeCtrlL {\n\t\t\t// clear screen\n\t\t\tclearScreen()\n\t\t\tls.refreshLine()\n\t\t} else if r == KeycodeCtrlN {\n\t\t\t// next history item\n\t\t\tls.editSet(l.historyNext(ls))\n\t\t} else if r == KeycodeCtrlP {\n\t\t\t// previous history item\n\t\t\tls.editSet(l.historyPrev(ls))\n\t\t} else if r == KeycodeCtrlT {\n\t\t\t// swap current character with the previous\n\t\t\tls.editSwap()\n\t\t} else if r == KeycodeCtrlU {\n\t\t\t// delete the whole line\n\t\t\tls.deleteLine()\n\t\t} else if r == KeycodeCtrlW {\n\t\t\t// delete previous word\n\t\t\tls.deletePrevWord()\n\t\t} else {\n\t\t\t// insert the character into the line buffer\n\t\t\tls.editInsert(r)\n\t\t}\n\t}\n}", "func SetHandler(key string, f func([]string) string) {\n\n\t_, ok := commandMap[key]\n\tif ok {\n\t\tfmt.Println(\"overriding handler:\", key)\n\t}\n\tcommandMap[key] = f\n}", "func (v *IconView) SetCursor(path *TreePath, cell *CellRenderer, startEditing bool) {\n\tC.gtk_icon_view_set_cursor(v.native(), path.native(), cell.native(), gbool(startEditing))\n}", "func ClearLineEnd() {\n\tfmt.Printf(\"\\033[0K\")\n}", "func ClearLineEnd() {\n\tfmt.Printf(\"\\033[0K\")\n}", "func (s *State) SetKeyboardFocus(c Component) {\n\ts.focused = c\n\ts.focusNext = false\n\ts.update = true\n}", "func (vm *C8VM) SetKeymask(code uint8) {\n\tvm.key |= (1 << code)\n}", "func (tbd *TermboxDriver) SetCursor(x, y int) {\n\ttermbox.SetCursor(x, y)\n}", "func SetStopCh(stopCh chan struct{}) {\n\tstopChannel = stopCh\n}", "func ClearLinePartialBackward() {\n\temitEscape(\"K\", 1)\n}", "func (dw *DrawingWand) SetStrokeLineCap(lineCap LineCap) {\n\tC.MagickDrawSetStrokeLineCap(dw.dw, C.LineCap(lineCap))\n}", "func (v *View) SetKeybindings(bindings KeyBindings) {\n\tv.bindings = bindings\n}", "func SetConsole() error {\n\treturn nil\n}", "func (m *RegistryKeyState) SetKey(value *string)() {\n m.key = value\n}", "func (win *Window) SetAcceptFocus(setting bool) {\n\twin.Candy().Guify(\"gtk_window_set_accept_focus\", win, setting)\n}", "func (d *Display) AutoLineWrapOn() error {\n\t_, err := d.port.Write([]byte(AutoLineWrapOn))\n\treturn err\n}", "func ctrlKey(r rune) rune { return r & 0x1f }", "func (tv *TextView) SetCursor(pos TextPos) {\n\tif tv.NLines == 0 || tv.Buf == nil {\n\t\ttv.CursorPos = TextPosZero\n\t\treturn\n\t}\n\ttv.ClearScopelights()\n\ttv.CursorPos = tv.Buf.ValidPos(pos)\n\ttv.CursorMovedSig()\n\ttxt := tv.Buf.Line(tv.CursorPos.Ln)\n\tch := tv.CursorPos.Ch\n\tif ch < len(txt) {\n\t\tr := txt[ch]\n\t\tif r == '{' || r == '}' || r == '(' || r == ')' || r == '[' || r == ']' {\n\t\t\ttp, found := tv.Buf.FindScopeMatch(txt[ch], tv.CursorPos)\n\t\t\tif found {\n\t\t\t\ttv.Scopelights = append(tv.Scopelights, NewTextRegionPos(tv.CursorPos, TextPos{tv.CursorPos.Ln, tv.CursorPos.Ch + 1}))\n\t\t\t\ttv.Scopelights = append(tv.Scopelights, NewTextRegionPos(tp, TextPos{tp.Ln, tp.Ch + 1}))\n\t\t\t\tif tv.CursorPos.Ln < tp.Ln {\n\t\t\t\t\ttv.RenderLines(tv.CursorPos.Ln, tp.Ln)\n\t\t\t\t} else {\n\t\t\t\t\ttv.RenderLines(tp.Ln, tv.CursorPos.Ln)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (hw *HighlightedWriter) EraseLine() {\n\thw.delegate.EraseLine()\n}", "func SetBindHook(bh BindHook) {\n\tif bh != nil {\n\t\tbindHook = bh\n\t}\n}", "func (obj *Device) SetCursorPosition(x int, y int, flags uint32) {\n\tsyscall.Syscall6(\n\t\tobj.vtbl.SetCursorPosition,\n\t\t4,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(x),\n\t\tuintptr(y),\n\t\tuintptr(flags),\n\t\t0,\n\t\t0,\n\t)\n}", "func (win *Window) SetKeyCallback(callback KeyCallback) KeyCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.KeyCallback\n\tcallbacks.KeyCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetKeyCallback(win.c())\n\t} else {\n\t\tC.goRemoveKeyCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetKeyCallback(callback KeyCallback) KeyCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.KeyCallback\n\tcallbacks.KeyCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetKeyCallback(win.c())\n\t} else {\n\t\tC.goRemoveKeyCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (tv *TextView) KeyInput(kt *key.ChordEvent) {\n\tif gi.KeyEventTrace {\n\t\tfmt.Printf(\"TextView KeyInput: %v\\n\", tv.PathUnique())\n\t}\n\tkf := gi.KeyFun(kt.Chord())\n\twin := tv.ParentWindow()\n\ttv.ClearScopelights()\n\n\ttv.RefreshIfNeeded()\n\n\tcpop := win.CurPopup()\n\tif gi.PopupIsCompleter(cpop) {\n\t\tsetprocessed := tv.Buf.Complete.KeyInput(kf)\n\t\tif setprocessed {\n\t\t\tkt.SetProcessed()\n\t\t}\n\t}\n\n\tif gi.PopupIsCorrector(cpop) {\n\t\tsetprocessed := tv.Buf.SpellCorrect.KeyInput(kf)\n\t\tif setprocessed {\n\t\t\tkt.SetProcessed()\n\t\t}\n\t}\n\n\tif kt.IsProcessed() {\n\t\treturn\n\t}\n\tif tv.Buf == nil || tv.Buf.NumLines() == 0 {\n\t\treturn\n\t}\n\n\t// cancelAll cancels search, completer, and..\n\tcancelAll := func() {\n\t\ttv.CancelComplete()\n\t\ttv.CancelCorrect()\n\t\ttv.ISearchCancel()\n\t\ttv.QReplaceCancel()\n\t\ttv.lastAutoInsert = 0\n\t}\n\n\tif kf != gi.KeyFunRecenter { // always start at centering\n\t\ttv.lastRecenter = 0\n\t}\n\n\tif kf != gi.KeyFunUndo && tv.HasFlag(int(TextViewLastWasUndo)) {\n\t\ttv.Buf.EmacsUndoSave()\n\t\ttv.ClearFlag(int(TextViewLastWasUndo))\n\t}\n\n\tgotTabAI := false // got auto-indent tab this time\n\n\t// first all the keys that work for both inactive and active\n\tswitch kf {\n\tcase gi.KeyFunMoveRight:\n\t\ttv.ISearchCancel() // note: may need to generalize to cancel more stuff\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorForward(1)\n\t\ttv.ShiftSelectExtend(kt)\n\t\ttv.OfferComplete()\n\t\ttv.ISpellKeyInput(kt)\n\tcase gi.KeyFunWordRight:\n\t\ttv.ISearchCancel()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorForwardWord(1)\n\t\ttv.ShiftSelectExtend(kt)\n\t\ttv.OfferComplete()\n\tcase gi.KeyFunMoveLeft:\n\t\ttv.ISearchCancel()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorBackward(1)\n\t\ttv.ShiftSelectExtend(kt)\n\t\ttv.OfferComplete()\n\tcase gi.KeyFunWordLeft:\n\t\ttv.ISearchCancel()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorBackwardWord(1)\n\t\ttv.ShiftSelectExtend(kt)\n\t\ttv.OfferComplete()\n\tcase gi.KeyFunMoveUp:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorUp(1)\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunMoveDown:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorDown(1)\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunPageUp:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorPageUp(1)\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunPageDown:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorPageDown(1)\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunHome:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorStartLine()\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunEnd:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorEndLine()\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunDocHome:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorStartDoc()\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunDocEnd:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ShiftSelect(kt)\n\t\ttv.CursorEndDoc()\n\t\ttv.ShiftSelectExtend(kt)\n\tcase gi.KeyFunRecenter:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.ReMarkup()\n\t\ttv.CursorRecenter()\n\tcase gi.KeyFunSelectMode:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.SelectModeToggle()\n\tcase gi.KeyFunCancelSelect:\n\t\ttv.CancelComplete()\n\t\tkt.SetProcessed()\n\t\ttv.EscPressed() // generic cancel\n\tcase gi.KeyFunSelectAll:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.SelectAll()\n\tcase gi.KeyFunCopy:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.Copy(true) // reset\n\tcase gi.KeyFunSearch:\n\t\tkt.SetProcessed()\n\t\ttv.QReplaceCancel()\n\t\ttv.CancelComplete()\n\t\ttv.ISearchStart()\n\tcase gi.KeyFunReplace:\n\t\tkt.SetProcessed()\n\t\ttv.CancelComplete()\n\t\ttv.ISearchCancel()\n\t\ttv.QReplacePrompt()\n\tcase gi.KeyFunAbort:\n\t\tkt.SetProcessed()\n\t\ttv.CancelComplete()\n\t\ttv.EscPressed()\n\tcase gi.KeyFunJump:\n\t\tkt.SetProcessed()\n\t\tcancelAll()\n\t\ttv.JumpToLinePrompt()\n\tcase gi.KeyFunHistPrev:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorToHistPrev()\n\tcase gi.KeyFunHistNext:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorToHistNext()\n\t}\n\tif tv.IsInactive() {\n\t\tswitch {\n\t\tcase kf == gi.KeyFunFocusNext: // tab\n\t\t\tkt.SetProcessed()\n\t\t\ttv.CursorNextLink(true)\n\t\tcase kf == gi.KeyFunFocusPrev: // tab\n\t\t\tkt.SetProcessed()\n\t\t\ttv.CursorPrevLink(true)\n\t\tcase kt.Rune == ' ' || kf == gi.KeyFunAccept || kf == gi.KeyFunEnter:\n\t\t\tkt.SetProcessed()\n\t\t\ttv.CursorPos.Ch--\n\t\t\ttv.CursorNextLink(true) // todo: cursorcurlink\n\t\t\ttv.OpenLinkAt(tv.CursorPos)\n\t\t}\n\t\treturn\n\t}\n\tif kt.IsProcessed() {\n\t\ttv.SetFlagState(gotTabAI, int(TextViewLastWasTabAI))\n\t\treturn\n\t}\n\tswitch kf {\n\t// case gi.KeyFunAccept: // ctrl+enter\n\t// \ttv.ISearchCancel()\n\t// \ttv.QReplaceCancel()\n\t// \tkt.SetProcessed()\n\t// \ttv.FocusNext()\n\tcase gi.KeyFunBackspace:\n\t\t// todo: previous item in qreplace\n\t\tif tv.ISearch.On {\n\t\t\ttv.ISearchBackspace()\n\t\t} else {\n\t\t\tkt.SetProcessed()\n\t\t\ttv.CursorBackspace(1)\n\t\t\ttv.OfferComplete()\n\t\t}\n\tcase gi.KeyFunKill:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorKill()\n\tcase gi.KeyFunDelete:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorDelete(1)\n\tcase gi.KeyFunBackspaceWord:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorBackspaceWord(1)\n\t\ttv.OfferComplete()\n\tcase gi.KeyFunDeleteWord:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.CursorDeleteWord(1)\n\tcase gi.KeyFunCut:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.Cut()\n\tcase gi.KeyFunPaste:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.Paste()\n\tcase gi.KeyFunPasteHist:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.PasteHist()\n\tcase gi.KeyFunUndo:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.Undo()\n\t\ttv.SetFlag(int(TextViewLastWasUndo))\n\tcase gi.KeyFunRedo:\n\t\tcancelAll()\n\t\tkt.SetProcessed()\n\t\ttv.Redo()\n\tcase gi.KeyFunComplete:\n\t\ttv.ISearchCancel()\n\t\tkt.SetProcessed()\n\t\tif tv.Buf.IsSpellCorrectEnabled(tv.CursorPos) {\n\t\t\ttv.OfferCorrect()\n\t\t} else {\n\t\t\ttv.ForceComplete = true\n\t\t\ttv.OfferComplete()\n\t\t\ttv.ForceComplete = false // ROR: I definitely don't like this option! want it just when I want it!\n\t\t}\n\tcase gi.KeyFunLookup:\n\t\ttv.ISearchCancel()\n\t\tkt.SetProcessed()\n\t\ttv.Lookup()\n\tcase gi.KeyFunEnter:\n\t\tcancelAll()\n\t\tif !kt.HasAnyModifier(key.Control, key.Meta) {\n\t\t\tkt.SetProcessed()\n\t\t\tif tv.Buf.Opts.AutoIndent {\n\t\t\t\tbufUpdt, winUpdt, autoSave := tv.Buf.BatchUpdateStart()\n\t\t\t\ttv.InsertAtCursor([]byte(\"\\n\"))\n\t\t\t\ttbe, _, cpos := tv.Buf.AutoIndent(tv.CursorPos.Ln, DefaultIndentStrings, DefaultUnindentStrings)\n\t\t\t\tif tbe != nil {\n\t\t\t\t\ttv.RenderLines(tv.CursorPos.Ln, tv.CursorPos.Ln+1)\n\t\t\t\t\ttv.SetCursorShow(TextPos{Ln: tbe.Reg.End.Ln, Ch: cpos})\n\t\t\t\t}\n\t\t\t\ttv.Buf.BatchUpdateEnd(bufUpdt, winUpdt, autoSave)\n\t\t\t} else {\n\t\t\t\ttv.InsertAtCursor([]byte(\"\\n\"))\n\t\t\t}\n\t\t\ttv.ISpellKeyInput(kt)\n\t\t}\n\t\t// todo: KeFunFocusPrev -- unindent\n\tcase gi.KeyFunFocusNext: // tab\n\t\tcancelAll()\n\t\tif !kt.HasAnyModifier(key.Control, key.Meta) {\n\t\t\tkt.SetProcessed()\n\t\t\twupdt := tv.TopUpdateStart()\n\t\t\tlasttab := tv.HasFlag(int(TextViewLastWasTabAI))\n\t\t\tif !lasttab && tv.CursorPos.Ch == 0 && tv.Buf.Opts.AutoIndent { // todo: only at 1st pos now\n\t\t\t\t_, _, cpos := tv.Buf.AutoIndent(tv.CursorPos.Ln, DefaultIndentStrings, DefaultUnindentStrings)\n\t\t\t\ttv.CursorPos.Ch = cpos\n\t\t\t\ttv.RenderLines(tv.CursorPos.Ln, tv.CursorPos.Ln)\n\t\t\t\ttv.RenderCursor(true)\n\t\t\t\tgotTabAI = true\n\t\t\t} else {\n\t\t\t\ttv.InsertAtCursor(indent.Bytes(tv.Buf.Opts.IndentChar(), 1, tv.Sty.Text.TabSize))\n\t\t\t\ttv.RenderLines(tv.CursorPos.Ln, tv.CursorPos.Ln)\n\t\t\t}\n\t\t\ttv.TopUpdateEnd(wupdt)\n\t\t\ttv.ISpellKeyInput(kt)\n\t\t}\n\tcase gi.KeyFunNil:\n\t\tif unicode.IsPrint(kt.Rune) {\n\t\t\tif !kt.HasAnyModifier(key.Control, key.Meta) {\n\t\t\t\ttv.KeyInputInsertRune(kt)\n\t\t\t}\n\t\t}\n\t\tif unicode.IsSpace(kt.Rune) {\n\t\t\ttv.ForceComplete = false\n\t\t}\n\t\ttv.ISpellKeyInput(kt)\n\t}\n\ttv.SetFlagState(gotTabAI, int(TextViewLastWasTabAI))\n}", "func RewindLines(n int) {\n\tfor i := 0; i < n; i++ {\n\t\tfmt.Printf(\"\\033[1A\\033[K\")\n\t}\n}", "func SetReadLineFn(fn ReadLineFnType) {\n\treadLineFn = fn\n}", "func (ls *linestate) completeLine() rune {\n\t// get a list of line completions\n\tlc := ls.ts.completionCallback(ls.String())\n\tif len(lc) == 0 {\n\t\t// no line completions\n\t\tbeep()\n\t\treturn KeycodeNull\n\t}\n\t// navigate and display the line completions\n\tstop := false\n\tidx := 0\n\tu := utf8{}\n\tvar r rune\n\tfor !stop {\n\t\tif idx < len(lc) {\n\t\t\t// save the line buffer\n\t\t\tsavedBuf := ls.buf\n\t\t\tsavedPos := ls.pos\n\t\t\t// show the completion\n\t\t\tls.buf = []rune(lc[idx])\n\t\t\tls.pos = len(ls.buf)\n\t\t\tls.refreshLine()\n\t\t\t// restore the line buffer\n\t\t\tls.buf = savedBuf\n\t\t\tls.pos = savedPos\n\t\t} else {\n\t\t\t// show the original buffer\n\t\t\tls.refreshLine()\n\t\t}\n\t\t// navigate through the completions\n\t\tr = u.getRune(ls.ifd, nil)\n\t\tif r == KeycodeNull {\n\t\t\t// error on read\n\t\t\tstop = true\n\t\t} else if r == KeycodeTAB {\n\t\t\t// loop through the completions\n\t\t\tidx = (idx + 1) % (len(lc) + 1)\n\t\t\tif idx == len(lc) {\n\t\t\t\tbeep()\n\t\t\t}\n\t\t} else if r == KeycodeESC {\n\t\t\t// could be an escape, could be an escape sequence\n\t\t\tif wouldBlock(ls.ifd, &timeout20ms) {\n\t\t\t\t// nothing more to read, looks like a single escape\n\t\t\t\t// re-show the original buffer\n\t\t\t\tif idx < len(lc) {\n\t\t\t\t\tls.refreshLine()\n\t\t\t\t}\n\t\t\t\t// don't pass the escape key back\n\t\t\t\tr = KeycodeNull\n\t\t\t} else {\n\t\t\t\t// probably an escape sequence\n\t\t\t\t// update the buffer and return\n\t\t\t\tif idx < len(lc) {\n\t\t\t\t\tls.buf = []rune(lc[idx])\n\t\t\t\t\tls.pos = len(ls.buf)\n\t\t\t\t}\n\t\t\t}\n\t\t\tstop = true\n\t\t} else {\n\t\t\t// update the buffer and return\n\t\t\tif idx < len(lc) {\n\t\t\t\tls.buf = []rune(lc[idx])\n\t\t\t\tls.pos = len(ls.buf)\n\t\t\t}\n\t\t\tstop = true\n\t\t}\n\t}\n\t// return the last rune read\n\treturn r\n}", "func (b *Buffer) processActionKey(key int) bool {\n\tswitch key {\n\tcase sdl.K_CAPSLOCK:\n\t\tCAPS_LOCK = !CAPS_LOCK\n\t\treturn true\n\tcase sdl.K_RETURN:\n\t\tif SUPER_DOWN {\n\t\t\t// in sublime this goes\n\t\t\t// into the next block\n\t\t\t// nicely indented!\n\t\t}\n\n\t\tinitial_x := b.curs.x\n\t\tprevLineLen := b.contents[b.curs.y].Len()\n\n\t\tvar newRope *rope.Rope\n\t\tif initial_x < prevLineLen && initial_x > 0 {\n\t\t\t// we're not at the end of the line, but we're not at\n\t\t\t// the start, i.e. we're SPLITTING the line\n\t\t\tleft, right := b.contents[b.curs.y].Split(initial_x)\n\t\t\tnewRope = right\n\t\t\tb.contents[b.curs.y] = left\n\t\t} else if initial_x == 0 {\n\t\t\t// we're at the start of a line, so we want to\n\t\t\t// shift the line down and insert an empty line\n\t\t\t// above it!\n\t\t\tb.contents = append(b.contents, new(rope.Rope)) // grow\n\t\t\tcopy(b.contents[b.curs.y+1:], b.contents[b.curs.y:]) // shift\n\t\t\tb.contents[b.curs.y] = new(rope.Rope) // set\n\t\t\tb.curs.move(0, 1)\n\t\t\treturn true\n\t\t} else {\n\t\t\t// we're at the end of a line\n\t\t\tnewRope = new(rope.Rope)\n\t\t}\n\n\t\tb.curs.move(0, 1)\n\t\tfor x := 0; x < initial_x; x++ {\n\t\t\t// TODO(Felix): there's a bug here where\n\t\t\t// this doesn't account for the rendered x\n\t\t\t// position when we use tabs as tabs and not spaces\n\t\t\tb.curs.move(-1, 0)\n\t\t}\n\n\t\tb.contents = append(b.contents, nil)\n\t\tcopy(b.contents[b.curs.y+1:], b.contents[b.curs.y:])\n\t\tb.contents[b.curs.y] = newRope\n\t\treturn true\n\tcase sdl.K_BACKSPACE:\n\t\tif SUPER_DOWN {\n\t\t\tb.deleteBeforeCursor()\n\t\t} else {\n\t\t\tb.deletePrev()\n\t\t}\n\t\treturn true\n\tcase sdl.K_RIGHT:\n\t\tcurrLineLength := b.contents[b.curs.y].Len()\n\n\t\tif CONTROL_DOWN && b.parent != nil {\n\t\t\tb.parent.ChangeFocus(1)\n\t\t\treturn true\n\t\t}\n\n\t\tif SUPER_DOWN {\n\t\t\tfor b.curs.x < currLineLength {\n\t\t\t\tb.curs.move(1, 0)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\t// FIXME this is weird!\n\t\tif ALT_DOWN {\n\t\t\tcurrLine := b.contents[b.curs.y]\n\n\t\t\tvar i int\n\t\t\tfor i = b.curs.x + 1; i < currLine.Len(); i++ {\n\t\t\t\tcurr := currLine.Index(i)\n\t\t\t\tif curr <= ' ' || curr == '_' {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor j := 0; j < i; j++ {\n\t\t\t\tb.moveRight()\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\tb.moveRight()\n\t\treturn true\n\tcase sdl.K_LEFT:\n\t\tif CONTROL_DOWN && b.parent != nil {\n\t\t\tb.parent.ChangeFocus(-1)\n\t\t\treturn true\n\t\t}\n\n\t\tif SUPER_DOWN {\n\t\t\t// TODO go to the nearest \\t\n\t\t\t// if no \\t (i.e. start of line) go to\n\t\t\t// the start of the line!\n\t\t\tb.curs.gotoStart()\n\t\t}\n\n\t\tif ALT_DOWN {\n\t\t\tcurrLine := b.contents[b.curs.y]\n\n\t\t\ti := b.curs.x\n\t\t\tfor i > 0 {\n\t\t\t\tcurrChar := currLine.Index(i)\n\t\t\t\t// TODO is a seperator thing?\n\t\t\t\tif currChar <= ' ' || currChar == '_' {\n\t\t\t\t\t// move over one more?\n\t\t\t\t\ti = i - 1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\ti = i - 1\n\t\t\t}\n\n\t\t\tstart := b.curs.x\n\t\t\tfor j := 0; j < start-i; j++ {\n\t\t\t\tb.moveLeft()\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\tb.moveLeft()\n\t\treturn true\n\tcase sdl.K_UP:\n\t\tif ALT_DOWN {\n\t\t\treturn b.swapLineUp()\n\t\t}\n\n\t\tif SUPER_DOWN {\n\t\t\t// go to the start of the file\n\t\t}\n\n\t\tif b.curs.y > 0 {\n\t\t\toffs := 0\n\t\t\tprevLineLen := b.contents[b.curs.y-1].Len()\n\t\t\tif b.curs.x > prevLineLen {\n\t\t\t\toffs = prevLineLen - b.curs.x\n\t\t\t}\n\t\t\t// TODO: offset should account for tabs\n\t\t\tb.curs.move(offs, -1)\n\t\t}\n\t\treturn true\n\tcase sdl.K_DOWN:\n\t\tif ALT_DOWN {\n\t\t\treturn b.swapLineDown()\n\t\t}\n\n\t\tif SUPER_DOWN {\n\t\t\t// go to the end of the file\n\t\t}\n\n\t\tif b.curs.y < len(b.contents)-1 {\n\t\t\toffs := 0\n\t\t\tnextLineLen := b.contents[b.curs.y+1].Len()\n\t\t\tif b.curs.x > nextLineLen {\n\t\t\t\toffs = nextLineLen - b.curs.x\n\t\t\t}\n\t\t\t// TODO: offset should account for tabs\n\t\t\tb.curs.move(offs, 1)\n\t\t}\n\t\treturn true\n\tcase sdl.K_TAB:\n\t\tif b.cfg.Editor.Tabs_Are_Spaces {\n\t\t\t// make an empty rune array of TAB_SIZE, cast to string\n\t\t\t// and insert it.\n\t\t\tb.contents[b.curs.y] = b.contents[b.curs.y].Insert(b.curs.x, b.makeTab())\n\t\t\tb.curs.move(int(b.cfg.Editor.Tab_Size), 0)\n\t\t} else {\n\t\t\tb.contents[b.curs.y] = b.contents[b.curs.y].Insert(b.curs.x, string('\\t'))\n\t\t\t// the actual position is + 1, but we make it\n\t\t\t// move by TAB_SIZE characters on the view.\n\t\t\tb.curs.moveRender(1, 0, int(b.cfg.Editor.Tab_Size), 0)\n\t\t}\n\t\treturn true\n\n\tcase sdl.K_END:\n\t\tcurrLine := b.contents[b.curs.y]\n\t\tif b.curs.x < currLine.Len() {\n\t\t\tdistToMove := currLine.Len() - b.curs.x\n\t\t\tb.curs.move(distToMove, 0)\n\t\t}\n\t\treturn true\n\n\tcase sdl.K_HOME:\n\t\tif b.curs.x > 0 {\n\t\t\tb.curs.move(-b.curs.x, 0)\n\t\t}\n\t\treturn true\n\n\tcase sdl.K_PAGEUP:\n\t\tb.scrollUp()\n\t\treturn true\n\n\tcase sdl.K_PAGEDOWN:\n\t\tb.scrollDown()\n\t\treturn true\n\n\tcase sdl.K_DELETE:\n\t\tb.deleteNext()\n\t\treturn true\n\n\tcase sdl.K_LGUI:\n\t\tfallthrough\n\tcase sdl.K_RGUI:\n\t\tfallthrough\n\n\tcase sdl.K_LALT:\n\t\tfallthrough\n\tcase sdl.K_RALT:\n\t\tfallthrough\n\n\tcase sdl.K_LCTRL:\n\t\tfallthrough\n\tcase sdl.K_RCTRL:\n\t\tfallthrough\n\n\tcase sdl.K_LSHIFT:\n\t\tfallthrough\n\tcase sdl.K_RSHIFT:\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m *display) SetTextWindow(id int) (int) {\n\tdata := []byte{0xFE, 0x2A, byte(id)}\n\tn1 := m.Send(data)\n return n1\n}", "func (m *Win32LobAppRegistryDetection) SetKeyPath(value *string)() {\n err := m.GetBackingStore().Set(\"keyPath\", value)\n if err != nil {\n panic(err)\n }\n}", "func (v *TextView) SetEditable(editable bool) {\n\tC.gtk_text_view_set_editable(v.native(), gbool(editable))\n}", "func (m *IosDeviceFeaturesConfiguration) SetLockScreenFootnote(value *string)() {\n err := m.GetBackingStore().Set(\"lockScreenFootnote\", value)\n if err != nil {\n panic(err)\n }\n}", "func SetCharCallback(f CharHandler) {\n\tchar = append(char, f)\n\tC.glfwSetCharCB()\n}", "func ClearLine() {\n\tfmt.Printf(CSI+EraseLineSeq, 2)\n}", "func (s *Screen) SetCursorVisible(visible bool) { s.cursorVisible = visible }", "func (w *IPWriter) SetCurrentLine(n uint) {\n\tw.currentLine = n\n}", "func (protocol *DebuggerProtocol) SetBreakpoint(\n\tparams *debugger.SetBreakpointParams,\n) <-chan *debugger.SetBreakpointResult {\n\tresultChan := make(chan *debugger.SetBreakpointResult)\n\tcommand := NewCommand(protocol.Socket, \"Debugger.setBreakpoint\", params)\n\tresult := &debugger.SetBreakpointResult{}\n\n\tgo func() {\n\t\tresponse := <-protocol.Socket.SendCommand(command)\n\t\tif nil != response.Error && 0 != response.Error.Code {\n\t\t\tresult.Err = response.Error\n\t\t} else {\n\t\t\tresult.Err = json.Unmarshal(response.Result, &result)\n\t\t}\n\t\tresultChan <- result\n\t\tclose(resultChan)\n\t}()\n\n\treturn resultChan\n}", "func (term *Terminal) ClearLine() {\n\tfmt.Printf(\"\\r%s\\r\", term.clearer)\n}", "func (m *Win32LobAppRegistryRule) SetKeyPath(value *string)() {\n m.keyPath = value\n}", "func (e *LineEditor) CursorHome() {\n\te.Cx = 0\n}", "func (w *VT100Writer) EraseLine() {\n\tw.WriteRaw([]byte{0x1b, '[', '2', 'K'})\n}", "func RestoreCursorPosition() {\n\tfmt.Printf(\"\\033[u\")\n}", "func RestoreCursorPosition() {\n\tfmt.Printf(\"\\033[u\")\n}", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharCallback(callback CharCallback) CharCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharCallback\n\tcallbacks.CharCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func SetKeyboardLeds(leds int) bool {\n\treturn bool(C.al_set_keyboard_leds(C.int(leds)))\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetCharModsCallback(callback CharModsCallback) CharModsCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.CharModsCallback\n\tcallbacks.CharModsCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetCharModsCallback(win.c())\n\t} else {\n\t\tC.goRemoveCharModsCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (c *Switch) Set(k string) error {\n\tc.lock.RLock()\n\tif _, ok := c.subRenderables[k]; !ok {\n\t\treturn oakerr.NotFound{InputName: \"k:\" + k}\n\t}\n\tc.lock.RUnlock()\n\tc.curRenderable = k\n\treturn nil\n}", "func (buf *CommandBuffer) SetLineWidth(lineWidth float32) {\n\tC.domVkCmdSetLineWidth(buf.fps[vkCmdSetLineWidth], buf.hnd, C.float(lineWidth))\n}", "func (d Display) SetCursor(flag int) error {\n\tret, err := C.caca_set_cursor(d.Dp, C.int(flag))\n\n\tif int(ret) == -1 {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (ls *linestate) editBackspace() {\n\tif ls.pos > 0 && len(ls.buf) > 0 {\n\t\tls.buf = append(ls.buf[:ls.pos-1], ls.buf[ls.pos:]...)\n\t\tls.pos--\n\t\tls.refreshLine()\n\t}\n}", "func (l *ListInfo) keyEvent() (lineData []string) {\n\tl.CursorLine = 0\n\theadLine := 2\n\n\t_, height := termbox.Size()\n\theight = height - headLine\n\n\tl.Keyword = \"\"\n\tallFlag := false // input Ctrl + A flag\n\n\tl.getFilterText()\n\tl.draw()\n\n\tfor {\n\t\tswitch ev := termbox.PollEvent(); ev.Type {\n\t\t// Type Key\n\t\tcase termbox.EventKey:\n\t\t\tswitch ev.Key {\n\t\t\t// ESC or Ctrl + C Key (Exit)\n\t\t\tcase termbox.KeyEsc, termbox.KeyCtrlC:\n\t\t\t\ttermbox.Close()\n\t\t\t\tos.Exit(0)\n\n\t\t\t// AllowUp Key\n\t\t\tcase termbox.KeyArrowUp:\n\t\t\t\tif l.CursorLine > 0 {\n\t\t\t\t\tl.CursorLine -= 1\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// AllowDown Key\n\t\t\tcase termbox.KeyArrowDown:\n\t\t\t\tif l.CursorLine < len(l.ViewText)-headLine {\n\t\t\t\t\tl.CursorLine += 1\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// AllowRight Key\n\t\t\tcase termbox.KeyArrowRight:\n\t\t\t\tnextPosition := ((l.CursorLine + height) / height) * height\n\t\t\t\tif nextPosition+2 <= len(l.ViewText) {\n\t\t\t\t\tl.CursorLine = nextPosition\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// AllowLeft Key\n\t\t\tcase termbox.KeyArrowLeft:\n\t\t\t\tbeforePosition := ((l.CursorLine - height) / height) * height\n\t\t\t\tif beforePosition >= 0 {\n\t\t\t\t\tl.CursorLine = beforePosition\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// Tab Key(select)\n\t\t\tcase termbox.KeyTab:\n\t\t\t\tif l.MultiFlag == true {\n\t\t\t\t\tl.toggle(strings.Fields(l.ViewText[l.CursorLine+1])[0])\n\t\t\t\t}\n\t\t\t\tif l.CursorLine < len(l.ViewText)-headLine {\n\t\t\t\t\tl.CursorLine += 1\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// Ctrl + a Key(all select)\n\t\t\tcase termbox.KeyCtrlA:\n\t\t\t\tif l.MultiFlag == true {\n\t\t\t\t\tl.allToggle(allFlag)\n\t\t\t\t\t// allFlag Toggle\n\t\t\t\t\tif allFlag == false {\n\t\t\t\t\t\tallFlag = true\n\t\t\t\t\t} else {\n\t\t\t\t\t\tallFlag = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tl.draw()\n\n\t\t\t// Ctrl + h Key(Help Window)\n\t\t\t//case termbox.KeyCtrlH:\n\n\t\t\t// Enter Key\n\t\t\tcase termbox.KeyEnter:\n\t\t\t\tif len(l.SelectName) == 0 {\n\t\t\t\t\tl.SelectName = append(l.SelectName, strings.Fields(l.ViewText[l.CursorLine+1])[0])\n\t\t\t\t}\n\t\t\t\treturn\n\n\t\t\t// BackSpace Key\n\t\t\tcase termbox.KeyBackspace, termbox.KeyBackspace2:\n\t\t\t\tif len(l.Keyword) > 0 {\n\t\t\t\t\tl.deleteRune()\n\n\t\t\t\t\tl.getFilterText()\n\t\t\t\t\tif l.CursorLine > len(l.ViewText) {\n\t\t\t\t\t\tl.CursorLine = len(l.ViewText)\n\t\t\t\t\t}\n\t\t\t\t\tif l.CursorLine < 0 {\n\t\t\t\t\t\tl.CursorLine = 0\n\t\t\t\t\t}\n\t\t\t\t\tallFlag = false\n\t\t\t\t\tl.draw()\n\t\t\t\t}\n\n\t\t\t// Space Key\n\t\t\tcase termbox.KeySpace:\n\t\t\t\tl.Keyword = l.Keyword + \" \"\n\t\t\t\tl.draw()\n\n\t\t\t// Other Key\n\t\t\tdefault:\n\t\t\t\tif ev.Ch != 0 {\n\t\t\t\t\tl.insertRune(ev.Ch)\n\t\t\t\t\tl.getFilterText()\n\t\t\t\t\tif l.CursorLine > len(l.ViewText)-headLine {\n\t\t\t\t\t\tl.CursorLine = len(l.ViewText) - headLine\n\t\t\t\t\t}\n\t\t\t\t\tallFlag = false\n\t\t\t\t\tl.draw()\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Type Mouse\n\t\tcase termbox.EventMouse:\n\t\t\tif ev.Key == termbox.MouseLeft {\n\t\t\t\t// mouse select line is (ev.MouseY - headLine) line.\n\t\t\t\tmouseSelectLine := ev.MouseY - headLine\n\n\t\t\t\tif mouseSelectLine <= len(l.ViewText)-headLine {\n\t\t\t\t\tl.CursorLine = mouseSelectLine\n\t\t\t\t}\n\t\t\t\tl.draw()\n\t\t\t}\n\n\t\t// Other\n\t\tdefault:\n\t\t\tl.draw()\n\t\t}\n\t}\n}", "func enableAutofocus() {\n\tmyCommand := fmt.Sprintf(\"v4l2-ctl --set-ctrl=focus_auto=1\")\n\terr := exec.Command(\"/bin/sh\", \"-c\", myCommand).Run()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func showCursor() {\n\tfmt.Printf(\"\\033[?25h\")\n}", "func (ptr *Application) onClickMenuEditCut() {\n\tptr.textEditor.Cut()\n}", "func (w *Wrapper) SetMask(c Color, m uint16) error {\n\tcurrent := w32.GetConsoleScreenBufferInfo(w.h)\n\tif current == nil {\n\t\treturn syscall.Errno(w32.GetLastError())\n\t}\n\tif !w32.SetConsoleTextAttribute(w.h, apply(current.WAttributes, uint16(c), uint16(m))) {\n\t\treturn syscall.Errno(w32.GetLastError())\n\t}\n\treturn nil\n}", "func (em *Vi) HandleExKey(e *novi.KeyEvent) {\n\t/*\n\t Left/right: move cursor\n\t backspace: remove characters, escape if empty\n\n\t nice to have:\n\t up/down> history (if empty)\n\t*/\n\tswitch e.Key {\n\tcase novi.KeyBackspace:\n\t\tif em.ex.input.Len() == 0 {\n\t\t\tem.c <- &novi.CloseInputEvent{ID: 1}\n\t\t}\n\t\tem.ex.input.Backspace()\n\tcase novi.KeyLeft:\n\t\tem.ex.input.CursorLeft()\n\tcase novi.KeyRight:\n\t\tem.ex.input.CursorRight()\n\tcase novi.KeyEscape:\n\t\tem.ex.Clear()\n\t\tem.c <- &novi.CloseInputEvent{ID: 1}\n\t\treturn\n\tcase novi.KeyEnter:\n\t\tlog.Printf(\"Handling ex command '%s'\", em.ex.input.ToString())\n\t\tem.HandleExCommand()\n\t\tem.ex.Clear()\n\t\tem.c <- &novi.CloseInputEvent{ID: 1}\n\t\treturn\n\t}\n\tem.c <- &novi.UpdateInputEvent{ID: 1, Text: em.ex.input.ToString(), Pos: em.ex.input.Pos}\n}", "func (l *Linenoise) historySet(idx int, line string) {\n\tl.history[len(l.history)-1-idx] = line\n}", "func (c *Client) Set(key string) error {\n\tif key == \"REPEAT\" {\n\t\tc.repeat = true\n\t}\n\n\treturn nil\n}", "func SetAndProtectTerm() {\n\t// disable input buffering\n\texec.Command(\"stty\", \"-F\", \"/dev/tty\", \"cbreak\", \"min\", \"1\").Run()\n\t// do not display entered characters on the screen\n\texec.Command(\"stty\", \"-F\", \"/dev/tty\", \"-echo\").Run()\n\t// restore the echoing state when exiting\n\tdefer exec.Command(\"stty\", \"-F\", \"/dev/tty\", \"echo\").Run()\n\n\t// ensure we use echo even on sigterm/ctrl+c\n\tc := make(chan os.Signal, 1)\n\tsignal.Notify(c, os.Interrupt, syscall.SIGTERM)\n\tgo func() {\n\t\t<-c\n\t\texec.Command(\"stty\", \"-F\", \"/dev/tty\", \"echo\").Run()\n\t\tos.Exit(1)\n\t}()\n}", "func (d *Device) setWindow(x, y, w, h int16) {\n\tx += d.columnOffset\n\ty += d.rowOffset\n\tcopy(d.buf[:4], []uint8{uint8(x >> 8), uint8(x), uint8((x + w - 1) >> 8), uint8(x + w - 1)})\n\td.sendCommand(CASET, d.buf[:4])\n\tcopy(d.buf[:4], []uint8{uint8(y >> 8), uint8(y), uint8((y + h - 1) >> 8), uint8(y + h - 1)})\n\td.sendCommand(RASET, d.buf[:4])\n\td.sendCommand(RAMWR, nil)\n}", "func (rk *caIdemixRevocationKey) SetNewKey() (err error) {\n\trk.key, err = rk.idemixLib.GenerateLongTermRevocationKey()\n\treturn err\n}", "func (i *InputHandler) setMouseDown(button int) {\n\ti.buttonStates[button] = keyStatePrePressed\n}", "func (tv *TextView) JumpToLinePrompt() {\n\tgi.StringPromptDialog(tv.Viewport, \"\", \"Line no..\",\n\t\tgi.DlgOpts{Title: \"Jump To Line\", Prompt: \"Line Number to jump to\"},\n\t\ttv.This(), func(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tdlg := send.(*gi.Dialog)\n\t\t\tif sig == int64(gi.DialogAccepted) {\n\t\t\t\tval := gi.StringPromptDialogValue(dlg)\n\t\t\t\tln, ok := kit.ToInt(val)\n\t\t\t\tif ok {\n\t\t\t\t\ttv.JumpToLine(int(ln))\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n}", "func (s *SetupScreen) Handle(e string) {\n\t// if arrow keys and no selected item, change the selected item\n\tif !s.editing {\n\t\tif e == \"<Up>\" || e == \"k\" {\n\t\t\ts.changeSelection(-1)\n\t\t\treturn\n\t\t}\n\t\tif e == \"<Down>\" || e == \"j\" {\n\t\t\ts.changeSelection(1)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif e == \"<Space>\" {\n\t\ts.toggle()\n\t\treturn\n\t}\n\tcurrent := s.fields[s.selected]\n\n\tif s.editing {\n\t\t// All the keys that could be used to \"undo\" - as of right now github.com/gizak/termui is not\n\t\t// working correctly and backspaces are coming through as \"C-8>\" - when this is fixed/PR'ed\n\t\t// these conditions as well as what we allow through anyKey in main, can be updated.\n\t\tif e == \"<Backspace>\" || e == \"<Delete>\" || e == \"C-8>\" {\n\t\t\tif len(current.Text) > 0 {\n\t\t\t\tcurrent.Text = current.Text[:len(current.Text)-1]\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif len(e) >= 4 {\n\t\t\treturn\n\t\t}\n\n\t\t// append the character to the text\n\t\tcurrent.Text += e\n\t} else {\n\t\tif e == \"q\" {\n\t\t\tui.StopLoop()\n\t\t}\n\t}\n\n}", "func (b *Bot) SetEditMessageHandler(fn editMessageHandlerFunc) {\n\tb.handlers.editMessageHandler = fn\n}", "func (i *Ime) SetCursorPosition(parameters Object, callback func(success bool)) {\n\ti.o.Call(\"setCursorPosition\", parameters, callback)\n}", "func ClearLine() string {\n\tif runtime.GOOS == \"windows\" {\n\t\tif w := stdoutTerminalWidth(); w > 0 {\n\t\t\treturn strings.Repeat(\" \", w-1) + \"\\r\"\n\t\t}\n\t\treturn \"\"\n\t}\n\treturn \"\\x1b[2K\"\n}", "func (c *Characteristic) SetEndHandle(endh uint16) { c.endh = endh }", "func (s *Surface) SetLineMiterLimit(miter float64) {\n\ts.Ctx.Set(\"miterLimit\", miter)\n}", "func SetResponder(contentType ContentType, responder responders.Func) {\n\t_ = defaultCtrl.SetResponder(contentType, responder)\n}" ]
[ "0.5973567", "0.4932849", "0.49110886", "0.4889821", "0.48842877", "0.48081532", "0.48081532", "0.47633767", "0.47557762", "0.47259524", "0.47226557", "0.471854", "0.46006963", "0.46006963", "0.45853287", "0.45676532", "0.45553032", "0.45468715", "0.45246252", "0.45215952", "0.45158324", "0.45155558", "0.4504217", "0.44900513", "0.44616604", "0.445376", "0.44458687", "0.44424662", "0.44416672", "0.4435368", "0.4432736", "0.44063795", "0.44063795", "0.43588418", "0.4358802", "0.4352804", "0.43025786", "0.42870834", "0.42813775", "0.42703244", "0.42592227", "0.42482758", "0.42399737", "0.4239659", "0.42325038", "0.4222922", "0.4218814", "0.4214783", "0.42100734", "0.4192449", "0.4192449", "0.4187618", "0.418568", "0.41855645", "0.41810602", "0.41727698", "0.4168441", "0.41663232", "0.4160015", "0.41560653", "0.41458032", "0.41456786", "0.4143138", "0.41355115", "0.41175538", "0.4115453", "0.4097895", "0.409521", "0.40946427", "0.40901184", "0.40901184", "0.40898818", "0.40898818", "0.40826765", "0.40762624", "0.40762624", "0.40736842", "0.40720794", "0.40663746", "0.4050154", "0.40497693", "0.40477484", "0.40466976", "0.4043514", "0.4039307", "0.40380204", "0.40260085", "0.40198588", "0.40098068", "0.40092367", "0.40069395", "0.40058824", "0.40007168", "0.40000537", "0.39965", "0.3994213", "0.39882183", "0.39816585", "0.3980909", "0.3976551" ]
0.80387086
0
Command History pop an entry from the history list
func (l *Linenoise) historyPop(idx int) string { if idx < 0 { // pop the last entry idx = len(l.history) - 1 } if idx >= 0 && idx < len(l.history) { s := l.history[idx] l.history = append(l.history[:idx], l.history[idx+1:]...) return s } // nothing to pop return "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (z *zpoolctl) History(ctx context.Context, options string, pool string) *execute {\n\targs := []string{\"history\"}\n\tif len(options) > 0 {\n\t\targs = append(args, options)\n\t}\n\tif len(pool) > 0 {\n\t\targs = append(args, pool)\n\t}\n\treturn &execute{ctx: ctx, name: z.cmd, args: args}\n}", "func historyAction(splited []string) {\n var length = len(splited)\n if length == 1 {\n printGlobalHistory()\n return\n }\n switch splited[1] {\n case \"del\", \"delete\": historyDelete(splited, length)\n case \"loc\", \"local\": historyLocal(splited, length)\n }\n}", "func (cd *circularDependency) pop() {\n\t//log.Println(\"Removing:\", cd.Dependents[len(cd.Dependents)-1])\n\tcd.dependents = cd.dependents[:len(cd.dependents)-1]\n}", "func (h *History) Clear() {\n\th.tmp = make([]string, len(h.histories))\n\tfor i := range h.histories {\n\t\th.tmp[i] = h.histories[i]\n\t}\n\th.tmp = append(h.tmp, \"\")\n\th.selected = len(h.tmp) - 1\n}", "func (ptr *terminalPrompter) AppendHistory(command string) {\n\tptr.State.AppendHistory(command)\n}", "func (app *application) historyCmd(p *project, cmd *historyApiCommand) (*response, error) {\n\n\tresp := newResponse(\"history\")\n\n\tchannel := cmd.Channel\n\n\tif channel == \"\" {\n\t\tlogger.ERROR.Println(\"channel required\")\n\t\treturn nil, ErrInvalidApiMessage\n\t}\n\n\tbody := map[string]interface{}{\n\t\t\"channel\": channel,\n\t}\n\n\tresp.Body = body\n\n\tchOpts, err := app.channelOpts(p.Name, channel)\n\tif err != nil {\n\t\tresp.Err(err)\n\t\treturn resp, nil\n\t}\n\n\tif chOpts.HistorySize <= 0 || chOpts.HistoryLifetime <= 0 {\n\t\tresp.Err(ErrNotAvailable)\n\t\treturn resp, nil\n\t}\n\n\thistory, err := app.history(p.Name, channel)\n\tif err != nil {\n\t\tresp.Err(ErrInternalServerError)\n\t\treturn resp, nil\n\t}\n\n\tresp.Body = map[string]interface{}{\n\t\t\"channel\": channel,\n\t\t\"data\": history,\n\t}\n\treturn resp, nil\n}", "func uxHistory(cmd cli.Command) cli.Command {\n\thistoryFlags := []cli.Flag{\n\t\tcli.BoolFlag{\n\t\t\tName: \"no-history\",\n\t\t\tUsage: \"do not create a history entry\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"history.author\",\n\t\t\tUsage: \"author value for the history entry\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"history.comment\",\n\t\t\tUsage: \"comment for the history entry\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"history.created\",\n\t\t\tUsage: \"created value for the history entry\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"history.created_by\",\n\t\t\tUsage: \"created_by value for the history entry\",\n\t\t},\n\t}\n\tcmd.Flags = append(cmd.Flags, historyFlags...)\n\n\toldBefore := cmd.Before\n\tcmd.Before = func(ctx *cli.Context) error {\n\t\t// --no-history is incompatible with other --history.* options.\n\t\tif ctx.Bool(\"no-history\") {\n\t\t\tfor _, flag := range historyFlags {\n\t\t\t\tif name := flag.GetName(); name == \"no-history\" {\n\t\t\t\t\tcontinue\n\t\t\t\t} else if ctx.IsSet(name) {\n\t\t\t\t\treturn errors.Errorf(\"--no-history and --%s may not be specified together\", name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Include any old befores set.\n\t\tif oldBefore != nil {\n\t\t\treturn oldBefore(ctx)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn cmd\n}", "func historyDelete(splited []string, length int) {\n if length == 2 {\n connect.DeleteGlobalMessages()\n return\n }\n connect.DeleteLocalMessages(splited[2:])\n}", "func viewHistory(board *chess.Board, includeEval bool, resultString string) {\n\tvar input rune\n\tindex := len(board.History) - 1\n\ttempBoard := board\n\treader := bufio.NewReader(os.Stdin)\n\tfor {\n\t\t//fmt.Print(\"\\033[1;1H\")\n\t\t//fmt.Print(\"\\033[0J\")\n\t\ttempBoard.PrintBoard(false)\n\t\tif includeEval {\n\t\t\tfmt.Println(\"Basic: \", eval.EvaluateBasic(tempBoard), \" With tables: \", eval.EvaluateWithTables(tempBoard))\n\t\t}\n\t\tfmt.Println(\"Options: a: move back one ply, d: move backward one ply, q: quit\")\n\t\tif index == -1 {\n\t\t\tfmt.Println(\"Beginning of game!\")\n\t\t} else if index == len(board.History)-1 {\n\t\t\tfmt.Println(\"End of game!\")\n\t\t\tfmt.Println(resultString)\n\t\t}\n\t\tinput, _, _ = reader.ReadRune()\n\t\tif input == 'q' {\n\t\t\tquit(board)\n\t\t} else if input == 'a' {\n\t\t\tif index == -1 { //reset index so doesn't run of end of History at first of game\n\t\t\t\tindex++\n\t\t\t}\n\t\t\tindex-- //adjust index\n\t\t\tif index == -1 {\n\t\t\t\ttempBoard, _ = chess.ParseFen(\"\") //index of -1 means initial position (not recorded in History)\n\t\t\t} else {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index])\n\t\t\t}\n\n\t\t} else if input == 'd' {\n\t\t\tif index == len(board.History)-1 { //reset index\n\t\t\t\tindex--\n\t\t\t}\n\t\t\tindex++ //adjust index\n\t\t\tif index == -1 {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index+1])\n\t\t\t} else {\n\t\t\t\ttempBoard, _ = chess.ParseFen(board.History[index])\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (el *ExitList) Pop(exitInterface ExitInterface) error {\n\tif el.module == nil {\n\t\treturn errors.New(\"[Smoothly Exit] Pop: plz init ExitList first\")\n\t}\n\n\t// Judge whether it exists or not\n\tmoduleName := exitInterface.GetModuleName()\n\tif _, ok := el.module[moduleName]; ok {\n\t\treturn errors.New(\"[Smoothly Exit] Pop: this module(\" + moduleName + \") name is exist\")\n\t}\n\n\t// Add value\n\telement := el.ll.PushFront(exitInterface)\n\tel.module[moduleName] = element\n\n\treturn nil\n}", "func (g *Generator) ClearHistory() {\n\tg.image.History = []ispec.History{}\n}", "func (l *Linenoise) historyGet(idx int) string {\n\treturn l.history[len(l.history)-1-idx]\n}", "func (h *History) Last() *Entry {\n\treturn &(*h)[len(*h)-1]\n}", "func (f *ExtensionStoreDeleteFunc) History() []ExtensionStoreDeleteFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreDeleteFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (mnu *MedicalNoteUpdate) ClearHistory() *MedicalNoteUpdate {\n\tmnu.clearedHistory = true\n\treturn mnu\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 (h *History) Last() []*Action {\n\tif len(h.actions) == 0 {\n\t\treturn nil\n\t}\n\treturn h.actions[len(h.actions)-1]\n}", "func (stepList *StepList) Pop() steps.Step {\n\tif stepList.IsEmpty() {\n\t\treturn nil\n\t}\n\tresult := stepList.List[0]\n\tstepList.List = stepList.List[1:]\n\treturn result\n}", "func (q *CommandQueue) Pop() string {\n\tq.lock.Lock()\n\tres := q.Commands[0]\n\tq.Commands = q.Commands[1:len(q.Commands)]\n\tq.lock.Unlock()\n\treturn res\n}", "func (h *History) GetLast() string {\n return h.GetLine(len(h.histories) - 1)\n}", "func (em *eventManager) Pop() any {\n\te := em.heap[len(em.heap)-1]\n\tem.heap = em.heap[:len(em.heap)-1]\n\tdelete(em.reverseLookup, e.eh)\n\treturn e\n}", "func (e *TarantoolEngine) history(chID ChannelID) (msgs []Message, err error) {\n\tconn, err := e.pool.get()\n\tif err != nil {\n\t\tlogger.ERROR.Printf(\"history tarantool pool error: %v\\n\", err.Error())\n\t\treturn nil, err\n\t}\n\n\thistory, err := conn.Call(\"notification_channel_history\", []interface{}{chID})\n\tif err != nil {\n\t\tlogger.ERROR.Printf(\"history error: %v\\n\", err.Error())\n\t\treturn nil, err\n\t}\n\n\treturn processHistory(history)\n}", "func LevelPop() {\n len := len(logLevelStack)\n logLevel, logLevelStack = logLevelStack[len-1], logLevelStack[:len-1] \n}", "func (p *path) Pop() interface{} {\n\told := *p\n\tn := len(old)\n\tx := old[n-1]\n\t*p = old[0 : n-1]\n\treturn x\n}", "func (f *LSIFStoreClearFunc) History() []LSIFStoreClearFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreClearFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *LSIFStoreClearFunc) History() []LSIFStoreClearFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreClearFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (ptr *terminalPrompter) SetHistory(history []string) {\n\tptr.State.ReadHistory(strings.NewReader(strings.Join(history, \"\\n\")))\n}", "func (c *Client) SPop(_ context.Context, key string) *redis.StringCmd {\n\treturn c.cli.SPop(key)\n}", "func (set Set) Pop(ctx context.Context) (string, error) {\n\treq := newRequest(\"*2\\r\\n$4\\r\\nSPOP\\r\\n$\")\n\treq.addString(set.name)\n\treturn set.c.cmdString(ctx, req)\n}", "func (s *SimpleChaincode) pat_gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tpatKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", patKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(patKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForPatient returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (o *openList) Pop() interface{} {\n\topn := *o\n\tit := opn[len(opn)-1]\n\tit.pqindex = -1\n\t*o = opn[:len(opn)-1]\n\treturn it\n}", "func (stack *PfxStack) Pop() {\n\tstack.Entries = stack.Entries[:len(stack.Entries)-1]\n\tif !stack.Entries[len(stack.Entries)-1].Last {\n\t\tstack.Entries[len(stack.Entries)-1].Preamble = stack.GetPreamble(stack.FirstDash)\n\t}\n}", "func (mnuo *MedicalNoteUpdateOne) ClearHistory() *MedicalNoteUpdateOne {\n\tmnuo.clearedHistory = true\n\treturn mnuo\n}", "func (h *History) List() {\n\tload := reverse(h.Load())\n\tprompt := promptui.Select{\n\t\tLabel: \"Target hisotry\",\n\t\tItems: load,\n\t\tSize: 10,\n\t}\n\n\ti, _, err := prompt.Run()\n\n\tif err != nil {\n\t\tlog.Fatalln(\"Prompt failed: \\n\", err)\n\t}\n\n\titem := load[i]\n\th.Write(item)\n\tExecuteItem(h.binary, item)\n}", "func (board *Board) popState() UndoInfo {\n\tundoInfo := board.undoInfoList[board.gamePly]\n\tboard.gamePly--\n\treturn undoInfo\n}", "func (this popChannel) stack(cmd ...*URLContext) {\n\ttoStack := cmd\n\tfor {\n\t\tselect {\n\t\tcase this <- toStack:\n\t\t\treturn\n\t\tcase old := <-this:\n\t\t\t// Content of the channel got emptied and is now in old, so append whatever\n\t\t\t// is in toStack to it, so that it can either be inserted in the channel,\n\t\t\t// or appended to some other content that got through in the meantime.\n\t\t\ttoStack = append(old, toStack...)\n\t\t}\n\t}\n}", "func (s *stack) pop() {\n\ts.items = s.items[:len(s.items)-1]\n}", "func (s *HeroesServiceChaincode) gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tvegKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", vegKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(vegKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForVegetable returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func MoveToHistory(job *AnalyzeJob) {\n\tanalyzeStatus.Lock()\n\tdelete(analyzeStatus.jobs, job)\n\tanalyzeStatus.history = append(analyzeStatus.history, job)\n\tnumJobs := len(analyzeStatus.history)\n\tif numJobs > numMaxHistoryJobs {\n\t\tanalyzeStatus.history = analyzeStatus.history[numJobs-numMaxHistoryJobs:]\n\t}\n\tanalyzeStatus.Unlock()\n}", "func (list *TList) HPop() string {\n\tlist.mux.Lock()\n\n\tif list.Head() == nil {\n\t\tlist.mux.Unlock()\n\t\treturn \"\"\n\t}\n\n\tstr := util.ToString(list.list.Remove(list.Head()))\n\tlist.mux.Unlock()\n\treturn str\n}", "func (c *Client) LPop(key string) (*string, error) {\n\treq := cmd([]string{\"lpop\", key})\n\tres, err := c.processRequest(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.bulkString(res)\n}", "func (m *OrderedMap[K,V]) PopBack() (k K, v V, ok bool) {\n\te := m.list.Back()\n\tif e == nil {\n\t\treturn\n\t}\n\tk, v, ok = e.Value.Key, e.Value.Value, true\n\tdelete(m.mp, k)\n\tm.list.Remove(e)\n\treturn\n}", "func (canvas *Canvas) Pop() {\n\twriteCommand(canvas.contents, \"Q\")\n}", "func (f *DBStoreDeleteUploadsWithoutRepositoryFunc) History() []DBStoreDeleteUploadsWithoutRepositoryFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteUploadsWithoutRepositoryFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func get_history(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start getHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tresults, err := ConvHistoryResult(resultsIterator)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tfmt.Println(\"end getHistory\")\n\n\treturn shim.Success(results)\n}", "func (a *LocalActivations) Pop() {\n\tcount := len(a.activations)\n\tif count < 1 {\n\t\treturn\n\t}\n\ta.activations = a.activations[:count-1]\n}", "func (s *Storage) ListPop(key string) (string, error) {\n\tshard := s.getShard(key)\n\n\tshard.mutex.Lock()\n\tdefer shard.mutex.Unlock()\n\n\tif item, ok := shard.keyValues[key]; ok {\n\t\tif isExpired(item.expiration) {\n\t\t\treturn \"\", nil\n\t\t}\n\n\t\tif list, ok := item.value.([]string); ok {\n\t\t\tif len(list) == 0 {\n\t\t\t\treturn \"\", newErrCustom(errEmptyList)\n\t\t\t}\n\n\t\t\tlastElem := list[len(list)-1]\n\t\t\titem.value = list[:len(list)-1]\n\t\t\tshard.keyValues[key] = item\n\t\t\treturn lastElem, nil\n\t\t}\n\t\treturn \"\", newErrCustom(errWrongType)\n\t}\n\treturn \"\", nil\n}", "func (cl *charLine) rxPop(rx *regexp.Regexp) (string, error) {\n\tr := rx.FindString(cl.string())\n\ts := rx.ReplaceAllString(cl.string(), \"\")\n\t*cl = charLine(s)\n\treturn r, nil\n}", "func (l *Linenoise) HistoryAdd(line string) {\n\tif l.historyMaxlen == 0 {\n\t\treturn\n\t}\n\t// don't re-add the last entry\n\tif len(l.history) != 0 && line == l.history[len(l.history)-1] {\n\t\treturn\n\t}\n\t// add the line to the history\n\tif len(l.history) == l.historyMaxlen {\n\t\t// remove the first entry\n\t\tl.historyPop(0)\n\t}\n\tl.history = append(l.history, line)\n}", "func (s *BaseGShellListener) ExitCommandListItem(ctx *CommandListItemContext) {}", "func (f *DBStoreHardDeleteUploadByIDFunc) History() []DBStoreHardDeleteUploadByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreHardDeleteUploadByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (q *Stack) Pop() string {\n\ts := *q\n\tlast := s[len(s)-1]\n\t*q = s[:len(s)-1]\n\treturn last\n}", "func (h *Strings) Pop() string {\n\tif h.less == nil {\n\t\tPopToLastF(len(h.list), h.list.Less, h.list.Swap)\n\t} else {\n\t\tPopToLastF(len(h.list), h.less, h.list.Swap)\n\t}\n\n\tres := h.list[len(h.list)-1]\n\th.list[len(h.list)-1] = \"\" // remove the reference in h.list\n\th.list = h.list[:len(h.list)-1]\n\n\treturn res\n}", "func History(ctx context.Context, channelName string) ([]*types.Message, error) {\n\tchannel := getChannel(channelName)\n\tmessages := messagesFromHistory(channel.History)\n\n\treturn messages, nil\n}", "func (h *MethodCallHistory) GetHistory() []*MethodCall {\n\tdefer h.RUnlock()\n\th.RLock()\n\treturn h.history\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 (l *pqList) Pop() interface{} {\n\treturn l.Remove(len(l.Slice) - 1)\n}", "func pop(s []string) string {\n\tpop := s[0]\n\ts = remove(s, pop)\n\treturn pop\n}", "func (puo *PatientrecordUpdateOne) RemoveHistorytaking(h ...*Historytaking) *PatientrecordUpdateOne {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn puo.RemoveHistorytakingIDs(ids...)\n}", "func pop(a *Stack) {\n if a.head == 0 {\n fmt.Println(\"STACK EMPTY\")\n } else {a.con = a.con[:len(a.con)-1]\n\tfmt.Println(\"by reference function call\",a.con)\n\ta.head--\n }\n}", "func (f *DBStoreDeleteUploadsStuckUploadingFunc) History() []DBStoreDeleteUploadsStuckUploadingFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteUploadsStuckUploadingFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (h *History) Add(input string) {\n\th.histories = append(h.histories, input)\n\th.Clear()\n}", "func (list *List) Pop() string {\n\tsize := list.Len() - 1\n\n\tif size == -1 {\n\t\tpanic(\"Trying to pop from an empty List\")\n\t}\n\n\tstr := list.data[size]\n\tlist.data = list.data[:size]\n\n\treturn str\n}", "func (vm *VM) bufferPop() (string, error) {\n\tcurrentBuffer := vm.buffer\n\tif currentBuffer == nil {\n\t\treturn \"\", ErrorBufferEmpty\n\t}\n\tvm.buffer = currentBuffer.previous\n\treturn currentBuffer.value, nil\n}", "func (q *queryPQ) Pop() any {\n\titem := (*q)[len(*q)-1]\n\t*q = (*q)[:len(*q)-1]\n\treturn item\n}", "func RemoveLastElemFromTop(c *gin.Context) { dequeueTop([]qMessage{}) }", "func (f *UploadServiceDeleteUploadByIDFunc) History() []UploadServiceDeleteUploadByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceDeleteUploadByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (stack *savepointStack) popToIdx(idx int) {\n\t*stack = (*stack)[:idx+1]\n}", "func (f *ReleaseStoreHandleFunc) History() []ReleaseStoreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype KeyModificationWrapper struct {\n\t\tRealValue interface{} `json:\"InterfaceValue\"`\n\t\tTx queryresult.KeyModification\n\t}\n\tvar sliceReal []KeyModificationWrapper\n\n\tvar history []queryresult.KeyModification\n\tvar value interface{}\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start GetHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar singleReal KeyModificationWrapper\n\t\tvar tx queryresult.KeyModification\n\t\tsingleReal.Tx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //value has been deleted\n\t\t\tvar emptyBytes []byte\n\t\t\tsingleReal.Tx.Value = emptyBytes //copy nil value\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\t\tsingleReal.Tx.Value = historyData.Value //copy value over\n\t\t\tsingleReal.Tx.Timestamp = historyData.Timestamp\n\t\t\tsingleReal.Tx.IsDelete = historyData.IsDelete\n\t\t\tsingleReal.RealValue = value\n\t\t}\n\t\thistory = append(history, tx) //add this Tx to the list\n\t\tsliceReal = append(sliceReal, singleReal)\n\t}\n\t// fmt.Printf(\"- getHistoryForService returning:\\n%s\", history)\n\tPrettyPrintHistory(history)\n\n\t//change to array of bytes\n\t// historyAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\n\trealAsBytes, _ := json.Marshal(sliceReal)\n\treturn shim.Success(realAsBytes)\n}", "func (p *RestPresence) History(params *PaginateParams) (*PaginatedResult, error) {\n\tpath := \"/channels/\" + p.channel.uriName + \"/presence/history\"\n\treturn newPaginatedResult(presMsgType, path, params, query(p.client.get), p.logger())\n}", "func (room *RoomRecorder) history() []*action_.PlayerAction {\n\troom.historyM.RLock()\n\tv := room._history\n\troom.historyM.RUnlock()\n\treturn v\n}", "func (w *walk) pop() {\n\tif len(*w) > 0 {\n\t\t*w = (*w)[:len(*w)-1]\n\t}\n}", "func (h *minPath) Pop() interface{} {\n\told := *h\n\tn := len(old)\n\tx := old[n-1]\n\t*h = old[0 : n-1]\n\treturn x\n}", "func CommandUndo(conf Config, args []string, ctx, query Query) error {\n\tvar err error\n\tn := 1\n\tif len(args) == 3 {\n\t\tn, err = strconv.Atoi(args[2])\n\t\tif err != nil {\n\t\t\tHelp(CMD_UNDO)\n\t\t\treturn err\n\t\t}\n\t}\n\n\tMustRunGitCmd(conf.Repo, \"revert\", \"--no-gpg-sign\", \"--no-edit\", \"HEAD~\"+strconv.Itoa(n)+\"..\")\n\n\treturn nil\n}", "func (f *UploadServiceDeleteUploadsFunc) History() []UploadServiceDeleteUploadsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceDeleteUploadsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (s *items) pop() (out Item) {\n\tindex := len(*s) - 1\n\tout = (*s)[index]\n\t(*s)[index] = nil\n\t*s = (*s)[:index]\n\treturn\n}", "func (pu *PatientrecordUpdate) RemoveHistorytaking(h ...*Historytaking) *PatientrecordUpdate {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn pu.RemoveHistorytakingIDs(ids...)\n}", "func (f *ResolverDeleteUploadByIDFunc) History() []ResolverDeleteUploadByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverDeleteUploadByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverDeleteIndexByIDFunc) History() []ResolverDeleteIndexByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverDeleteIndexByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func getPrevCommand(g *gocui.Gui, v *gocui.View) error {\n\ts := v.Buffer()\n\ts = screen.sb.GetPrevCommand(s)\n\tif len(s) == 0 {\n\t\tresetCursor(v)\n\t}\n\n\tv.Clear()\n\tv.Write([]byte(s))\n\n\treturn nil\n}", "func Pop() Action {\n\treturn ActionPop{}\n}", "func (c Clipboard) GetHistory() ([]string, error) {\n\titems, err := c.Storage.GetHistory(c.HistorySize)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn items, nil\n}", "func (s *orderedItems) Pop() interface{} {\n\told := *s\n\tn := len(old)\n\tx := old[n-1]\n\t*s = old[0 : n-1]\n\treturn x\n}", "func (s *state) pop(mark int) {\n\ts.vars = s.vars[0:mark]\n}", "func (stack *Stack) Pop() string {\n\tret := (*stack)[len(*stack)-1]\n\t*stack = (*stack)[:len(*stack)-1]\n\treturn ret\n}", "func (f *ReleaseStoreTransactFunc) History() []ReleaseStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (t *shimTestCC) historyq(stub ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 1 {\n\t\treturn Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\treturn Success(buffer.Bytes())\n}", "func (f *DBStoreDeleteIndexesWithoutRepositoryFunc) History() []DBStoreDeleteIndexesWithoutRepositoryFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteIndexesWithoutRepositoryFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (client SmartGroupsClient) GetHistoryResponder(resp *http.Response) (result SmartGroupModification, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (l *list) Pop() {\n\tl.elements = l.elements[:len(l.elements)-1]\n}", "func (f *DBStoreDirtyRepositoriesFunc) History() []DBStoreDirtyRepositoriesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDirtyRepositoriesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDirtyRepositoriesFunc) History() []DBStoreDirtyRepositoriesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDirtyRepositoriesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (ss *StringStack) Pop() {\n\tss.stack = ss.stack[:len(ss.stack)-1]\n}", "func (c *Commands) Remove(name string) (found bool) {\n\tfor index, cmd := range c.list {\n\t\tif cmd.Name == name {\n\t\t\tfound = true\n\t\t\tc.changed = true\n\t\t\tc.list = append(c.list[:index], c.list[index+1:]...)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (l *List) PopFront() *Process {\n\tp := (*l)[0]\n\t*l = (*l)[1:]\n\treturn p\n}", "func (s *Steps) Pop() (Step, Path) {\n\treturn s.step, s.parent\n}", "func LPop(conn redigo.Conn, key string, dest interface{}) (bool, error) {\n\treturn Result(conn.Do(\"LPOP\", key)).StringToJSON(dest)\n}", "func (f *ExtensionStoreUpdateFunc) History() []ExtensionStoreUpdateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreUpdateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (h *History) Cut(to int) int {\n\tb := len(h.actions)\n\th.actions = h.actions[:to]\n\th.head = len(h.actions)\n\ta := len(h.actions)\n\treturn b - a\n}" ]
[ "0.63282084", "0.5945465", "0.5863756", "0.5819657", "0.58017015", "0.5801636", "0.5786378", "0.5783973", "0.57822776", "0.57009435", "0.5689128", "0.56723243", "0.563348", "0.5607726", "0.5600586", "0.5591681", "0.5548713", "0.553627", "0.5528185", "0.5520647", "0.5512427", "0.5510041", "0.5461835", "0.5444675", "0.5423435", "0.5423435", "0.5420843", "0.542001", "0.5413694", "0.54131883", "0.5394393", "0.5391595", "0.5388195", "0.53844863", "0.53822786", "0.5375562", "0.53731394", "0.5366949", "0.53602284", "0.53570473", "0.5354048", "0.5344367", "0.5333926", "0.5325983", "0.5320632", "0.5316647", "0.53135234", "0.53105736", "0.53044677", "0.5304076", "0.5299549", "0.52974236", "0.52952003", "0.5293773", "0.5288681", "0.52869385", "0.5285633", "0.52716845", "0.5257517", "0.52570397", "0.525595", "0.5234456", "0.5232322", "0.52313334", "0.52268136", "0.5225783", "0.521637", "0.5212786", "0.52102154", "0.52038145", "0.5193011", "0.5187949", "0.51817936", "0.51811993", "0.51788497", "0.5177803", "0.51606584", "0.5160063", "0.5158369", "0.5156884", "0.5152426", "0.5142071", "0.51291215", "0.51236445", "0.5105684", "0.51049215", "0.5099142", "0.50866055", "0.50862116", "0.50861746", "0.5080869", "0.50774986", "0.50774986", "0.5077124", "0.50766087", "0.5069389", "0.50628835", "0.50626", "0.50520575", "0.50475115" ]
0.74988085
0
Set a history entry by index number.
func (l *Linenoise) historySet(idx int, line string) { l.history[len(l.history)-1-idx] = line }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n Nodes) SetIndex(i int, node *Node)", "func (lo *LuaObject) Set(idx interface{}, val interface{}) interface{} {\n L := lo.L\n lo.Push() // the table\n GoToLua(L, nil, valueOf(idx))\n GoToLua(L, nil, valueOf(val))\n L.SetTable(-3)\n L.Pop(1) // the table\n return val\n}", "func (sa *SnapshotArray) Set(index int, val int) {\n\tsa.current[index] = val\n}", "func (this *SnapshotArray) Set(index int, val int) {\n\tif len(this.arr[index]) < this.snapId+1 {\n\t\tfor len(this.arr[index]) < this.snapId+1 {\n\t\t\tthis.arr[index] = append(this.arr[index], this.arr[index][len(this.arr[index])-1])\n\t\t}\n\t}\n\tthis.arr[index][this.snapId] = val\n}", "func (list *List) Set(index int, value interface{}) {\n\n\tif !list.withinRange(index) {\n\t\t// Append\n\t\tif index == list.size {\n\t\t\tlist.Add(value)\n\t\t}\n\t\treturn\n\t}\n\n\tfoundElement := list.first\n\tfor e := 0; e != index; {\n\t\te, foundElement = e+1, foundElement.next\n\t}\n\tfoundElement.value = value\n}", "func (hat *HashedArrayTree) Set(index int, value interface{}) error {\n\tif !hat.validIndex(index) {\n\t\treturn ErrIndexOutOfRange\n\t}\n\tti, li := hat.topIndex(index), hat.leafIndex(index)\n\that.top[ti][li] = value\n\treturn nil\n}", "func (ll *LinkedList) Set(index uint, data interface{}) {\n\tll.Lock()\n\tdefer ll.Unlock()\n\n\tif index >= ll.size {\n\t\tpanic(&IndexOutOfRangeError{size: ll.size})\n\t}\n\n\tnode := ll.findNode(index)\n\tnode.data = data\n}", "func (cache *cache) SetValue(index, value int) error {\n\tbs := []byte(strconv.Itoa(value))\n\tsetItem := memcache.Item{\n\t\tKey: strconv.Itoa(index),\n\t\tValue: bs}\n\tif err := cache.client.Set(&setItem); err != nil {\n\t\treturn err\n\t}\n\tif MaxCalculatedIndex < index {\n\t\tMaxCalculatedIndex = index\n\t}\n\treturn nil\n}", "func (e *Engine) setIndex(index int64) {\n\te.Index = index\n\te.Name = naming.Name(index)\n}", "func (d *V8interceptor) SetByindex(index int32, object, value *V8value, exception *string) int32 {\n\texception_ := C.cef_string_userfree_alloc()\n\tsetCEFStr(*exception, exception_)\n\tdefer func() {\n\t\t*exception = cefstrToString(exception_)\n\t\tC.cef_string_userfree_free(exception_)\n\t}()\n\treturn int32(C.gocef_v8interceptor_set_byindex(d.toNative(), C.int(index), object.toNative(), value.toNative(), (*C.cef_string_t)(exception_), d.set_byindex))\n}", "func (room *RoomRecorder) setHistory(history []*action_.PlayerAction) {\n\troom.historyM.Lock()\n\troom._history = history\n\troom.historyM.Unlock()\n}", "func (m *RecurrencePattern) SetIndex(value *WeekIndex)() {\n m.index = value\n}", "func (access IntAccess) Set(row int, val int) {\n access.rawData[access.indices[row]] = val\n}", "func (v Value) SetIndex(i int, x interface{}) {\n\tpanic(message)\n}", "func (mnu *MedicalNoteUpdate) SetHistory(h *History) *MedicalNoteUpdate {\n\treturn mnu.SetHistoryID(h.ID)\n}", "func (f *BatchFuture) Set(index uint64, err error) {\n\tf.index = index\n\tf.err = err\n\tclose(f.waitCh)\n}", "func (aa *Array) Set(idx int, node interface{}) error {\n\t// do not lock if not needed\n\tif idx < 0 || idx >= aa.length {\n\t\treturn fmt.Errorf(\"index %d is larger than array size (%d)\", idx, aa.length)\n\t}\n\n\taa.mutex.Lock()\n\taa.items[idx] = node\n\taa.mutex.Unlock()\n\treturn nil\n}", "func (i Index) Set(sourceID string, id int, table string, record *Record) {\n\tinfo := RecordInfo{\n\t\tID: id,\n\t\tTable: table,\n\t\tRecord: record,\n\t}\n\n\tsourceID = strings.ToLower(sourceID)\n\tsourceID = strings.TrimSpace(sourceID)\n\ti[sourceID] = info\n}", "func lset(writer *reply.Reply, command *resp.Command, store *storage.Storage) {\n if len(command.Key) < 1 || len(command.Args) < 2 {\n writer.SendError(fmt.Errorf(\"LSET expects 3 argument(s)\"))\n return\n }\n value := store.Get(command.Key)\n if value == nil {\n writer.SendNull()\n return\n }\n index, error := strconv.Atoi(command.Args[0])\n if error == nil {\n value.(*structs.List).Set(index, command.Args[1])\n writer.SendString(\"OK\")\n } else {\n writer.SendError(fmt.Errorf(\"Index is not integer\"))\n }\n}", "func (l *List) SetKey(key Item, to Item) (err error) {\n\tval, ok := castNumeric(key)\n\tif !ok {\n\t\treturn newError(ErrType, \"can only index a list with a numeric type\")\n\t}\n\n\tindex := int(val)\n\n\tif index < 0 || index >= len(l.value) {\n\t\treturn newError(ErrIndex, \"index out of bounds\")\n\t}\n\n\tl.value[index] = to\n\treturn nil\n}", "func (arr *ArrayList) Set(index uint32, newItem ItemType) {\n if index < arr.length {\n arr.data[index] = newItem\n } else {\n panic(\"out of bounds\")\n }\n}", "func set(l *foo, i byte, to *foo) {\n\tif i == Next {\n\t\tl.next = to\n\t\treturn\n\t}\n\tl.prev = to\n}", "func (access ObjectAccess) Set(row int, val interface{}) {\n access.rawData[access.indices[row]] = val\n}", "func (bitmap *bitmap) Set(index int) {\n\tbitmap.set(index, 1)\n}", "func (self *TileSprite) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func (q *Queue) SetIndexed(repoName string, opts IndexOptions, state indexState) {\n\tq.mu.Lock()\n\titem := q.get(repoName)\n\titem.setIndexState(state)\n\tif state != indexStateFail {\n\t\titem.indexed = reflect.DeepEqual(opts, item.opts)\n\t}\n\tif item.heapIdx >= 0 {\n\t\t// We only update the position in the queue, never add it.\n\t\theap.Fix(&q.pq, item.heapIdx)\n\t}\n\tq.mu.Unlock()\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 (d *Dao) AddHisIdxCache(c context.Context, tp int32, oid int64, month string, dates []string) (err error) {\n\tvar (\n\t\tconn = d.dmMC.Get(c)\n\t\tkey = keyHistoryIdx(tp, oid, month)\n\t)\n\tdefer conn.Close()\n\titem := &memcache.Item{\n\t\tKey: key,\n\t\tObject: dates,\n\t\tFlags: memcache.FlagJSON,\n\t\tExpiration: d.historyExpire,\n\t}\n\tif err = conn.Set(item); err != nil {\n\t\tlog.Error(\"conn.Set(%s) error(%v)\", key, err)\n\t}\n\treturn\n}", "func (buf *ListBuffer) Set(idx BufferIndex, item Item) (*error.Error) {\n\tinRange, initialized := buf.legalIndex(idx)\n\tif !inRange {\n\t\tdesc := fmt.Sprintf(\n\t\t\t\"idx, %d, is out of range for IndexBuffer of length %d.\",\n\t\t\tidx, len(buf.Buffer),\n\t\t)\n\t\treturn error.New(error.Value, desc)\n\t} else if !initialized {\n\t\tdesc := fmt.Sprintf(\n\t\t\t\"Item at idx, %d, has the Type value Uninitialized.\", idx,\n\t\t)\n\t\treturn error.New(error.Value, desc)\n\t}\n\n\tbuf.Buffer[idx].Item = item\n\treturn nil\n}", "func (self *Graphics) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func poolSetIndex(a interface{}, i int) {\n\ta.(*freeClientPoolEntry).index = i\n}", "func (self *SinglePad) SetIndexA(member int) {\n self.Object.Set(\"index\", member)\n}", "func (l *Linenoise) historyGet(idx int) string {\n\treturn l.history[len(l.history)-1-idx]\n}", "func (ll *LevelLedger) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error {\n\tk := prefixkey(scopeIDLifeline, ref.Key())\n\tencoded, err := index.EncodeClassLifeline(idx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ll.ldb.Put(k, encoded, nil)\n}", "func (d *Dao) HistoryIdxCache(c context.Context, tp int32, oid int64, month string) (dates []string, err error) {\n\tvar (\n\t\tconn = d.dmMC.Get(c)\n\t\tkey = keyHistoryIdx(tp, oid, month)\n\t)\n\tdefer conn.Close()\n\titem, err := conn.Get(key)\n\tif err != nil {\n\t\tif err == memcache.ErrNotFound {\n\t\t\terr = nil\n\t\t\tPromCacheMiss(\"dm_history_index\", 1)\n\t\t} else {\n\t\t\tlog.Error(\"mc.Get(%s) error(%v)\", key, err)\n\t\t}\n\t\treturn\n\t}\n\tPromCacheHit(\"dm_history_index\", 1)\n\tif err = conn.Scan(item, &dates); err != nil {\n\t\tlog.Error(\"conn.Scan(%+v) error(%v)\", item, err)\n\t}\n\treturn\n}", "func (this *Tuple) Set(n int, item interface{}) {\n\tthis.data[this.Offset(n)] = item\n}", "func (o *FakeObject) SetIndex(i int, value interface{}) {\n\treflect.ValueOf(o.Value).Index(i).Set(reflect.ValueOf(value))\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistory(h *History) *MedicalNoteUpdateOne {\n\treturn mnuo.SetHistoryID(h.ID)\n}", "func (ll *LevelLedger) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error {\n\tk := prefixkey(scopeIDLifeline, ref.Key())\n\tencoded, err := index.EncodeObjectLifeline(idx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ll.ldb.Put(k, encoded, nil)\n}", "func (h *VersionHistories) SetCurrentVersionHistoryIndex(\n\tindex int,\n) error {\n\n\tif index < 0 || index >= len(h.Histories) {\n\t\treturn &shared.BadRequestError{Message: \"invalid current branch index.\"}\n\t}\n\n\th.CurrentVersionHistoryIndex = index\n\treturn nil\n}", "func (t *FenwickTreeSimple) Set(index int, value int) {\n\tt.Update(index, value-t.Get(index))\n}", "func (r *ReleaseNotes) Set(prNumber int, note *ReleaseNote) {\n\tr.byPR[prNumber] = note\n\tr.history = append(r.history, prNumber)\n}", "func (_m *MockMutableSeriesIterators) SetAt(idx int, iter SeriesIterator) {\n\t_m.ctrl.Call(_m, \"SetAt\", idx, iter)\n}", "func (access StringAccess) Set(row int, val string) {\n access.rawData[access.indices[row]] = val\n}", "func (store *EntryStore) Set(id []byte, entry *hexalog.Entry) error {\n\tval, err := proto.Marshal(entry)\n\tif err == nil {\n\t\terr = store.db.Put(store.wo, id, val)\n\t}\n\treturn err\n}", "func (this *Value) SetIndex(index int, val interface{}) {\n\tif this.parsedType == ARRAY && index >= 0 {\n\t\tswitch parsedValue := this.parsedValue.(type) {\n\t\tcase []*Value:\n\t\t\tif index < len(parsedValue) {\n\t\t\t\t// if we've already parsed the object, store it there\n\t\t\t\tswitch val := val.(type) {\n\t\t\t\tcase *Value:\n\t\t\t\t\tparsedValue[index] = val\n\t\t\t\tdefault:\n\t\t\t\t\tparsedValue[index] = NewValue(val)\n\t\t\t\t}\n\t\t\t}\n\t\tcase nil:\n\t\t\t// if not store it in alias\n\t\t\tif this.alias == nil {\n\t\t\t\tthis.alias = make(map[string]*Value)\n\t\t\t}\n\t\t\tswitch val := val.(type) {\n\t\t\tcase *Value:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = val\n\t\t\tdefault:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = NewValue(val)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (nemo *NEMO) HSetIndexInfo(key []byte, index []byte) error {\n\tvar cErr *C.char\n\tC.nemo_HSetIndexInfo(nemo.c,\n\t\tgoByte2char(key), C.size_t(len(key)),\n\t\tgoByte2char(index), C.size_t(len(index)),\n\t\t&cErr,\n\t)\n\tif cErr != nil {\n\t\tres := errors.New(C.GoString(cErr))\n\t\tC.free(unsafe.Pointer(cErr))\n\t\treturn res\n\t}\n\treturn nil\n}", "func (s *MapStorage) Set(channel string, replayID int) {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\ts.store[channel] = replayID\n}", "func (m *BrowserSiteList) SetRevision(value *string)() {\n err := m.GetBackingStore().Set(\"revision\", value)\n if err != nil {\n panic(err)\n }\n}", "func (pool *FixedBytePool) Set(index int32, key []byte) error {\n\tif int(index) >= pool.maxElemNum {\n\t\treturn fmt.Errorf(\"index out of range %d %d\", index, pool.maxElemNum)\n\t}\n\n\tif len(key) != pool.elemSize {\n\t\treturn fmt.Errorf(\"length must be %d while %d\", pool.elemSize, len(key))\n\t}\n\tstart := int(index) * pool.elemSize\n\tcopy(pool.buf[start:], key)\n\n\treturn nil\n}", "func (as AccountStorage) SetBalanceHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64, history *BalanceHistory) sdk.Error {\n\tstore := ctx.KVStore(as.key)\n\thistoryBytes, err := as.cdc.MarshalJSON(*history)\n\tif err != nil {\n\t\treturn ErrFailedToMarshalBalanceHistory(err)\n\t}\n\tstore.Set(getBalanceHistoryKey(me, bucketSlot), historyBytes)\n\treturn nil\n}", "func (c *Cache) Set(key string, value interface{}) {\n\tif el, ok := c.cacheByKey[key]; ok {\n\t\tc.linkedList.MoveToFront(el)\n\t\tel.Value.(*entry).value = value\n\t\treturn\n\t}\n\n\tel := c.linkedList.PushFront(&entry{key: key, value: value})\n\tc.cacheByKey[key] = el\n\n\tif c.linkedList.Len() > c.maxEntries {\n\t\tc.cleanUp()\n\t}\n}", "func (as AccountStorage) SetRewardHistory(\n\tctx sdk.Context, me types.AccountKey, bucketSlot int64, history *RewardHistory) sdk.Error {\n\tstore := ctx.KVStore(as.key)\n\thistoryBytes, err := as.cdc.MarshalJSON(*history)\n\tif err != nil {\n\t\treturn ErrFailedToMarshalRewardHistory(err)\n\t}\n\tstore.Set(getRewardHistoryKey(me, bucketSlot), historyBytes)\n\treturn nil\n}", "func SetNumberEntries(nentries int) {\n\tC.hepevt_set_number_entries(C.int(nentries))\n}", "func (m *MerkleTree) Set(index []byte, key string, value []byte) error {\n\tcommitment, err := crypto.NewCommit([]byte(key), value)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttoAdd := userLeafNode{\n\t\tkey: key,\n\t\tvalue: append([]byte{}, value...), // make a copy of value\n\t\tindex: index,\n\t\tcommitment: commitment,\n\t}\n\tm.insertNode(index, &toAdd)\n\treturn nil\n}", "func HistoryRecord(env *Environment, command []string, date time.Time, code int) error {\n\tif env == nil {\n\t\treturn nil\n\t}\n\n\thistoryPath := env.LocalPath(HistoryDir)\n\tif utils.IsNotExist(historyPath) {\n\t\terr := utils.MkdirAll(historyPath, 0755)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\th := &historyRow{\n\t\tCommand: strings.Join(command, \" \"),\n\t\tDate: date,\n\t\tCode: code,\n\t}\n\n\treturn h.save(historyPath)\n}", "func (self *FileBaseDataStore) SetIndex(\n\tconfig_obj *api_proto.Config,\n\tindex_urn string,\n\tentity string,\n\tkeywords []string) error {\n\n\tfor _, keyword := range keywords {\n\t\tsubject := path.Join(index_urn, strings.ToLower(keyword), entity)\n\t\terr := writeContentToFile(config_obj, subject, []byte{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func Put(stub shim.ChaincodeStubInterface, object interface{}, indexStr string, id string) (error) {\n\t// append the id to the array of indexes\n\tlogger.Debugf(\"Storing %v %v\", indexStr, id)\n\n\t_, err := append_id(stub, indexStr, id, true)\n\n\tif err != nil { return errors.Wrap(err, \"Error appending new id \"+id+\" to \"+indexStr) }\n\tlogger.Debugf(\"Id %v appended to index: %v\", id, indexStr)\n\n\t// Store the object on the blockchain\n\titem, err := json.Marshal(object)\n\terr = stub.PutState(id, item)\n\tif err != nil { return errors.Wrap(err, \"Error putting data into ledger\") } // TODO: (determine) is there a rollback of the append_id if this happens?\n\n\tlogger.Infof(\"Created %v %v\", reflect.TypeOf(object), id)\n\n\treturn nil\n}", "func (h History) AttachIndexIfNoExists() {\n\tif len(h) != 0 && h[0].Index.Present() {\n\t\treturn\n\t}\n\tfor i := range h {\n\t\th[i].Index = IntOptional{i}\n\t}\n}", "func (ptr *terminalPrompter) SetHistory(history []string) {\n\tptr.State.ReadHistory(strings.NewReader(strings.Join(history, \"\\n\")))\n}", "func SetURL(index int, url string) (err error) {\n\tclient := getClient()\n\terr = client.Set(\"url\"+string(index), url, 0).Err()\n\treturn\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistoryID(id uuid.UUID) *MedicalNoteUpdateOne {\n\tif mnuo.history == nil {\n\t\tmnuo.history = make(map[uuid.UUID]struct{})\n\t}\n\tmnuo.history[id] = struct{}{}\n\treturn mnuo\n}", "func (h *History) Add(entry string) {\n\th.lock.Lock()\n\tdefer h.lock.Unlock()\n\n\tmax := cap(h.entries)\n\th.head = (h.head + 1) % max\n\th.entries[h.head] = entry\n\tif h.size < max {\n\t\th.size++\n\t}\n}", "func (h *History) GetLine(idx int) string {\n return h.histories[idx]\n}", "func (c *FakeZkConn) Set(path string, data []byte, version int32) (*zk.Stat, error) {\n\tc.history.addToHistory(\"Set\", path, data, version)\n\treturn nil, nil\n}", "func (c *LRU) Set(key string, value interface{}) {\n\tif e, ok := c.m[key]; ok {\n\t\tc.l.MoveToFront(e)\n\t\te.Value.(*lruEntry).v = value\n\t} else {\n\t\tc.m[key] = c.l.PushFront(&lruEntry{key, value})\n\t}\n}", "func (n *Node) setSuccIndex(node shared.NodeInfo, index int) {\n\tn.update.Lock()\n\n\tn.succList[index] = node\n\n\tn.update.Unlock()\n}", "func (mnu *MedicalNoteUpdate) SetHistoryID(id uuid.UUID) *MedicalNoteUpdate {\n\tif mnu.history == nil {\n\t\tmnu.history = make(map[uuid.UUID]struct{})\n\t}\n\tmnu.history[id] = struct{}{}\n\treturn mnu\n}", "func (item *queueItem) setIndexState(state indexState) {\n\tif state == item.indexState {\n\t\treturn\n\t}\n\tif item.indexState != \"\" {\n\t\tmetricIndexState.WithLabelValues(string(item.indexState)).Dec()\n\t}\n\titem.indexState = state\n\tif item.indexState != \"\" {\n\t\tmetricIndexState.WithLabelValues(string(item.indexState)).Inc()\n\t}\n}", "func (e *EntrySet) Set(key string, v string) {\n e.keys[key] = v\n}", "func (rf *Raft) logEntryAt(logIndex int) raftLogEntry {\n\tif logIndex < 0 {\n\t\tpanic(\"logIndex < 0\")\n\t}\n\treturn rf.logEntries[logIndex]\n}", "func settabss(L LuaState, k string, v string) {\n\tlua_pushstring(L, v)\n\tlua_setfield(L, -2, k)\n}", "func (self *TileSprite) SetChildIndexI(args ...interface{}) {\n self.Object.Call(\"setChildIndex\", args)\n}", "func (tl *TransactionList) Set(key, value string) {\n\tif tl.head != nil {\n\t\ttl.head.Set(key, value)\n\t} else {\n\t\tStorage[key] = value\n\t}\n}", "func (m watchMap) set(ino *inode, watch *watch) {\n\ti := m[ino.volume]\n\tif i == nil {\n\t\ti = make(indexMap)\n\t\tm[ino.volume] = i\n\t}\n\ti[ino.index] = watch\n}", "func (i *indexerGCV) Set(key gcvKey, val gcvVal) {\r\n\ti.Lock()\r\n\ti.idxr[key] = append(i.idxr[key], val)\r\n\ti.Unlock()\r\n}", "func (m *stateManager) Set(key types.StateEntryKey, stateEntry types.StateEntry) (err error) {\n\t// Check stateEntry is not a pointer.\n\tval := reflect.ValueOf(stateEntry)\n\tif val.Kind() == reflect.Ptr {\n\t\treturn errors.New(\"stateEntry must not be a pointer\")\n\t}\n\n\tif err = m.ensureLoaded(); err != nil {\n\t\treturn\n\t}\n\n\t// Update or add state entry.\n\tm.state[key] = stateEntry\n\tm.stateChanged = true\n\n\treturn\n}", "func (h *Hash) Store(key string, value int) {\n\n\t// For the specified key, identify what bucket in\n\t// the slice we need to store the key/value inside of.\n\tidx := h.hashKey(key)\n\n\t// Extract a copy of the bucket from the hash table.\n\tbucket := h.buckets[idx]\n\t// Iterate over the indexes for the specified bucket.\n\tfor idx := range bucket {\n\n\t\t// Compare the keys and if there is a match replace the\n\t\t// existing entry value for the new value.\n\t\tif bucket[idx].key == key {\n\t\t\tbucket[idx].value = value\n\t\t\treturn\n\t\t}\n\t}\n\n\t// This key does not exist, so add this new value.\n\th.buckets[idx] = append(bucket, entry{key, value})\n}", "func (e *HTMLApplet) TabIndex(v int) *HTMLApplet {\n\te.a[\"tabindex\"] = v\n\treturn e\n}", "func (a *BooleanArchive) SetValue(entryIndex int, value bool) {\n\tif entryIndex >= a.size {\n\t\toutOfBoundsError := errors.New(\"index out of range\")\n\t\tpanic(outOfBoundsError)\n\t}\n\ta.setValueUnchecked(entryIndex, value)\n\ta.resetCache()\n}", "func (s *Store) SetLastEvent(epoch idx.Epoch, from idx.ValidatorID, id hash.Event) {\n\tes := s.getEpochStore(epoch)\n\tif es == nil {\n\t\treturn\n\t}\n\n\tkey := from.Bytes()\n\tif err := es.table.Tips.Put(key, id.Bytes()); err != nil {\n\t\ts.Log.Crit(\"Failed to put key-value\", \"err\", err)\n\t}\n}", "func (p *Buffer) saveIndex(ptr unsafe.Pointer, idx uint) {\n\tif p.array_indexes == nil {\n\t\t// the 1st time we need to allocate\n\t\tp.array_indexes = make(map[unsafe.Pointer]uint)\n\t}\n\tp.array_indexes[ptr] = idx\n}", "func (h *Header) Set(key, value string) {\n\tif i, ok := h.index(key); ok {\n\t\th.slice[i+1] = value\n\t} else {\n\t\th.slice = append(h.slice, key, value)\n\t}\n}", "func (s *SGTree) Set(i int, e interface{}) {\n\ts.data[i] = e\n\ts.set(0, 0, len(s.data)-1, i, e)\n}", "func (m *SmsLogRow) SetId(value *string)() {\n err := m.GetBackingStore().Set(\"id\", value)\n if err != nil {\n panic(err)\n }\n}", "func (h *hashDisk) Set(value []byte, fileIndex, fileOffset uint32) error {\n\tif bytes.Equal(value, h.emptyValue) {\n\t\treturn ErrInvalidKey\n\t}\n\tif h.totalEntries >= h.MaxSize {\n\t\treturn ErrNoSpace\n\t}\n\tnewEntry := true\n\t// Compute hash\n\tslot := hyperloglog.MurmurBytes(value) % h.entries\n\toffset := slot * h.entrySize\n\tfor { // Try to find an empty slot\n\t\tslotValue := h.m[offset : offset+keySize]\n\t\tif bytes.Equal(slotValue, value) {\n\t\t\t// Found same key, override. We could just return instead but it was found in\n\t\t\t// benchmarks that it hardly change anything at all so it's better to be able to override\n\t\t\tnewEntry = false\n\t\t\tbreak\n\t\t}\n\t\tif bytes.Equal(slotValue, h.emptyValue) {\n\t\t\t// Found empty slot\n\t\t\tbreak\n\t\t}\n\t\tslot = (slot + 1) % h.entries\n\t\toffset = slot * h.entrySize\n\t}\n\t// Insert\n\tindexes := make([]byte, 4+4)\n\tencoding.PutUint32(indexes[0:4], fileIndex)\n\tencoding.PutUint32(indexes[4:8], fileOffset)\n\tcopy(h.m[offset:offset+keySize], value)\n\tcopy(h.m[offset+keySize:offset+keySize+8], indexes)\n\tif newEntry {\n\t\th.totalEntries++\n\t}\n\treturn nil\n}", "func (spriteBatch *SpriteBatch) Set(index int, args ...float32) error {\n\treturn spriteBatch.addv(spriteBatch.texture.getVerticies(), generateModelMatFromArgs(args), index)\n}", "func (r *SlidingWindow) Set(index int, value interface{}) bool {\n\tindex -= r.base\n\tif index < 0 || index >= r.Capacity() {return false}\n\tindex = r.normalize(index + r.start)\n\tr.values[index].value = value\n\tif !r.values[index].present {\n\t\tr.values[index].present = true\n\t\tr.count++\n\t}\n\treturn true\n}", "func SetHistoryPath(fp string) {\n\tins := getInstance()\n\tcfg := ins.Config.Clone()\n\tcfg.HistoryFile = fp\n\tins.SetConfig(cfg)\n}", "func (e *ObservableEditableBuffer) Set(hash []byte) {\n\te.details.Hash.Set(hash)\n}", "func (u *LRU) Set(key string, value string) {\n\tu.mu.Lock()\n\tdefer u.mu.Unlock()\n\n\t// no eviction required?\n\tif len(u.entries) < u.max {\n\t\tu.entries[key] = u.last.PushBack(kvpair{key, value})\n\t\treturn\n\t}\n\n\t// last touched should be at the front of the list\n\told := u.last.Front()\n\tdelete(u.entries, old.Value.(kvpair).Key)\n\tu.last.Remove(old)\n\tu.entries[key] = u.last.PushBack(kvpair{key, value})\n\n}", "func SetPosition(index int, x, y, z, t float64) {\n\tC.hepevt_set_position(\n\t\tC.int(index+1),\n\t\tC.double(x), C.double(y),\n\t\tC.double(z), C.double(t))\n}", "func (c *Chip8) SetIndex() {\n\tc.index = c.inst & 0x0FFF\n}", "func (sr *ScenarioResults) initHistIdx(sc *StockScenario) {\n\tsr.StockHistIdx = make([]int, len(sc.Stocks))\n\n\tsr.Shares = make([]float64, len(sc.Stocks))\n\n\tfor i, stock := range sc.Stocks {\n\t\tsr.StockHistIdx[i] = stock.getHistIdx(sr.Date, 0)\n\t}\n}", "func SetItem(slice []int, index, value int) []int {\n\tif checkOutOfBounds(index, len(slice)) {\n\t\treturn append(slice, value)\n\t}\n\tslice[index] = value\n\treturn slice\n}", "func (ms Float64Slice) SetAt(i int, val float64) {\n\t(*ms.getOrig())[i] = val\n}", "func store(ptr **int, value *int) {\n\t*ptr = value\n\t// @callers callers-store \"^\"\n}", "func (c Cache) SetNumberDataPoint(identifier string, point *pmetric.NumberDataPoint) {\n\tc.numberCache[identifier] = usedNumberPoint{point, true}\n}", "func (w *Writer) Set(key, value []byte, o *db.WriteOptions) error {\n\tif w.err != nil {\n\t\treturn w.err\n\t}\n\tif w.cmp.Compare(w.prevKey, key) >= 0 {\n\t\tw.err = fmt.Errorf(\"leveldb/table: Set called in non-increasing key order: %q, %q\", w.prevKey, key)\n\t\treturn w.err\n\t}\n\tw.flushPendingBH(key)\n\tw.append(key, value, w.nEntries%w.blockRestartInterval == 0)\n\t// If the estimated block size is sufficiently large, finish the current block.\n\tif w.buf.Len()+4*(len(w.restarts)+1) >= w.blockSize {\n\t\tbh, err := w.finishBlock()\n\t\tif err != nil {\n\t\t\tw.err = err\n\t\t\treturn w.err\n\t\t}\n\t\tw.pendingBH = bh\n\t}\n\treturn nil\n}", "func (delegateObject *delegateObject) SetState(db Database, key, value common.Hash) {\n\tdelegateObject.db.journal = append(delegateObject.db.journal, storageChange{\n\t\taccount: &delegateObject.address,\n\t\tkey: key,\n\t\tprevalue: delegateObject.GetState(db, key),\n\t})\n\tdelegateObject.setState(key, value)\n}" ]
[ "0.6136136", "0.60229445", "0.59669566", "0.58444846", "0.58164537", "0.5784874", "0.5704292", "0.56925535", "0.56398296", "0.5635676", "0.5568834", "0.5554014", "0.5502249", "0.54614896", "0.5451086", "0.5443747", "0.544068", "0.5435106", "0.5402735", "0.53784984", "0.5377253", "0.53766614", "0.53668386", "0.53492445", "0.5295715", "0.5292437", "0.52753544", "0.52744585", "0.5257981", "0.52532244", "0.5237884", "0.5224205", "0.5218373", "0.5214753", "0.52084243", "0.520103", "0.5196871", "0.5193385", "0.5186417", "0.51854146", "0.51688653", "0.51507014", "0.5141966", "0.51283205", "0.5120688", "0.5103255", "0.5097961", "0.509622", "0.50873834", "0.5068957", "0.5066017", "0.50575984", "0.5038738", "0.502664", "0.5022695", "0.501859", "0.5010309", "0.5006314", "0.4980812", "0.4963955", "0.49581957", "0.49443322", "0.49419808", "0.4917863", "0.49143934", "0.49046624", "0.4898324", "0.48895636", "0.48827437", "0.48776877", "0.4877435", "0.4872951", "0.487209", "0.48712203", "0.48691425", "0.48627198", "0.4860208", "0.4851684", "0.4841588", "0.48394254", "0.4834216", "0.48327246", "0.48326722", "0.48234105", "0.48145208", "0.48133734", "0.4807695", "0.48064485", "0.48021862", "0.47997347", "0.47988552", "0.47953603", "0.47929123", "0.47861078", "0.47848207", "0.4783847", "0.47806743", "0.47708175", "0.47697333", "0.4769466" ]
0.6641271
0
Get a history entry by index number.
func (l *Linenoise) historyGet(idx int) string { return l.history[len(l.history)-1-idx] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l *LevelDBLog) Get(index int) (*Entry, error) {\n\tl.RLock()\n\tdefer l.RUnlock()\n\n\tif l.db == nil {\n\t\treturn nil, errors.New(\"log database has been closed \")\n\t}\n\n\tdata, err := l.db.Get(l.makeKey(index), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tentry := new(Entry)\n\tif err = entry.Load(data); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif entry.Index != index {\n\t\treturn nil, errors.New(\"log is not consistent with entries\")\n\t}\n\treturn entry, nil\n}", "func (l *log) get(index int) *Entry {\n\tif index < len(l.entries) {\n\t\treturn l.entries[index]\n\t}\n\treturn nil\n}", "func (l *InMemoryLog) Get(index int) (*Entry, error) {\n\tl.RLock()\n\tdefer l.RUnlock()\n\n\te := l.get(index)\n\tif e == nil {\n\t\treturn nil, fmt.Errorf(\"no entry at index %d\", index)\n\t}\n\n\tif e.Index != index {\n\t\treturn nil, errors.New(\"log is not consistent with entries\")\n\t}\n\treturn e, nil\n}", "func (h *History) GetLine(idx int) string {\n return h.histories[idx]\n}", "func (m *Memory) GetEntry(index uint64) (*commonpb.Entry, error) {\n\tentry, ok := m.log[index]\n\n\tif !ok {\n\t\treturn nil, ErrKeyNotFound\n\t}\n\n\treturn entry, nil\n}", "func (l *FileLog) Get(index int) (*Entry, error) {\n\tl.RLock()\n\tdefer l.RUnlock()\n\n\te := l.get(index)\n\tif e == nil {\n\t\treturn nil, fmt.Errorf(\"no entry at index %d\", index)\n\t}\n\n\tif e.Index != index {\n\t\treturn nil, errors.New(\"log is not consistent with entries\")\n\t}\n\treturn e, nil\n}", "func (h *History) Get(num int) []string {\n\th.lock.Lock()\n\tdefer h.lock.Unlock()\n\n\tmax := cap(h.entries)\n\tif num > h.size {\n\t\tnum = h.size\n\t}\n\n\tr := make([]string, num)\n\tfor i := 0; i < num; i++ {\n\t\tidx := (h.head - i) % max\n\t\tif idx < 0 {\n\t\t\tidx += max\n\t\t}\n\t\tr[num-i-1] = h.entries[idx]\n\t}\n\n\treturn r\n}", "func (s *storage) getEntry(index uint64, e *entry) error {\n\tb, err := s.log.Get(index)\n\tif err == log.ErrNotFound {\n\t\treturn err\n\t} else if err != nil {\n\t\tpanic(opError(err, \"Log.Get(%d)\", index))\n\t}\n\tif err = e.decode(bytes.NewReader(b)); err != nil {\n\t\tpanic(opError(err, \"log.Get(%d).decode()\", index))\n\t}\n\tif e.index != index {\n\t\tpanic(opError(fmt.Errorf(\"got %d, want %d\", e.index, index), \"log.Get(%d).index: \", index))\n\t}\n\treturn nil\n}", "func (d *Dao) HistoryIdxCache(c context.Context, tp int32, oid int64, month string) (dates []string, err error) {\n\tvar (\n\t\tconn = d.dmMC.Get(c)\n\t\tkey = keyHistoryIdx(tp, oid, month)\n\t)\n\tdefer conn.Close()\n\titem, err := conn.Get(key)\n\tif err != nil {\n\t\tif err == memcache.ErrNotFound {\n\t\t\terr = nil\n\t\t\tPromCacheMiss(\"dm_history_index\", 1)\n\t\t} else {\n\t\t\tlog.Error(\"mc.Get(%s) error(%v)\", key, err)\n\t\t}\n\t\treturn\n\t}\n\tPromCacheHit(\"dm_history_index\", 1)\n\tif err = conn.Scan(item, &dates); err != nil {\n\t\tlog.Error(\"conn.Scan(%+v) error(%v)\", item, err)\n\t}\n\treturn\n}", "func (rf *Raft) logEntryAt(logIndex int) raftLogEntry {\n\tif logIndex < 0 {\n\t\tpanic(\"logIndex < 0\")\n\t}\n\treturn rf.logEntries[logIndex]\n}", "func (n *Node) GetLog(index uint64) *LogEntry {\n\treturn n.StableStore.GetLog(index)\n}", "func (w *XPubWallet) GetEntryAt(i int) Entry {\n\treturn w.Entries[i]\n}", "func (ps *PrimeStore) GetByIndex(nth uint64) (n uint64) {\n\tdefer Tracer(NewTrace(\"GetByIndex\"))\n\n\tn = 0\n\tif nth < ps.base || nth >= (ps.base+ps.count) {\n\t\tlog.Print(\"out of range.\", nth, \" \", ps)\n\t\treturn\n\t}\n\n\tn = ps.index[nth-ps.base]\n\treturn\n}", "func (h *VersionHistories) GetVersionHistory(\n\tbranchIndex int,\n) (*VersionHistory, error) {\n\n\tif branchIndex < 0 || branchIndex > len(h.Histories) {\n\t\treturn nil, &shared.BadRequestError{Message: \"invalid branch index.\"}\n\t}\n\n\treturn h.Histories[branchIndex], nil\n}", "func (stub *MockStub) GetHistoryForKey(key string) (shim.HistoryQueryIteratorInterface, error) {\n\treturn nil, errors.New(\"not implemented\")\n}", "func (r *raftLog) GetLog(idx uint64, log *raft.Log) error {\n\tif r.hasCache {\n\t\tr.RLock()\n\t\tcached := r.cache[idx%r.cacheSize]\n\t\tr.RUnlock()\n\t\tif cached != nil && cached.Index == idx {\n\t\t\t*log = *cached\n\t\t\treturn nil\n\t\t}\n\t}\n\ttx, err := r.conn.Begin(false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar key [8]byte\n\tbinary.BigEndian.PutUint64(key[:], idx)\n\tbucket := tx.Bucket(logsBucket)\n\tval := bucket.Get(key[:])\n\tif val == nil {\n\t\terr = raft.ErrLogNotFound\n\t} else {\n\t\terr = r.decodeRaftLog(val, log)\n\t}\n\ttx.Rollback()\n\treturn err\n}", "func (s *StashList) getStashAtIdx(ctx context.Context, idx int) (hash.Hash, error) {\n\tamCount, err := s.am.Count()\n\tif err != nil {\n\t\treturn hash.Hash{}, err\n\t}\n\tif amCount <= idx {\n\t\treturn hash.Hash{}, fmt.Errorf(\"fatal: log for 'stash' only has %v entries\", amCount)\n\t}\n\n\tstash, err := getNthStash(ctx, s.am, amCount, idx)\n\tif err != nil {\n\t\treturn hash.Hash{}, err\n\t}\n\n\treturn stash.addr, nil\n}", "func GetHistory(db *gorm.DB, id int) History {\n\tvar history History\n\tdb.First(&history, id)\n\treturn history\n}", "func GetHistoryById(historyId int , o orm.Ormer) (*models.History){\n\thistory :=models.History{Id: historyId}\n\terr:= o.Read(&history)\n\tif err == orm.ErrNoRows {\n\t\tfmt.Println(\"error: can`t find the battle\")\n\t} else if err == orm.ErrMissPK {\n\t\tfmt.Println(\"error: can`t find the primary key\")\n\t} else {\n\t\tfmt.Println(\"query finished\")\n\t}\n\treturn &history\n}", "func (i *InmemStore) GetLog(index uint64, log *Log) error {\n\ti.l.RLock()\n\tdefer i.l.RUnlock()\n\tl, ok := i.logs[index]\n\tif !ok {\n\t\treturn ErrLogNotFound\n\t}\n\t*log = *l\n\treturn nil\n}", "func (q *CouchHistoryDBQueryExecutor) GetHistoryForKey(namespace string, key string) (commonledger.ResultsIterator, error) {\n\tlogger.Debug(\"Entered GetHistoryForKey\")\n\n\tif ledgerconfig.IsHistoryDBEnabled() == false {\n\t\treturn nil, errors.New(\"History tracking not enabled - historyDatabase is false\")\n\t}\n\n\tstartKey := constructStartKey(key)\n\tendKey := constructEndKey(key)\n\n\tlogger.Debugf(\"[GetHistoryForKey] startKey=%s, endKey=%s\", startKey, endKey)\n\n\t// range scan to find any history records starting with namespace~key\n\tcouchdbScanner, err := q.historyDB.getCouchdbRangeScanIterator(namespace, startKey, endKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlogger.Debug(\"Existing GetHistoryForKey\")\n\treturn newHistoryScanner(namespace, key, *couchdbScanner, q.blockStore, emptyBookmark, historyForKey), nil\n}", "func (self *OCSPResponder) getIndexEntry(s *big.Int) (*IndexEntry, error) {\n\tlog.Println(fmt.Sprintf(\"Looking for serial 0x%x\", s))\n\tif err := self.parseIndex(); err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, ent := range self.IndexEntries {\n\t\tif ent.Serial.Cmp(s) == 0 {\n\t\t\treturn &ent, nil\n\t\t}\n\t}\n\treturn nil, errors.New(fmt.Sprintf(\"Serial 0x%x not found\", s))\n}", "func (l *DolceLog) GetFromIndex(index int) ([]string, error) {\n\tl.logMutex.Lock()\n\tdefer l.logMutex.Unlock()\n\n\tvar result = make([]string, 0)\n\ti := 0\n\n\tf, err := os.Open(dlog.filename)\n\tdefer f.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\n\tscanner := bufio.NewScanner(f)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tsepIndex := strings.Index(line, \" \")\n\t\tid, err := strconv.Atoi(line[:sepIndex])\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Index retrieval error.\")\n\t\t}\n\n\t\tif index <= id {\n\t\t\tresult = append(result, line)\n\t\t}\n\t\ti++\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn result, nil\n}", "func (c *Client) GetHistory(project string) (Events, error) {\n\tu := make(map[string]string)\n\tu[\"project\"] = project\n\tvar data Events\n\tvar res []byte\n\tif err := c.Get(&res, \"history\", u); err != nil {\n\t\treturn data, err\n\t}\n\txmlErr := xml.Unmarshal(res, &data)\n\treturn data, xmlErr\n}", "func (rb *RingBuffer) Get(index int) (ans stats.Record) {\n\trb.lock.RLock()\n\tdefer rb.lock.RUnlock()\n\tif index < 0 {\n\t\tindex = len(rb.data) + index\n\t}\n\treturn rb.data[(rb.seq+uint64(index))%uint64(len(rb.data))]\n}", "func (entity *MilitaryHistory) Get(context *pg.DB, account int64) (int, error) {\n\tentity.AccountID = account\n\n\toptions := &orm.CreateTableOptions{\n\t\tTemp: false,\n\t\tIfNotExists: true,\n\t}\n\n\tvar err error\n\tif err = context.CreateTable(&MilitaryHistory{}, options); err != nil {\n\t\treturn entity.ID, err\n\t}\n\n\tif entity.ID != 0 {\n\t\terr = context.Select(entity)\n\t}\n\n\tif entity.HasServedID != 0 {\n\t\tif _, err := entity.HasServed.Get(context, account); err != nil {\n\t\t\treturn entity.ID, err\n\t\t}\n\t}\n\n\tif entity.ListID != 0 {\n\t\tif _, err := entity.List.Get(context, account); err != nil {\n\t\t\treturn entity.ID, err\n\t\t}\n\t}\n\n\treturn entity.ID, err\n}", "func get_history(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start getHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tresults, err := ConvHistoryResult(resultsIterator)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tfmt.Println(\"end getHistory\")\n\n\treturn shim.Success(results)\n}", "func (b *BadgerStore) GetLog(index uint64, log *raft.Log) error {\n\terr := b.conn.View(func(txn *badger.Txn) error {\n\t\titem, err := txn.Get(uint64ToBytes(index))\n\t\tif err != nil {\n\t\t\tswitch err {\n\t\t\tcase badger.ErrKeyNotFound:\n\t\t\t\treturn raft.ErrLogNotFound\n\t\t\tdefault:\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tval, err := item.Value()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn decodeMsgPack(val, log)\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s ConsoleIndexStore) GetIndex(string) (i Index, e error) {\n\treturn IndexFromReader(os.Stdin)\n}", "func (r *raftLog) getIndex(first bool) (uint64, error) {\n\ttx, err := r.conn.Begin(false)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tvar (\n\t\tkey []byte\n\t\tidx uint64\n\t)\n\tcurs := tx.Bucket(logsBucket).Cursor()\n\tif first {\n\t\tkey, _ = curs.First()\n\t} else {\n\t\tkey, _ = curs.Last()\n\t}\n\tif key != nil {\n\t\tidx = binary.BigEndian.Uint64(key)\n\t}\n\ttx.Rollback()\n\treturn idx, nil\n}", "func (l *Linenoise) historyPop(idx int) string {\n\tif idx < 0 {\n\t\t// pop the last entry\n\t\tidx = len(l.history) - 1\n\t}\n\tif idx >= 0 && idx < len(l.history) {\n\t\ts := l.history[idx]\n\t\tl.history = append(l.history[:idx], l.history[idx+1:]...)\n\t\treturn s\n\t}\n\t// nothing to pop\n\treturn \"\"\n}", "func (b *raftBadger) GetLog(idx uint64, log *raft.Log) error {\n\n\treturn b.gs.GetStore().(*badger.DB).View(func(txn *badger.Txn) error {\n\t\titem, _ := txn.Get(logKeyOf(idx))\n\t\tif item == nil {\n\t\t\tb.logger.Error(\"GetLog\", \"index\", hclog.Fmt(\"%v\", idx))\n\t\t\treturn raft.ErrLogNotFound\n\t\t}\n\t\terr := item.Value(func(val []byte) error {\n\t\t\tbuf := bytes.NewBuffer(val)\n\t\t\tdec := gob.NewDecoder(buf)\n\t\t\treturn dec.Decode(&log)\n\t\t})\n\t\treturn err\n\t})\n}", "func (b *baseKVStoreBatch) Entry(index int) (*writeInfo, error) {\n\tif index < 0 || index >= len(b.writeQueue) {\n\t\treturn nil, errors.Wrap(ErrInvalidDB, \"index out of range\")\n\t}\n\treturn &b.writeQueue[index], nil\n}", "func (s *transactionStore) GetByIndex(ctx context.Context, index configapi.Index) (*configapi.Transaction, error) {\n\t// If the transaction is not already in the cache, get it from the underlying primitive.\n\tentry, err := s.transactions.GetIndex(ctx, indexedmap.Index(index))\n\tif err != nil {\n\t\treturn nil, errors.FromAtomix(err)\n\t}\n\ttransaction := entry.Value\n\ttransaction.Index = configapi.Index(entry.Index)\n\ttransaction.Version = uint64(entry.Version)\n\treturn transaction, nil\n}", "func (s *SmartContract) getHistoryForAuditLogKey(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\n\tif len(args) < 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments.\")\n\t}\n\n\tresultsIterator, err := APIstub.GetHistoryForKey(args[0])\n\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\n\tdefer resultsIterator.Close()\n\n\tbuffer := buildTimeLine(resultsIterator)\n\n\tfmt.Printf(\"- getHistoryForAuditKey returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n\n}", "func (s *dataSet) get(i int) entry {\n\tv := s.e(i).value(s.buf)\n\treturn entry{v.bytes(), v.ord()}\n}", "func (lo *LuaObject) Get(idx interface{}) interface{} {\n L := lo.L\n lo.Push() // the table\n GoToLua(L, nil, valueOf(idx))\n L.GetTable(-2)\n val := LuaToGo(L, nil, -1)\n L.Pop(1) // the table\n return val\n}", "func (cache *Cache) GetAt(seqno uint16, index uint16, result []byte) uint16 {\n\tcache.mu.Lock()\n\tdefer cache.mu.Unlock()\n\n\tif int(index) >= len(cache.entries) {\n\t\treturn 0\n\t}\n\tif cache.entries[index].seqno != seqno {\n\t\treturn 0\n\t}\n\treturn uint16(copy(\n\t\tresult[:cache.entries[index].length()],\n\t\tcache.entries[index].buf[:]),\n\t)\n}", "func (s *Stack) Get(index int) (interface{}, error) {\n\tif index < 0 || index >= s.count {\n\t\treturn nil, fmt.Errorf(\"Requested index %d outside stack, length %d\", index, s.count)\n\t}\n\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\n\tn := s.top\n\tfor i := 1; i < s.count-index; i++ {\n\t\tn = n.next\n\t}\n\n\treturn n.data, nil\n}", "func (d *Dao) HistoryView(c context.Context, mid, hid int64, ip string) (history *archive.ArcHistory, err error) {\n\tparams := url.Values{}\n\tparams.Set(\"hid\", strconv.FormatInt(hid, 10))\n\tparams.Set(\"mid\", strconv.FormatInt(mid, 10))\n\tvar res struct {\n\t\tCode int `json:\"code\"`\n\t\tData *archive.ArcHistory `json:\"data\"`\n\t}\n\tif err = d.client.Get(c, d.hView, ip, params, &res); err != nil {\n\t\tlog.Error(\"archive.HistoryView url(%s) mid(%d) error(%v)\", d.hView+\"?\"+params.Encode(), mid, err)\n\t\terr = ecode.CreativeArchiveAPIErr\n\t\treturn\n\t}\n\tif res.Code != 0 {\n\t\tlog.Error(\"archive.HistoryView url(%s) mid(%d) res(%v)\", d.hView+\"?\"+params.Encode(), mid, res)\n\t\terr = ecode.CreativeArchiveAPIErr\n\t\treturn\n\t}\n\thistory = res.Data\n\treturn\n}", "func (b *baseKVStoreBatch) Entry(index int) (*WriteInfo, error) {\n\tif index < 0 || index >= len(b.writeQueue) {\n\t\treturn nil, errors.Wrap(ErrOutOfBound, \"index out of range\")\n\t}\n\treturn b.writeQueue[index], nil\n}", "func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error) {\n\thlist := make([]proto.Message, 0)\n\tif err := store.ReadHistory(datatype, realm, user, id, &hlist); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// TODO: perhaps this should be the empty list?\n\t\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"no config history available\")\n\t\t}\n\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"service storage unavailable: %v, retry later\", err)\n\t}\n\the := make([]*cpb.HistoryEntry, len(hlist))\n\tvar ok bool\n\tfor i, e := range hlist {\n\t\the[i], ok = e.(*cpb.HistoryEntry)\n\t\tif !ok {\n\t\t\treturn nil, http.StatusInternalServerError, fmt.Errorf(\"cannot load history entry %d\", i)\n\t\t}\n\t}\n\thistory := &cpb.History{\n\t\tHistory: he,\n\t}\n\tpageToken := r.URL.Query().Get(\"pageToken\")\n\tstart, err := strconv.ParseInt(pageToken, 10, 64)\n\tif err != nil {\n\t\tstart = 0\n\t}\n\n\tpageSize := r.URL.Query().Get(\"pageSize\")\n\tsize, err := strconv.ParseInt(pageSize, 10, 64)\n\tif err != nil || size < 1 {\n\t\tsize = 50\n\t}\n\tif size > 1000 {\n\t\tsize = 1000\n\t}\n\t// Reverse order\n\ta := history.History\n\tfor i := len(a)/2 - 1; i >= 0; i-- {\n\t\topp := len(a) - 1 - i\n\t\ta[i], a[opp] = a[opp], a[i]\n\t}\n\n\tfor i, entry := range history.History {\n\t\tif entry.Revision <= start {\n\t\t\thistory.History = history.History[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(history.History) > int(size) {\n\t\thistory.NextPageToken = fmt.Sprintf(\"%d\", history.History[size].Revision)\n\t\thistory.History = history.History[:size]\n\t}\n\treturn history, http.StatusOK, nil\n}", "func (list *RecentlyUsedList) Get(index uint) string {\n return list.items[index]\n}", "func (commit *Commit) GetByIndex(index int) *Vote {\n\treturn commit.Precommits[index]\n}", "func (d *V8interceptor) GetByindex(index int32, object *V8value, retval **V8value, exception *string) int32 {\n\tretval_ := (*retval).toNative()\n\texception_ := C.cef_string_userfree_alloc()\n\tsetCEFStr(*exception, exception_)\n\tdefer func() {\n\t\t*exception = cefstrToString(exception_)\n\t\tC.cef_string_userfree_free(exception_)\n\t}()\n\treturn int32(C.gocef_v8interceptor_get_byindex(d.toNative(), C.int(index), object.toNative(), &retval_, (*C.cef_string_t)(exception_), d.get_byindex))\n}", "func (d *Dao) History(c context.Context, mid int64) (h *model.UserEventHistory, err error) {\n\tvar (\n\t\trow *sql.Row\n\t)\n\th = &model.UserEventHistory{}\n\trow = d.db.QueryRow(c, fmt.Sprintf(_getLastHistorySQL, hitHistory(mid)), mid)\n\tif err = row.Scan(&h.ID, &h.Mid, &h.EventID, &h.Score, &h.BaseScore, &h.EventScore, &h.Remark, &h.Reason, &h.FactorVal, &h.CTime); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\terr = nil\n\t\t\th = nil\n\t\t\treturn\n\t\t}\n\t\tlog.Error(\"History row.Scan(%d) error(%v)\", mid, err)\n\t}\n\treturn\n}", "func (entries Entries) get(key uint64) Entry {\n\ti := entries.search(key)\n\tif i == len(entries) {\n\t\treturn nil\n\t}\n\n\tif entries[i].Key() == key {\n\t\treturn entries[i]\n\t}\n\n\treturn nil\n}", "func (ls *LevelDBStore) GetLog(index uint64, log *raft.Log) error {\n\tls.rwMtx.Lock()\n\tdefer ls.rwMtx.Unlock()\n\tval, err := ls.ldb.Get(uint64ToBytes(index), nil)\n\tif err != nil {\n\t\tif err == leveldb.ErrNotFound {\n\t\t\treturn raft.ErrLogNotFound\n\t\t}\n\t\treturn err\n\t}\n\treturn decodeMsgPack(val, log)\n}", "func (sa *SnapshotArray) Get(index int, snap int) int {\n\tfor id := snap; id >= 0; id-- {\n\t\thistory := sa.snaps[id]\n\t\tif t, ok := history[index]; ok {\n\t\t\treturn t\n\t\t}\n\t}\n\treturn 0 //default value\n}", "func (h *VersionHistories) GetCurrentVersionHistoryIndex() int {\n\treturn h.CurrentVersionHistoryIndex\n}", "func (t *FenwickTreeSimple) Get(index int) int {\n\treturn t.QueryRange(index, index)\n}", "func (c *EatinghistoryClient) Get(ctx context.Context, id int) (*Eatinghistory, error) {\n\treturn c.Query().Where(eatinghistory.ID(id)).Only(ctx)\n}", "func (h *History) Last() *Entry {\n\treturn &(*h)[len(*h)-1]\n}", "func (m NumSeriesDistribution) Get(index int) *NumSeries {\n\tif index > -1 {\n\t\tif s, ok := m[index]; ok {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn nil\n}", "func (g *Group) Entry(i int) *Entry {\n\treturn g.entries[i]\n}", "func (l *Int32) Get(index int) int32 {\n\treturn l.values[index]\n}", "func (commit *Commit) GetByIndex(valIdx int32) *Vote {\n\treturn commit.GetVote(valIdx)\n}", "func (s *IdeaStorage) GetByNumber(number int) (*models.Idea, error) {\n\tfor _, idea := range s.ideas {\n\t\tif idea.Number == number {\n\t\t\treturn idea, nil\n\t\t}\n\t}\n\treturn nil, app.ErrNotFound\n}", "func (fdb *fdbSlice) getBackIndexEntry(docid []byte, workerId int) (Key, error) {\n\n\tcommon.Tracef(\"ForestDBSlice::getBackIndexEntry \\n\\tSliceId %v IndexInstId %v Get BackIndex Key - %s\",\n\t\tfdb.id, fdb.idxInstId, docid)\n\n\tvar k Key\n\tvar kbyte []byte\n\tvar err error\n\n\tkbyte, err = fdb.back[workerId].GetKV([]byte(docid))\n\n\t//forestdb reports get in a non-existent key as an\n\t//error, skip that\n\tif err != nil && err.Error() != \"key not found\" {\n\t\treturn k, err\n\t}\n\n\tk, err = NewKeyFromEncodedBytes(kbyte)\n\n\treturn k, err\n}", "func (f *ResolverGetIndexByIDFunc) History() []ResolverGetIndexByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverGetIndexByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (keyDB *KeyDB) GetHashChainEntry(domain string, position uint64) (string, error) {\n\tvar entry string\n\tdmn := identity.MapDomain(domain)\n\terr := keyDB.getHashChainEntryQuery.QueryRow(dmn, position).Scan(&entry)\n\tswitch {\n\tcase err != nil:\n\t\treturn \"\", log.Error(err)\n\tdefault:\n\t\treturn entry, nil\n\t}\n}", "func GetStashAtIdx(ctx context.Context, ns tree.NodeStore, val types.Value, idx int) (hash.Hash, error) {\n\tstashList, err := getExistingStashList(ctx, ns, val)\n\tif err != nil {\n\t\treturn hash.Hash{}, err\n\t}\n\n\treturn stashList.getStashAtIdx(ctx, idx)\n}", "func (s *HeroesServiceChaincode) gethistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 3\")\n\t}\n\n\tvegKey := args[1]\n\tfmt.Printf(\"##### start History of Record: %s\\n\", vegKey)\n\n\tresultsIterator, err := stub.GetHistoryForKey(vegKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForVegetable returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (hat *HashedArrayTree) Get(index int) (interface{}, error) {\n\tif !hat.validIndex(index) {\n\t\treturn nil, ErrIndexOutOfRange\n\t}\n\tti, li := hat.topIndex(index), hat.leafIndex(index)\n\treturn hat.top[ti][li], nil\n}", "func GetHistory(s *aklib.DBConfig) ([]*History, error) {\n\tvar hist []*History\n\treturn hist, s.DB.View(func(txn *badger.Txn) error {\n\t\terr := db.Get(txn, nil, &hist, db.HeaderWalletHistory)\n\t\tif err == badger.ErrKeyNotFound {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t})\n}", "func (store *EntryStore) Get(id []byte) (*hexalog.Entry, error) {\n\tsl, err := store.db.Get(store.ro, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer sl.Free()\n\n\tdata := sl.Data()\n\tif data == nil {\n\t\treturn nil, hexatype.ErrEntryNotFound\n\t}\n\n\tvar entry hexalog.Entry\n\terr = proto.Unmarshal(data, &entry)\n\treturn &entry, err\n}", "func (s *backupEntryLister) Get(name string) (*v1alpha1.BackupEntry, error) {\n\tobj, exists, err := s.indexer.GetByKey(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !exists {\n\t\treturn nil, errors.NewNotFound(v1alpha1.Resource(\"backupentry\"), name)\n\t}\n\treturn obj.(*v1alpha1.BackupEntry), nil\n}", "func (ms *InMemoryStore) getBasketIndex(\n ctx context.Context,\n id int64,\n) (*Basket, int, *Error) {\n if len(ms.baskets) <= 0 {\n return nil, -1, &Error{\n Code: http.StatusNotFound,\n Message: \"There are no baskets\",\n }\n }\n\n for idx, value := range ms.baskets {\n if value.ID == id {\n return value, idx, nil\n }\n }\n\n return nil, -1, &Error{\n Code: http.StatusNotFound,\n Message: \"Basket not found\",\n }\n}", "func (this *MyLinkedList) Get(index int) int {\n\tif index < 0 || index > this.size-1 {\n\t\treturn -1\n\t}\n\treturn this.listMap[index].Val\n}", "func (f *AutoIndexingServiceGetIndexByIDFunc) History() []AutoIndexingServiceGetIndexByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetIndexByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (tb *tableManager) getEntry(keyIn uint64) (*tableEntry, error) {\n\tkey, ok := CleanKey(keyIn)\n\tif !ok {\n\t\tlog.Println(\"Key out of range.\")\n\t\treturn nil, errors.New(\"Key out of range.\")\n\t}\n\tentry, ok := tb.data[key]\n\tif !ok {\n\t\treturn nil, errors.New(\"Key not found in table.\")\n\t}\n\treturn entry, nil\n}", "func (s *Client) GetHistory(username string) (*sessions.History, error) {\n\tdata := &sessions.History{\n\t\tInput: []string{},\n\t\tReply: []string{},\n\t}\n\n\tfor i := 0; i < sessions.HistorySize; i++ {\n\t\tdata.Input = append(data.Input, \"undefined\")\n\t\tdata.Reply = append(data.Reply, \"undefined\")\n\t}\n\n\trows, err := s.db.Query(\"SELECT input,reply FROM history WHERE user_id = (SELECT id FROM users WHERE username = ?) ORDER BY timestamp ASC LIMIT 10;\", username)\n\tif err != nil {\n\t\treturn data, err\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar input, reply string\n\t\terr := rows.Scan(&input, &reply)\n\t\tif err != nil {\n\t\t\tlog.Println(\"[ERROR]\", err)\n\t\t\tcontinue\n\t\t}\n\t\tdata.Input = data.Input[:len(data.Input)-1] // Pop\n\t\tdata.Input = append([]string{strings.TrimSpace(input)}, data.Input...) // Unshift\n\t\tdata.Reply = data.Reply[:len(data.Reply)-1] // Pop\n\t\tdata.Reply = append([]string{strings.TrimSpace(reply)}, data.Reply...) // Unshift\n\n\t}\n\n\treturn data, nil\n}", "func (c *Client) History(asset int) *HistoryService {\n\treturn &HistoryService{service{c}, asset}\n}", "func (server *p2pLogEx) GetEntryByEncodedHash(logEx *LogEx, key log.EncodedHash, logEntry *log.LogEntry) error {\n p := logEx.theLog.GetEntryByEncodedHash(key)\n p2pDebug.Debugf(\"Log entry to send: %+v\", p)\n p.CopyTo(logEntry)\n if logEntry == nil {\n return p2pDebug.Error(errors.New(\"Teapot: Log entry with the specified hash doesn't exist\"))\n }\n return nil\n}", "func (t *BenchmarkerChaincode) GetHistoryForKey(stub shim.ChaincodeStubInterface, seed, keySizeLo, keySizeHi int) pb.Response {\n\tvar (\n\t\tkm NoopKeyMapper\n\t)\n\n\tkey := km.GetKeys(seed, 1, keySizeLo, keySizeHi)[0]\n\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfmt.Printf(\"GetHistoryForKey: Getting history for key '%s'\\n\", key)\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\treturn shim.Success(buffer.Bytes())\n}", "func getHistory(stub shim.ChaincodeStubInterface, args []string) (string, error) {\n\tif len(args) != 1 {\n\t\treturn \"\", fmt.Errorf(\"Incorrect arguments. Expecting a key\")\n\t}\n\n\tresultsIterator, err := stub.GetHistoryForKey(args[0])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to get asset: %s with error: %s\", args[0], err)\n\t}\n\tif resultsIterator == nil {\n\t\treturn \"\", fmt.Errorf(\"history not found: %s\", args[0])\n\t}\n\n\tdefer resultsIterator.Close()\n\n\t// buffer is a JSON array containing historic values for the marble\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn \"iterating error\", err\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\\n\", buffer.String())\n\n\treturn buffer.String(), nil\n}", "func getNthStash(ctx context.Context, am prolly.AddressMap, count, idx int) (*stashHead, error) {\n\tvar stashList = getStashListOrdered(ctx, am, count)\n\tif count <= idx {\n\t\treturn nil, fmt.Errorf(\"error: stash list only has %v entries\", idx)\n\t}\n\treturn stashList[idx], nil\n}", "func NewHistoryIndexBlobKey(domainID, workflowID, runID string) (blob.Key, error) {\n\tif len(domainID) == 0 || len(workflowID) == 0 || len(runID) == 0 {\n\t\treturn nil, errInvalidKeyInput\n\t}\n\tdomainIDHash := fmt.Sprintf(\"%v\", farm.Fingerprint64([]byte(domainID)))\n\tworkflowIDHash := fmt.Sprintf(\"%v\", farm.Fingerprint64([]byte(workflowID)))\n\trunIDHash := fmt.Sprintf(\"%v\", farm.Fingerprint64([]byte(runID)))\n\tcombinedHash := strings.Join([]string{domainIDHash, workflowIDHash, runIDHash}, \"\")\n\treturn blob.NewKey(\"index\", combinedHash)\n}", "func (server *LogEx) GetEntryByEncodedHash(key log.EncodedHash, logEntry *log.LogEntry) error {\n return server.p2p.GetEntryByEncodedHash(server, key, logEntry)\n}", "func (l *List) Get(index int) interface{} {\n\tif index < 0 || index >= l.len {\n\t\treturn -1\n\t}\n\n\tvar cur *Node\n\tif index < l.len/2 { // 从head开始查询\n\t\tcur = l.head\n\t\t// 空节点head的index是0\n\t\tfor i := 0; i < index; i++ {\n\t\t\tcur = cur.next\n\t\t}\n\t} else { // 从tail开始查询\n\t\tcur = l.tail\n\t\tfor i := l.len + 1; i > index; i-- {\n\t\t\tcur = cur.prev\n\t\t}\n\t}\n\n\treturn cur.value\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 (_Bindings *BindingsSession) BorrowIndex() (*big.Int, error) {\n\treturn _Bindings.Contract.BorrowIndex(&_Bindings.CallOpts)\n}", "func (cc CoinCap) GetHistory(baseID, interval string, timeFrom, timeTo int64) (history []CCHistoryItem, err error) {\n\tbaseID = strings.ToLower(strings.Join(strings.Split(baseID, \" \"), \"-\"))\n\turl := fmt.Sprintf(\"%s/assets/%s/history?interval=%s&start=%d&end=%d\",\n\t\tcc.BaseURL, baseID, interval, timeFrom, timeTo)\n\tresponse, err := http.Get(url)\n\tif err != nil {\n\t\treturn\n\t}\n\tresult := struct {\n\t\tError string `json:\"error\"`\n\t\tData []CCHistoryItem `json:\"Data\"`\n\t}{}\n\terr = json.NewDecoder(response.Body).Decode(&result)\n\tif err != nil {\n\t\treturn\n\t}\n\tif result.Error != \"\" {\n\t\terr = errors.New(result.Error)\n\t\treturn\n\t}\n\thistory = result.Data\n\treturn\n}", "func (s *State) GetHistory(height uint32) (*StateKeyFrame, error) {\n\ts.mtx.RLock()\n\tdefer s.mtx.RUnlock()\n\n\t// Seek to state to target height.\n\tif err := s.history.SeekTo(height); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Take a snapshot of the history.\n\treturn s.snapshot(), nil\n}", "func (as *Addresses) Get(index int) (*Address, error) {\n\tif index < 0 || index >= len(as.values) {\n\t\treturn nil, errors.New(\"get: index out of range\")\n\t}\n\treturn &Address{as.values[index]}, nil\n}", "func (sc *LoanDocContract) History(ctx contractapi.TransactionContextInterface, key string) ([]LoanDocHistory, error) {\n\n\titer, err := ctx.GetStub().GetHistoryForKey(key)\n\tif err != nil {\n return nil, err\n\t}\n\tdefer func() { _ = iter.Close() }()\n\n\tvar results []LoanDocHistory\n\tfor iter.HasNext() {\n\t\tstate, err := iter.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tentryObj := new(LoanDocObj)\n\t\tif errNew := json.Unmarshal(state.Value, entryObj); errNew != nil {\n\t\t\treturn nil, errNew\n\t\t}\n\n\t\tentry := LoanDocHistory{\n\t\t\tTxID:\t\tstate.GetTxId(),\n\t\t\tTimestamp:\ttime.Unix(state.GetTimestamp().GetSeconds(), 0),\n\t\t\tLoanDoc:\tentryObj,\n\t\t}\n\n\t\tresults = append(results, entry)\n\t}\n\treturn results, nil\n}", "func (s *Client) GetHistory(ctx context.Context, scripthash string) ([]*GetMempoolResult, error) {\n\tvar resp GetMempoolResp\n\n\terr := s.request(ctx, \"blockchain.scripthash.get_history\", []interface{}{scripthash}, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp.Result, err\n}", "func (c *FakeReleaseHistories) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ReleaseHistory, err error) {\n\tobj, err := c.Fake.\n\t\tInvokes(testing.NewGetAction(releasehistoriesResource, c.ns, name), &v1alpha1.ReleaseHistory{})\n\n\tif obj == nil {\n\t\treturn nil, err\n\t}\n\treturn obj.(*v1alpha1.ReleaseHistory), err\n}", "func (c *Collection) GetHistory(keyComponents ...string) (HistoryQueryIteratorInterface, error) {\n\tkey, err := c.formatKey(keyComponents)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get history from collection. %s\", err.Error())\n\t}\n\n\tvar shqi shim.HistoryQueryIteratorInterface\n\n\tif c.Name != WorldStateIdentifier {\n\t\treturn nil, fmt.Errorf(\"Failed to get history from collection. %s\", \"Historic data does not exist for non world state collections\")\n\t}\n\n\tshqi, err = c.Stub.GetHistoryForKey(key)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to get history from collection. %s\", err.Error())\n\t}\n\n\thqi := new(HistoryQueryIterator)\n\thqi.Serializer = c.Serializer\n\thqi.Iterator = shqi\n\n\treturn hqi, nil\n}", "func GetHistory(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\ttype KeyModificationWrapper struct {\n\t\tRealValue interface{} `json:\"InterfaceValue\"`\n\t\tTx queryresult.KeyModification\n\t}\n\tvar sliceReal []KeyModificationWrapper\n\n\tvar history []queryresult.KeyModification\n\tvar value interface{}\n\n\tif len(args) != 1 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 1\")\n\t}\n\n\tkey := args[0]\n\tfmt.Printf(\"- start GetHistory: %s\\n\", key)\n\n\t// Get History\n\tresultsIterator, err := stub.GetHistoryForKey(key)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tfor resultsIterator.HasNext() {\n\t\thistoryData, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\n\t\tvar singleReal KeyModificationWrapper\n\t\tvar tx queryresult.KeyModification\n\t\tsingleReal.Tx.TxId = historyData.TxId //copy transaction id over\n\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\tif historyData.Value == nil { //value has been deleted\n\t\t\tvar emptyBytes []byte\n\t\t\tsingleReal.Tx.Value = emptyBytes //copy nil value\n\t\t} else {\n\t\t\tjson.Unmarshal(historyData.Value, &value) //un stringify it aka JSON.parse()\n\t\t\tsingleReal.Tx.Value = historyData.Value //copy value over\n\t\t\tsingleReal.Tx.Timestamp = historyData.Timestamp\n\t\t\tsingleReal.Tx.IsDelete = historyData.IsDelete\n\t\t\tsingleReal.RealValue = value\n\t\t}\n\t\thistory = append(history, tx) //add this Tx to the list\n\t\tsliceReal = append(sliceReal, singleReal)\n\t}\n\t// fmt.Printf(\"- getHistoryForService returning:\\n%s\", history)\n\tPrettyPrintHistory(history)\n\n\t//change to array of bytes\n\t// historyAsBytes, _ := json.Marshal(history) //convert to array of bytes\n\n\trealAsBytes, _ := json.Marshal(sliceReal)\n\treturn shim.Success(realAsBytes)\n}", "func (args Arguments) Get(index int) interface{} {\n\tif index+1 > len(args) {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Cannot call Get(%d) because there are %d argument(s).\", index, len(args)))\n\t}\n\treturn args[index]\n}", "func (c *postgresReadOnlyCollection) GetRevByIndex(index *Index, indexVal string, val proto.Message, opts *Options, f func(string, int64) error) error {\n\tif err := c.validateIndex(index); err != nil {\n\t\treturn err\n\t}\n\treturn c.listRev(map[string]string{indexFieldName(index): indexVal}, val, opts, f)\n}", "func (i *Inspector) History(qname string, n int) ([]*DailyStats, error) {\n\tif err := base.ValidateQueueName(qname); err != nil {\n\t\treturn nil, err\n\t}\n\tstats, err := i.rdb.HistoricalStats(qname, n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar res []*DailyStats\n\tfor _, s := range stats {\n\t\tres = append(res, &DailyStats{\n\t\t\tQueue: s.Queue,\n\t\t\tProcessed: s.Processed,\n\t\t\tFailed: s.Failed,\n\t\t\tDate: s.Time,\n\t\t})\n\t}\n\treturn res, nil\n}", "func (_Bindings *BindingsCallerSession) BorrowIndex() (*big.Int, error) {\n\treturn _Bindings.Contract.BorrowIndex(&_Bindings.CallOpts)\n}", "func (_OracleMgr *OracleMgrCaller) GetOracleAtIndex(opts *bind.CallOpts, index *big.Int) (struct {\n\tCode common.Address\n\tDeposit *big.Int\n}, error) {\n\tret := new(struct {\n\t\tCode common.Address\n\t\tDeposit *big.Int\n\t})\n\tout := ret\n\terr := _OracleMgr.contract.Call(opts, out, \"getOracleAtIndex\", index)\n\treturn *ret, err\n}", "func (cm CMap) Index(keyValue interface{}) interface{} {\n\tentry := cm.FindBy(keyValue, Equals)\n\n\tif entry == nil {\n\t\treturn nil\n\t}\n\treturn entry.Value\n}", "func (i *LogStore) GetLog(index uint64, log *Log) bool {\n\ti.l.RLock()\n\tdefer i.l.RUnlock()\n\tl, ok := i.logs[index]\n\tif !ok {\n\t\treturn false\n\t}\n\t*log = *l\n\treturn true\n}", "func (buf *ListBuffer) Get(idx BufferIndex) (Item, *error.Error) {\n\tinRange, initialized := buf.legalIndex(idx)\n\tif !inRange {\n\t\tdesc := fmt.Sprintf(\n\t\t\t\"idx, %d, is out of range for IndexBuffer of length %d.\",\n\t\t\tidx, len(buf.Buffer),\n\t\t)\n\t\treturn Item{}, error.New(error.Value, desc)\n\t} else if !initialized {\n\t\tdesc := fmt.Sprintf(\n\t\t\t\"Item at idx, %d, has the Type value Uninitialized.\", idx,\n\t\t)\n\t\treturn Item{}, error.New(error.Value, desc)\n\t}\n\n\treturn buf.Buffer[idx].Item, nil\n}", "func (w *worker) GetHistoryByVisitID(ctx context.Context, vID string) ([]uLocVisit, error) {\n\tid, err := internalID(vID)\n\tif err != nil {\n\t\treturn []uLocVisit{}, err\n\t}\n\n\tr := make(chan getHistoryByVisitIDData)\n\n\tw.r <- func(h []uLoc) {\n\t\tif id < 1 || int(id) > len(h) { // dont >= because we subtract 1 - we begin at user index 1 rather than 0\n\t\t\tr <- getHistoryByVisitIDData{uLoc{}, ErrIDNotFound}\n\t\t\treturn\n\t\t}\n\t\tr <- getHistoryByVisitIDData{h[id-1], nil} // remember to subtract 1\n\t\treturn\n\t}\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn []uLocVisit{}, ErrContextCancelled\n\tcase ret := <-r:\n\t\tif ret.e != nil {\n\t\t\t// return empty array in case of invalid id\n\t\t\treturn []uLocVisit{}, nil\n\t\t}\n\t\treturn []uLocVisit{uLocVisit{ret.u, visitID{vID}}}, ret.e\n\t}\n}", "func (tt *TtTable) GetEntry(key position.Key) *TtEntry {\n\te := &tt.data[tt.hash(key)]\n\tif e.Key == key {\n\t\treturn e\n\t}\n\treturn nil\n}" ]
[ "0.69890547", "0.6931922", "0.68567276", "0.6717915", "0.6651019", "0.6597902", "0.6479551", "0.602872", "0.5932064", "0.5927579", "0.58827543", "0.58690596", "0.57837945", "0.5757964", "0.56649727", "0.56580347", "0.5641616", "0.5640364", "0.56182176", "0.5607699", "0.55965686", "0.5595686", "0.55892986", "0.55619764", "0.5556236", "0.5546085", "0.5545991", "0.5537168", "0.5516818", "0.5494808", "0.5472774", "0.5444786", "0.5441411", "0.54014903", "0.539965", "0.53635734", "0.5342762", "0.5333316", "0.53142697", "0.53082466", "0.53057516", "0.53057307", "0.5288729", "0.5285225", "0.52763003", "0.5276183", "0.5268398", "0.52520597", "0.5248987", "0.524837", "0.5245841", "0.52372646", "0.5230292", "0.52168554", "0.518725", "0.518582", "0.5181352", "0.51595294", "0.51542294", "0.5149888", "0.51478416", "0.5145938", "0.5133045", "0.5129414", "0.51228166", "0.5117876", "0.51085645", "0.5106782", "0.51022345", "0.50909805", "0.50885457", "0.5088527", "0.5071675", "0.506966", "0.506438", "0.50384915", "0.50323015", "0.50288534", "0.5026265", "0.5017234", "0.5013778", "0.5011432", "0.5007516", "0.5002132", "0.49985644", "0.49979478", "0.4993612", "0.4989199", "0.49878535", "0.49724934", "0.49652332", "0.49596408", "0.49558935", "0.4954847", "0.49505106", "0.49488938", "0.494033", "0.4940023", "0.49390146", "0.49202746" ]
0.67635894
3
Return the full history list.
func (l *Linenoise) historyList() []string { return l.history }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *ReleaseStoreHandleFunc) History() []ReleaseStoreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreHandleFunc) History() []DBStoreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreHandleFunc) History() []DBStoreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDirtyRepositoriesFunc) History() []DBStoreDirtyRepositoriesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDirtyRepositoriesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDirtyRepositoriesFunc) History() []DBStoreDirtyRepositoriesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDirtyRepositoriesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreGetLatestFunc) History() []ReleaseStoreGetLatestFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetLatestFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreListFunc) History() []ExtensionStoreListFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreListFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceGetUnsafeDBFunc) History() []AutoIndexingServiceGetUnsafeDBFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetUnsafeDBFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreHandleFunc) History() []ExtensionStoreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreTransactFunc) History() []ReleaseStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreGetLatestBatchFunc) History() []ReleaseStoreGetLatestBatchFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetLatestBatchFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreUpdateFunc) History() []ExtensionStoreUpdateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreUpdateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreListPublishersFunc) History() []ExtensionStoreListPublishersFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreListPublishersFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreGetByUUIDFunc) History() []ExtensionStoreGetByUUIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreGetByUUIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreWithFunc) History() []ReleaseStoreWithFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreWithFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreTransactFunc) History() []DBStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreTransactFunc) History() []DBStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreCreateFunc) History() []ReleaseStoreCreateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreCreateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ReleaseStoreGetArtifactsFunc) History() []ReleaseStoreGetArtifactsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreGetArtifactsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreGetPublisherFunc) History() []ExtensionStoreGetPublisherFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreGetPublisherFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreGetUploadsFunc) History() []DBStoreGetUploadsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreGetUploadsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreGetUploadsFunc) History() []DBStoreGetUploadsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreGetUploadsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreTransactFunc) History() []ExtensionStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverIndexConnectionResolverFunc) History() []ResolverIndexConnectionResolverFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverIndexConnectionResolverFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceGetListTagsFunc) History() []AutoIndexingServiceGetListTagsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetListTagsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverIndexConfigurationFunc) History() []ResolverIndexConfigurationFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverIndexConfigurationFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreCreateFunc) History() []ExtensionStoreCreateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreCreateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreStaleSourcedCommitsFunc) History() []DBStoreStaleSourcedCommitsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreStaleSourcedCommitsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *JobRunFunc) History() []JobRunFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]JobRunFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverQueryResolverFunc) History() []ResolverQueryResolverFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverQueryResolverFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *LSIFStoreTransactFunc) History() []LSIFStoreTransactFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreTransactFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistory(s *aklib.DBConfig) ([]*History, error) {\n\tvar hist []*History\n\treturn hist, s.DB.View(func(txn *badger.Txn) error {\n\t\terr := db.Get(txn, nil, &hist, db.HeaderWalletHistory)\n\t\tif err == badger.ErrKeyNotFound {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t})\n}", "func (f *AutoIndexingServiceGetIndexesFunc) History() []AutoIndexingServiceGetIndexesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetIndexesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreWithFunc) History() []ExtensionStoreWithFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreWithFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverQueueAutoIndexJobForRepoFunc) History() []ResolverQueueAutoIndexJobForRepoFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverQueueAutoIndexJobForRepoFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *UploadServiceGetListTagsFunc) History() []UploadServiceGetListTagsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetListTagsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *JobNameFunc) History() []JobNameFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]JobNameFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceGetIndexByIDFunc) History() []AutoIndexingServiceGetIndexByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetIndexByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreGetByIDFunc) History() []ExtensionStoreGetByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreGetByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreGetByExtensionIDFunc) History() []ExtensionStoreGetByExtensionIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreGetByExtensionIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceRepositoryIDsWithConfigurationFunc) History() []AutoIndexingServiceRepositoryIDsWithConfigurationFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceRepositoryIDsWithConfigurationFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func history() ([]gitobject.Commit, error) {\n\t// Open the repo\n\tr, err := git.PlainOpen(getGitDir())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get the HEAD\n\tcIter, err := r.Log(&git.LogOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Make a list of commits\n\tvar commits []gitobject.Commit\n\terr = cIter.ForEach(func(c *gitobject.Commit) error {\n\t\tcommits = append(commits, *c)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Sort the commits\n\tsort.Slice(commits, func(i, j int) bool {\n\t\treturn commits[i].Author.When.Local().Unix() < commits[j].Author.When.Local().Unix()\n\t})\n\n\treturn commits, nil\n}", "func (f *DBStoreSoftDeleteOldUploadsFunc) History() []DBStoreSoftDeleteOldUploadsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreSoftDeleteOldUploadsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (hr Repository) All() ([]HistoryModel, error) {\n\trows, err := hr.db.Query(`select * from history`)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer rows.Close()\n\n\tvar historyList []HistoryModel\n\n\tfor rows.Next() {\n\t\tvar history HistoryModel\n\t\terr := rows.Scan(&history.ID, &history.Startdate, &history.Enddate, &history.Area)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\thistoryList = append(historyList, HistoryModel{\n\t\t\tID: history.ID,\n\t\t\tStartdate: history.Startdate,\n\t\t\tEnddate: history.Enddate,\n\t\t\tArea: history.Area,\n\t\t})\n\t}\n\treturn historyList, nil\n}", "func (g *Generator) History() []ispec.History {\n\tcopy := []ispec.History{}\n\tfor _, v := range g.image.History {\n\t\tcopy = append(copy, v)\n\t}\n\treturn copy\n}", "func (f *ResolverCommitGraphFunc) History() []ResolverCommitGraphFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverCommitGraphFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDoneFunc) History() []DBStoreDoneFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDoneFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDoneFunc) History() []DBStoreDoneFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDoneFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *UploadServiceGetUploadsFunc) History() []UploadServiceGetUploadsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetUploadsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func History(ctx context.Context, channelName string) ([]*types.Message, error) {\n\tchannel := getChannel(channelName)\n\tmessages := messagesFromHistory(channel.History)\n\n\treturn messages, nil\n}", "func (f *WithHooksPreHandleFunc) History() []WithHooksPreHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]WithHooksPreHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceGetIndexesByIDsFunc) History() []AutoIndexingServiceGetIndexesByIDsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceGetIndexesByIDsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverGetIndexByIDFunc) History() []ResolverGetIndexByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverGetIndexByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *UploadServiceGetAuditLogsForUploadFunc) History() []UploadServiceGetAuditLogsForUploadFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetAuditLogsForUploadFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreSelectRepositoriesForRetentionScanFunc) History() []DBStoreSelectRepositoriesForRetentionScanFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreSelectRepositoriesForRetentionScanFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreRefreshCommitResolvabilityFunc) History() []DBStoreRefreshCommitResolvabilityFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreRefreshCommitResolvabilityFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverUploadConnectionResolverFunc) History() []ResolverUploadConnectionResolverFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverUploadConnectionResolverFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreGetFeaturedExtensionsFunc) History() []ExtensionStoreGetFeaturedExtensionsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreGetFeaturedExtensionsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *PolicyServiceGetRetentionPolicyOverviewFunc) History() []PolicyServiceGetRetentionPolicyOverviewFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]PolicyServiceGetRetentionPolicyOverviewFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *LSIFStoreClearFunc) History() []LSIFStoreClearFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreClearFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *LSIFStoreClearFunc) History() []LSIFStoreClearFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreClearFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *WithHooksPostHandleFunc) History() []WithHooksPostHandleFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]WithHooksPostHandleFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverUpdateIndexConfigurationByRepositoryIDFunc) History() []ResolverUpdateIndexConfigurationByRepositoryIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverUpdateIndexConfigurationByRepositoryIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreUpdateUploadRetentionFunc) History() []DBStoreUpdateUploadRetentionFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreUpdateUploadRetentionFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *LSIFStoreDoneFunc) History() []LSIFStoreDoneFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreDoneFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistoryRecords() ([]string, error) {\n\trecords := []string{}\n\n\t// \tGet bash history records\n\tbashRecords, err := getBashHistoryRecords()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trecords = append(records, bashRecords...)\n\n\t//Get zsh history records\n\tzshRecords, err := getZshHistoryRecords()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trecords = append(records, zshRecords...)\n\treturn records, nil\n}", "func (f *PipelineRunFunc) History() []PipelineRunFuncCall {\n\treturn f.history\n}", "func (f *UploadServiceGetCommitGraphMetadataFunc) History() []UploadServiceGetCommitGraphMetadataFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetCommitGraphMetadataFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreCommitsVisibleToUploadFunc) History() []DBStoreCommitsVisibleToUploadFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreCommitsVisibleToUploadFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (env *Environment) GetHistory(count int, all bool) ([]*historyRow, error) {\n\tfList, err := getHistoryFileList(env.LocalPath(HistoryDir))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trows := []*historyRow{}\n\tfor _, f := range fList {\n\t\trs, err := f.getHistory()\n\t\tif err != nil {\n\t\t\treturn rows, err\n\t\t}\n\t\tif (len(rows)+len(rs)) > count && !all {\n\t\t\ti := len(rows) + len(rs) - count\n\t\t\trows = append(rs[i:], rows...)\n\t\t\tbreak\n\t\t}\n\n\t\trows = append(rs, rows...)\n\t}\n\treturn rows, nil\n}", "func (f *UploadServiceGetUploadsByIDsFunc) History() []UploadServiceGetUploadsByIDsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetUploadsByIDsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *SubRepoPermissionCheckerEnabledFunc) History() []SubRepoPermissionCheckerEnabledFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]SubRepoPermissionCheckerEnabledFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFunc) History() []AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]AutoIndexingServiceNumRepositoriesWithCodeIntelligenceFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverGetIndexesByIDsFunc) History() []ResolverGetIndexesByIDsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverGetIndexesByIDsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *UploadServiceGetUploadDocumentsForPathFunc) History() []UploadServiceGetUploadDocumentsForPathFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]UploadServiceGetUploadDocumentsForPathFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (p *RestPresence) History(params *PaginateParams) (*PaginatedResult, error) {\n\tpath := \"/channels/\" + p.channel.uriName + \"/presence/history\"\n\treturn newPaginatedResult(presMsgType, path, params, query(p.client.get), p.logger())\n}", "func (o ApplicationStatusPtrOutput) History() ApplicationStatusHistoryArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationStatus) []ApplicationStatusHistory {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.History\n\t}).(ApplicationStatusHistoryArrayOutput)\n}", "func (o ApplicationStatusOutput) History() ApplicationStatusHistoryArrayOutput {\n\treturn o.ApplyT(func(v ApplicationStatus) []ApplicationStatusHistory { return v.History }).(ApplicationStatusHistoryArrayOutput)\n}", "func (f *ResolverGetUploadsByIDsFunc) History() []ResolverGetUploadsByIDsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverGetUploadsByIDsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreDeleteFunc) History() []ExtensionStoreDeleteFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreDeleteFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func getHistory(source string) ([]TransferData, error) {\n\turl := fmt.Sprintf(\"%s/history?duration=%s\", source, url.QueryEscape(AgentRouter.CronInterval))\n\tresp := utils.FetchResponse(url, []byte{})\n\tif resp.Error != nil {\n\t\treturn nil, resp.Error\n\t}\n\tvar transferRecords []TransferData\n\terr := json.Unmarshal(resp.Data, &transferRecords)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn transferRecords, nil\n}", "func (db *MongoDB) ListHistory(id string, begin time.Time, end time.Time, projection Projection) ([]Report, error) {\n\topts := db.applyProjection(&options.FindOptions{Sort: bson.M{\"server_time\": 1}}, projection)\n\tfilter := bson.M{\"id\": id, \"server_time\": bson.M{\"$gte\": begin.Unix(), \"$lte\": end.Unix()}}\n\tcur, err := db.instance.Collection(logCollection).Find(context.Background(), filter, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer db.safeClose(cur)\n\treturn db.decodeReports(cur)\n}", "func (f *DBStoreDeleteUploadsStuckUploadingFunc) History() []DBStoreDeleteUploadsStuckUploadingFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteUploadsStuckUploadingFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (c Clipboard) GetHistory() ([]string, error) {\n\titems, err := c.Storage.GetHistory(c.HistorySize)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn items, nil\n}", "func (f *DBStoreDeleteOldIndexesFunc) History() []DBStoreDeleteOldIndexesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteOldIndexesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreGetConfigurationPoliciesFunc) History() []DBStoreGetConfigurationPoliciesFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreGetConfigurationPoliciesFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *PipelineAddFunc) History() []PipelineAddFuncCall {\n\treturn f.history\n}", "func (s *Client) GetHistory(username string) (*sessions.History, error) {\n\tdata := &sessions.History{\n\t\tInput: []string{},\n\t\tReply: []string{},\n\t}\n\n\tfor i := 0; i < sessions.HistorySize; i++ {\n\t\tdata.Input = append(data.Input, \"undefined\")\n\t\tdata.Reply = append(data.Reply, \"undefined\")\n\t}\n\n\trows, err := s.db.Query(\"SELECT input,reply FROM history WHERE user_id = (SELECT id FROM users WHERE username = ?) ORDER BY timestamp ASC LIMIT 10;\", username)\n\tif err != nil {\n\t\treturn data, err\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar input, reply string\n\t\terr := rows.Scan(&input, &reply)\n\t\tif err != nil {\n\t\t\tlog.Println(\"[ERROR]\", err)\n\t\t\tcontinue\n\t\t}\n\t\tdata.Input = data.Input[:len(data.Input)-1] // Pop\n\t\tdata.Input = append([]string{strings.TrimSpace(input)}, data.Input...) // Unshift\n\t\tdata.Reply = data.Reply[:len(data.Reply)-1] // Pop\n\t\tdata.Reply = append([]string{strings.TrimSpace(reply)}, data.Reply...) // Unshift\n\n\t}\n\n\treturn data, nil\n}", "func (d *Dao) HistoryList(c context.Context, mid, aid int64, ip string) (historys []*archive.ArcHistory, err error) {\n\tparams := url.Values{}\n\tparams.Set(\"aid\", strconv.FormatInt(aid, 10))\n\tparams.Set(\"mid\", strconv.FormatInt(mid, 10))\n\tvar res struct {\n\t\tCode int `json:\"code\"`\n\t\tData []*archive.ArcHistory `json:\"data\"`\n\t}\n\tif err = d.client.Get(c, d.hList, ip, params, &res); err != nil {\n\t\tlog.Error(\"archive.HistoryList url(%s) mid(%d) error(%v)\", d.hList+\"?\"+params.Encode(), mid, err)\n\t\terr = ecode.CreativeArchiveAPIErr\n\t\treturn\n\t}\n\tif res.Code != 0 {\n\t\tlog.Error(\"archive.HistoryList url(%s) mid(%d) res(%v)\", d.hList+\"?\"+params.Encode(), mid, res)\n\t\terr = ecode.CreativeArchiveAPIErr\n\t\treturn\n\t}\n\thistorys = res.Data\n\treturn\n}", "func (f *ConnDoFunc) History() []ConnDoFuncCall {\n\treturn f.history\n}", "func (sc *LoanMarketShareContract) History(ctx contractapi.TransactionContextInterface, key string) ([]LoanMarketShareHistory, error) {\n\n\titer, err := ctx.GetStub().GetHistoryForKey(key)\n\tif err != nil {\n return nil, err\n\t}\n\tdefer func() { _ = iter.Close() }()\n\n\tvar results []LoanMarketShareHistory\n\tfor iter.HasNext() {\n\t\tstate, err := iter.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tentryObj := new(LoanMarketShareObj)\n\t\tif errNew := json.Unmarshal(state.Value, entryObj); errNew != nil {\n\t\t\treturn nil, errNew\n\t\t}\n\n\t\tentry := LoanMarketShareHistory{\n\t\t\tTxID:\t\tstate.GetTxId(),\n\t\t\tTimestamp:\ttime.Unix(state.GetTimestamp().GetSeconds(), 0),\n\t\t\tLoanMarketShare:\tentryObj,\n\t\t}\n\n\t\tresults = append(results, entry)\n\t}\n\treturn results, nil\n}", "func (f *ConnSendFunc) History() []ConnSendFuncCall {\n\treturn f.history\n}", "func (f *ExtensionStoreCountPublishersFunc) History() []ExtensionStoreCountPublishersFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreCountPublishersFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (s *CqlStore) History(id ID, limit int) ([]Status, error) {\n\tif s.session == nil {\n\t\treturn []Status{}, NewStoreClosedError()\n\t}\n\tvar items []Status\n\tvar errors []string\n\titer := s.session.Query(\"select status, type, name, contents from items where id=? order by updated desc limit ?\", IDToString(id), limit).Iter()\n\tvar status, ttype, name, contents string\n\tfor iter.Scan(&status, &ttype, &name, &contents) {\n\t\tvar cnts map[string]interface{}\n\t\tvar err error\n\t\tif len(contents) > 0 {\n\t\t\terr = json.Unmarshal([]byte(contents), &cnts)\n\t\t}\n\t\tif err != nil {\n\t\t\terrors = append(errors, NewItemUnmarshallError(err).Error())\n\t\t} else {\n\t\t\titems = append(items, Status{Item{id, ttype, name, cnts}, status})\n\t\t}\n\n\t}\n\tif err := iter.Close(); err != nil {\n\t\terrors = append(errors, NewStoreInternalError(err).Error())\n\t}\n\treturn items, NewMultipleItemErrors(errors)\n}", "func (f *ExtensionStoreCountFunc) History() []ExtensionStoreCountFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreCountFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *FinalizerFinalizeFunc) History() []FinalizerFinalizeFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]FinalizerFinalizeFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *DBStoreDeleteIndexesWithoutRepositoryFunc) History() []DBStoreDeleteIndexesWithoutRepositoryFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]DBStoreDeleteIndexesWithoutRepositoryFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *SubRepoPermissionCheckerPermissionsFunc) History() []SubRepoPermissionCheckerPermissionsFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]SubRepoPermissionCheckerPermissionsFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ResolverGetUploadByIDFunc) History() []ResolverGetUploadByIDFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ResolverGetUploadByIDFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error) {\n\thlist := make([]proto.Message, 0)\n\tif err := store.ReadHistory(datatype, realm, user, id, &hlist); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// TODO: perhaps this should be the empty list?\n\t\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"no config history available\")\n\t\t}\n\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"service storage unavailable: %v, retry later\", err)\n\t}\n\the := make([]*cpb.HistoryEntry, len(hlist))\n\tvar ok bool\n\tfor i, e := range hlist {\n\t\the[i], ok = e.(*cpb.HistoryEntry)\n\t\tif !ok {\n\t\t\treturn nil, http.StatusInternalServerError, fmt.Errorf(\"cannot load history entry %d\", i)\n\t\t}\n\t}\n\thistory := &cpb.History{\n\t\tHistory: he,\n\t}\n\tpageToken := r.URL.Query().Get(\"pageToken\")\n\tstart, err := strconv.ParseInt(pageToken, 10, 64)\n\tif err != nil {\n\t\tstart = 0\n\t}\n\n\tpageSize := r.URL.Query().Get(\"pageSize\")\n\tsize, err := strconv.ParseInt(pageSize, 10, 64)\n\tif err != nil || size < 1 {\n\t\tsize = 50\n\t}\n\tif size > 1000 {\n\t\tsize = 1000\n\t}\n\t// Reverse order\n\ta := history.History\n\tfor i := len(a)/2 - 1; i >= 0; i-- {\n\t\topp := len(a) - 1 - i\n\t\ta[i], a[opp] = a[opp], a[i]\n\t}\n\n\tfor i, entry := range history.History {\n\t\tif entry.Revision <= start {\n\t\t\thistory.History = history.History[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(history.History) > int(size) {\n\t\thistory.NextPageToken = fmt.Sprintf(\"%d\", history.History[size].Revision)\n\t\thistory.History = history.History[:size]\n\t}\n\treturn history, http.StatusOK, nil\n}" ]
[ "0.7481514", "0.7468895", "0.7468895", "0.7467521", "0.7467521", "0.745048", "0.74211055", "0.7408736", "0.7403688", "0.73958266", "0.7388008", "0.7362413", "0.7357153", "0.7351966", "0.7335992", "0.73349196", "0.73349196", "0.73216414", "0.7314814", "0.7314499", "0.7290348", "0.7290348", "0.7268706", "0.72667", "0.72611576", "0.72609156", "0.7247559", "0.7245089", "0.72290236", "0.72164243", "0.719012", "0.7185096", "0.7178418", "0.71744704", "0.71649426", "0.7143088", "0.7138661", "0.7131157", "0.7130566", "0.712546", "0.7124362", "0.71221375", "0.7109612", "0.7099073", "0.7094699", "0.7094041", "0.70926833", "0.70926833", "0.70843697", "0.70830995", "0.70818615", "0.7079029", "0.7076474", "0.7069236", "0.70592535", "0.70509857", "0.7044748", "0.7035903", "0.70156413", "0.7012484", "0.7012484", "0.7000253", "0.6998209", "0.6994012", "0.6986614", "0.69758576", "0.6973439", "0.69666874", "0.6959437", "0.6953203", "0.6952585", "0.69429165", "0.69423544", "0.69015294", "0.69008213", "0.68879527", "0.6886994", "0.6885775", "0.6885227", "0.68821305", "0.6875915", "0.68674684", "0.68639797", "0.6857511", "0.68545455", "0.68418086", "0.6838611", "0.6827116", "0.6820565", "0.68191427", "0.68179905", "0.68128234", "0.6802673", "0.68003964", "0.6798144", "0.6796386", "0.6780046", "0.67737067", "0.67727697", "0.6763802" ]
0.78417665
0
Return next history item.
func (l *Linenoise) historyNext(ls *linestate) string { if len(l.history) == 0 { return "" } // update the current history entry with the line buffer l.historySet(ls.historyIndex, ls.String()) ls.historyIndex-- // next history item if ls.historyIndex < 0 { ls.historyIndex = 0 } return l.historyGet(ls.historyIndex) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (scanner *HistoryScanner) Next() (commonledger.QueryResult, error) {\n\tlogger.Debugf(\"Entered HistoryScanner.Next\")\n\n\tblockAndTxNum, err := scanner.couchdbScanner.Next()\n\tif blockAndTxNum == nil {\n\t\treturn nil, err\n\t}\n\n\tlogger.Debugf(\"[HistoryScanner.Next] blockAndTxNum=%v\", blockAndTxNum)\n\n\tblkTxNum := blockAndTxNum.(*blockTxNum)\n\n\tkeyToUse := scanner.key\n\tif keyToUse == \"\" {\n\t\tkeyToUse = blkTxNum.getKey()\n\t}\n\n\tlogger.Debugf(\"Found history record for namespace:%s key:%s at blockNumTranNum %v:%v\\n\",\n\t\tscanner.namespace, keyToUse, blkTxNum.getBlockNum(), blkTxNum.getTxNum())\n\n\t// Get the transaction from block storage that is associated with this history record\n\ttranEnvelope, err := scanner.blockStore.RetrieveTxByBlockNumTranNum(blkTxNum.getBlockNum(), blkTxNum.getTxNum())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get the txid, key write value, timestamp, and delete indicator associated with this transaction\n\tvar queryResult commonledger.QueryResult\n\tqueryResult, err = getKeyModificationFromTran(tranEnvelope, scanner.namespace, keyToUse, scanner.hType)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttxid := queryResult.(*queryresult.KeyModification).TxId\n\tlogger.Debugf(\"Found historic key value for namespace:%s key:%s from transaction %s\\n\",\n\t\tscanner.namespace, keyToUse, txid)\n\n\treturn queryResult, nil\n}", "func (v *VersionHistory) GetLastItem() (*VersionHistoryItem, error) {\n\n\tif len(v.Items) == 0 {\n\t\treturn nil, &shared.BadRequestError{Message: \"version history is empty.\"}\n\t}\n\n\treturn v.Items[len(v.Items)-1].Duplicate(), nil\n}", "func getLatestHistoryFile(dir string) (item historyItem) {\n\tfileList, err := getHistoryFileList(dir)\n\t// start from 0\n\tif len(fileList) == 0 || err != nil {\n\t\titem.index = 0\n\t\titem.path = filepath.Join(dir, fmt.Sprintf(\"%s%s\", historyPrefix, strconv.Itoa(item.index)))\n\t\treturn\n\t}\n\n\tlatestItem := fileList[0]\n\n\tif latestItem.info.Size() >= historySize {\n\t\titem.index = latestItem.index + 1\n\t\titem.path = filepath.Join(dir, fmt.Sprintf(\"%s%s\", historyPrefix, strconv.Itoa(item.index)))\n\t} else {\n\t\titem = latestItem\n\t}\n\n\treturn\n}", "func (q *Queue) GetNext() ([]byte, error) {\n\tq.Lock()\n\tdefer q.Unlock()\n\n\titem, err := q.readItemByID(q.head + 1)\n\tif err != nil {\n\t\treturn item.Value, err\n\t}\n\n\terr = q.db.Delete(item.Key, nil)\n\tif err == nil {\n\t\tq.head++\n\t}\n\treturn item.Value, err\n}", "func (w *Window) Next() error {\n\trawurl, err := w.history.Next()\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 (it *subIterator) Next() Item {\n\tif it.iterator.state == pastRear {\n\t\treturn nil\n\t}\n\n\titem := it.iterator.Next()\n\n\tif item != nil && it.toKey.Less(item) {\n\t\tit.iterator.state = pastRear\n\t\treturn nil\n\t}\n\n\treturn item\n}", "func (l *reader) nextItem() item {\n\tif l.peekCount > 0 {\n\t\tl.peekCount--\n\t} else {\n\t\tl.token[0] = l.nextItemFromInput()\n\t}\n\treturn l.token[l.peekCount]\n}", "func (c *Conn) Next(ctx context.Context) (i Item, err error) {\n\tvar tx pgx.Tx\n\ttx, err = c.db.Begin(ctx)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trow := tx.QueryRow(ctx, \"SELECT url, priority FROM jobs ORDER BY priority DESC FOR UPDATE skip locked\")\n\n\tif err = row.Scan(&i.URL, &i.Priority); err != nil {\n\t\tif err == pgx.ErrNoRows {\n\t\t\terr = ErrNoItem\n\t\t}\n\n\t\treturn\n\t}\n\n\ti.tx = *&tx\n\n\treturn\n}", "func (qi *Items) Next() *pageloader.Request {\n\tqi.Lock()\n\tlog.Println(\"pulling request from the queue\")\n\tif qi.Length == 0 {\n\t\tlog.Println(\"nothing in the queue\")\n\t\treturn nil\n\t}\n\tt := qi.Stack[0]\n\ttCopy := *t\n\tqi.Stack = qi.Stack[1:]\n\tqi.Length--\n\tlog.Printf(\"queue length now: %d\\n\", qi.Length)\n\tqi.Unlock()\n\treturn &tCopy\n}", "func (i *Item) Next() *Item {\n\treturn i.next\n}", "func (i Item) Next() *Item {\n\treturn i.next\n}", "func (v *VersionHistory) GetFirstItem() (*VersionHistoryItem, error) {\n\n\tif len(v.Items) == 0 {\n\t\treturn nil, &shared.BadRequestError{Message: \"version history is empty.\"}\n\t}\n\n\treturn v.Items[0].Duplicate(), nil\n}", "func (h *History) Last() *Entry {\n\treturn &(*h)[len(*h)-1]\n}", "func (l *reader) peekItem() item {\n\tif l.peekCount > 0 {\n\t\treturn l.token[l.peekCount-1]\n\t}\n\tl.peekCount = 1\n\tl.token[0] = l.nextItemFromInput()\n\n\treturn l.token[0]\n}", "func (h *RedisHelper) GetNextVal(key string) (id int64, err error) {\n\tsql := \"INCR\"\n\tvar (\n\t\treply interface{}\n\t)\n\treply, err = h.Conn.Do(sql, key)\n\tif err != nil {\n\t\treturn\n\t}\n\tid, err = redis.Int64(reply, err)\n\treturn\n}", "func (i *bufferItem) Next(ctx context.Context, forceClose <-chan struct{}) (*bufferItem, error) {\n\t// See if there is already a next value, block if so. Note we don't rely on\n\t// state change (chan nil) as that's not threadsafe but detecting close is.\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn nil, ctx.Err()\n\tcase <-forceClose:\n\t\treturn nil, fmt.Errorf(\"subscription closed\")\n\tcase <-i.link.nextCh:\n\t}\n\n\t// Check if the reader is too slow and the event buffer as discarded the event\n\t// This must happen after the above select to prevent a random selection\n\t// between linkCh and droppedCh\n\tselect {\n\tcase <-i.link.droppedCh:\n\t\treturn nil, fmt.Errorf(\"event dropped from buffer\")\n\tdefault:\n\t}\n\n\t// If channel closed, there must be a next item to read\n\tnextRaw := i.link.next.Load()\n\tif nextRaw == nil {\n\t\t// shouldn't be possible\n\t\treturn nil, errors.New(\"invalid next item\")\n\t}\n\tnext := nextRaw.(*bufferItem)\n\tif next.Err != nil {\n\t\treturn nil, next.Err\n\t}\n\treturn next, nil\n}", "func (t *Tree) next() item {\n\tif t.peekCount > 0 {\n\t\tt.peekCount--\n\t} else {\n\t\tt.token[0] = t.lex.nextItem()\n\t}\n\treturn t.token[t.peekCount]\n}", "func (_CraftingI *CraftingICaller) NextItem(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _CraftingI.contract.Call(opts, &out, \"next_item\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (feed *feed) Next() chan *Item {\n\tif feed.next == nil {\n\t\tpanic(errors.New(\"feed hasn't been initialised yet\"))\n\t}\n\treturn feed.next\n}", "func (_CraftingI *CraftingISession) NextItem() (*big.Int, error) {\n\treturn _CraftingI.Contract.NextItem(&_CraftingI.CallOpts)\n}", "func (l *Linenoise) historyGet(idx int) string {\n\treturn l.history[len(l.history)-1-idx]\n}", "func (this *Iter) Next() (interface{}, *Error) {\n\n\tif this.index > len(*this.list)-2 {\n\t\tif (this.nextPageQuery == nil) { return nil, MakeError(ErrorParse, nil, errors.New(\"At last item\")) }\n\t\tif err := this.nextPage(); err != nil { return nil, err }\n\t\tthis.index = -1\n\t}\n\t\n\tthis.index++\n\titem := (*this.list)[this.index]\n\t\n\treturn item, nil\n}", "func (r *ObjectsListingXact) Next() (entry *cmn.BucketEntry, err error) {\n\tres, err := r.NextN(1)\n\tif len(res) == 0 {\n\t\treturn nil, err\n\t}\n\tdebug.Assert(len(res) == 1)\n\treturn res[0], err\n}", "func (_CraftingI *CraftingICallerSession) NextItem() (*big.Int, error) {\n\treturn _CraftingI.Contract.NextItem(&_CraftingI.CallOpts)\n}", "func (id *RequestID) GetNext() int64 {\n\tid.Lock()\n\tid.Value++\n\tv := id.Value\n\tid.Unlock()\n\treturn v\n}", "func (h *History) GetLast() string {\n return h.GetLine(len(h.histories) - 1)\n}", "func (cur *sequenceCursor) current() sequenceItem {\n\td.PanicIfFalse(cur.valid())\n\treturn cur.getItem(cur.idx)\n}", "func (p *Pool) Next() (*Item, error) {\n\tif len(p.items) < 1 {\n\t\tif err := p.addNew(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tselect {\n\tcase v := <-p.items:\n\t\treturn &Item{\n\t\t\tvalue: v,\n\t\t\trestore: func() {\n\t\t\t\tp.items <- v\n\t\t\t},\n\t\t\tremove: func() {\n\t\t\t\tp.mu.Lock()\n\t\t\t\tdefer p.mu.Unlock()\n\t\t\t\tp.curSize--\n\t\t\t},\n\t\t\tmu: new(sync.Mutex),\n\t\t}, nil\n\tcase <-time.After(p.timeout):\n\t\treturn nil, ErrTimeout\n\t}\n}", "func (app *HailingApp) NextStep(userID string) (*ReservationRecord, string) {\n\trec, err := app.FindOrCreateRecord(userID)\n\tif err != nil {\n\t\treturn nil, \"-\"\n\t}\n\tnextStep := rec.WhatsNext()\n\trec.Waiting = nextStep\n\n\terr = app.SaveRecordToRedis(rec)\n\tif err != nil {\n\t\treturn nil, \"-\"\n\t}\n\treturn rec, nextStep\n}", "func (c *cache) next() uint {\n\tval := c.data[c.ptr]\n\tc.ptr++\n\treturn val\n}", "func (o *Links) GetNext() string {\n\tif o == nil || o.Next == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Next\n}", "func (i *Indexio) Next(key string) (idx uint32, err error) {\n\terr = i.db.Update(func(txn turtleDB.Txn) (err error) {\n\t\tvar bkt turtleDB.Bucket\n\t\tif bkt, err = txn.Get(\"indexes\"); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tif idx, err = getCurrent(bkt, key); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\t// Set the index as the next value\n\t\treturn bkt.Put(key, idx+1)\n\t})\n\n\treturn\n}", "func (it *SnapshotIterator) Next() (*netapppb.Snapshot, error) {\n\tvar item *netapppb.Snapshot\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 (c *Comics) Next() string {\n\tnext := c.Num + 1\n\n\treturn fmt.Sprintf(\"/?id=%d\", next)\n}", "func (gores *Gores) NextItemForTimestamp(timestamp int64) map[string]interface{} {\n\tvar res map[string]interface{}\n\n\ttimeStr := strconv.FormatInt(timestamp, 10)\n\tkey := fmt.Sprintf(delayedQueuePrefix, timeStr)\n\n\tconn := gores.pool.Get()\n\tdefer conn.Close()\n\n\treply, err := conn.Do(\"LPOP\", key)\n\tif reply == nil || err != nil {\n\t\treturn res\n\t}\n\tdata, err := redis.Bytes(reply, err)\n\tif err != nil {\n\t\treturn res\n\t}\n\tres, _ = gores.Decode(data)\n\tllen, err := conn.Do(\"LLEN\", key)\n\tif llen == nil || err != nil {\n\t\treturn res\n\t}\n\tif llen.(int64) == 0 {\n\t\tconn.Do(\"DEL\", key)\n\t\tconn.Do(\"ZREM\", watchedSchedules, timestamp)\n\t}\n\treturn res\n}", "func (h *History) GetLine(idx int) string {\n return h.histories[idx]\n}", "func (lb *smoothWeightedRR) Next() interface{} {\n\ti := lb.nextWeightedItem()\n\tif i == nil {\n\t\treturn nil\n\t}\n\n\treturn i.item\n}", "func (l *lexer) nextItem() Item {\n\titem := <-l.items\n\treturn item\n}", "func (d *Db) GetNextRecord(r *Record) (*Record, error) {\n\tnr := &Record{rec: C.wg_get_next_record(d.db, r.rec)}\n\tif nr.rec == nil {\n\t\treturn nil, WDBError(\"Done With DB\")\n\t}\n\treturn nr, nil\n}", "func (list *thingList) getNext() (grokeddit.Thing, error) {\n\tif !list.hasNext() {\n\t\treturn grokeddit.Thing{}, errors.New(\"No more things to iterate\")\n\t}\n\n\tif !list.currentThings.hasNext() {\n\t\tnextChunk := <-list.chunkChannel\n\n\t\t// set this variable now, a channel check can only be\n\t\t// done if async request is active.\n\t\tlist.moreThings = nextChunk.moreThings\n\t\tif nextChunk.moreThings {\n\t\t\tlist.fetchNextBlockAsync()\n\t\t}\n\n\t\tif nextChunk.retrievalError != nil {\n\t\t\treturn grokeddit.Thing{}, errors.New(\"Unable to fetch more things: \" + nextChunk.retrievalError.Error())\n\t\t}\n\n\t\tlist.currentThings.setArray(nextChunk.nextThings)\n\t}\n\n\treturn list.currentThings.getNext()\n}", "func (bst *BST) NextItem(val interface{}) interface{} {\n\tvar node = Next(bst, val)\n\tif node == nil {\n\t\treturn nil\n\t}\n\treturn node.Key\n}", "func (iter *Iterator) Next() interface{} {\n\treturn iter.currentNode.item\n}", "func (it *Iterator) GetNext() (kv datasync.KeyVal, stop bool) {\n\tkv, stop = it.delegate.GetNext()\n\tif stop {\n\t\treturn nil, stop\n\t}\n\treturn kv, stop\n}", "func (a *AddedReactions) GetNextOffset() (value string) {\n\tif a == nil {\n\t\treturn\n\t}\n\treturn a.NextOffset\n}", "func (c *Cursor) Next() (key, value []byte) {\n\tif c.index >= len(c.items)-1 {\n\t\treturn nil, nil\n\t}\n\n\tc.index++\n\treturn c.items[c.index].Key, c.items[c.index].Value\n}", "func (l *lexer) nextItem() item {\n\titem := <-l.items\n\tl.lastPos = item.pos\n\treturn item\n}", "func (l *lexer) nextItem() item {\n\titem := <-l.items\n\tl.lastPos = item.pos\n\treturn item\n}", "func (l *lexer) nextItem() item {\n\titem := <-l.items\n\tl.lastPos = item.pos\n\treturn item\n}", "func (bsi *BookShelfIterator) Next() interface{} {\n\tbook := bsi.Books[bsi.last]\n\tbsi.last++\n\treturn book\n}", "func Next() string {\n\n\t_, err := os.Stat(\"/dev/shm/goicy/next.mp3\")\n\n\tif os.IsNotExist(err) {\n\t\t//file does not exist\n\t\t//buffer the next file\n\t\tsaveNext()\n\t} else if err != nil {\n\t\tlogger.Log(\"Unknown file error \"+err.Error(), logger.LOG_INFO)\n\t}\n\t//move the file from next to current\n\t//buffer the next file\n\tos.Rename(\"/dev/shm/goicy/next.mp3\", \"/dev/shm/goicy/current.mp3\")\n\tappendHistory(pl.NextTrack)\n\tgo saveNext()\n\treturn \"/dev/shm/goicy/current.mp3\"\n}", "func (i *Iterator) Next() interface{} { // TODO return value needed?\n\tif len(i.Target) == 0 {\n\t\treturn nil\n\t}\n\tif i.Index+1 == len(i.Target) {\n\t\ti.Index = 0\n\t} else {\n\t\ti.Index++\n\t}\n\treturn i.Value()\n}", "func (q *Queue) Peek(n int) (item interface{}) {\n item = q.queue[n]\n return\n}", "func (s *scanner) nextToken() tokenRef {\n\titem := <-s.items\n\ts.lastPos = item.pos\n\treturn item\n}", "func (m *ExpressionPager) Next() ql.Token {\n\tif m.peekCount > 0 {\n\t\tm.peekCount--\n\t} else {\n\t\tm.token[0] = m.lex.NextToken()\n\t}\n\treturn m.token[m.peekCount]\n}", "func (player *musicPlayer) next() (string, error) {\n\tplayer.Lock()\n\tvar songToResume string\n\tif player.state.current < len(player.state.queue)-1 {\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\n\t} else {\n\t\tplayer.Unlock()\n\t\treturn songToResume, errors.New(cannot_next_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 (r *RingT[T]) Next() *T {\n\tif r.Len() == 0 {\n\t\treturn nil\n\t}\n\tt := r.tail\n\tr.tail = (r.tail + 1) & r.mask\n\titem := r.items[t]\n\tr.items[t] = nil // erase item, so that the garbage collector can do it's job\n\treturn item\n}", "func (group *Group) Next() Node {\n\tif group.cursor == group.Count() {\n\t\tgroup.cursor = 0\n\t}\n\n\tNode := group.items[group.cursor]\n\tgroup.cursor++\n\treturn Node\n}", "func (itr *combinedIterator) Next() (*statedb.VersionedKV, error) {\n\tif itr.dbItem == nil && itr.updatesItem == nil {\n\t\tlogger.Debugf(\"dbItem and updatesItem both are nil.\")\n\t\treturn itr.serveEndKeyIfNeeded()\n\t}\n\tvar moveDBItr bool\n\tvar moveUpdatesItr bool\n\tvar selectedItem *statedb.VersionedKV\n\tcompResult := compareKeys(itr.dbItem, itr.updatesItem)\n\tlogger.Debugf(\"compResult=%d\", compResult)\n\tswitch compResult {\n\tcase -1:\n\t\t// dbItem is smaller\n\t\tselectedItem = itr.dbItem\n\t\tmoveDBItr = true\n\tcase 0:\n\t\t// both items are same so, choose the updatesItem (latest)\n\t\tselectedItem = itr.updatesItem\n\t\tmoveUpdatesItr = true\n\t\tmoveDBItr = true\n\tcase 1:\n\t\t// updatesItem is smaller\n\t\tselectedItem = itr.updatesItem\n\t\tmoveUpdatesItr = true\n\t}\n\tvar err error\n\tif moveDBItr {\n\t\tif itr.dbItem, err = itr.dbItr.Next(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif moveUpdatesItr {\n\t\tif itr.updatesItem, err = itr.updatesItr.Next(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif isDelete(selectedItem) {\n\t\treturn itr.Next()\n\t}\n\tlogger.Debugf(\"Returning item=%#v. Next dbItem=%#v, Next updatesItem=%#v\", selectedItem, itr.dbItem, itr.updatesItem)\n\treturn selectedItem, nil\n}", "func (media *SavedMedia) GetNextID() string {\n\treturn formatID(media.NextID)\n}", "func (l *lexer) nextItem() item {\n\treturn <-l.items\n}", "func (l *lexer) nextItem() item {\n\treturn <-l.items\n}", "func (l *lexer) nextItem() item {\n\treturn <-l.items\n}", "func (l *lexer) nextItem() item {\n\treturn <-l.items\n}", "func (l List) Next(element interface{}) interface{} {\n\titem, found := l.find(element)\n\tif found {\n\t\treturn item.Next.Value\n\t}\n\treturn nil\n}", "func (it *TensorboardTimeSeriesIterator) Next() (*aiplatformpb.TensorboardTimeSeries, error) {\n\tvar item *aiplatformpb.TensorboardTimeSeries\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 (i Item) Prev() *Item {\n\treturn i.prev\n}", "func (l *List) Last() *Item {\r\n\treturn l.last\r\n}", "func (i *Item) Prev() *Item {\n\treturn i.prev\n}", "func (lt *LineTask) Next() *LineTask {\n\treturn lt.next\n}", "func (id *KeyManager) Next() string {\n\tid.idMutex.Lock()\n\tnext := id.nextID\n\tid.nextID++\n\tid.idMutex.Unlock()\n\treturn fmt.Sprintf(\"%x\", next)\n}", "func GetNextId(db *sql.DB, url string) int {\n\tgetNextIdSQL := `INSERT INTO links (url, created_at) VALUES (?, ?);`\n\n\tstatement, err := db.Prepare(getNextIdSQL)\n\tif err != nil {\n\t\tlog.Printf(\"Error inserting into links table: %v\\n\", err)\n\t}\n\tr, err := statement.Exec(url, time.Now().Format(time.RFC3339))\n\tif err != nil {\n\t\tlog.Printf(\"Error executing statement: %v\\n\", err)\n\t}\n\n\tid, err := r.LastInsertId()\n\tif err != nil {\n\t\tlog.Printf(\"Error getting last ID: %v\\n\", err)\n\t}\n\treturn int(id)\n}", "func getNextID() int {\n\tlp := productList[len(productList)-1]\n\treturn lp.ID + 1\n}", "func (it *QueueIterator) Next() (*cloudtaskspb.Queue, error) {\n\tvar item *cloudtaskspb.Queue\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 (it *Iterator) Next() {\n\t// Reuse current item\n\tit.item.wg.Wait() // Just cleaner to wait before pushing to avoid doing ref counting.\n\tit.waste.push(it.item)\n\n\t// Set next item to current\n\tit.item = it.data.pop()\n\n\t// Advance internal iterator until entry is not deleted\n\tfor it.iitr.Next(); it.iitr.Valid(); it.iitr.Next() {\n\t\tif bytes.HasPrefix(it.iitr.Key(), badgerPrefix) {\n\t\t\tcontinue\n\t\t}\n\t\tif it.iitr.Value().Meta&BitDelete == 0 { // Not deleted.\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !it.iitr.Valid() {\n\t\treturn\n\t}\n\titem := it.newItem()\n\tit.fill(item)\n\tit.data.push(item)\n}", "func (l *Lexer) Next() (i *Item) {\n\tfor {\n\t\tif head := l.dequeue(); head != nil {\n\t\t\treturn head\n\t\t}\n\t\tif l.state == nil {\n\t\t\treturn &Item{ItemEOF, l.start, \"\"}\n\t\t}\n\t\tl.state = l.state(l)\n\t}\n\tpanic(\"unreachable\")\n}", "func (it *LinkedListIterator) Next() interface{} {\n\tif it.HasNext() {\n\t\tit.index++\n\t\treturn it.list.Get(it.index)\n\t}\n\treturn nil\n}", "func (l *reader) nextItemFromInput() item {\n\tfor {\n\t\tselect {\n\t\tcase item := <-l.items:\n\t\t\treturn item\n\t\tdefault:\n\t\t\tl.state = l.state(l)\n\t\t}\n\t}\n\tpanic(\"not reached\")\n}", "func (v *Vault) ItemHistory(id string) ([]*Item, error) {\n\tpath := dstore.Path(\"pull\")\n\tds, err := v.store.List(&ListOptions{Prefix: path, NoData: true})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpaths := []string{}\n\tfor _, doc := range ds {\n\t\tif strings.HasPrefix(dstore.PathFrom(doc.Path, 2), dstore.Path(\"item\", id)) {\n\t\t\tpaths = append(paths, doc.Path)\n\t\t}\n\t}\n\n\titems := make([]*Item, 0, len(paths))\n\tfor _, p := range paths {\n\t\tb, err := v.store.Get(p)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif b == nil {\n\t\t\tcontinue\n\t\t}\n\t\tvar event events.Event\n\t\tif err := msgpack.Unmarshal(b, &event); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tid := dstore.PathLast(p)\n\t\titem, err := decryptItem(event.Data, v.mk, id)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\titems = append(items, item)\n\t}\n\n\tpending, err := v.findPendingItems(id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\titems = append(items, pending...)\n\n\treturn items, nil\n}", "func (it *Iterator) Item() *KVItem { return it.item }", "func (l *Lexer) NextItem() Item {\n\titem := <-l.items\n\tl.lastPos = item.Pos\n\treturn item\n}", "func (s *Select) GetNext(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 (p *Playlist) Next() {\n\tp.ch <- \"next\"\n}", "func (result *BufferedResult) Next() ([]byte, error) {\n\tif !result.HasNext() {\n\t\treturn nil, errors.New(\"no more values\")\n\t}\n\tionBinary := result.values[result.index]\n\tresult.index++\n\treturn ionBinary, nil\n}", "func (c *remoteCursor) Next() ([]byte, []byte, error) {\n\treturn c.next()\n}", "func (l *Lexer) nextItem() item {\n\tfor {\n\t\tselect {\n\t\tcase item := <-l.items:\n\t\t\treturn item\n\t\tdefault:\n\t\t\tif l.state == nil {\n\t\t\t\treturn item{}\n\t\t\t}\n\n\t\t\tl.state = l.state(l)\n\t\t}\n\t}\n\n\tpanic(\"not reached\")\n}", "func nextIndex(ctx context.Context) int {\n\treturn int(strconv.MustParseInt(ctx.Value(\"item.index\")))\n}", "func nextIndex(ctx context.Context) int {\n\treturn int(strconv.MustParseInt(ctx.Value(\"item.index\")))\n}", "func nextIndex(ctx context.Context) int {\n\treturn int(strconv.MustParseInt(ctx.Value(\"item.index\")))\n}", "func (s *itemStack) Peek() Item {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\treturn s.items[len(s.items)-1]\n}", "func (it *JobIterator) Next() (*Job, error) {\n\tif err := it.nextFunc(); err != nil {\n\t\treturn nil, err\n\t}\n\titem := it.items[0]\n\tit.items = it.items[1:]\n\treturn item, nil\n}", "func (u *Updater) Next() (bool, dht.NodeID, SeekRequest) {\n\tvar ln int\n\tlinks := len(u.network.ID()) * 8\n\n\tln = u.queueLen()\n\n\t// By lazy populating the queue, as responses come back, that can be used in\n\t// later requests.\n\tfor ; ln == 0; ln = u.queueLen() {\n\t\tif u.idx >= links {\n\t\t\treturn false, nil, SeekRequest{}\n\t\t}\n\t\tif u.idx > u.depth {\n\t\t\tu.idx = links - 1\n\t\t}\n\t\tu.queueIdx(u.idx)\n\t\tu.idx++\n\t}\n\tid, sr := u.seekRequest(u.queue[ln-1])\n\tu.Lock()\n\tu.queue = u.queue[:ln-1]\n\tu.Unlock()\n\treturn true, id, sr\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 *JobIterator) Next() (*runpb.Job, error) {\n\tvar item *runpb.Job\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 (db *BotDB) GetNextEvent(guild uint64, ty uint8) ScheduleEvent {\n\tp := ScheduleEvent{}\n\terr := db.sqlGetNextEvent.QueryRow(guild, ty).Scan(&p.ID, &p.Date, &p.Type, &p.Data)\n\tif err == sql.ErrNoRows || db.CheckError(\"GetNextEvent\", err) != nil {\n\t\treturn ScheduleEvent{0, time.Now().UTC(), 0, \"\"}\n\t}\n\treturn p\n}", "func (c *changeCache) getNextSequence() (nextSequence uint64) {\n\tc.lock.RLock()\n\tnextSequence = c.nextSequence\n\tc.lock.RUnlock()\n\treturn nextSequence\n}", "func (this *RedisSequencer) Next() (int, error) {\n\tif !this.isRolling && !this.isReverse {\n\t\treturn this.incr()\n\t}\n\n\tif !this.isRolling && this.isReverse {\n\t\treturn this.decr()\n\t}\n\n\tif this.isRolling && !this.isReverse {\n\t\tval, err := this.incr()\n\t\tif err == nil {\n\t\t\treturn val, nil\n\t\t}\n\t\tif err != nil && err != ErrLimitReached {\n\t\t\treturn 0, err\n\t\t}\n\t\t//limit reached reset.\n\t\terr = this.reset()\n\t\tif err == nil {\n\t\t\treturn this.incr()\n\t\t}\n\t\treturn 0, err\n\t}\n\n\tif this.isRolling && this.isReverse {\n\t\tval, err := this.decr()\n\t\tif err == nil {\n\t\t\treturn val, nil\n\t\t}\n\t\tif err != nil && err != ErrLimitReached {\n\t\t\treturn 0, err\n\t\t}\n\t\t//limit reached reset.\n\t\terr = this.reset()\n\t\tif err == nil {\n\t\t\treturn this.decr()\n\t\t}\n\t\treturn 0, err\n\t}\n\treturn 0, fmt.Errorf(\"Invalid Option. How did u landed here?\")\n}", "func (it *RowIterator) Next() (*channelpb.Row, error) {\n\tvar item *channelpb.Row\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 (q *Query) NextIdentifier() int {\n\tq.sequence += 1\n\treturn q.sequence\n}", "func (q *Queue) NextTask() string {\n\tif len(q.tasks) > 0 {\n\t\treturn q.tasks[0]\n\t}\n\treturn \"\"\n}", "func (e *IndexLookUpExecutor) Next() (*Row, error) {\n\tfor {\n\t\tif e.taskCurr == nil {\n\t\t\ttaskCurr, ok := <-e.taskChan\n\t\t\tif !ok {\n\t\t\t\treturn nil, e.tasksErr\n\t\t\t}\n\t\t\te.taskCurr = taskCurr\n\t\t}\n\t\trow, err := e.taskCurr.getRow()\n\t\tif err != nil {\n\t\t\treturn nil, errors.Trace(err)\n\t\t}\n\t\tif row != nil {\n\t\t\treturn row, nil\n\t\t}\n\t\te.taskCurr = nil\n\t}\n}" ]
[ "0.6240852", "0.6158178", "0.6149909", "0.61473864", "0.61101425", "0.6086889", "0.6012917", "0.58869714", "0.58832574", "0.5821239", "0.5730625", "0.57183653", "0.56548566", "0.56508684", "0.5626105", "0.56022394", "0.55524296", "0.5536614", "0.5530655", "0.5525143", "0.5524946", "0.548528", "0.5456748", "0.54400945", "0.54257953", "0.5412376", "0.5400656", "0.53901196", "0.5375937", "0.5353216", "0.5348335", "0.5347404", "0.5344489", "0.5339112", "0.5328766", "0.53181964", "0.5307364", "0.5297472", "0.5286247", "0.5278372", "0.52768064", "0.5275105", "0.52704835", "0.52666914", "0.5264385", "0.5254296", "0.5254296", "0.5254296", "0.5226678", "0.52264327", "0.5214711", "0.52124584", "0.52091396", "0.5208629", "0.52063626", "0.5201309", "0.51974535", "0.51962936", "0.5193119", "0.51930344", "0.51930344", "0.51930344", "0.51930344", "0.5177307", "0.5165853", "0.51616496", "0.5158614", "0.5156946", "0.51530445", "0.51426136", "0.51322705", "0.5130378", "0.5122155", "0.5115245", "0.5106622", "0.5098836", "0.5087839", "0.50824964", "0.50730795", "0.50682586", "0.50635874", "0.50533044", "0.50454634", "0.50424176", "0.50284034", "0.5026625", "0.5026625", "0.5026625", "0.5020556", "0.5017682", "0.50159574", "0.50053245", "0.50022817", "0.50015885", "0.49919462", "0.49918467", "0.499033", "0.49874467", "0.49821296", "0.4975043" ]
0.6385678
0
Return previous history item.
func (l *Linenoise) historyPrev(ls *linestate) string { if len(l.history) == 0 { return "" } // update the current history entry with the line buffer l.historySet(ls.historyIndex, ls.String()) ls.historyIndex++ // previous history item if ls.historyIndex >= len(l.history) { ls.historyIndex = len(l.history) - 1 } return l.historyGet(ls.historyIndex) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 (i *Item) Prev() *Item {\n\treturn i.prev\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 (i Item) Prev() *Item {\n\treturn i.prev\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 (bd *BlockDAG) GetPrevious(h *hash.Hash) *hash.Hash {\n\tbd.stateLock.Lock()\n\tdefer bd.stateLock.Unlock()\n\n\tif h == nil {\n\t\treturn nil\n\t}\n\tif h.IsEqual(bd.GetGenesisHash()) {\n\t\treturn nil\n\t}\n\tb := bd.getBlock(h)\n\tif b == nil {\n\t\treturn nil\n\t}\n\tif b.GetOrder() == 0 {\n\t\treturn nil\n\t}\n\t// TODO\n\treturn bd.instance.GetBlockByOrder(b.GetOrder() - 1)\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 (o *Note) GetPrevNumber() int { return o.Number }", "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 (l *Linenoise) historyGet(idx int) string {\n\treturn l.history[len(l.history)-1-idx]\n}", "func (player *Player) Previous() {\n\tplayer.obj.Call(\"org.mpris.MediaPlayer2.Player.Previous\", 0)\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 GetPreviousClose() {\n\tcryptoService := crypto.NewCryptoService(os.Getenv(\"MICRO_API_TOKEN\"))\n\trsp, err := cryptoService.History(&crypto.HistoryRequest{\n\t\tSymbol: \"BTCUSD\",\n\t})\n\tfmt.Println(rsp, err)\n}", "func (n *Node) getPrev() shared.NodeInfo {\n\tn.prevLock.RLock()\n\n\tprev := n.prev\n\n\tn.prevLock.RUnlock()\n\n\treturn prev\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 *touch) GetPreviousLocation() Point {\n\treturn &point{t.Call(\"getPreviousLocation\")}\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 GetPreviousClose() {\n\tcryptoService := crypto.NewCryptoService(\"YOUR_MICRO_TOKEN_HERE\")\n\trsp, _ := cryptoService.History(crypto.HistoryRequest{\n\t\tSymbol: \"BTCUSD\",\n\t})\n\tfmt.Println(rsp)\n}", "func (l *List) AwayPrev() *Element {\n\treturn l.root.AwayPrev()\n}", "func (p *Player) Previous() { p.Player.Call(INTERFACE+\".Player.Previous\", 0) }", "func (block *Block) GetPreviousHash() Hash {\n\treturn block.previousHash\n}", "func (folderWatcher *FolderWatcher) getPreviousEntryList() []string {\n\treturn folderWatcher.previousEntries\n}", "func (h *History) Last() *Entry {\n\treturn &(*h)[len(*h)-1]\n}", "func (n *snode) previous() *snode {\n\treturn n.backward\n}", "func (c *Client) PlaylistPrevious() error {\n\t_, err := c.Exec(\"playlist-prev\", \"weak\")\n\treturn err\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 (v *VersionHistory) GetLastItem() (*VersionHistoryItem, error) {\n\n\tif len(v.Items) == 0 {\n\t\treturn nil, &shared.BadRequestError{Message: \"version history is empty.\"}\n\t}\n\n\treturn v.Items[len(v.Items)-1].Duplicate(), nil\n}", "func (bc *Blockchain) GetPreviousBlock() Block {\n return bc.Chain[len(bc.Chain) - 1]\n}", "func (h *History) GetLast() string {\n return h.GetLine(len(h.histories) - 1)\n}", "func (bst *BST) PrevItem(val interface{}) interface{} {\n\tvar node = Prev(bst, val)\n\tif node == nil {\n\t\treturn nil\n\t}\n\treturn node.Key\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 (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 (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 (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 (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 (e *Element) Prev() *Element {\n\tif e != nil && e.prev != nil {\n\t\treturn e.prev\n\t}\n\treturn nil\n}", "func (o *Links) GetPrev() string {\n\tif o == nil || o.Prev == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Prev\n}", "func (l *Linenoise) historyPop(idx int) string {\n\tif idx < 0 {\n\t\t// pop the last entry\n\t\tidx = len(l.history) - 1\n\t}\n\tif idx >= 0 && idx < len(l.history) {\n\t\ts := l.history[idx]\n\t\tl.history = append(l.history[:idx], l.history[idx+1:]...)\n\t\treturn s\n\t}\n\t// nothing to pop\n\treturn \"\"\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 (l *idList) Back() *idElement {\n\tif l.len == 0 {\n\t\treturn nil\n\t}\n\treturn l.root.prev\n}", "func (q *QuestionnaireT) Prev() int {\n\tpg, _ := q.prevInNavi()\n\treturn pg\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 (it *Iterator) Prev() {\n\tit.listIter.Prev()\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 (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 (b *BlockChain) GetPrevHash() (ret [32]byte) {\n\tb.mux.RLock()\n\tdefer b.mux.RUnlock()\n\tcopy(ret[:], b.leafHash[:])\n\treturn\n}", "func (e *Element) Prev() *Element {\n\tif p := e.prev; e != nil && p.queue.root != p {\n\t\treturn p\n\t}\n\treturn nil\n}", "func (c *Cursor) Previous() {\n\tc.pos--\n}", "func (e *Node) Prev() *Node {\n\treturn e.prev\n}", "func (e *Node) Prev() *Node {\n\treturn e.prev\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 (n *Node) Prev() *Node {\n\treturn n.previous\n}", "func (pagedList *PagedList) GetPreviousPage() (*Embed, error) {\n\treturn pagedList.GetPage(pagedList.PageNumber - 1)\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 (p *parser) previous() lexer.Token {\n\treturn p.tokens[p.current-1]\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) Prev() *Node {\n\treturn n.prev\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 (tw *TimeWheel) getPreviousTickIndex() int {\n\ttw.mux.Lock()\n\tdefer tw.mux.Unlock()\n\n\tcti := tw.currentTickIndex\n\t// When cti==0 then cti's id wiil be ticksOfWheel-1\n\tif 0 == cti {\n\t\treturn tw.ticksOfWheel - 1\n\t}\n\treturn cti - 1\n}", "func (e *Element) AwayPrev() *Element {\n\tif e == nil || e.away == nil {\n\t\treturn nil\n\t}\n\treturn e.away.Prev()\n}", "func (e *OrderedMapElement[K, V]) Prev() *OrderedMapElement[K, V] {\n\tif !e.element.left.Empty() {\n\t\tlineage := e.lineage.Push(e.element)\n\t\tm := e.element.left\n\t\tfor !m.Empty() && m.right != nil {\n\t\t\tlineage = lineage.Push(m)\n\t\t\tm = m.right\n\t\t}\n\t\treturn &OrderedMapElement[K, V]{\n\t\t\tlineage: lineage,\n\t\t\telement: m,\n\t\t}\n\t}\n\tfor l := e.lineage; !l.Empty(); l = l.Pop() {\n\t\tif l.Peek().key < e.element.key {\n\t\t\treturn &OrderedMapElement[K, V]{\n\t\t\t\tlineage: l.Pop(),\n\t\t\t\telement: l.Peek(),\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (o *Pagination) GetPreviousUri() string {\n\tif o == nil || o.PreviousUri == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.PreviousUri\n}", "func (c Git) GetPreviousTag(tag, gitPath string) (string, error) {\n\tout, err := c.PreviousTagGetter(\"git\", \"-C\", gitPath, \"describe\", \"--tags\", \"--abbrev=0\", tag+\"^\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn strings.TrimSpace(out), 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 (el *Element) MustPrevious() *Element {\n\tparent, err := el.Previous()\n\tel.e(err)\n\treturn parent\n}", "func (t *Tree) Prev(rr dns.RR) *Elem {\n\tif t.Root == nil {\n\t\treturn nil\n\t}\n\tn := t.Root.floor(rr)\n\tif n == nil {\n\t\treturn nil\n\t}\n\treturn n.Elem\n}", "func (machine *Machine) Previous() StateType {\n\tmachine.lock.Lock()\n\tdefer machine.lock.Unlock()\n\n\treturn machine.previous\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 (self *Graphics) PreviousPosition() *Point{\n return &Point{self.Object.Get(\"previousPosition\")}\n}", "func getPrevCommand(g *gocui.Gui, v *gocui.View) error {\n\ts := v.Buffer()\n\ts = screen.sb.GetPrevCommand(s)\n\tif len(s) == 0 {\n\t\tresetCursor(v)\n\t}\n\n\tv.Clear()\n\tv.Write([]byte(s))\n\n\treturn nil\n}", "func (p *Pagination) previousPage() int {\n\tif !p.hasPrevious() {\n\t\treturn p.CurrentPage\n\t}\n\treturn p.CurrentPage - 1\n}", "func (parent *node) previousChild(child dom.Node) dom.Node {\n\tif child == nil {\n\t\treturn nil\n\t}\n\tfor i, c := range parent.children {\n\t\tif c != child {\n\t\t\tcontinue\n\t\t}\n\t\tif i > 0 {\n\t\t\treturn parent.children[i-1]\n\t\t} else {\n\t\t\treturn nil\n\t\t}\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 (t *touch) GetPreviousLocationInView() Point {\n\treturn &point{t.Call(\"getPreviousLocationInView\")}\n}", "func (ref *UIElement) PreviousContents() []*UIElement {\n\treturn ref.SliceOfUIElementAttr(PreviousContentsAttribute)\n}", "func (chunk *ResultNodeListChunk) Prev() *ResultNodeListChunk {\n\treturn chunk.prev\n}", "func (m *Migrate) PreviousFrom(version string) (string, error) {\n\tfor key, ver := range m.versions {\n\t\tif ver == version {\n\t\t\tif key > 0 {\n\t\t\t\treturn m.versions[key-1], nil\n\t\t\t}\n\n\t\t\treturn \"0\", nil\n\t\t}\n\t}\n\n\treturn \"\", errors.New(\"cannot find specified migration\")\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) SetPrevious(previous string) {\n\to.Previous = previous\n}", "func (i treapIter) prev() treapIter {\n\ti.t = i.t.pred(i.f)\n\treturn i\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 (m *Model) PrevPage() {\n\tif m.Page > 0 {\n\t\tm.Page--\n\t}\n}", "func getPreviousSnapshot(\n\titems []*configservice.ConfigurationItem,\n\tt time.Time,\n\tbucket, region string,\n\tsvc s3iface.S3API) (*s3.Object, string, error) {\n\t// Get time from three hours before change...since snapshots are taken every\n\t// three hours, this will ensure we are looking in the correct folder by date\n\tprevTime := t.Add(time.Hour * time.Duration(-snapshotFrequency))\n\tyear, month, day := prevTime.Date()\n\taccount := aws.StringValue(items[0].AccountId)\n\tprefix := strings.Join([]string{\n\t\t\"awsconfig\",\n\t\t\"AWSLogs\",\n\t\taccount,\n\t\t\"Config\",\n\t\tregion,\n\t\tstrconv.Itoa(year),\n\t\tstrconv.Itoa(int(month)),\n\t\tstrconv.Itoa(day),\n\t\t\"ConfigSnapshot\",\n\t}, \"/\")\n\tinput := &s3.ListObjectsInput{\n\t\tBucket: aws.String(bucket),\n\t\tPrefix: aws.String(prefix),\n\t}\n\n\tresults, err := svc.ListObjects(input)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tfor _, o := range results.Contents {\n\t\tm := aws.TimeValue(o.LastModified)\n\t\tif m.After(prevTime) && m.Before(t) {\n\t\t\treturn getSnapshot(svc, bucket, o)\n\t\t}\n\t}\n\n\treturn nil, \"\", errors.New(\"snapshot not found\")\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}", "func (resp *BytesWatchPutResp) GetPrevValue() []byte {\n\treturn resp.prevValue\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 (s *State) PreviousCounter() uint32 {\n\treturn s.previousCounter\n}", "func (o *Note) GetPrevSubKey() string { return o.SubKey }", "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 (o *MovableObject) Prev() {\n\to.point.X -= o.Arrow.X\n\to.point.Y -= o.Arrow.Y\n}", "func (self *TileSprite) PreviousPosition() *Point{\n return &Point{self.Object.Get(\"previousPosition\")}\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 (n *Node) Prev() *Node {\n\tif n.list != nil && n.prev != &n.list.root {\n\t\treturn n.prev\n\t}\n\treturn nil\n}", "func (i *LevelIterator) Prev() *FileMetadata {\n\tif i.iter.r == nil {\n\t\treturn nil\n\t}\n\tif invariants.Enabled && (i.iter.pos < 0 || (i.start != nil && cmpIter(i.iter, *i.start) < 0)) {\n\t\tpanic(\"pebble: cannot prev backward-exhausted iterator\")\n\t}\n\ti.iter.prev()\n\tif !i.iter.valid() {\n\t\treturn nil\n\t}\n\treturn i.skipFilteredBackward(i.iter.cur())\n}", "func (n *Node) Prev() *Node {\n\tif p := n.prev; n.list != nil && n != &n.list.root {\n\t\treturn p\n\t}\n\treturn nil\n}", "func (resp *BytesWatchDelResp) GetPrevValue() []byte {\n\treturn nil\n}", "func (as appendStrategy) previous() error {\n\treturn as.previousErr\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 (o *Cell) GetPrevX() int { return o.X }", "func (p *Polygon) prevVertex(i int) *PolygonVertex {\n\tif i == 0 {\n\t\tif p.closed {\n\t\t\treturn &p.vlist[len(p.vlist)-1]\n\t\t}\n\t\treturn nil\n\t}\n\treturn &p.vlist[i-1]\n}" ]
[ "0.7453633", "0.71359205", "0.7092377", "0.70064306", "0.66395694", "0.6634504", "0.66225123", "0.65715575", "0.6396531", "0.6357935", "0.63571906", "0.6289258", "0.62834173", "0.62746674", "0.62656605", "0.6253417", "0.6253129", "0.6231659", "0.6221888", "0.62133807", "0.6210267", "0.6204433", "0.61841124", "0.6175107", "0.6169671", "0.6168888", "0.615464", "0.61396503", "0.6097435", "0.6096977", "0.6089762", "0.60851383", "0.6064444", "0.6055089", "0.60547733", "0.6037831", "0.6036985", "0.603004", "0.6013201", "0.59851253", "0.5979449", "0.5971118", "0.5963418", "0.5947685", "0.59401184", "0.5933546", "0.59310293", "0.5921668", "0.5906001", "0.5906001", "0.5887594", "0.58809274", "0.5871013", "0.5864344", "0.5854429", "0.58536476", "0.58472973", "0.584456", "0.58407676", "0.5839549", "0.58356744", "0.5816532", "0.5812052", "0.5805526", "0.57938087", "0.5791952", "0.5790251", "0.57877773", "0.5782197", "0.57780075", "0.5771296", "0.57708645", "0.5770164", "0.57659906", "0.57636297", "0.57537097", "0.5753582", "0.57528484", "0.5748571", "0.5734716", "0.5733646", "0.5720463", "0.571207", "0.5701463", "0.5688887", "0.56848603", "0.5683962", "0.5683588", "0.56794745", "0.5663747", "0.5662964", "0.56621605", "0.56485057", "0.5644845", "0.564162", "0.56308866", "0.56210136", "0.5615113", "0.5614194", "0.5609741" ]
0.7345694
1
HistoryAdd adds a new entry to the history.
func (l *Linenoise) HistoryAdd(line string) { if l.historyMaxlen == 0 { return } // don't re-add the last entry if len(l.history) != 0 && line == l.history[len(l.history)-1] { return } // add the line to the history if len(l.history) == l.historyMaxlen { // remove the first entry l.historyPop(0) } l.history = append(l.history, line) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *History) Add(input string) {\n\th.histories = append(h.histories, input)\n\th.Clear()\n}", "func (h *History) Add(entry string) {\n\th.lock.Lock()\n\tdefer h.lock.Unlock()\n\n\tmax := cap(h.entries)\n\th.head = (h.head + 1) % max\n\th.entries[h.head] = entry\n\tif h.size < max {\n\t\th.size++\n\t}\n}", "func (bh *browserHistory) Add(record string) {\n\tbh.Records = append(bh.Records, record)\n}", "func AddHistory(content string) error {\n\tins := getInstance()\n\treturn ins.SaveHistory(content)\n}", "func (e *TarantoolEngine) addHistory(chID ChannelID, message Message, size, lifetime int64) (err error) {\n\t// not implemented\n\treturn\n}", "func (h *History) Add(action []*Action) {\n\th.actions = append(h.actions, action)\n\th.head++\n}", "func (g *Generator) AddHistory(history ispec.History) {\n\tg.image.History = append(g.image.History, history)\n}", "func (s *Client) AddHistory(username, input, reply string) {\n\ts.Init(username)\n\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\ttx, _ := s.db.Begin()\n\tstmt, _ := tx.Prepare(`INSERT INTO history (user_id, input,reply)VALUES((SELECT id FROM users WHERE username = ?),?,?);`)\n\tdefer stmt.Close()\n\tstmt.Exec(username, input, reply)\n\ttx.Commit()\n}", "func (d *Dao) Add(ctx context.Context, h *model.History) error {\n\tvalueByte, err := json.Marshal(h)\n\tif err != nil {\n\t\tlog.Error(\"json.Marshal(%v) error(%v)\", h, err)\n\t\treturn err\n\t}\n\tfValues := make(map[string][]byte)\n\tcolumn := d.column(h.Aid, h.TP)\n\tfValues[column] = valueByte\n\tkey := hashRowKey(h.Mid)\n\tvalues := map[string]map[string][]byte{family: fValues}\n\tctx, cancel := context.WithTimeout(ctx, time.Duration(d.conf.Info.WriteTimeout))\n\tdefer cancel()\n\tif _, err = d.info.PutStr(ctx, tableInfo, key, values); err != nil {\n\t\tlog.Error(\"info.PutStr error(%v)\", err)\n\t}\n\treturn nil\n}", "func (d *Dao) AddHistoryCache(c context.Context, tp int32, oid, timestamp int64, value []byte) (err error) {\n\tvar (\n\t\tconn = d.dmMC.Get(c)\n\t\tkey = keyHistory(tp, oid, timestamp)\n\t)\n\tdefer conn.Close()\n\titem := &memcache.Item{\n\t\tKey: key,\n\t\tValue: value,\n\t\tExpiration: d.historyExpire,\n\t}\n\tif err = conn.Set(item); err != nil {\n\t\tlog.Error(\"conn.Set(%s) error(%v)\", key, err)\n\t}\n\treturn\n}", "func (ht *historyTable) add(m Move, delta int32) {\n\th := historyHash(m)\n\tif ht[h].move != m {\n\t\tht[h] = historyEntry{stat: delta, move: m}\n\t} else {\n\t\tht[h].stat += delta\n\t}\n}", "func (h *History) Add(key int, input, output interface{}, start, end int64) {\n\th.Lock()\n\tdefer h.Unlock()\n\tif _, exists := h.shard[key]; !exists {\n\t\th.shard[key] = make([]*operation, 0)\n\t}\n\to := &operation{input, output, start, end}\n\th.shard[key] = append(h.shard[key], o)\n\th.operations = append(h.operations, o)\n}", "func (h *History) Add(key int, input, output interface{}, start, end int64) {\n\th.Lock()\n\tdefer h.Unlock()\n\tif _, exists := h.shard[key]; !exists {\n\t\th.shard[key] = make([]*operation, 0)\n\t}\n\to := &operation{input, output, start, end}\n\th.shard[key] = append(h.shard[key], o)\n\th.operations = append(h.operations, o)\n}", "func (pu *PatientrecordUpdate) AddHistorytaking(h ...*Historytaking) *PatientrecordUpdate {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn pu.AddHistorytakingIDs(ids...)\n}", "func (puo *PatientrecordUpdateOne) AddHistorytaking(h ...*Historytaking) *PatientrecordUpdateOne {\n\tids := make([]int, len(h))\n\tfor i := range h {\n\t\tids[i] = h[i].ID\n\t}\n\treturn puo.AddHistorytakingIDs(ids...)\n}", "func (h *VersionHistories) AddVersionHistory(\n\tv *VersionHistory,\n) (bool, int, error) {\n\n\tif v == nil {\n\t\treturn false, 0, &shared.BadRequestError{Message: \"version histories is null.\"}\n\t}\n\n\t// assuming existing version histories inside are valid\n\tincomingFirstItem, err := v.GetFirstItem()\n\tif err != nil {\n\t\treturn false, 0, err\n\t}\n\n\tcurrentVersionHistory, err := h.GetVersionHistory(h.CurrentVersionHistoryIndex)\n\tif err != nil {\n\t\treturn false, 0, err\n\t}\n\tcurrentFirstItem, err := currentVersionHistory.GetFirstItem()\n\tif err != nil {\n\t\treturn false, 0, err\n\t}\n\n\tif incomingFirstItem.Version != currentFirstItem.Version {\n\t\treturn false, 0, &shared.BadRequestError{Message: \"version history first item does not match.\"}\n\t}\n\n\t// TODO maybe we need more strict validation\n\n\tnewVersionHistory := v.Duplicate()\n\th.Histories = append(h.Histories, newVersionHistory)\n\tnewVersionHistoryIndex := len(h.Histories) - 1\n\n\t// check if need to switch current branch\n\tnewLastItem, err := newVersionHistory.GetLastItem()\n\tif err != nil {\n\t\treturn false, 0, err\n\t}\n\tcurrentLastItem, err := currentVersionHistory.GetLastItem()\n\tif err != nil {\n\t\treturn false, 0, err\n\t}\n\n\tcurrentBranchChanged := false\n\tif newLastItem.Version > currentLastItem.Version {\n\t\tcurrentBranchChanged = true\n\t\th.CurrentVersionHistoryIndex = newVersionHistoryIndex\n\t}\n\treturn currentBranchChanged, newVersionHistoryIndex, nil\n}", "func AppendHistory(db *gorm.DB, id int, newHistory []History) {\n\tvar lastMatch History\n\tdb.Where(\"player_id = ?\", id).Order(\"match_date desc\").First(&lastMatch)\n\n\tfor i := 0; i < len(newHistory); i++ {\n\t\tif newHistory[i].MatchDate.After(lastMatch.MatchDate) {\n\t\t\tdb.Create(&newHistory[i])\n\t\t}\n\t}\n}", "func (h *StmtHistory) Add(st sqlexec.Statement, stmtCtx *stmtctx.StatementContext) {\n\ts := &stmtRecord{\n\t\tst: st,\n\t\tstmtCtx: stmtCtx,\n\t}\n\th.history = append(h.history, s)\n}", "func (n *NodeManager) NewHistoryEntry(entry interface{}) error {\n\tif err := n.DB.Create(&entry).Error; err != nil {\n\t\treturn fmt.Errorf(\"Create newNodeHistoryEntry %v\", err)\n\t}\n\treturn nil\n}", "func (cp *ChangeLog) Add(newEntry LogEntry) {\n\tnewEntry.assertValid()\n\tif len(cp.Entries) == 0 || newEntry.Sequence == cp.Since {\n\t\tcp.Since = newEntry.Sequence - 1\n\t}\n\tcp.Entries = append(cp.Entries, &newEntry)\n}", "func (x *XmpMM) AppendVersionHistory(action ActionType, modifier, changed string, date xmp.Date) {\n\t// append change to last version\n\tv := x.GetLastVersion()\n\n\t// make new version if none exists or if list does not contain\n\t// entry for the current version\n\tif v == nil || v.Version != x.VersionID {\n\t\tv = &StVersion{\n\t\t\tEvent: ResourceEvent{\n\t\t\t\tAction: action,\n\t\t\t\tChanged: xmpdm.NewPartList(changed),\n\t\t\t\tInstanceID: x.InstanceID,\n\t\t\t\tSoftwareAgent: xmp.Agent,\n\t\t\t\tWhen: date,\n\t\t\t},\n\t\t\tModifier: modifier,\n\t\t\tModifyDate: date,\n\t\t\tVersion: x.VersionID,\n\t\t}\n\t\tx.AddVersion(v)\n\t\treturn\n\t}\n\tv.Event.Changed.Add(changed)\n}", "func AddToHistory(history History, result map[string]string, now time.Time) History {\n\tfor key, val := range result {\n\t\tkeyHist, ok := history[key]\n\t\tif !ok {\n\t\t\tkeyHist = make(map[string]time.Time)\n\t\t\thistory[key] = keyHist\n\t\t}\n\t\tkeyHist[val] = now\n\t}\n\n\treturn history\n}", "func (tuo *TransactionfactorUpdateOne) AddTransactionhistory(t ...*Transactionfactorhistory) *TransactionfactorUpdateOne {\n\tids := make([]int, len(t))\n\tfor i := range t {\n\t\tids[i] = t[i].ID\n\t}\n\treturn tuo.AddTransactionhistoryIDs(ids...)\n}", "func (tu *TransactionfactorUpdate) AddTransactionhistory(t ...*Transactionfactorhistory) *TransactionfactorUpdate {\n\tids := make([]int, len(t))\n\tfor i := range t {\n\t\tids[i] = t[i].ID\n\t}\n\treturn tu.AddTransactionhistoryIDs(ids...)\n}", "func (h *changepointHeuristic) addToHistory(positionCounts counts) {\n\tif positionCounts.Runs > 0 {\n\t\th.addedUnexpectedRuns = positionCounts.HasUnexpected > 0\n\t\th.addedExpectedRuns = (positionCounts.Runs - positionCounts.HasUnexpected) > 0\n\t}\n\tif positionCounts.Retried > 0 {\n\t\th.addedUnexpectedAfterRetry = positionCounts.UnexpectedAfterRetry > 0\n\t\th.addedExpectedAfterRetry = (positionCounts.Retried - positionCounts.UnexpectedAfterRetry) > 0\n\t}\n}", "func HistoryRecord(env *Environment, command []string, date time.Time, code int) error {\n\tif env == nil {\n\t\treturn nil\n\t}\n\n\thistoryPath := env.LocalPath(HistoryDir)\n\tif utils.IsNotExist(historyPath) {\n\t\terr := utils.MkdirAll(historyPath, 0755)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\th := &historyRow{\n\t\tCommand: strings.Join(command, \" \"),\n\t\tDate: date,\n\t\tCode: code,\n\t}\n\n\treturn h.save(historyPath)\n}", "func (l *RaftLog) addEntry(term uint64, data []byte) {\n\tnewEntry := pb.Entry{\n\t\tIndex: l.LastIndex() + 1,\n\t\tTerm: term,\n\t\tData: data,\n\t}\n\tl.entries = append(l.entries, newEntry)\n\tl.pendingEntries = append(l.pendingEntries, newEntry)\n}", "func saveAddHistoryTime(w http.ResponseWriter, r *http.Request, t map[string]interface{}) {\n\tf := firego.NewGAE(appengine.NewContext(r), FIRE_URL)\n\tf.Auth(FIRE_AUTH)\n\tif e := f.Update(t); e == nil {\n\t\tif _, e := f.Push(nil); e == nil {\n\t\t\tstatus(w, fmt.Sprintf(\"updated history: %v\", t[\"lastSave\"]), 200)\n\t\t} else {\n\t\t\ts := fmt.Sprintf(\"Firebase push error: %v\", e)\n\t\t\tstatus(w, s, 303)\n\t\t}\n\t} else {\n\t\ts := fmt.Sprintf(\"Firebase update command error: %v\", e)\n\t\tstatus(w, s, 304)\n\t}\n}", "func (h CRConfigHistoryThreadsafe) Add(i *CRConfigStat) {\n\th.m.Lock()\n\tdefer h.m.Unlock()\n\n\tif *h.length != 0 {\n\t\tlast := (*h.hist)[(*h.pos-1)%*h.limit]\n\t\tdatesEqual := (i.Stats.DateUnixSeconds == nil && last.Stats.DateUnixSeconds == nil) || (i.Stats.DateUnixSeconds != nil && last.Stats.DateUnixSeconds != nil && *i.Stats.DateUnixSeconds == *last.Stats.DateUnixSeconds)\n\t\tcdnsEqual := (i.Stats.CDNName == nil && last.Stats.CDNName == nil) || (i.Stats.CDNName != nil && last.Stats.CDNName != nil && *i.Stats.CDNName == *last.Stats.CDNName)\n\t\treqAddrsEqual := i.ReqAddr == last.ReqAddr\n\t\tif reqAddrsEqual && datesEqual && cdnsEqual {\n\t\t\treturn\n\t\t}\n\t}\n\n\t(*h.hist)[*h.pos] = *i\n\t*h.pos = (*h.pos + 1) % *h.limit\n\tif *h.length < *h.limit {\n\t\t*h.length++\n\t}\n}", "func (h *History) AddOperation(key int, o *operation) {\n\th.Lock()\n\tdefer h.Unlock()\n\tif _, exists := h.shard[key]; !exists {\n\t\th.shard[key] = make([]*operation, 0)\n\t}\n\th.shard[key] = append(h.shard[key], o)\n\th.operations = append(h.operations, o)\n}", "func (hll *HyperLogLog) Add(s string) {\n\th := hash(s)\n\tbinaryIndex, unusedBinary := hll.splitBinary(h)\n\thll.bucketGroup[binaryIndex].updateLongestRun(unusedBinary)\n}", "func (dc *DigestCache) Add(hash []byte, text []byte) {\n\tdc.Records[string(hash)] = text\n}", "func InsertHistory(history *models.History , o orm.Ormer) (bool){\n\tnum , err:= o.Insert(history)\n\tif (err ==nil){\n\t\tfmt.Println(\"mysql row affected nums: \" , num)\n\t\treturn true\n\t}\n\treturn false;\n}", "func (uuo *UserUpdateOne) AddAuthHistories(a ...*Auth) *UserUpdateOne {\n\tids := make([]int, len(a))\n\tfor i := range a {\n\t\tids[i] = a[i].ID\n\t}\n\treturn uuo.AddAuthHistoryIDs(ids...)\n}", "func (ptr *terminalPrompter) AppendHistory(command string) {\n\tptr.State.AppendHistory(command)\n}", "func (l *List) Add(entry *Process) {\r\n\tl.list.PushBack(entry)\r\n}", "func (s *MemStateStore) Add(state, url string) error {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\n\tif state == \"\" {\n\t\treturn fmt.Errorf(\"State argument not provided\")\n\t}\n\n\ts.states[state] = url\n\n\treturn nil\n}", "func (s *SmartContract) addAuditLogEntry(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\n\tif len(args) != 11 {\n\t\treturn shim.Error(\"Incorrect number of arguments.\")\n\t}\n\n\ttxntmsp, err := APIstub.GetTxTimestamp()\n\tif err != nil {\n\t\treturn shim.Error(\"Error converting timestamp\")\n\t}\n\ttime := time.Unix(txntmsp.Seconds, int64(txntmsp.Nanos)).String()\n\n\tauditLog := AuditLog{}\n\tauditLog.LogID = args[0]\n\tauditLog.Timestamp = time\n\tauditLog.UserIdentity = args[1]\n\tauditLog.UserRole = args[2]\n\tauditLog.MSP = args[3]\n\tauditLog.Channel = args[4]\n\tauditLog.ChaincodeVersion = args[5]\n\tauditLog.ChaincodeName = args[6]\n\tauditLog.FunctionCall = args[7]\n\tauditLog.RecordID = args[8]\n\tauditLog.RecordHash = args[9]\n\tauditLog.Status = args[10]\n\n\tauditLogAsBytes, _ := json.Marshal(auditLog)\n\tAPIstub.PutState(args[0], auditLogAsBytes)\n\n\treturn shim.Success(nil)\n}", "func (o *Post) AddPostHistories(ctx context.Context, exec boil.ContextExecutor, insert bool, related ...*PostHistory) error {\n\tvar err error\n\tfor _, rel := range related {\n\t\tif insert {\n\t\t\trel.PostID = o.ID\n\t\t\tif err = rel.Insert(ctx, exec, boil.Infer()); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to insert into foreign table\")\n\t\t\t}\n\t\t} else {\n\t\t\tupdateQuery := fmt.Sprintf(\n\t\t\t\t\"UPDATE \\\"post_histories\\\" SET %s WHERE %s\",\n\t\t\t\tstrmangle.SetParamNames(\"\\\"\", \"\\\"\", 1, []string{\"post_id\"}),\n\t\t\t\tstrmangle.WhereClause(\"\\\"\", \"\\\"\", 2, postHistoryPrimaryKeyColumns),\n\t\t\t)\n\t\t\tvalues := []interface{}{o.ID, rel.ID}\n\n\t\t\tif boil.DebugMode {\n\t\t\t\tfmt.Fprintln(boil.DebugWriter, updateQuery)\n\t\t\t\tfmt.Fprintln(boil.DebugWriter, values)\n\t\t\t}\n\n\t\t\tif _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to update foreign table\")\n\t\t\t}\n\n\t\t\trel.PostID = o.ID\n\t\t}\n\t}\n\n\tif o.R == nil {\n\t\to.R = &postR{\n\t\t\tPostHistories: related,\n\t\t}\n\t} else {\n\t\to.R.PostHistories = append(o.R.PostHistories, related...)\n\t}\n\n\tfor _, rel := range related {\n\t\tif rel.R == nil {\n\t\t\trel.R = &postHistoryR{\n\t\t\t\tPost: o,\n\t\t\t}\n\t\t} else {\n\t\t\trel.R.Post = o\n\t\t}\n\t}\n\treturn nil\n}", "func (m *RestaurantMutation) AddHistoryIDs(ids ...int) {\n\tif m.histories == nil {\n\t\tm.histories = make(map[int]struct{})\n\t}\n\tfor i := range ids {\n\t\tm.histories[ids[i]] = struct{}{}\n\t}\n}", "func (b *RaftBalloon) Add(event []byte) (*balloon.Snapshot, error) {\n\tcmd := &commands.AddEventCommand{Event: event}\n\tresp, err := b.raftApply(commands.AddEventCommandType, cmd)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb.metrics.Adds.Inc()\n\n\tsnapshot := resp.(*fsmAddResponse).snapshot\n\tp := protocol.Snapshot(*snapshot)\n\n\t//Send snapshot to the snapshot channel\n\tb.snapshotsCh <- &p // TODO move this to an upper layer (shard manager?)\n\n\treturn snapshot, nil\n}", "func appendUFATransactionHistory(stub shim.ChaincodeStubInterface, ufanumber string, payload string) error {\n\tvar recordList []string\n\n\tlogger.Info(\"Appending to transaction history \" + ufanumber)\n\trecBytes, _ := stub.GetState(UFA_TRXN_PREFIX + ufanumber)\n\n\tif recBytes == nil {\n\t\tlogger.Info(\"Updating the transaction history for the first time\")\n\t\trecordList = make([]string, 0)\n\t} else {\n\t\terr := json.Unmarshal(recBytes, &recordList)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"Failed to unmarshal appendUFATransactionHistory \")\n\t\t}\n\t}\n\trecordList = append(recordList, payload)\n\tbytesToStore, _ := json.Marshal(recordList)\n\tlogger.Info(\"After updating the transaction history\" + string(bytesToStore))\n\tstub.PutState(UFA_TRXN_PREFIX+ufanumber, bytesToStore)\n\tlogger.Info(\"Appending to transaction history \" + ufanumber + \" Done!!\")\n\treturn nil\n}", "func appendUFATransactionHistory(stub shim.ChaincodeStubInterface, ufanumber string, payload string) error {\r\n\tvar recordList []string\r\n\r\n\tlogger.Info(\"Appending to transaction history \" + ufanumber)\r\n\trecBytes, _ := stub.GetState(UFA_TRXN_PREFIX + ufanumber)\r\n\r\n\tif recBytes == nil {\r\n\t\tlogger.Info(\"Updating the transaction history for the first time\")\r\n\t\trecordList = make([]string, 0)\r\n\t} else {\r\n\t\terr := json.Unmarshal(recBytes, &recordList)\r\n\t\tif err != nil {\r\n\t\t\treturn errors.New(\"Failed to unmarshal appendUFATransactionHistory \")\r\n\t\t}\r\n\t}\r\n\trecordList = append(recordList, payload)\r\n\tbytesToStore, _ := json.Marshal(recordList)\r\n\tlogger.Info(\"After updating the transaction history\" + string(bytesToStore))\r\n\tstub.PutState(UFA_TRXN_PREFIX+ufanumber, bytesToStore)\r\n\tlogger.Info(\"Appending to transaction history \" + ufanumber + \" Done!!\")\r\n\treturn nil\r\n}", "func (puo *PatientrecordUpdateOne) AddHistorytakingIDs(ids ...int) *PatientrecordUpdateOne {\n\tpuo.mutation.AddHistorytakingIDs(ids...)\n\treturn puo\n}", "func (d *Dao) AddCache(c context.Context, mid int64, h *model.History) (err error) {\n\tvar (\n\t\tb []byte\n\t\tidxKey, key = keyIndex(mid), keyHistory(mid)\n\t)\n\tif b, err = json.Marshal(h); err != nil {\n\t\treturn\n\t}\n\tconn := d.redis.Get(c)\n\tdefer conn.Close()\n\tif err = conn.Send(\"ZADD\", idxKey, h.Unix, h.Aid); err != nil {\n\t\tlog.Error(\"conn.Send(ZADD %s,%d) error(%v)\", key, h.Aid, err)\n\t\treturn\n\t}\n\tif err = conn.Send(\"HSET\", key, h.Aid, string(b)); err != nil {\n\t\tlog.Error(\"conn.Send(HSET %s,%d) error(%v)\", key, h.Aid, err)\n\t\treturn\n\t}\n\tif err = conn.Send(\"EXPIRE\", idxKey, d.expire); err != nil {\n\t\tlog.Error(\"conn.Send(EXPIRE) error(%v)\", err)\n\t\treturn\n\t}\n\tif err = conn.Send(\"EXPIRE\", key, d.expire); err != nil {\n\t\tlog.Error(\"conn.Send(EXPIRE) error(%v)\", err)\n\t\treturn\n\t}\n\tif err = conn.Flush(); err != nil {\n\t\tlog.Error(\"conn.Flush() error(%v)\", err)\n\t\treturn\n\t}\n\tfor i := 0; i < 2+2; i++ {\n\t\tif _, err = conn.Receive(); err != nil {\n\t\t\tlog.Error(\"conn.Receive() error(%v)\", err)\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (uu *UserUpdate) AddAuthHistories(a ...*Auth) *UserUpdate {\n\tids := make([]int, len(a))\n\tfor i := range a {\n\t\tids[i] = a[i].ID\n\t}\n\treturn uu.AddAuthHistoryIDs(ids...)\n}", "func (h *HistoricalRecords) Append(tr *TransferRecord) {\n\th.mutex.Lock()\n\th.records = append(h.records, tr)\n\th.mutex.Unlock()\n}", "func (f *PipelineAddFunc) History() []PipelineAddFuncCall {\n\treturn f.history\n}", "func add(c *cli.Context) error {\n\tproject := c.Args().First()\n\n\tslug, err := getSlug(project)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err)\n\t\treturn err\n\t}\n\tabsolutePath, _ := filepath.Abs(project)\n\n\trecord := ledger.Record{Path: absolutePath, Slug: slug}\n\trecord.RemoveFromLedger()\n\trecord.AddToLedger()\n\n\treturn nil\n}", "func NewHistory(size int) *History {\n\treturn &History{\n\t\tentries: make([]string, size),\n\t}\n}", "func CreateHistory(c *gin.Context) {\n\tnewHistoryPoint := model.History{}\n\tuserID, _ := strconv.Atoi(c.Param(\"userId\"))\n\tbodyErr := c.BindJSON(&newHistoryPoint)\n\n\tspecificExercise := service.GetSpecificExercise(int(newHistoryPoint.RoutineSpecificExercisesID))\n\tassignedRoutine := service.GetAssignedRoutine(int(specificExercise.AssignedRoutinesID))\n\n\tif uint64(userID) != assignedRoutine.UserID {\n\t\tc.String(400, \"Bad request\")\n\t\treturn\n\t}\n\n\terr := service.CreateHistory(newHistoryPoint)\n\n\tif bodyErr == nil {\n\t\tif err != nil {\n\t\t\terror := service.GetGormErrorCode(err.Error())\n\n\t\t\tc.JSON(500, error)\n\t\t} else {\n\t\t\tc.String(200, \"ok\")\n\t\t}\n\t}\n}", "func (lw *StandardLogWriter) AddEntry(opEntry OperationEntry) {\n\tlw.OpEntries = append(lw.OpEntries, opEntry)\n}", "func (keyDB *KeyDB) AddHashChainEntry(\n\tdomain string,\n\tposition uint64,\n\tentry string,\n) error {\n\tdmn := identity.MapDomain(domain)\n\t_, err := keyDB.addHashChainEntryQuery.Exec(dmn, position, entry)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) History(asset int) *HistoryService {\n\treturn &HistoryService{service{c}, asset}\n}", "func (e *Entries) AddHash(hash *chainhash.Hash) {\n\t*e = append(*e, hash[:])\n}", "func (mnu *MedicalNoteUpdate) SetHistory(h *History) *MedicalNoteUpdate {\n\treturn mnu.SetHistoryID(h.ID)\n}", "func (z *zpoolctl) History(ctx context.Context, options string, pool string) *execute {\n\targs := []string{\"history\"}\n\tif len(options) > 0 {\n\t\targs = append(args, options)\n\t}\n\tif len(pool) > 0 {\n\t\targs = append(args, pool)\n\t}\n\treturn &execute{ctx: ctx, name: z.cmd, args: args}\n}", "func (pu *PatientrecordUpdate) AddHistorytakingIDs(ids ...int) *PatientrecordUpdate {\n\tpu.mutation.AddHistorytakingIDs(ids...)\n\treturn pu\n}", "func (c *Controller) AddNewURLEntry(urlEntry *URLEntry) {\n\tselect {\n\tcase <-c.ctx.Done():\n\t\treturn\n\tcase c.subTree <- urlEntry:\n\t}\n}", "func (l *Linenoise) HistorySave(fname string) {\n\tif len(l.history) == 0 {\n\t\treturn\n\t}\n\tf, err := os.Create(fname)\n\tif err != nil {\n\t\tlog.Printf(\"error opening %s\\n\", fname)\n\t\treturn\n\t}\n\t_, err = f.WriteString(strings.Join(l.history, \"\\n\"))\n\tif err != nil {\n\t\tlog.Printf(\"%s error writing %s\\n\", fname, err)\n\t}\n\tf.Close()\n}", "func (s *Summary) Add(line log.Line) {\n\ts.logs = append(s.logs, line)\n}", "func (db *BalanceDB) CreateHistoryLog(ctx context.Context, tx pgx.Tx, h *model.TransactionHistory) error {\n\t_, err := tx.Exec(ctx, `\n\t\tINSERT INTO \n\t\t\ttransaction_history\n\t\t\t(id_from, id_to, amount, comment, created_at)\n\t\tVALUES\n\t\t\t($1, $2, $3, $4, $5)\n\t`, h.IDFrom, h.IDTo, h.Amount, h.Comment, h.CreatedAt)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *Controller) AddNewRecordURLEntry(urlEntry *URLEntry) {\n\tselect {\n\tcase <-c.ctx.Done():\n\t\treturn\n\tcase c.record <- urlEntry:\n\t}\n}", "func (m *FlynnManifest) Add(version, commit string) error {\n\tversions := make(sortVersions, 0, len(m.Versions)+1)\n\tfor _, v := range m.Versions {\n\t\tif v.version() == version {\n\t\t\treturn errors.New(\"version already in manifest\")\n\t\t}\n\t\tversions = append(versions, v)\n\t}\n\tversions = append(versions, &FlynnVersion{Version: version, Commit: commit})\n\tsort.Sort(sort.Reverse(versions))\n\tm.Versions = make([]*FlynnVersion, 0, maxVersions)\n\tfor i := 0; i < len(versions) && i < maxVersions; i++ {\n\t\tm.Versions = append(m.Versions, versions[i].(*FlynnVersion))\n\t}\n\tm.Current = m.Versions[0]\n\treturn nil\n}", "func (c *Cache) Add(buildid int64, hash string) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\tc.hashes[buildid] = hash\n}", "func (s *storage) appendEntry(e *entry) {\n\tassert(e.index == s.lastLogIndex+1)\n\tw := new(bytes.Buffer)\n\tif err := e.encode(w); err != nil {\n\t\tpanic(bug{fmt.Sprintf(\"entry.encode(%d)\", e.index), err})\n\t}\n\tif err := s.log.Append(w.Bytes()); err != nil {\n\t\tpanic(opError(err, \"Log.Append\"))\n\t}\n\ts.lastLogIndex, s.lastLogTerm = e.index, e.term\n}", "func (h *History) AppendPass(seatIndex int) {\n\t*h = append(*h, Entry{\n\t\tType: PassEntryType,\n\t\tSeatIndex: seatIndex,\n\t})\n}", "func (h *History) AddResult(rtt time.Duration, err error) {\n h.Lock()\n\n h.results.PushFront(Result{RTT: rtt, Lost: err != nil})\n for h.results.Len() > 301 {\n e := h.results.Back()\n h.results.Remove(e)\n }\n h.Unlock()\n}", "func (p *logPusher) AddLogEntry(logEvent *Event) error {\n\tvar err error\n\tif logEvent != nil {\n\t\terr = logEvent.Validate(p.logger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tprevBatch := p.addLogEvent(logEvent)\n\t\tif prevBatch != nil {\n\t\t\terr = p.pushEventBatch(prevBatch)\n\t\t}\n\t}\n\treturn err\n}", "func (cache *Cache) AddEntry (path string) *FilePrint {\n ent, ok := cache.FilePrints[path]\n if ! ok {\n ent = new(FilePrint)\n ent.Local.Changed = true\n ent.Remote.Changed = true\n cache.FilePrints[path] = ent\n }\n return ent\n}", "func (m *Manager) AddRecord(thread string, stamp time.Time, contents map[string][]byte, sign bool) (bool, error) {\n\tr, err := record.New(m.self, thread, stamp, contents, sign)\n\tif log.If(err) {\n\t\treturn false, err\n\t}\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\treturn m.recent.Add(r)\n}", "func (h HyperLogLog) Add(ctx context.Context, values ...string) (int64, error) {\n\treq := newRequestSize(2+len(values), \"\\r\\n$5\\r\\nPFADD\\r\\n$\")\n\treq.addStringAndStrings(h.name, values)\n\treturn h.c.cmdInt(ctx, req)\n}", "func (f *Feed) AddEntry(\n\ttitle string,\n\turl string,\n\tid string,\n\tupdatedDate time.Time,\n\tpubDate time.Time,\n\tauthorName string,\n\tauthorURL string,\n\tauthorEmail string,\n\tcontentHTML string) error {\n\n\tf.Entries = append(f.Entries, Entry{\n\t\tTitle: title,\n\t\tLink: Link{\n\t\t\tRel: \"alternate\",\n\t\t\tType: \"text/html\",\n\t\t\tHref: url,\n\t\t},\n\t\tID: id,\n\t\tUpdated: updatedDate,\n\t\tPublished: pubDate,\n\t\tAuthor: Author{\n\t\t\tName: authorName,\n\t\t\tURI: authorURL,\n\t\t\tEmail: authorEmail,\n\t\t},\n\t\tContent: Content{\n\t\t\tType: \"html\",\n\t\t\tText: contentHTML,\n\t\t},\n\t})\n\n\treturn nil\n}", "func (*recentSearches) Add(ctx context.Context, q string) error {\n\tinsert := `INSERT INTO recent_searches (query) VALUES ($1)`\n\tif dbconn.Global == nil {\n\t\treturn errors.New(\"db connection is nil\")\n\t}\n\tres, err := dbconn.Global.ExecContext(ctx, insert, q)\n\tif err != nil {\n\t\treturn errors.Errorf(\"inserting %q into recentSearches table: %v\", q, err)\n\t}\n\tnrows, err := res.RowsAffected()\n\tif err != nil {\n\t\treturn errors.Errorf(\"getting number of affected rows: %v\", err)\n\t}\n\tif nrows == 0 {\n\t\treturn errors.Errorf(\"failed to insert row for query %q\", q)\n\t}\n\treturn nil\n}", "func (m *Member) AppendEntry(leader string, term uint64, value int64, prevLogID int64) (bool, error) {\n\tlog.Infoln(\"Requesting log entry of\", m.Name, \"Value\", value)\n\tvar conn *grpc.ClientConn\n\tconn, err := grpc.Dial(m.Address(), grpc.WithInsecure())\n\tif err != nil {\n\t\treturn false, NewRaftError(m, err)\n\t}\n\tdefer conn.Close()\n\tapi := raftapi.NewRaftServiceClient(conn)\n\tctx := context.Background()\n\tresponse, err := api.AppendEntry(ctx, &raftapi.AppendEntryRequest{\n\t\tTerm: term,\n\t\tLeader: leader,\n\t\tPrevLogId: prevLogID,\n\t\tPrevLogTerm: term,\n\t\tEntry: &raftapi.LogEntry{\n\t\t\tTerm: term,\n\t\t\tValue: value,\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn false, NewRaftError(m, err)\n\t}\n\n\treturn response.Success, nil\n}", "func (l *Linenoise) historySet(idx int, line string) {\n\tl.history[len(l.history)-1-idx] = line\n}", "func NewHistory() *History {\n\treturn &History{\n\t\tshard: make(map[int][]*operation),\n\t\toperations: make([]*operation, 0),\n\t}\n}", "func NewHistory() *History {\n\treturn &History{\n\t\tshard: make(map[int][]*operation),\n\t\toperations: make([]*operation, 0),\n\t}\n}", "func (db *pg) Add(ctx context.Context, action string) error {\n\tuserID := ctx.Value(\"userId\").(string)\n\tconst stmt = `INSERT INTO audit.\"Logs\" VALUES (NOW(), $1, $2);`\n\tif _, err := db.ExecContext(ctx, stmt, userID, action); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (uuo *UserUpdateOne) AddJobHistories(j ...*JobHistory) *UserUpdateOne {\n\tids := make([]int, len(j))\n\tfor i := range j {\n\t\tids[i] = j[i].ID\n\t}\n\treturn uuo.AddJobHistoryIDs(ids...)\n}", "func (f *StatsReq) AddLog(pageLog *PageLog) {\n\n}", "func (tuo *TransactionfactorUpdateOne) AddTransactionhistoryIDs(ids ...int) *TransactionfactorUpdateOne {\n\ttuo.mutation.AddTransactionhistoryIDs(ids...)\n\treturn tuo\n}", "func (rl *readline) WriteHistory() error {\n\tf, err := os.OpenFile(rl.historyFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = rl.State.WriteHistory(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (router *Router) AddEntry(origin, address string, onlyIfNotExists bool) bool {\n\toldValue, found := router.GetAddress(origin)\n\tisNew := false\n\tif !found || (!onlyIfNotExists && oldValue.String() != address) {\n\t\tisNew = true\n\t\tnewEntry := utils.PeerAddress{}\n\t\terr := newEntry.Set(address)\n\t\tif err != nil {\n\t\t\tlogger.Logw(\"Error updating router entry\")\n\t\t\treturn false\n\t\t}\n\t\trouter.setEntry(origin, newEntry)\n\t}\n\treturn isNew\n}", "func (d *Dao) AddHisIdxCache(c context.Context, tp int32, oid int64, month string, dates []string) (err error) {\n\tvar (\n\t\tconn = d.dmMC.Get(c)\n\t\tkey = keyHistoryIdx(tp, oid, month)\n\t)\n\tdefer conn.Close()\n\titem := &memcache.Item{\n\t\tKey: key,\n\t\tObject: dates,\n\t\tFlags: memcache.FlagJSON,\n\t\tExpiration: d.historyExpire,\n\t}\n\tif err = conn.Set(item); err != nil {\n\t\tlog.Error(\"conn.Set(%s) error(%v)\", key, err)\n\t}\n\treturn\n}", "func NewHistory(capacity int) History {\n history := History{}\n history.results = list.New()\n history.results.Init()\n return history\n}", "func (v *VersionHistory) AddOrUpdateItem(\n\titem *VersionHistoryItem,\n) error {\n\n\tif len(v.Items) == 0 {\n\t\tv.Items = []*VersionHistoryItem{item.Duplicate()}\n\t\treturn nil\n\t}\n\n\tlastItem := v.Items[len(v.Items)-1]\n\tif item.Version < lastItem.Version {\n\t\treturn &shared.BadRequestError{Message: fmt.Sprintf(\n\t\t\t\"cannot update version history with a lower version %v. Last version: %v\",\n\t\t\titem.Version, lastItem.Version,\n\t\t)}\n\t}\n\n\tif item.EventID <= lastItem.EventID {\n\t\treturn &shared.BadRequestError{Message: fmt.Sprintf(\n\t\t\t\"cannot add version history with a lower event id %v. Last event id: %v\",\n\t\t\titem.EventID, lastItem.EventID,\n\t\t)}\n\t}\n\n\tif item.Version > lastItem.Version {\n\t\t// Add a new history\n\t\tv.Items = append(v.Items, item.Duplicate())\n\t} else {\n\t\t// item.Version == lastItem.Version && item.EventID > lastItem.EventID\n\t\t// Update event ID\n\t\tlastItem.EventID = item.EventID\n\t}\n\treturn nil\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistoryID(id uuid.UUID) *MedicalNoteUpdateOne {\n\tif mnuo.history == nil {\n\t\tmnuo.history = make(map[uuid.UUID]struct{})\n\t}\n\tmnuo.history[id] = struct{}{}\n\treturn mnuo\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistory(h *History) *MedicalNoteUpdateOne {\n\treturn mnuo.SetHistoryID(h.ID)\n}", "func (c *FakeReleaseHistories) Create(ctx context.Context, releaseHistory *v1alpha1.ReleaseHistory, opts v1.CreateOptions) (result *v1alpha1.ReleaseHistory, err error) {\n\tobj, err := c.Fake.\n\t\tInvokes(testing.NewCreateAction(releasehistoriesResource, c.ns, releaseHistory), &v1alpha1.ReleaseHistory{})\n\n\tif obj == nil {\n\t\treturn nil, err\n\t}\n\treturn obj.(*v1alpha1.ReleaseHistory), err\n}", "func (app *manager) Add(evt Event) error {\n\tlength := len(app.evts)\n\tid := evt.Identifier()\n\tkeyname := evt.Hash().String()\n\n\tif id < length {\n\t\tif _, ok := app.evts[id][keyname]; ok {\n\t\t\tstr := fmt.Sprintf(\"the event (identifier: %d, hash: %s) already exists\", id, keyname)\n\t\t\treturn errors.New(str)\n\t\t}\n\n\t\tapp.evts[id][keyname] = evt\n\t\treturn nil\n\t}\n\n\tdiff := (id - length) + 1\n\tfor i := 0; i < diff; i++ {\n\t\tapp.evts = append(app.evts, map[string]Event{})\n\t}\n\n\tapp.evts[id][keyname] = evt\n\treturn nil\n}", "func (d *Dao) History(c context.Context, mid int64) (h *model.UserEventHistory, err error) {\n\tvar (\n\t\trow *sql.Row\n\t)\n\th = &model.UserEventHistory{}\n\trow = d.db.QueryRow(c, fmt.Sprintf(_getLastHistorySQL, hitHistory(mid)), mid)\n\tif err = row.Scan(&h.ID, &h.Mid, &h.EventID, &h.Score, &h.BaseScore, &h.EventScore, &h.Remark, &h.Reason, &h.FactorVal, &h.CTime); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\terr = nil\n\t\t\th = nil\n\t\t\treturn\n\t\t}\n\t\tlog.Error(\"History row.Scan(%d) error(%v)\", mid, err)\n\t}\n\treturn\n}", "func (_m *Cache) Add(ctx context.Context, hash string, query string) {\n\t_m.Called(ctx, hash, query)\n}", "func (s *Store) Add(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\tif _, ok := s.m[key]; ok {\n\t\treturn store.ErrKeyExists\n\t}\n\n\ts.m[key] = entry{data: b}\n\treturn nil\n}", "func (m *MemoryLogger) Append(newEntry LogEntry) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\tm.Entries[m.index] = newEntry\n\tm.index = (m.index + 1) % maxLogItems\n}", "func NewHistory() *History {\n\treturn &History{\n\t\thead: 0,\n\t\tactions: make([][]*Action, 0),\n\t}\n}", "func (dbc *DatabaseCfg) AddAlertEventHist(dev *AlertEventHist) (int64, error) {\n\tvar err error\n\tvar affected int64\n\tsession := dbc.x.NewSession()\n\tdefer session.Close()\n\n\taffected, err = session.Insert(dev)\n\tif err != nil {\n\t\tsession.Rollback()\n\t\treturn 0, err\n\t}\n\t//no other relation\n\terr = session.Commit()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tlog.Infof(\"Added new Alert event history Successfully with id %d\", dev.ID)\n\tdbc.addChanges(affected)\n\treturn affected, nil\n}", "func (r *repo) Add(tl *Tracklist) {\n\tr.Tracklists = append(r.Tracklists, tl)\n}", "func AddEntry(storage core.StorageClient) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tvar (\n\t\t\terr error\n\t\t\tentry models.Entry\n\t\t)\n\n\t\terr = c.Bind(&entry)\n\t\tif err != nil {\n\t\t\tc.Status(http.StatusBadRequest)\n\n\t\t\treturn\n\t\t}\n\n\t\tentry.Id = uuid.New().String()\n\n\t\terr = storage.Add(entry)\n\t\tif err != nil {\n\t\t\tvar storageError *core.StorageError\n\n\t\t\tif errors.As(err, &storageError) {\n\t\t\t\tc.Status(storageError.StatusCode())\n\t\t\t} else {\n\t\t\t\tc.Status(http.StatusInternalServerError)\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t\tc.JSON(http.StatusCreated, entry)\n\t}\n}", "func (c *EntryCache) add(e *Entry) error {\n\thashes, err := allHashes(e, c.hashes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif _, present := c.entries[e.name]; present {\n\t\t// log or fail...?\n\t\tc.log.Warning(\"[cache] Overwriting cache entry '%s'\", e.name)\n\t} else {\n\t\tc.log.Info(\"[cache] Adding entry for '%s'\", e.name)\n\t}\n\tc.entries[e.name] = e\n\tfor _, h := range hashes {\n\t\tc.lookupMap[h] = e\n\t}\n\treturn nil\n}" ]
[ "0.779259", "0.76407737", "0.74760807", "0.7376757", "0.7210713", "0.7104174", "0.7063229", "0.70470685", "0.6975838", "0.69305986", "0.67309284", "0.66359496", "0.66359496", "0.6457", "0.64496887", "0.637711", "0.6339429", "0.63130957", "0.62378895", "0.6207263", "0.6129786", "0.60587627", "0.5986708", "0.59359366", "0.5917502", "0.5901275", "0.5885181", "0.58686066", "0.57789004", "0.5758049", "0.57548535", "0.57490855", "0.5728425", "0.56919384", "0.5675158", "0.56659126", "0.5653489", "0.56476825", "0.5633226", "0.5629517", "0.56277204", "0.5626015", "0.55853313", "0.5565407", "0.55506283", "0.5539344", "0.5518653", "0.5503285", "0.54895765", "0.54843944", "0.5468798", "0.5460144", "0.5431153", "0.541692", "0.5416191", "0.54133105", "0.5395252", "0.53936917", "0.53820825", "0.53761286", "0.53716516", "0.5368625", "0.5350468", "0.5348815", "0.53465444", "0.53389347", "0.5333371", "0.53302085", "0.5317748", "0.5307631", "0.5300304", "0.5296687", "0.52966404", "0.52926356", "0.5291761", "0.52766854", "0.52720314", "0.52720314", "0.5260638", "0.52587193", "0.5253089", "0.5247105", "0.5233037", "0.52155703", "0.5214912", "0.52120787", "0.5199184", "0.5196275", "0.519154", "0.51903635", "0.51883155", "0.5187662", "0.5180435", "0.5171631", "0.51710796", "0.51566714", "0.515663", "0.51552105", "0.5151768", "0.5145551" ]
0.7841567
0
HistorySetMaxlen sets the maximum length for the history. Truncate the current history if needed.
func (l *Linenoise) HistorySetMaxlen(n int) { if n < 0 { return } l.historyMaxlen = n currentLength := len(l.history) if currentLength > l.historyMaxlen { // truncate and retain the latest history l.history = l.history[currentLength-l.historyMaxlen:] } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *RedisStore) SetMaxLength(l int) {\n\tif l >= 0 {\n\t\ts.maxLength = l\n\t}\n}", "func (store *RedisStore) SetMaxLength(l int) {\r\n\tif l >= 0 {\r\n\t\tstore.maxLength = l\r\n\t}\r\n}", "func (r *Release) getMaxHistory() []string {\n\tif r.MaxHistory != 0 {\n\t\treturn []string{\"--history-max\", strconv.Itoa(r.MaxHistory)}\n\t}\n\treturn []string{}\n}", "func (m *ItemsMutator) MaxLength(v int) *ItemsMutator {\n\tm.proxy.maxLength = &v\n\treturn m\n}", "func (o ApplicationSpecOutput) RevisionHistoryLimit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ApplicationSpec) *int { return v.RevisionHistoryLimit }).(pulumi.IntPtrOutput)\n}", "func (_m *RediStore) SetMaxLength(l int) {\n\t_m.Called(l)\n}", "func (o StorageClusterSpecOutput) RevisionHistoryLimit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v StorageClusterSpec) *int { return v.RevisionHistoryLimit }).(pulumi.IntPtrOutput)\n}", "func WithMaxReleaseHistory(maxHistory int) Option {\n\treturn func(r *Reconciler) error {\n\t\tif maxHistory < 0 {\n\t\t\treturn errors.New(\"maximum Helm release history size must not be negative\")\n\t\t}\n\t\tr.maxHistory = maxHistory\n\t\treturn nil\n\t}\n}", "func WithMaxReleaseHistory(maxHistory int) Option {\n\treturn func(r *Reconciler) error {\n\t\tif maxHistory < 0 {\n\t\t\treturn errors.New(\"maximum Helm release history size must not be negative\")\n\t\t}\n\t\tr.maxHistory = maxHistory\n\t\treturn nil\n\t}\n}", "func (q *Queue) SetMaxLen(maxLen int) {\n\tq.lock.Lock()\n\tdefer q.lock.Unlock()\n\n\tq.maxLen = maxLen\n}", "func (m *ParameterMutator) MaxLength(v int) *ParameterMutator {\n\tm.proxy.maxLength = &v\n\treturn m\n}", "func (o ApplicationSpecPtrOutput) RevisionHistoryLimit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ApplicationSpec) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.RevisionHistoryLimit\n\t}).(pulumi.IntPtrOutput)\n}", "func (o StorageClusterSpecPtrOutput) RevisionHistoryLimit() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *StorageClusterSpec) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.RevisionHistoryLimit\n\t}).(pulumi.IntPtrOutput)\n}", "func (r *Release) inheritMaxHistory(s *State) {\n\tif s.Settings.GlobalMaxHistory != 0 {\n\t\tif r.MaxHistory == 0 {\n\t\t\tr.MaxHistory = s.Settings.GlobalMaxHistory\n\t\t}\n\t}\n}", "func SetMaxLength(maxLength int) Option {\n\treturn func(o *options) {\n\t\to.maxLength = maxLength\n\t}\n}", "func OptMaxLen(maxLen int) Option {\n\treturn func(afb *Buffer) {\n\t\tafb.MaxLen = maxLen\n\t}\n}", "func WithMaxLen(maxLen int) Option {\n\treturn func(o *options) {\n\t\to.maxLength = maxLen\n\t}\n}", "func (t *dataType) MaxLen(n int) *dataType {\n\tt.str.MaxLen(n)\n\treturn t\n}", "func NewHistory(size int) *History {\n\treturn &History{\n\t\tentries: make([]string, size),\n\t}\n}", "func MaxLength(val any, maxLen int) bool {\n\tln := CalcLength(val)\n\treturn ln != -1 && ln <= maxLen\n}", "func (s *FilesystemStore) MaxLength(l int) {\n\tfor _, c := range s.Codecs {\n\t\tif codec, ok := c.(*securecookie.SecureCookie); ok {\n\t\t\tcodec.MaxLength(l)\n\t\t}\n\t}\n}", "func MaxBacklog(n int) ReporterOption {\n\treturn func(r *httpReporter) { r.maxBacklog = n }\n}", "func MaxLength(val interface{}, maxLen int) bool {\n\tln := CalcLength(val)\n\tif ln == -1 {\n\t\treturn false\n\t}\n\n\treturn ln <= maxLen\n}", "func (d *Domain) MaxLength(m int) *Domain {\n\td.checks[\"maxlength\"] = m\n\treturn d\n}", "func (cp *ChangeLog) TruncateTo(maxLength int) int {\n\tif remove := len(cp.Entries) - maxLength; remove > 0 {\n\t\t// Set Since to the max of the sequences being removed:\n\t\tfor _, entry := range cp.Entries[0:remove] {\n\t\t\tif entry.Sequence > cp.Since {\n\t\t\t\tcp.Since = entry.Sequence\n\t\t\t}\n\t\t}\n\t\t// Copy entries into a new array to avoid leaving the entire old array in memory:\n\t\tnewEntries := make([]*LogEntry, maxLength)\n\t\tcopy(newEntries, cp.Entries[remove:])\n\t\tcp.Entries = newEntries\n\t\treturn remove\n\t}\n\treturn 0\n}", "func (_Token *TokenSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (fb *Firebase) LimitToLast(value int64) *Firebase {\n\tc := fb.copy()\n\tif value > 0 {\n\t\tc.params.Set(limitToLastParam, strconv.FormatInt(value, 10))\n\t} else {\n\t\tc.params.Del(limitToLastParam)\n\t}\n\treturn c\n}", "func (m *WorkflowExecutionInfo) GetHistorySize() int64 {\n\tif m != nil {\n\t\treturn m.HistorySize\n\t}\n\treturn 0\n}", "func MaxLength(max int) BuiltInFieldRule {\n\treturn newLengthRule(MsgMaxLengthFormat, nil, &max)\n}", "func (_Token *TokenCallerSession) BaseRewardHistoryLength() (*big.Int, error) {\n\treturn _Token.Contract.BaseRewardHistoryLength(&_Token.CallOpts)\n}", "func (v *verifier) MaxLength(length int) *verifier {\n\treturn v.addVerification(\"MaxLength\", len(v.Query) <= length)\n}", "func (t *StringDataType) MaxLen(n int) *StringDataType {\n\treturn t.Validate(func(s string) error {\n\t\tif len(s) > n {\n\t\t\treturn fmt.Errorf(\"length of string did not meet the maximum length requirement of %d\", n)\n\t\t}\n\t\treturn nil\n\t})\n}", "func (m *ItemsMutator) ClearMaxLength() *ItemsMutator {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\tm.proxy.maxLength = nil\n\treturn m\n}", "func recoverHistory(node *centrifuge.Node, ch string, since centrifuge.StreamPosition, maxPublicationLimit int) (centrifuge.HistoryResult, error) {\n\tlimit := centrifuge.NoLimit\n\tif maxPublicationLimit > 0 {\n\t\tlimit = maxPublicationLimit\n\t}\n\treturn node.History(ch, centrifuge.WithLimit(limit), centrifuge.WithSince(&since))\n}", "func (_Token *TokenCaller) BaseRewardHistoryLength(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Token.contract.Call(opts, out, \"baseRewardHistoryLength\")\n\treturn *ret0, err\n}", "func (f *StringField) MaxLength(max int) {\n\tmsg := fmt.Sprintf(\"The value must be at most %d characters long\", max)\n\tf.check(func() (err *FieldError) {\n\t\tif len(f.Value) > max {\n\t\t\terr = NewFieldError(MAXLENGTH, f.Name, msg)\n\t\t}\n\t\treturn\n\t})\n}", "func (s *Set) SetMaxLineSize(i int) {\n\ts.MaxLineSize = i\n}", "func StringMaxLength(max int) BuiltInFieldRule {\n\treturn newLengthRule(MsgStringMaxLengthFormat, nil, &max)\n}", "func (o QuotaLimitOutput) MaxLimit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v QuotaLimit) *string { return v.MaxLimit }).(pulumi.StringPtrOutput)\n}", "func (b *MessagesGetLongPollHistoryBuilder) PreviewLength(v int) *MessagesGetLongPollHistoryBuilder {\n\tb.Params[\"preview_length\"] = v\n\treturn b\n}", "func (opts *LoggerOptions) SetMaxDocumentLength(maxDocumentLength uint) *LoggerOptions {\n\topts.MaxDocumentLength = maxDocumentLength\n\n\treturn opts\n}", "func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error) {\n\thlist := make([]proto.Message, 0)\n\tif err := store.ReadHistory(datatype, realm, user, id, &hlist); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// TODO: perhaps this should be the empty list?\n\t\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"no config history available\")\n\t\t}\n\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"service storage unavailable: %v, retry later\", err)\n\t}\n\the := make([]*cpb.HistoryEntry, len(hlist))\n\tvar ok bool\n\tfor i, e := range hlist {\n\t\the[i], ok = e.(*cpb.HistoryEntry)\n\t\tif !ok {\n\t\t\treturn nil, http.StatusInternalServerError, fmt.Errorf(\"cannot load history entry %d\", i)\n\t\t}\n\t}\n\thistory := &cpb.History{\n\t\tHistory: he,\n\t}\n\tpageToken := r.URL.Query().Get(\"pageToken\")\n\tstart, err := strconv.ParseInt(pageToken, 10, 64)\n\tif err != nil {\n\t\tstart = 0\n\t}\n\n\tpageSize := r.URL.Query().Get(\"pageSize\")\n\tsize, err := strconv.ParseInt(pageSize, 10, 64)\n\tif err != nil || size < 1 {\n\t\tsize = 50\n\t}\n\tif size > 1000 {\n\t\tsize = 1000\n\t}\n\t// Reverse order\n\ta := history.History\n\tfor i := len(a)/2 - 1; i >= 0; i-- {\n\t\topp := len(a) - 1 - i\n\t\ta[i], a[opp] = a[opp], a[i]\n\t}\n\n\tfor i, entry := range history.History {\n\t\tif entry.Revision <= start {\n\t\t\thistory.History = history.History[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(history.History) > int(size) {\n\t\thistory.NextPageToken = fmt.Sprintf(\"%d\", history.History[size].Revision)\n\t\thistory.History = history.History[:size]\n\t}\n\treturn history, http.StatusOK, nil\n}", "func WithMaxSize(s uint) LogBufferOption {\n\treturn func(o *logBufferOptions) {\n\t\to.maxSize = s\n\t}\n}", "func (c *AuditClient) SetBacklogLimit(limit uint32, wm WaitMode) error {\n\tstatus := AuditStatus{\n\t\tMask: AuditStatusBacklogLimit,\n\t\tBacklogLimit: limit,\n\t}\n\treturn c.set(status, wm)\n}", "func (o *QueryUserExpGrantHistoryParams) SetLimit(limit *int32) {\n\to.Limit = limit\n}", "func NewMaxLen(len uint64) *MaxLen {\n\treturn &MaxLen{val: value.NewUInt(len)}\n}", "func SetBacklogLimit(limit uint32) (err error) {\n\tclient, err := libaudit.NewAuditClient(nil)\n\tdefer client.Close()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Failed to initialize client\")\n\t}\n\tif err := client.SetBacklogLimit(limit, libaudit.WaitForReply); err != nil {\n\t\treturn errors.Wrap(err, \"Failed to set backlog limit\")\n\t}\n\treturn nil\n}", "func (r *StandardAnalyzer) SetMaxTokenLength(length int) {\n\tr.maxTokenLength = length\n}", "func (h *History) Len() int {\n\treturn h.size\n}", "func (e *TarantoolEngine) addHistory(chID ChannelID, message Message, size, lifetime int64) (err error) {\n\t// not implemented\n\treturn\n}", "func (m *ParameterMutator) ClearMaxLength() *ParameterMutator {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\tm.proxy.maxLength = nil\n\treturn m\n}", "func (this *NowStr) MaxArgs() int { return 1 }", "func (c *Collection) History(id string, limit int) (valuesAsBytes [][]byte, err error) {\n\tvaluesAsBytes = make([][]byte, limit)\n\tcount := 0\n\n\treturn valuesAsBytes, c.db.badger.View(func(txn *badger.Txn) error {\n\t\topt := badger.DefaultIteratorOptions\n\t\topt.AllVersions = true\n\t\titer := txn.NewIterator(opt)\n\t\tdefer iter.Close()\n\n\t\tdbKey := c.buildDBKey(id)\n\t\tbreakAtNext := false\n\t\tfor iter.Seek(dbKey); iter.ValidForPrefix(dbKey); iter.Next() {\n\t\t\tif count >= limit || breakAtNext {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\titem := iter.Item()\n\t\t\tif item.DiscardEarlierVersions() {\n\t\t\t\tbreakAtNext = true\n\t\t\t}\n\n\t\t\tvar content []byte\n\t\t\tcontent, err = item.ValueCopy(content)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tcontent, err = c.db.decryptData(item.Key(), content)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tvaluesAsBytes[count] = content\n\n\t\t\tcount++\n\t\t}\n\n\t\t// Clean the end of the slice to gives only the existing values\n\t\tvaluesAsBytes = valuesAsBytes[:count]\n\n\t\treturn nil\n\t})\n}", "func (mnu *MedicalNoteUpdate) SetHistory(h *History) *MedicalNoteUpdate {\n\treturn mnu.SetHistoryID(h.ID)\n}", "func (fhc *historyConfig) NewHistory(tag string, index, maxHistories int) (bot.HistoryLogger, error) {\n\tdirPath := path.Join(fhc.Directory, tag)\n\tfilePath := path.Join(dirPath, fmt.Sprintf(\"%s-%d.log\", tag, index))\n\tif err := os.MkdirAll(dirPath, 0755); err != nil {\n\t\treturn nil, fmt.Errorf(\"Error creating history directory '%s': %v\", dirPath, err)\n\t}\n\tif file, err := os.Create(filePath); err != nil {\n\t\treturn nil, fmt.Errorf(\"Error creating history file '%s': %v\", filePath, err)\n\t} else {\n\t\thl := log.New(file, \"\", logFlags)\n\t\thf := &historyFile{\n\t\t\thl,\n\t\t\tfile,\n\t\t}\n\t\tif index-maxHistories >= 0 {\n\t\t\tfor i := index - maxHistories; i >= 0; i-- {\n\t\t\t\trmPath := path.Join(dirPath, fmt.Sprintf(\"%s-%d.log\", tag, i))\n\t\t\t\t_, err := os.Stat(rmPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\trerr := os.Remove(rmPath)\n\t\t\t\tif rerr != nil {\n\t\t\t\t\trobot.Log(bot.Error, fmt.Sprint(\"Error removing old log file '%s': %v\", rmPath, rerr))\n\t\t\t\t\t// assume it's pointless to keep trying to delete files\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn hf, nil\n\t}\n}", "func (v *Validator) MaxLength(field string, d int) {\n\tvalue := v.model[field]\n\n\tif value == \"\" {\n\t\treturn\n\t}\n\n\tif utf8.RuneCountInString(value) > d {\n\t\tv.errors[\"errors\"] = append(v.errors[\"errors\"], ErrFieldTooLong(d))\n\t}\n}", "func (c Conn) MaxLength() int {\n\treturn MaxLength\n}", "func (gq *Dispatch) MaxLen() int {\n return gq.maxlength\n}", "func (f *FileHandler) SetMaxLevel(l LogLevel) {\n\tif l < f.min {\n\t\treturn\n\t}\n\tf.max = l\n}", "func (s *DTMFSpecification) SetMaxLength(v int64) *DTMFSpecification {\n\ts.MaxLength = &v\n\treturn s\n}", "func (o QuotaLimitResponseOutput) MaxLimit() pulumi.StringOutput {\n\treturn o.ApplyT(func(v QuotaLimitResponse) string { return v.MaxLimit }).(pulumi.StringOutput)\n}", "func (bh browserHistory) Len() int { return len(bh.Records) }", "func truncateToMaxSize(input []byte) []byte {\n\tif len(input) > maxInputSize {\n\t\treturn input[:maxInputSize]\n\t}\n\treturn input\n}", "func OptPubSubHistoryCap(cap int) Opt {\n\treturn func(app *App) {\n\t\tapp.pubSubHistoryCap = cap\n\t}\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *memoryCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func WrapHistory(h Handler, w http.ResponseWriter, r *http.Request) {\n\tvar aOffset *int32\n\tvar aLimit *int32\n\n\tq := r.URL.Query()\n\n\tif _, ok := q[\"offset\"]; ok {\n\t\t{\n\t\t\tparsed, err := strconv.ParseInt(q.Get(\"offset\"), 10, 32)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, \"Parameter 'offset': \"+err.Error(), http.StatusBadRequest)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconverted := int32(parsed)\n\t\t\taOffset = &converted\n\t\t}\n\t}\n\n\tif _, ok := q[\"limit\"]; ok {\n\t\t{\n\t\t\tparsed, err := strconv.ParseInt(q.Get(\"limit\"), 10, 32)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, \"Parameter 'limit': \"+err.Error(), http.StatusBadRequest)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconverted := int32(parsed)\n\t\t\taLimit = &converted\n\t\t}\n\t}\n\n\th.History(w,\n\t\tr,\n\t\taOffset,\n\t\taLimit)\n}", "func MaxStringLength(str string, params ...string) bool {\n\n\tif len(params) == 1 {\n\t\tstrLength := utf8.RuneCountInString(str)\n\t\tmax, _ := ToInt(params[0])\n\t\treturn strLength <= int(max)\n\t}\n\n\treturn false\n}", "func (g *Graph) HistorySize() HistorySize {\n\tg.treeLock.Lock()\n\tdefer g.treeLock.Unlock()\n\tg.tagLock.Lock()\n\tdefer g.tagLock.Unlock()\n\tg.historyLock.Lock()\n\tdefer g.historyLock.Unlock()\n\tif len(g.treeRecords) != 0 {\n\t\tpanic(fmt.Sprintf(\"%d tree records remain!\", len(g.treeRecords)))\n\t}\n\tif len(g.tagRecords) != 0 {\n\t\tpanic(fmt.Sprintf(\"%d tag records remain!\", len(g.tagRecords)))\n\t}\n\treturn g.historySize\n}", "func SetMaxNumberEntries(sz int) {\n\tC.hepevt_set_max_number_entries(C.int(sz))\n}", "func (c *FakeClient) ReleaseHistory(rlsName string, max int) ([]*release.Release, error) {\n\treturn c.Rels, nil\n}", "func (ptr *terminalPrompter) SetHistory(history []string) {\n\tptr.State.ReadHistory(strings.NewReader(strings.Join(history, \"\\n\")))\n}", "func (sbr *smtpBufferedReader) setLimit(n int64) {\n\tsbr.alr.setLimit(n)\n}", "func (msg *MsgFilterClear) MaxPayloadLength(pver uint32) uint32 {\n\treturn 0\n}", "func (m Logon) SetMaxMessageSize(v int) {\n\tm.Set(field.NewMaxMessageSize(v))\n}", "func (o *QueryChangesParams) SetLimit(limit *int64) {\n\to.Limit = limit\n}", "func GetRevisionHistoryLimitOrDefault(rollout *v1alpha1.Rollout) int32 {\n\tif rollout.Spec.RevisionHistoryLimit == nil {\n\t\treturn DefaultRevisionHistoryLimit\n\t}\n\treturn *rollout.Spec.RevisionHistoryLimit\n}", "func (e SszNetworkEncoder) MaxLength(length int) int {\n\tif e.UseSnappyCompression {\n\t\treturn snappy.MaxEncodedLen(length)\n\t}\n\treturn length\n}", "func (f *StringSetFilter) ItemMaxLen(length int) *StringSetFilter {\r\n\tf.AddValidator(func(paramName string, paramValue []string) *Error {\r\n\t\tfor _, v := range paramValue {\r\n\t\t\tif len(v) > length {\r\n\t\t\t\treturn NewError(ErrorInvalidParam, paramName, \"ItemTooLong\")\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn nil\r\n\t})\r\n\treturn f\r\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *loadingCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func maxLength(values []string) (max int) {\n\tfor _, s := range values {\n\t\tif len(s) > max {\n\t\t\tmax = len(s)\n\t\t}\n\t}\n\treturn\n}", "func (d *PerfData) SetMax(max string) {\n\tif !valueCheck.MatchString(max) {\n\t\tpanic(\"invalid value\")\n\t}\n\td.max = max\n\td.bits = d.bits | PDAT_MAX\n}", "func (msg *MsgFetchSmartContractInfo) MaxPayloadLength(pver uint32) uint32 {\n\t// 10k. In theory this message is very small.\n\treturn 10240\n}", "func (mnu *MedicalNoteUpdate) SetHistoryID(id uuid.UUID) *MedicalNoteUpdate {\n\tif mnu.history == nil {\n\t\tmnu.history = make(map[uuid.UUID]struct{})\n\t}\n\tmnu.history[id] = struct{}{}\n\treturn mnu\n}", "func (w *ScrollWidget) SetMax(max int) {\n\tw.max = max\n\tw.clampCurrent()\n}", "func (_m *RediStore) SetMaxAge(v int) {\n\t_m.Called(v)\n}", "func maxlength(interpreter *Interpreter) {\n\tinterpreter.Pop()\n\tinterpreter.Push(float64(999999999)) // push arbitrary value\n}", "func getMaxLength(i int) int {\n\treturn len(strconv.FormatInt(int64(i), 10))\n}", "func (conn *Conn) SetMaxTopics(max int) {\n\tif max < 1 {\n\t\tmax = 50\n\t}\n\tconn.length = max\n}", "func MaxValSize(max int) Option {\n\treturn func(lc cacheWithOpts) error {\n\t\treturn lc.setMaxValSize(max)\n\t}\n}", "func NewHistoryBuilder(msBuilder MutableState, logger log.Logger) *HistoryBuilder {\n\treturn &HistoryBuilder{\n\t\ttransientHistory: []*types.HistoryEvent{},\n\t\thistory: []*types.HistoryEvent{},\n\t\tmsBuilder: msBuilder,\n\t}\n}", "func (b *MessagesGetLongPollHistoryBuilder) MsgsLimit(v int) *MessagesGetLongPollHistoryBuilder {\n\tb.Params[\"msgs_limit\"] = v\n\treturn b\n}", "func (context *context) SetMaxSegmentLength(n uint) {\n\tcontext.params.SetMaxSegmentLength(int(n))\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistory(h *History) *MedicalNoteUpdateOne {\n\treturn mnuo.SetHistoryID(h.ID)\n}", "func (st *Settings) SetMaxFrameSize(size uint32) {\n\tst.frameSize = size\n}", "func (st *Settings) SetMaxFrameSize(size uint32) {\n\tst.frameSize = size\n}", "func StdoutHistory(h string) ConfigOption {\n\treturn func(c *Config) error {\n\t\thist, err := strconv.Atoi(h)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tc.StdoutHistory = hist\n\t\treturn nil\n\t}\n}", "func OptAutoflushBufferMaxLen(maxLen int) AutoflushBufferOption {\n\treturn func(afb *AutoflushBuffer) {\n\t\tafb.MaxLen = maxLen\n\t}\n}", "func TruncateEncodedChangeLog(r *bytes.Reader, maxLength, minLength int, w io.Writer) (removed int, newLength int) {\n\tsince := readSequence(r)\n\t// Find the starting position and sequence of each entry:\n\tentryPos := make([]int64, 0, 1000)\n\tentrySeq := make([]uint64, 0, 1000)\n\tfor {\n\t\tpos, err := r.Seek(0, 1)\n\t\tif err != nil {\n\t\t\tpanic(\"Seek??\")\n\t\t}\n\t\tflags, err := r.ReadByte()\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak // eof\n\t\t\t}\n\t\t\tpanic(\"ReadByte failed\")\n\t\t}\n\t\tseq := readSequence(r)\n\t\tskipString(r)\n\t\tskipString(r)\n\t\tskipString(r)\n\t\tif flags > kMaxFlag {\n\t\t\tpanic(fmt.Sprintf(\"TruncateEncodedChangeLog: bad flags 0x%x, entry %d, offset %d\",\n\t\t\t\tflags, len(entryPos), pos))\n\t\t}\n\n\t\tentryPos = append(entryPos, pos)\n\t\tentrySeq = append(entrySeq, seq)\n\t}\n\n\t// How many entries to remove?\n\t// * Leave no more than maxLength entries\n\t// * Every sequence value removed should be less than every sequence remaining.\n\t// * The new 'since' value should be the maximum sequence removed.\n\toldLength := len(entryPos)\n\tremoved = oldLength - maxLength\n\tif removed <= 0 {\n\t\tremoved = 0\n\t} else {\n\t\tpivot, newSince := findPivot(entrySeq, removed-1)\n\t\tremoved = pivot + 1\n\t\tif oldLength-removed >= minLength {\n\t\t\tsince = newSince\n\t\t} else {\n\t\t\tremoved = 0\n\t\t\tbase.Warn(\"TruncateEncodedChangeLog: Couldn't find a safe place to truncate\")\n\t\t\t//TODO: Possibly find a pivot earlier than desired?\n\t\t}\n\t}\n\n\t// Write the updated Since and the remaining entries:\n\twriteSequence(since, w)\n\tif _, err := r.Seek(entryPos[removed], 0); err != nil {\n\t\tpanic(\"Seek back???\")\n\t}\n\tif _, err := io.Copy(w, r); err != nil {\n\t\tpanic(\"Copy???\")\n\t}\n\treturn removed, oldLength - removed\n}" ]
[ "0.69493216", "0.68986493", "0.6644048", "0.639017", "0.6385586", "0.6376215", "0.63593084", "0.6263625", "0.6263625", "0.62625104", "0.6247249", "0.6193528", "0.61780846", "0.60929585", "0.6009808", "0.58496416", "0.5797404", "0.5773891", "0.5693024", "0.5578844", "0.5536943", "0.5513917", "0.54901963", "0.54643637", "0.54612803", "0.5421222", "0.5404189", "0.54018664", "0.5400814", "0.5395184", "0.53450674", "0.5323413", "0.53002", "0.5269811", "0.5241949", "0.52370447", "0.52202207", "0.52150476", "0.5210061", "0.5187434", "0.5181968", "0.51696664", "0.51418006", "0.5139399", "0.5139355", "0.51316684", "0.51195604", "0.51156425", "0.51130366", "0.5111951", "0.5091338", "0.50891066", "0.5080087", "0.5078806", "0.5068051", "0.5062675", "0.505798", "0.50482905", "0.5028737", "0.50192875", "0.50081635", "0.50000584", "0.4996874", "0.4996837", "0.4979532", "0.4979532", "0.4974064", "0.4966069", "0.4965418", "0.49623847", "0.49592307", "0.4945677", "0.49444282", "0.4939689", "0.4939241", "0.49389032", "0.4920814", "0.4905268", "0.49052024", "0.48976645", "0.4885189", "0.48841637", "0.48609787", "0.4848777", "0.48452303", "0.4844385", "0.48384422", "0.4832028", "0.48190564", "0.48130608", "0.48028392", "0.47963265", "0.4792142", "0.4781433", "0.4776499", "0.47759125", "0.47759125", "0.47758996", "0.47745535", "0.47741568" ]
0.875326
0
HistorySave saves the history to a file.
func (l *Linenoise) HistorySave(fname string) { if len(l.history) == 0 { return } f, err := os.Create(fname) if err != nil { log.Printf("error opening %s\n", fname) return } _, err = f.WriteString(strings.Join(l.history, "\n")) if err != nil { log.Printf("%s error writing %s\n", fname, err) } f.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n *nameHistory) Save() error {\n\tif !n.isChanged {\n\t\treturn nil\n\t}\n\n\tfp, err := os.OpenFile(n.filepath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not open %q file: %v\", n.filepath, err)\n\t}\n\tdefer fp.Close()\n\n\tif err := yaml.NewEncoder(fp).Encode(n.entries); err != nil {\n\t\treturn fmt.Errorf(\"could not save table name history: %v\", err)\n\t}\n\n\tif err := utils.SyncFileAndDirectory(fp); err != nil {\n\t\treturn fmt.Errorf(\"could not sync oid to name map file: %v\", err)\n\t}\n\n\tn.isChanged = false\n\n\treturn nil\n}", "func (bh browserHistory) Save() error {\n\tbytes, err := json.Marshal(bh.Records)\n\tif err != nil {\n\t\treturn err\n\t}\n\tjs.Global().Get(\"localStorage\").Set(\"history\", string(bytes))\n\n\treturn nil\n}", "func (r *historyRow) save(dir string) error {\n\trBytes, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thistoryFile := getLatestHistoryFile(dir)\n\n\tf, err := os.OpenFile(historyFile.path, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = f.Write(append(rBytes, []byte(\"\\n\")...))\n\treturn err\n}", "func (rl *readline) WriteHistory() error {\n\tf, err := os.OpenFile(rl.historyFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = rl.State.WriteHistory(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func saveGame(board *chess.Board, name string) {\n\tname = strings.Trim(name, \"\\n\")\n\tfile, _ := os.Create(name)\n\twriter := bufio.NewWriter(file)\n\tfmt.Println(\"Name: \", name)\n\tfor i, v := range board.History {\n\t\twriter.WriteString(strconv.Itoa(i+1) + \": \")\n\t\twriter.WriteString(v)\n\t\twriter.WriteString(\"\\n\")\n\t}\n\twriter.Flush()\n\tfile.Close()\n\n}", "func (tv *TextView) SavePosHistory(pos TextPos) {\n\tif tv.Buf == nil {\n\t\treturn\n\t}\n\ttv.Buf.SavePosHistory(pos)\n\ttv.PosHistIdx = len(tv.Buf.PosHistory) - 1\n}", "func save(novel *Novel) {\n\t//if novel exist history\n\ttag := false\n\tfor index, historyNovel := range historyNovels {\n\t\tif historyNovel.Name == novel.Name {\n\t\t\thistoryNovels[index] = novel\n\t\t\ttag = true\n\t\t}\n\t}\n\tif !tag {\n\t\thistoryNovels = append(historyNovels, novel)\n\t}\n\tSaveHistory(historyNovels)\n\tfmt.Println(\"Save complete...\")\n}", "func (b *Bookmarks) Save() error {\n\treturn b.WriteToFile(b.Filename)\n}", "func (h *History) WriteFile(path string) error {\n\tfile, err := os.Create(path + \".csv\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tw := bufio.NewWriter(file)\n\th.RLock()\n\tdefer h.RUnlock()\n\n\tsort.Sort(byTime(h.operations))\n\n\tlatency := 0.0\n\tthroughput := 0\n\ts := 1.0\n\tfor _, o := range h.operations {\n\t\tstart := float64(o.start) / 1000000000.0\n\t\tend := float64(o.end) / 1000000000.0\n\t\tfmt.Fprintf(w, \"%v,%v,%f,%f\\n\", o.input, o.output, start, end)\n\t\tlatency += end - start\n\t\tthroughput++\n\t\tif end > s {\n\t\t\tfmt.Fprintf(w, \"PerSecond %f %d\\n\", latency/float64(throughput)*1000.0, throughput)\n\t\t\tlatency = 0\n\t\t\tthroughput = 0\n\t\t\ts++\n\t\t}\n\n\t\t// fmt.Fprintln(w, o)\n\t}\n\n\t// for k, ops := range h.shard {\n\t// \tfmt.Fprintf(w, \"key=%d\\n\", k)\n\t// \tfor _, o := range ops {\n\t// \t\tfmt.Fprintln(w, o)\n\t// \t}\n\t// }\n\treturn w.Flush()\n}", "func (h *History) WriteFile(path string) error {\n\tfile, err := os.Create(path + \".csv\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tw := bufio.NewWriter(file)\n\th.RLock()\n\tdefer h.RUnlock()\n\n\tsort.Sort(byTime(h.operations))\n\n\tlatency := 0.0\n\tthroughput := 0\n\ts := 1.0\n\tfor _, o := range h.operations {\n\t\tstart := float64(o.start) / 1000000000.0\n\t\tend := float64(o.end) / 1000000000.0\n\t\tfmt.Fprintf(w, \"%v,%v,%f,%f\\n\", o.input, o.output, start, end)\n\t\tlatency += end - start\n\t\tthroughput++\n\t\tif end > s {\n\t\t\tfmt.Fprintf(w, \"PerSecond %f %d\\n\", latency/float64(throughput)*1000.0, throughput)\n\t\t\tlatency = 0\n\t\t\tthroughput = 0\n\t\t\ts++\n\t\t}\n\n\t\t// fmt.Fprintln(w, o)\n\t}\n\n\t// for k, ops := range h.shard {\n\t// \tfmt.Fprintf(w, \"key=%d\\n\", k)\n\t// \tfor _, o := range ops {\n\t// \t\tfmt.Fprintln(w, o)\n\t// \t}\n\t// }\n\treturn w.Flush()\n}", "func (d deck) saveToFile (filename string) error {\n\t\treturn ioutil.WriteFile(filename, []byte (d.toString()), 0666)\n}", "func SaveToFile() error {\n\tdata, err := json.Marshal(Events)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(eventsFilename, data, 0644)\n}", "func (tb *TextBuf) SavePosHistory(pos TextPos) bool {\n\tif tb.PosHistory == nil {\n\t\ttb.PosHistory = make([]TextPos, 0, 1000)\n\t}\n\tsz := len(tb.PosHistory)\n\tif sz > 0 {\n\t\tif tb.PosHistory[sz-1].Ln == pos.Ln {\n\t\t\treturn false\n\t\t}\n\t}\n\ttb.PosHistory = append(tb.PosHistory, pos)\n\t// fmt.Printf(\"saved pos hist: %v\\n\", pos)\n\treturn true\n}", "func (o *Object) SaveToFile(filename string) {\n\tobjJson, _ := json.Marshal(o)\n\tioutil.WriteFile(filename, objJson, 0644)\n}", "func (b *bookMark) save(event win_eventlog.EvtHandle) error {\n\tnewBookmark, err := win_eventlog.UpdateBookmark(b.handle, event, b.buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := b.file.Truncate(0); err != nil {\n\t\treturn err\n\t}\n\tif _, err := b.file.Seek(0, 0); err != nil {\n\t\treturn err\n\t}\n\t_, err = b.file.WriteString(newBookmark)\n\treturn err\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0755)\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func WriteHistoryFile(\n\tfileList []CustomisationFile,\n\tcustomFilesFolder string,\n\tfileStatuses,\n\tcustomisationFolders []string,\n\thistoryFileFullPath string,\n\tendChan chan bool,\n\tlogger *zap.Logger,\n) {\n\tdefer DeferChannelSendTrue(endChan)\n\tlogger.Info(\"(WriteHistoryFile) Start writing to history file\")\n\thistoryFolder := filepath.Dir(historyFileFullPath)\n\terr := os.MkdirAll(historyFolder, 0755)\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\treturn\n\t}\n\thistoryFile, err := os.Create(historyFileFullPath)\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\treturn\n\t}\n\tdefer historyFile.Close()\n\n\t// Get current user name\n\tvar currentUserName string\n\tCurrentUser, err := user.Current()\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) Can't get current user name while save history- \", err))\n\t\tcurrentUserName = \"Can't resolve User Name\"\n\t} else {\n\t\tif CurrentUser.Name == \"\" {\n\t\t\tcurrentUserName = CurrentUser.Username\n\t\t} else {\n\t\t\tcurrentUserName = CurrentUser.Name\n\t\t}\n\t}\n\t_, err = historyFile.WriteString(fmt.Sprint(\n\t\t\"Program version: \",\n\t\tprogramVersion,\n\t\t\"\\n\",\n\t\t\"Started by: \",\n\t\tcurrentUserName,\n\t\t\"\\n\\nCollected folders\\n\"))\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\treturn\n\t}\n\t// Write found customisation folders\n\tfor _, fName := range customisationFolders {\n\t\t_, err = historyFile.WriteString(fmt.Sprint(fName, \"\\n\"))\n\t\tif err != nil {\n\t\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\t\treturn\n\t\t}\n\t}\n\t// Write collected files statuses\n\t_, err = historyFile.WriteString(\"\\nCollected files statuses\\n\")\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\treturn\n\t}\n\tfor index, file := range fileList {\n\t\tshortFilePath, err := filepath.Rel(customFilesFolder, file.SourcePath)\n\t\tif err != nil {\n\t\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\t\treturn\n\t\t}\n\t\tfileStatusString := fmt.Sprint(fileStatuses[index], shortFilePath, \"\\n\")\n\t\t_, err = historyFile.WriteString(fileStatusString)\n\t\tif err != nil {\n\t\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) History file not written - \", err))\n\t\t\treturn\n\t\t}\n\t}\n\tlogger.Info(\"(WriteHistoryFile) History file written successfully\")\n\terr = ClearOldFiles(historyFolder, HistoryFileName, 15)\n\tif err != nil {\n\t\tlogger.Warn(fmt.Sprint(\"(WriteHistoryFile) Can't clear old history files - \", err))\n\t}\n\treturn\n}", "func (d deck) saveToFile(fileName string) error {\n\treturn ioutil.WriteFile(fileName, []byte(d.toString()), 0776)\n}", "func (l Log) save(path string) error {\n\tlogs, err := loadLogs(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfound := false\n\tfor i, log := range logs {\n\t\tif l.Id == log.Id {\n\t\t\tfound = true\n\t\t\tlogs[i] = l\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !found {\n\t\tlogs = append(logs, l)\n\t}\n\n\tdata, err := json.Marshal(logs)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(path+\"/logs.json\", data, 0644)\n}", "func (s *stepSaver) Save() error {\n\tvar wg sync.WaitGroup\n\tfor _, f := range s.LogFiles() {\n\t\twg.Add(1)\n\t\tgo func(f *logFile) {\n\t\t\tdefer wg.Done()\n\n\t\t\terr := f.Save()\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"ERROR saving logfile:\", err)\n\t\t\t}\n\t\t}(f)\n\t}\n\n\twg.Wait()\n\treturn nil\n}", "func (d deck) saveToFile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666) //0666 is a default permission\n}", "func (h *Homework) save() (err error) {\n\tbuf, err := json.MarshalIndent(h, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(h.path, buf, 0777)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (d deck) saveToFile(filename string) error {\n\t//convert the d deck to single string (toString) and then convert to []byte slice and finally WritesFile create the file\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func (g *Generator) SaveToFile(path string) error {\n\tf, err := os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\treturn g.Save(f)\n}", "func (s *Service) HistoryToFiles(payments []types.Payment, dir string, records int) error {\n\n\tif len(payments) > 0 {\n\t\tif len(payments) <= records {\n\t\t\tfile, _ := os.OpenFile(dir+\"/payments.dump\", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)\n\t\t\tdefer func() {\n\t\t\t\tif cerr := file.Close(); cerr != nil {\n\t\t\t\t\tlog.Print(cerr)\n\t\t\t\t}\n\t\t\t}()\n\t\t\tvar str string\n\t\t\tfor _, val := range payments {\n\t\t\t\tstr += fmt.Sprint(val.ID) + \";\" + fmt.Sprint(val.AccountID) + \";\" + fmt.Sprint(val.Amount) + \";\" + fmt.Sprint(val.Category) + \";\" + fmt.Sprint(val.Status) + \"\\n\"\n\t\t\t}\n\t\t\tfile.WriteString(str)\n\t\t} else {\n\n\t\t\tvar str string\n\t\t\tk := 0\n\t\t\tj := 1\n\t\t\tvar file *os.File\n\t\t\tfor _, val := range payments {\n\t\t\t\tif k == 0 {\n\t\t\t\t\tfile, _ = os.OpenFile(dir+\"/payments\"+fmt.Sprint(j)+\".dump\", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)\n\t\t\t\t}\n\t\t\t\tk++\n\t\t\t\tstr = fmt.Sprint(val.ID) + \";\" + fmt.Sprint(val.AccountID) + \";\" + fmt.Sprint(val.Amount) + \";\" + fmt.Sprint(val.Category) + \";\" + fmt.Sprint(val.Status) + \"\\n\"\n\t\t\t\t_, err := file.WriteString(str)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Print(err)\n\t\t\t\t}\n\t\t\t\tif k == records {\n\t\t\t\t\tstr = \"\"\n\t\t\t\t\tj++\n\t\t\t\t\tk = 0\n\t\t\t\t\tfile.Close()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d deck) saveToFile(filename string) error {\n\ts := d.toString()\n\tdeckAsByteSlice := []byte(s)\n\treturn ioutil.WriteFile(filename, deckAsByteSlice, 0666)\n}", "func SaveToFile(fileName string, data interface{}) error {\n\tbytes, err := json.MarshalIndent(data, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(fileName, bytes, 0644)\n}", "func (classifier Classifier) SaveClassifierToFile(path string) error {\n\tfl, err := os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer fl.Close()\n\n\terr = gob.NewEncoder(fl).Encode(&classifier)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *DefaultParser) Save(buf *bytes.Buffer, filename string) error {\n\terr := ioutil.WriteFile(filename, buf.Bytes(), 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func saveAddHistoryTime(w http.ResponseWriter, r *http.Request, t map[string]interface{}) {\n\tf := firego.NewGAE(appengine.NewContext(r), FIRE_URL)\n\tf.Auth(FIRE_AUTH)\n\tif e := f.Update(t); e == nil {\n\t\tif _, e := f.Push(nil); e == nil {\n\t\t\tstatus(w, fmt.Sprintf(\"updated history: %v\", t[\"lastSave\"]), 200)\n\t\t} else {\n\t\t\ts := fmt.Sprintf(\"Firebase push error: %v\", e)\n\t\t\tstatus(w, s, 303)\n\t\t}\n\t} else {\n\t\ts := fmt.Sprintf(\"Firebase update command error: %v\", e)\n\t\tstatus(w, s, 304)\n\t}\n}", "func (d deck) saveToFile(fileName string) error{\n\n\t// WriteFile (filename, [] byte, permission)\n\treturn ioutil.WriteFile(fileName, []byte (d.toString()), 0666)\n}", "func (ml *MissingLog) SaveLog() error {\n\n\tjsonData, err := json.Marshal(ml.Entries)\n\tif nil != err {\n\t\tfmt.Printf(\"error marshalling log: %s\", err)\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(ml.LogFile, jsonData, os.ModeExclusive)\n\n}", "func (d deck) saveToFile(fileName string) error {\n\t//folosesc functia din package respectiv, apoi ca al doilea arg\n\t// convertesc in []byte ce rezulta din functia CUSTOM toString()\n\treturn ioutil.WriteFile(fileName, []byte(d.toString()), 0666)\n}", "func (cm *ClosestMatch) Save(filename string) error {\n\tf, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tenc := gob.NewEncoder(f)\n\treturn enc.Encode(cm)\n}", "func savingFile(states AllStates, ID string) {\n\tfile, err := os.Create(\"elevator_states.txt\") //Creates file that will only contain latest data\n\t//checks for errors and saves to file as JSON\n\tcheck(err)\n\te := json.NewEncoder(file).Encode(states) //saves the AllStates struct to file\n\tcheck(e)\n}", "func (p *Page) save() error {\n filename := p.Title + \".txt\"\n return ioutil.WriteFile(filename, p.Body, 0600)\n}", "func SaveHash(hash string) {\n\tfile, err := os.Create(fileName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer file.Close()\n\n\tfile.WriteString(hash)\n}", "func (file *File) Save() error {\n\tif file.path == \":memory:\" {\n\t\treturn nil\n\t}\n\n\t// Maybe an easier way is to use ioutil.WriteFile\n\tfp, err := os.OpenFile(file.path, os.O_TRUNC|os.O_WRONLY|os.O_CREATE, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer fp.Close()\n\n\tif len(file.cache) == 0 {\n\t\tfp.WriteString(\"\\n\")\n\t\treturn nil\n\t}\n\n\tfor _, alias := range file.cache {\n\t\tfp.WriteString(alias.String() + \"\\n\")\n\t}\n\n\treturn nil\n}", "func HistoryRecord(env *Environment, command []string, date time.Time, code int) error {\n\tif env == nil {\n\t\treturn nil\n\t}\n\n\thistoryPath := env.LocalPath(HistoryDir)\n\tif utils.IsNotExist(historyPath) {\n\t\terr := utils.MkdirAll(historyPath, 0755)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\th := &historyRow{\n\t\tCommand: strings.Join(command, \" \"),\n\t\tDate: date,\n\t\tCode: code,\n\t}\n\n\treturn h.save(historyPath)\n}", "func (p *Page) save() error {\n\tbody := fmt.Sprintf(\"<!-- Ingredients -->\\n%s\\n<!-- Instructions -->\\n%s\", p.Ingredients, p.Instructions)\n\treturn ioutil.WriteFile(filepath.Join(pagesDir, p.Filename+\".txt\"), []byte(body), 0600)\n}", "func (ws *Wallets) SaveToFile() (bool, error) {\n\tserialized, err := utils.Serialize(elliptic.P256(), ws)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\terr = ioutil.WriteFile(walletFile, serialized, 0644)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func (s *Session) SaveToFile(location string) (string, error) {\n\t// get absolute path\n\tabsPath, err := filepath.Abs(location)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// session to json bytes\n\tsessionJSON, err := json.Marshal(s)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// prettify JSON\n\tvar prettyJSON bytes.Buffer\n\terr = json.Indent(&prettyJSON, sessionJSON, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// if exists write to file\n\tif filehandler.FileExists(absPath) {\n\t\terr = ioutil.WriteFile(absPath, prettyJSON.Bytes(), 0644)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn \"\", nil\n\t}\n\n\t// create dirs\n\tdirPath := path.Dir(absPath)\n\terr = os.MkdirAll(dirPath, 0700)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// create file\n\t_, err = os.Create(absPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// write to file\n\terr = ioutil.WriteFile(absPath, prettyJSON.Bytes(), 0644)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn absPath, nil\n}", "func (m *settings) saveToDisk() error {\n\tb, err := json.Marshal(m.redirects)\n\tif err != nil {\n\t\tlog.Printf(\"Error marshalling %s\", err)\n\t\treturn fmt.Errorf(\"error marshalling %s\", err)\n\t}\n\n\tif err := ioutil.WriteFile(m.filename, b, 0644); err != nil {\n\t\treturn fmt.Errorf(\"unable to open file %s\", err)\n\t}\n\tlog.Printf(\"saving to disk.\")\n\treturn nil\n}", "func Save(path string, v interface{}) error {\n\tformatter, err := parsePath(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfile, err := os.OpenFile(path, os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\treturn formatter.Encode(file, v)\n}", "func (d *Diff) Save(folder string) error {\n\tif err := os.MkdirAll(folder, 0755); err != nil {\n\t\treturn err\n\t}\n\n\tfname := filepath.Join(folder, fmt.Sprintf(\"%s.md\", d.Title))\n\tlog.Infof(\"Creating diff file: %s\", fname)\n\tf, err := os.Create(fname)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.WriteString(d.String())\n\n\treturn err\n}", "func (env *PhotonEnvReader) SaveToFile(filepath string) {\n\tdataFile, err := os.Create(filepath)\n\tdefer dataFile.Close()\n\tif err != nil {\n\t\tlog.Fatalln(\"Create \" + filepath + \" file error !\")\n\t}\n\tdata, err := json.MarshalIndent(env, \"\", \"\\t\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\t_, err = dataFile.Write(data)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(\"Write env data to \" + filepath + \" done\")\n}", "func (d deck) saveTofile(filename string) error {\n\treturn ioutil.WriteFile(filename, []byte(d.toString()), 0666)\n}", "func (buf *Buf) Save(file string) error {\n\tif file == \"\" {\n\t\treturn errors.New(\"No filename given\")\n\t}\n\n\tbs := []byte(buf.Text())\n\terr := ioutil.WriteFile(file, bs, 0644)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s\", err)\n\t}\n\n\tbuf.Name = file\n\tbuf.ClearDirty()\n\treturn nil\n}", "func (page *Page) save() error {\n\tfilename := page.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, page.Body, 0600)\n}", "func (p *Page) save() error {\r\n\tfilename := p.Title + \".txt\"\r\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\r\n}", "func (p *Page) save() error {\n\tfilename := p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (s *saver) Save(journey models.Journey) error {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\tif s.state == closed {\n\t\treturn ErrSaverIsClosed\n\t}\n\n\tif len(s.buffer) == cap(s.buffer) {\n\t\treturn ErrInternalBufferIsFull\n\t}\n\n\ts.buffer = append(s.buffer, journey)\n\treturn nil\n}", "func SetHistoryPath(fp string) {\n\tins := getInstance()\n\tcfg := ins.Config.Clone()\n\tcfg.HistoryFile = fp\n\tins.SetConfig(cfg)\n}", "func (s *Script) Save(fn string) {\n\n\t// fmt.Println(s.String())\n\n\tBOM := \"\\uFEFF\"\n\tf, err := os.Create(fn)\n\tif err != nil {\n\t\tpanic(fmt.Errorf(\"writer: failed saving subtitle file: %s\", err))\n\t}\n\tdefer f.Close()\n\n\ts.MetaFilename = fn\n\n\tn, err := f.WriteString(BOM + s.String())\n\tif err != nil {\n\t\tfmt.Println(n, err)\n\t}\n\n\t// save changes\n\t// err =\n\tf.Sync()\n}", "func (fcb *FileCacheBackend) Save(ob types.OutgoingBatch) error {\n\tfilename := fcb.getFilename(fcb.getCacheFilename(ob))\n\tlog.Printf(\"Saving to %s\", filename)\n\tfile, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Unable to save to %s - %s\", filename, err)\n\t}\n\tdefer file.Close()\n\tfor _, item := range ob.Values {\n\t\tfile.WriteString(item + \"\\n\")\n\t}\n\treturn nil\n}", "func (p *Page) save() error {\n\tfilename := \"data/\" + p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (d *Database) SaveToFile() error {\n\t//TODO Use absolute path\n\terr := os.Chdir(\"../\" + config.DBFolder)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn err\n\t}\n\n\tf, err := os.Create(fmt.Sprintf(\"%s%d\", d.DatabaseName, d.Dlog.GetIndex()))\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn errors.New(\"error\")\n\t}\n\n\tfmt.Printf(\"Saving database instance to file. Max index: %d\\n\", d.Dlog.GetIndex())\n\tencoder := gob.NewEncoder(f)\n\terr = encoder.Encode(d.Data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf.Close()\n\n\treturn nil\n}", "func (app *service) Save(state State) error {\n\tjs, err := app.adapter.ToJSON(state)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tchainHash := state.Chain()\n\tindex := state.Height()\n\tpath := filePath(chainHash, index)\n\treturn app.fileService.Save(path, js)\n}", "func main() {\n\tfmt.Println(\"Testing the history file.\")\n\n\tallHistory := history.GetHistory()\n\tfmt.Println(\"1. This is the file:\", allHistory)\n\n\t// Prove singletoniness.\n\ttheOtherHistory := history.GetHistory()\n\tfmt.Println(\"2. This should be the same file:\", theOtherHistory)\n\t//allHistory.SetFilename(\"a/b/c/d\")\n\t//fmt.Println(\"1. After changing the filepath of allHistory:\", allHistory)\n\t//fmt.Println(\"2. Did this change too?\", theOtherHistory) // Yes, it did.\n\n\t// Read in the history file exactly once.\n\tallHistory.ReadInFile()\n\tfmt.Println(\"1.\", allHistory)\n\tfmt.Println(\"2.\", theOtherHistory)\n\n\t// Right now, a player joins a tournament when the player is added\n\t// to the Table(). This could be cleaned up in the future with\n\t// making a queue of players interest in playing a tournament.\n\tvar table models.Table\n\ttable.Initialize()\n\n\ttemp := models.NewAllInAlwaysPlayer(\"Alex\")\n\ttable.AddPlayerWithHistory(&temp)\n\n\tfmt.Println(table.GetStatus())\n\n\tallHistory.Write(\"tournament\", \"start=x;stop=y\")\n\ttid := history.GetUniqueId()\n\tallHistory.Write(\"tournament\", fmt.Sprintf(\"name=%s;state=starting\", tid))\n\n\n\n\n}", "func (w *worker) WriteHistory(ctx context.Context, e uLoc) (int, error) {\n\tr := make(chan int)\n\n\tw.w <- func(h []uLoc) []uLoc {\n\t\th = append(h, e)\n\t\tr <- len(h)\n\t\treturn h\n\t}\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn -1, ErrContextCancelled\n\tcase id := <-r:\n\t\treturn id, nil\n\t}\n}", "func SaveLastHead(hash string) {\n\tf, err := os.OpenFile(conf.LastHeadMarker, os.O_CREATE|os.O_RDWR, 0666)\n\tif err != nil {\n\t\tlog.Fatal(\"Could not save last status!\")\n\t}\n\tf.WriteString(hash)\n\tf.Close()\n}", "func SaveFile(name string, v interface{}) error {\n\tdata, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tp := filepath.Join(path, name)\n\terr = ioutil.WriteFile(p, data, 0740)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (env *Solo) SaveSnapshot(fname string) {\n\tenv.glbMutex.Lock()\n\tdefer env.glbMutex.Unlock()\n\n\tsnapshot := soloSnapshot{\n\t\tUtxoDB: env.utxoDB.State(),\n\t}\n\n\tfor _, ch := range env.chains {\n\t\tchainSnapshot := soloChainSnapshot{\n\t\t\tName: ch.Name,\n\t\t\tStateControllerKeyPair: rwutil.WriteToBytes(ch.StateControllerKeyPair),\n\t\t\tChainID: ch.ChainID.Bytes(),\n\t\t\tOriginatorPrivateKey: rwutil.WriteToBytes(ch.OriginatorPrivateKey),\n\t\t\tValidatorFeeTarget: ch.ValidatorFeeTarget.Bytes(),\n\t\t}\n\n\t\terr := ch.db.Iterate(kvstore.EmptyPrefix, func(k, v []byte) bool {\n\t\t\tchainSnapshot.DB = append(chainSnapshot.DB, k, v)\n\t\t\treturn true\n\t\t})\n\t\trequire.NoError(env.T, err)\n\n\t\tsnapshot.Chains = append(snapshot.Chains, chainSnapshot)\n\t}\n\n\tb, err := json.Marshal(snapshot)\n\trequire.NoError(env.T, err)\n\terr = os.WriteFile(fname, b, 0o600)\n\trequire.NoError(env.T, err)\n}", "func (l Level) save(path string) error {\n\tf, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0777)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open file to save level: %w\", err)\n\t}\n\tdefer f.Close()\n\tencoder := json.NewEncoder(f)\n\tencoder.SetIndent(\"\", \" \")\n\terr = encoder.Encode(l)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"save level: %w\", err)\n\t}\n\treturn nil\n}", "func (p *Page) save() error {\n\tfilename := \"./pages/\" + p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\n}", "func (d deck) saveDeckToFile(fileName string) error {\n\treturn ioutil.WriteFile(fileName, []byte(d.toString()), 0666)\n}", "func (s *Server) HistoryLogPath() string { return filepath.Join(s.GetLogDir(), \"history.log\") }", "func (j Journal) Save() error {\n\t// marshal journal to JSON\n\tdata, err := json.Marshal(j)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// truncate and rewrite to the journal file\n\tjournalFilePath, err := getJournalPath(j.Name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tjournalFile, err := os.OpenFile(journalFilePath, os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0660)\n\tdefer journalFile.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := journalFile.Write(data); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func SaveTimeline(file *os.File, run *int, NInfected *int) {\n\tfmt.Fprintf(file, \"%v,%v\\n\", *run, *NInfected)\n\treturn\n}", "func handleWriteHistory(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\tstatus(w, fmt.Sprintf(\"%v\", err), 500)\n\t\t}\n\t}()\n\n\ttimeFull, value := getAddHistoryTime(w, r)\n\n\trequest := Request{\"0\", []string{value}, \"CET\"}\n\tplist := buildResult(r, &request)\n\tif len(plist) > 0 {\n\t\tphoto := plist[0]\n\t\tif photo.Title != \"\" {\n\t\t\tf := firego.NewGAE(appengine.NewContext(r), FIRE_URL+\"history\")\n\t\t\tf.Auth(FIRE_AUTH)\n\t\t\tf.Push(photo)\n\t\t}\n\t}\n\tsaveAddHistoryTime(w, r, timeFull)\n}", "func (t *TaskList) Save() (err error) {\n\tfmt.Println(\"saving...\")\n\t//Preapreing buffered output to file\n\toutFile := os.Stdout\n\tif outFile, err = os.Create(t.File); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer outFile.Close()\n\twriter := bufio.NewWriter(outFile)\n\n\t//FLushing buffer if error\n\tdefer func() {\n\t\tif err == nil {\n\t\t\terr = writer.Flush()\n\t\t}\n\t}()\n\n\t//Writing name of tasks in 1st line\n\twriteLine := \"N: \" + t.Name + \"\\n\"\n\tif _, err = writer.WriteString(writeLine); err != nil {\n\t\treturn err\n\t}\n\t//creating string with task data and write it into the file\n\tfor taskname, tsk := range t.List {\n\t\twriteLine = \"T: \" + taskname + \" \" + tsk.Parent + \" \" + tsk.Done\n\t\tif tsk.Subtask != nil {\n\t\t\tfor _, subname := range tsk.Subtask {\n\t\t\t\twriteLine += \" \" + subname\n\t\t\t}\n\t\t} //end of subtask\n\t\twriteLine += \"\\n\"\n\t\t// Writing generated line to the file\n\t\tif _, err = writer.WriteString(writeLine); err != nil {\n\t\t\treturn err\n\t\t} //end of tasks in List\n\t}\n\n\tt.IsModify = \"\"\n\treturn nil\n}", "func (mnu *MedicalNoteUpdate) SetHistory(h *History) *MedicalNoteUpdate {\n\treturn mnu.SetHistoryID(h.ID)\n}", "func (p *Page) save() error {\n\tfilename := p.Title + \".txt\"\n\treturn ioutil.WriteFile(filename, p.Body, 0600)\t// 0600 = r-w permissions for current user only\n}", "func (r *RepoGob) Save(s *models.Counter) error {\n\n\tif s == nil {\n\t\treturn errors.New(\"counter struct not specified\")\n\t}\n\n\tbuf := new(bytes.Buffer)\n\tenc := gob.NewEncoder(buf)\n\terr := enc.Encode(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(r.path, buf.Bytes(), 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *SynapsesPersist) Save() {\n\tif m.changed {\n\t\tfmt.Println(\"Saving synaptic data...\")\n\t\tindentedJSON, _ := json.MarshalIndent(m.Synapses, \"\", \" \")\n\n\t\tdataPath, err := filepath.Abs(m.relativePath)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\terr = ioutil.WriteFile(dataPath+m.file, indentedJSON, 0644)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(\"ERROR:\", err)\n\t\t}\n\n\t\tm.Clean()\n\t\tfmt.Println(\"Synaptic data saved\")\n\t}\n}", "func (fb *FileBackend) save(state *storage.State) error {\n\tout, err := proto.Marshal(state)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to encode state: %w\", err)\n\t}\n\ttmp := fmt.Sprintf(fb.path+\".%v\", time.Now())\n\tif err := ioutil.WriteFile(tmp, out, 0600); err != nil {\n\t\treturn fmt.Errorf(\"failed to write state: %w\", err)\n\t}\n\terr = os.Rename(tmp, fb.path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to move state: %w\", err)\n\t}\n\treturn nil\n}", "func (d *Dirs) Save() {\n\tj, err := json.Marshal(*d)\n\tutils.HandleErr(err, \"marshal json\")\n\terr = ioutil.WriteFile(PathToFile, j, 0611)\n\tutils.HandleErr(err, \"write to file\")\n}", "func (f *File) Save(name string) error {\n\treturn ioutil.WriteFile(name, []byte(f.String()), 0666)\n}", "func (mnuo *MedicalNoteUpdateOne) SetHistory(h *History) *MedicalNoteUpdateOne {\n\treturn mnuo.SetHistoryID(h.ID)\n}", "func Save(obj any, file string) error {\n\tfp, err := os.Create(file)\n\tdefer fp.Close()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\tbw := bufio.NewWriter(fp)\n\terr = Write(obj, bw)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\terr = bw.Flush()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn err\n}", "func (f *FileV1) toHistory() History {\n\tm := make(map[string]Record)\n\tfor k, v := range f.Records {\n\t\tr := v.toRecord()\n\t\tm[k] = r\n\t}\n\treturn History{\n\t\trecords: m,\n\t}\n}", "func (gl GroceryList) Save() error {\n\tgl.mu.Lock()\n\terr := ioutil.WriteFile(\"./resources/grocery-list.txt\", gl.Body, os.ModeDevice)\n\tgl.mu.Unlock()\n\treturn err\n}", "func (b *Bookmarks) WriteToFile(path string) error {\n\tf, err := os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\treturn b.Write(f)\n}", "func (f *ReleaseStoreCreateFunc) History() []ReleaseStoreCreateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ReleaseStoreCreateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (s *FilesystemStore) save(session *SessionImp) error {\n\tencoded, err := securecookie.EncodeMulti(session.name, session.Values,\n\t\ts.Codecs...)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfilename := filepath.Join(s.path, \"session_\"+session.ID)\n\tfileMutex.Lock()\n\tdefer fileMutex.Unlock()\n\treturn ioutil.WriteFile(filename, []byte(encoded), 0600)\n}", "func (r *Recipes) Save() error {\n\tb, err := json.Marshal(r.values)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := ioutil.WriteFile(\"recipes.json\", b, 0644); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Save(path string, x interface{}) error {\n\tmtx.Lock()\n\tdefer mtx.Unlock()\n\n\tfile, err := os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tdata, err := toJSON(x)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = io.Copy(file, data)\n\treturn err\n}", "func (p *pqDB) WriteHistory(ctx context.Context, e uLoc) (int, error) {\n\n\tc := make(chan writeHistoryData)\n\n\tgo func(e uLoc, c chan writeHistoryData) {\n\t\tvar r writeHistoryData\n\t\tr.err = p.db.QueryRow(\"INSERT INTO visits(userId,name) VALUES($1,$2) returning id;\", e.UserID, e.Name).Scan(&r.lastInsertID)\n\t\tc <- r\n\t\tfmt.Println(\"last inserted id =\", r.lastInsertID)\n\t}(e, c)\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn -1, ErrContextCancelled\n\tcase r := <-c:\n\t\treturn r.lastInsertID, r.err\n\t}\n}", "func Save(fileName string, dst interface{}) error {\n\t// Create all directories\n\tif err := os.MkdirAll(filepath.Dir(fileName), os.ModePerm); err != nil {\n\t\treturn err\n\t}\n\tfile, err := os.Create(fileName)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\tif err == nil {\n\t\tencoder := gob.NewEncoder(file)\n\t\tif err = encoder.Encode(dst); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (S *Simulation) PrintHistory(file io.Writer) {\n\tfor group := range S.agentsByGroup {\n\t\tS.PrintGroupHistory(file, group)\n\t}\n}", "func (file *File) Save() {\n\tif file.autoFmt {\n\t\terr := file.Fmt()\n\t\tif err != nil {\n\t\t\tfile.NotifyUser(err.Error())\n\t\t}\n\t}\n\tfile.SnapshotSaved()\n\tcontents := []byte(file.ToString())\n\terr := ioutil.WriteFile(file.Name, contents, file.fileMode)\n\tif err != nil {\n\t\tfile.NotifyUser(\"Save Failed: \" + err.Error())\n\t} else {\n\t\tfile.savedBuffer.ReplaceBuffer(file.buffer.DeepDup())\n\t\tfile.NotifyUser(\"Saved.\")\n\t\tfile.modTime = time.Now()\n\t\tfile.md5sum = md5.Sum(contents)\n\t}\n}", "func (j *ReplayJob) saveReplay() error {\n\tpath := filepath.Join(DirOsr, fmt.Sprintf(\"%d.osr\", j.Id()))\n\tosr, err := base64.StdEncoding.DecodeString(j.Replay.Osr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tj.Logger().Println(\"Saving replay to\", path)\n\tif err = ioutil.WriteFile(path, osr, 0644); err != nil {\n\t\treturn err\n\t}\n\tj.runtime.Osr = path\n\treturn nil\n}", "func (f *LSIFStoreDoneFunc) History() []LSIFStoreDoneFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]LSIFStoreDoneFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func (f *ExtensionStoreCreateFunc) History() []ExtensionStoreCreateFuncCall {\n\tf.mutex.Lock()\n\thistory := make([]ExtensionStoreCreateFuncCall, len(f.history))\n\tcopy(history, f.history)\n\tf.mutex.Unlock()\n\n\treturn history\n}", "func save(bytes []byte, fh *os.File) error {\n\t_, err := fh.Write(bytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = fh.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r *Recipe) Save(fname string) (err error) {\n\tb, err := json.MarshalIndent(r, \"\", \" \")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = ioutil.WriteFile(fname, b, 0644)\n\treturn\n}" ]
[ "0.7479056", "0.73361117", "0.6937678", "0.6906065", "0.6509149", "0.6318169", "0.6227113", "0.6177289", "0.6128826", "0.6128826", "0.6123193", "0.6010694", "0.6007696", "0.5999719", "0.5982161", "0.5959738", "0.5958745", "0.5958745", "0.5958745", "0.5958745", "0.59560835", "0.5889023", "0.5863548", "0.58538944", "0.5838771", "0.5838627", "0.5832787", "0.5828168", "0.5814686", "0.5807984", "0.5801335", "0.5769", "0.5716979", "0.57139045", "0.5697455", "0.56939554", "0.5683069", "0.5679386", "0.5675407", "0.56179994", "0.5590644", "0.5589261", "0.5584696", "0.55843514", "0.5573696", "0.5547294", "0.5544013", "0.55123377", "0.5496939", "0.5495869", "0.54902077", "0.5481425", "0.54689157", "0.54423195", "0.5435597", "0.54331166", "0.5425777", "0.542428", "0.5419515", "0.5418194", "0.5413455", "0.54039896", "0.5397465", "0.53886867", "0.53876114", "0.5385796", "0.5354821", "0.5354654", "0.535366", "0.5345679", "0.5344061", "0.5336076", "0.5332138", "0.5327747", "0.53243226", "0.53186214", "0.53119653", "0.52954507", "0.52808833", "0.52732587", "0.5272726", "0.5267024", "0.52644473", "0.5256545", "0.5255311", "0.5253224", "0.52491754", "0.52483994", "0.52480114", "0.5245981", "0.5220025", "0.52092177", "0.5201788", "0.5201637", "0.519535", "0.51935184", "0.51918083", "0.5182994", "0.51670206", "0.5164694" ]
0.8345424
0
HistoryLoad loads history from a file.
func (l *Linenoise) HistoryLoad(fname string) { info, err := os.Stat(fname) if err != nil { return } if !info.Mode().IsRegular() { log.Printf("%s is not a regular file\n", fname) return } f, err := os.Open(fname) if err != nil { log.Printf("%s error on open %s\n", fname, err) return } b := bufio.NewReader(f) l.history = make([]string, 0, l.historyMaxlen) for { s, err := b.ReadString('\n') if err == nil || err == io.EOF { s = strings.TrimSpace(s) if len(s) != 0 { l.history = append(l.history, s) } if err == io.EOF { break } } else { log.Printf("%s error on read %s\n", fname, err) } } f.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n *nameHistory) Load() error {\n\tfp, err := os.OpenFile(n.filepath, os.O_RDONLY, os.ModePerm)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not open %q file: %v\", n.filepath, err)\n\t}\n\tdefer fp.Close()\n\n\tif err := yaml.NewDecoder(fp).Decode(&n.entries); err != nil {\n\t\treturn fmt.Errorf(\"could not decode file: %v\", err)\n\t}\n\n\tn.isChanged = false\n\n\treturn nil\n}", "func (bh *browserHistory) Load() error {\n\thist := js.Global().Get(\"localStorage\").Get(\"history\")\n\tif hist.Type() == js.TypeUndefined {\n\t\treturn nil // nothing to unmarashal\n\t}\n\tvar records []string\n\tif err := json.Unmarshal([]byte(hist.String()), &records); err != nil {\n\t\treturn err\n\t}\n\tbh.Records = records\n\n\treturn nil\n}", "func (t *T) Load(fileName string) error {\n\tfile, err := os.OpenFile(fileName, os.O_APPEND|os.O_RDWR, os.ModeAppend)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tt.file = file\n\tt.links = make(map[string]string)\n\n\tscanner := bufio.NewScanner(file)\n\n\tscanner.Split(bufio.ScanLines)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\ttokens := strings.Split(line, \",\")\n\n\t\tif len(tokens) != 2 {\n\t\t\tfile.Close()\n\t\t\treturn fmt.Errorf(\"invalid line: %s\", line)\n\t\t}\n\n\t\tt.links[tokens[0]] = tokens[1]\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tfile.Close()\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func ParseHistoryFile(b []byte) (*History, error) {\n\tversion, err := detectHistoryFileVersion(b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch version {\n\tcase 1:\n\t\treturn parseHistoryFileV1(b)\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown history file version: %d\", version)\n\t}\n}", "func (h *History) ReadFile(path string) error {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tr := csv.NewReader(file)\n\n\tfor {\n\t\trecord, err := r.Read()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif len(record) < 5 {\n\t\t\treturn errors.New(\"operation history file format error\")\n\t\t}\n\n\t\t// get id / key\n\t\tid, err := strconv.Atoi(record[0])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\toperation := new(operation)\n\n\t\t// get input\n\t\tif record[1] == \"null\" || record[1] == \"\" {\n\t\t\toperation.input = nil\n\t\t} else {\n\t\t\toperation.input = record[1]\n\t\t}\n\n\t\t// get output\n\t\tif record[2] == \"null\" || record[2] == \"\" {\n\t\t\toperation.output = nil\n\t\t} else {\n\t\t\toperation.output = record[2]\n\t\t}\n\n\t\t// get start time\n\t\tstart, err := strconv.ParseInt(record[3], 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t\treturn err\n\t\t}\n\t\toperation.start = start\n\n\t\t// get end time\n\t\tend, err := strconv.ParseInt(record[4], 10, 64)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t\treturn err\n\t\t}\n\t\toperation.end = end\n\n\t\th.AddOperation(id, operation)\n\t}\n\n\treturn file.Close()\n}", "func (lfile *Logfile) Load() ([]*LogRecord, error) {\n\tvar lrecs []*LogRecord\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tlrec := rec.ToLogRecord(lfile.debug)\n\t\t\tlrecs = append(lrecs, lrec)\n\t\t}\n\t\treturn nil\n\t}\n\terr := lfile.Process(f, LOG_RECORD, true)\n\treturn lrecs, err\n}", "func (s *Store) Load(ctx context.Context, aggregateID string, fromVersion, toVersion int) (eventsource.History, error) {\n\tdb, err := s.accessor.Open(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"load failed; unable to connect to db\")\n\t}\n\tdefer s.accessor.Close(db)\n\n\treturn s.doLoad(ctx, db, aggregateID, fromVersion, toVersion)\n}", "func LoadHistoryResult(t int64) error {\n\th, err := GetHistory(t)\n\tif err != nil {\n\t\treturn err\n\t}\n\trecordMutex.Lock()\n\tfor _, v := range h.Record {\n\t\tcurrentRecord[v] = countThres\n\t}\n\trecordMutex.Unlock()\n\treturn nil\n}", "func (d *Database) Load() error {\n\tb, err := ioutil.ReadFile(d.FilePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := json.Unmarshal(b, &d.State); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (d *Dump) Load() error {\n\td.mutex.Lock()\n\tdefer d.mutex.Unlock()\n\n\tvar (\n\t\tdata []byte\n\t\terr error\n\t)\n\n\tif data, err = ioutil.ReadFile(d.filename); err != nil {\n\t\treturn err\n\t}\n\n\treturn d.decodeGob(data)\n}", "func (f *FilePersist) Load(ctx context.Context) (map[string]string, error) {\n\tfr, err := os.Open(f.filename)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to open file: %w\", err)\n\t}\n\tdefer fr.Close()\n\n\tdb := make(map[string]string)\n\tif err := json.NewDecoder(fr).Decode(&db); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to decode file: %w\", err)\n\t}\n\treturn db, nil\n}", "func (s *Store) Load(ctx context.Context, aggregateID string, version int) (eventsource.History, error) {\n\tpartition := selectPartition(version, s.eventsPerItem)\n\tinput, err := makeQueryInput(s.tableName, s.hashKey, s.rangeKey, aggregateID, partition)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thistory := make(eventsource.History, 0, version)\n\n\tvar startKey map[string]*dynamodb.AttributeValue\n\tfor {\n\t\tout, err := s.api.Query(input)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif len(out.Items) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\t// events are stored within av as _t{version} = {event-type}, _d{version} = {serialized event}\n\t\tfor _, item := range out.Items {\n\t\t\tfor key, av := range item {\n\t\t\t\tif !isKey(key) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\trecordVersion, err := versionFromKey(key)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tif version > 0 && recordVersion > version {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\thistory = append(history, eventsource.Record{\n\t\t\t\t\tVersion: recordVersion,\n\t\t\t\t\tData: av.B,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tstartKey = out.LastEvaluatedKey\n\t\tif len(startKey) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tsort.Slice(history, func(i, j int) bool {\n\t\treturn history[i].Version < history[j].Version\n\t})\n\n\treturn history, nil\n}", "func (rl *readline) ReadHistory() error {\n\tf, err := os.Open(rl.historyFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\t_, err = rl.State.ReadHistory(f)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *Schedule) Load() {\r\n\tb, _ := ioutil.ReadFile(s.fileName)\r\n\tjson.Unmarshal(b, &s.ScheduleMap)\r\n}", "func LoadFromFile() error {\n\t_, err := os.Stat(eventsFilename)\n\tif os.IsNotExist(err) {\n\t\treturn nil\n\t}\n\tdata, err := ioutil.ReadFile(eventsFilename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(data, &Events)\n}", "func (m *SynapsesPersist) Load() {\n\tdataPath, err := filepath.Abs(m.relativePath)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\teFile, err := os.Open(dataPath + m.file)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer eFile.Close()\n\n\tbytes, err := ioutil.ReadAll(eFile)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = json.Unmarshal(bytes, &m.Synapses)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (self *LSHforest) Load(path string) error {\n\tb, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn msgpack.Unmarshal(b, self)\n}", "func (wd WorkDir) Load(file string) ([]byte, error) {\n\tfh, err := os.Open(wd.Join(file))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer fh.Close()\n\treturn ioutil.ReadAll(fh)\n}", "func loadLogs(path string) ([]Log, error) {\n\t// Create the file if it does not exist\n\tf, err := os.OpenFile(path+\"/logs.json\", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0644)\n\tif err == nil {\n\t\t// New file. Write empty list to it\n\t\t_, err = f.WriteString(\"[]\")\n\t\tif err != nil {\n\t\t\tf.Close()\n\t\t\treturn []Log{}, err\n\t\t}\n\t}\n\tf.Close()\n\n\t// Load the file\n\tlogs := &[]Log{}\n\tdata, err := ioutil.ReadFile(path + \"/logs.json\")\n\tif err != nil {\n\t\treturn []Log{}, err\n\t}\n\n\terr = json.Unmarshal(data, &logs)\n\tif err != nil {\n\t\treturn []Log{}, err\n\t}\n\n\treturn *logs, nil\n}", "func NewPostHistoryReaderFromFile(path string) (*Reader, error) {\n\treturn newReaderFromFile(path, typePostHistory)\n}", "func (c *Cache) LoadFile(filename string) (rl *RuleList, err error) {\n\tinfo, err := os.Stat(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif cf, ok := c.files[filename]; ok {\n\t\tif !cf.modTime.Before(info.ModTime()) {\n\t\t\t// cached RuleList is not older than the file, it's\n\t\t\t// good enough\n\t\t\treturn cf.rl, nil\n\t\t}\n\t}\n\t// here, either the cached RuleList is older than the file, or it\n\t// doesn't exist\n\trl, err = LoadFile(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.files[filename] = cachedFile{\n\t\tmodTime: info.ModTime(),\n\t\tname: filename,\n\t\trl: rl,\n\t}\n\treturn rl, nil\n}", "func Load(filePath string, t Tomler) error {\n\ttomlValue := t.TOMLValue()\n\tvar err error\n\tif _, err = toml.DecodeFile(filePath, tomlValue); err != nil {\n\t\treturn err\n\t}\n\treturn t.FromTOML(tomlValue)\n}", "func (l *Level) load(path string) error {\n\t*l = NewLevel()\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open file to load level: %w\", err)\n\t}\n\tdefer f.Close()\n\tdecoder := json.NewDecoder(f)\n\terr = decoder.Decode(l)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"decoding level from file: %w\", err)\n\t}\n\tfor _, a := range l.Art {\n\t\terr := a.Load()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"load %v: %w\", a.Path, err)\n\t\t}\n\t}\n\tif l.PlayerArt != nil {\n\t\terr := l.PlayerArt.Load()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"load player art %v: %w\", l.PlayerArt.Path, err)\n\t\t}\n\t}\n\tif l.BGArt != nil {\n\t\terr := l.BGArt.Load()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"load BG art %v: %w\", l.BGArt.Path, err)\n\t\t}\n\t}\n\tif l.BGAudio != nil {\n\t\terr = l.BGAudio.Load()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"load bg audio: %w\", err)\n\t\t}\n\t}\n\tfor n, t := range l.Triggers {\n\t\terr := t.Load()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"load trigger '%v': %w\", n, err)\n\t\t}\n\t\tl.Triggers[n] = t\n\t}\n\treturn nil\n}", "func (ed *Editor) Load(s []byte) {\n\tlast := len(ed.buffer.Lines) - 1\n\tall := address.Selection{To: address.Simple{last, ed.buffer.Lines[last].RuneCount()}}\n\ted.dot = ed.buffer.ClearSel(all)\n\ted.dot.To = ed.buffer.InsertString(address.Simple{}, string(s))\n\ted.history = new(hist.History)\n\ted.uncommitted = nil\n\ted.dirty = true\n}", "func main() {\n\tfmt.Println(\"Testing the history file.\")\n\n\tallHistory := history.GetHistory()\n\tfmt.Println(\"1. This is the file:\", allHistory)\n\n\t// Prove singletoniness.\n\ttheOtherHistory := history.GetHistory()\n\tfmt.Println(\"2. This should be the same file:\", theOtherHistory)\n\t//allHistory.SetFilename(\"a/b/c/d\")\n\t//fmt.Println(\"1. After changing the filepath of allHistory:\", allHistory)\n\t//fmt.Println(\"2. Did this change too?\", theOtherHistory) // Yes, it did.\n\n\t// Read in the history file exactly once.\n\tallHistory.ReadInFile()\n\tfmt.Println(\"1.\", allHistory)\n\tfmt.Println(\"2.\", theOtherHistory)\n\n\t// Right now, a player joins a tournament when the player is added\n\t// to the Table(). This could be cleaned up in the future with\n\t// making a queue of players interest in playing a tournament.\n\tvar table models.Table\n\ttable.Initialize()\n\n\ttemp := models.NewAllInAlwaysPlayer(\"Alex\")\n\ttable.AddPlayerWithHistory(&temp)\n\n\tfmt.Println(table.GetStatus())\n\n\tallHistory.Write(\"tournament\", \"start=x;stop=y\")\n\ttid := history.GetUniqueId()\n\tallHistory.Write(\"tournament\", fmt.Sprintf(\"name=%s;state=starting\", tid))\n\n\n\n\n}", "func (g *Gonf) Load() error {\n\tb, err := ioutil.ReadFile(g.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfg := map[string]interface{}{}\n\tif err := json.Unmarshal(b, &cfg); err != nil {\n\t\treturn err\n\t}\n\n\t// forbids access to Get/Set local and HTTP while reloading\n\tg.confLock.Lock()\n\tdefer g.confLock.Unlock()\n\tg.conf = cfg\n\n\treturn g.load(cfg, []string{}, []otoFlag{})\n}", "func (lm *LocalMeta) Load() error {\n\t// initialize gset\n\tvar err error\n\tlm.gset, err = gtid.ParserGTID(lm.flavor, \"\")\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tfile, err := os.Open(lm.filename)\n\tif err != nil && !os.IsNotExist(errors.Cause(err)) {\n\t\treturn errors.Trace(err)\n\t}\n\n\tif os.IsNotExist(errors.Cause(err)) {\n\t\treturn nil\n\t}\n\tdefer file.Close()\n\n\t_, err = toml.DecodeReader(file, lm)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tlm.gset, err = gtid.ParserGTID(lm.flavor, lm.BinlogGTID)\n\treturn errors.Trace(err)\n}", "func (c *UsageController) Load(r *http.Request) error {\n\tvar changelog []models.Usage\n\n\tdata, err := storage.GetFile(\"usage\", r)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = json.Unmarshal(data, &changelog)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.setList(changelog)\n\n\treturn nil\n}", "func HistoryFile(history_basename string) string {\n\thome_dir := os.Getenv(\"HOME\")\n\tif home_dir == \"\" {\n\t\t// FIXME: also try ~ ?\n\t\tfmt.Println(\"ignoring history file; environment variable HOME not set\")\n\t\treturn \"\"\n\t}\n\thistory_file := filepath.Join(home_dir, history_basename)\n\tif fi, err := os.Stat(history_file); err != nil {\n\t\tfmt.Println(\"No history file found to read in: \", err.Error())\n\t} else {\n\t\tif fi.IsDir() {\n\t\t\tErrmsg(\"Ignoring history file %s; is a directory, should be a file\",\n\t\t\t\thistory_file)\n\t\t\treturn \"\"\n\t\t}\n\t}\n\treturn history_file\n}", "func parseHistoryFileV1(b []byte) (*History, error) {\n\tvar f FileV1\n\n\terr := json.Unmarshal(b, &f)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th := f.toHistory()\n\n\treturn &h, nil\n}", "func (m *CSVManager) Load(pathAndFilename string) error {\n\te := m.List.Update(pathAndFilename)\n\treturn e\n}", "func (s Store) Load(aggregateID string) ([]midgard.Event, error) {\n\ts.mux.Lock()\n\tsession := s.getFreshSession()\n\n\tdefer func() {\n\t\ts.mux.Unlock()\n\t\tsession.Close()\n\t}()\n\n\tdocument, err := s.getDocument(aggregateID)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tevents := make([]midgard.Event, 0)\n\n\tfor _, v := range document.getHistory() {\n\t\tevent, err := s.serializer.Unmarshal(v)\n\n\t\tif err != nil {\n\t\t\treturn []midgard.Event{}, err\n\t\t}\n\n\t\tevents = append(events, event)\n\t}\n\n\treturn events, nil\n}", "func loadHisto() (r, g, b *Histo, err error) {\n\tfile, err := os.Open(\"r-g-b.gob\")\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tdefer file.Close()\n\tdec := gob.NewDecoder(file)\n\tif err := dec.Decode(&r); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tif err := dec.Decode(&g); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tif err := dec.Decode(&b); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\treturn r, g, b, nil\n}", "func HistoryFile(history_basename string) string {\n\thome_dir := os.Getenv(\"HOME\")\n\tif home_dir == \"\" {\n\t\t// FIXME: also try ~ ?\n\t\tfmt.Println(\"ignoring history file; environment variable HOME not set\")\n\t\treturn \"\"\n\t}\n\thistory_file := filepath.Join(home_dir, history_basename)\n\tif fi, err := os.Stat(history_file); err != nil {\n\t\tfmt.Println(\"No history file found to read in\")\n\t} else {\n\t\tif fi.IsDir() {\n\t\t\tfmt.Printf(\"Ignoring history file %s; is a directory, should be a file\",\n\t\t\t\thistory_file)\n\t\t\treturn \"\"\n\t\t}\n\t}\n\treturn history_file\n}", "func (db *LocalDb) load() error {\n\n\tdb.mutex.Lock()\n\tdefer db.mutex.Unlock()\n\n\t// read file\n\tdata, err := ioutil.ReadFile(constLocalDbFn)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn err\n\t}\n\n\t// decode json\n\tdb.users = make(map[string]*UserInfo)\n\tif err := json.Unmarshal(data, &db.users); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Load(path string) (db DB, err error) {\n\tdb.filePath = path\n\n\tb, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(b, &db)\n\n\treturn\n}", "func (w *Window) Load(rawurl string, v ...interface{}) error {\n\trawurl = fmt.Sprintf(rawurl, v...)\n\tu, err := url.Parse(rawurl)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcompoName := app.ComponentNameFromURL(u)\n\tisRegisteredCompo := driver.factory.Registered(compoName)\n\tcurrentURL, err := w.history.Current()\n\n\tif isRegisteredCompo && (err != nil || currentURL != u.String()) {\n\t\tw.history.NewEntry(u.String())\n\t}\n\treturn w.load(u)\n}", "func (c *Info) Load() error {\n\tb, err := ioutil.ReadFile(c.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.Lock()\n\terr = json.Unmarshal(b, c)\n\tc.Unlock()\n\n\treturn err\n}", "func (ifile *Indexfile) Load() (lfindex *Index, err error) {\n\tlfindex = new(Index)\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tirec := rec.ToIndexRecord(ifile.debug)\n\t\t\tlfindex.List = append(lfindex.List, irec)\n\t\t}\n\t\treturn nil\n\t}\n\terr = ifile.Process(f, INDEX_RECORD, false)\n\treturn\n}", "func loadFile() (*models.Page, error) {\n\tfilename := path.Join(\"logs\", \"log.txt\")\n\tbody, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &models.Page{Body: template.HTML(body)}, nil\n}", "func Load(filename string, prefs interface{}) error {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\treturn json.NewDecoder(f).Decode(&prefs)\n}", "func (r *PebbleFileRegistry) Load() error {\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\tr.mu.currProto = &enginepb.FileRegistry{}\n\tr.registryFilename = r.FS.PathJoin(r.DBDir, fileRegistryFilename)\n\tf, err := r.FS.Open(r.registryFilename)\n\tif oserror.IsNotExist(err) {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tvar b []byte\n\tif b, err = ioutil.ReadAll(f); err != nil {\n\t\treturn err\n\t}\n\tif err = protoutil.Unmarshal(b, r.mu.currProto); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Load(filename string) (*RBM, error) {\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer file.Close()\n\n\tdecoder := json.NewDecoder(file)\n\trbm := &RBM{}\n\terr = decoder.Decode(rbm)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn rbm, nil\n}", "func (s *Storage) Load(file string) error {\n\tnewDB, err := openDB(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\toldDB := s.getDB()\n\ts.db.Store(newDB)\n\tif oldDB != nil {\n\t\toldDB.Close()\n\t}\n\treturn nil\n}", "func (s *Storage) Load(file string) error {\n\tnewDB, err := openDB(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\toldDB := s.getDB()\n\ts.db.Store(newDB)\n\tif oldDB != nil {\n\t\toldDB.Close()\n\t}\n\treturn nil\n}", "func (s *Server) loadRules(file string) error {\n\tfi, err := os.Stat(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmtime := fi.ModTime()\n\tif mtime.Before(s.mtime) && s.rules != nil {\n\t\treturn nil // no change\n\t}\n\trules, err := parseRules(file)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parsing %s: %v\", file, err)\n\t}\n\ts.mu.Lock()\n\ts.mtime = mtime\n\ts.rules = rules\n\ts.mu.Unlock()\n\treturn nil\n}", "func LoadFromFile(path string, v interface{}) (err error) {\n\tr, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer utils.CheckClose(r, fmt.Sprintf(\"error closing %q\", path), &err)\n\treturn Load(r, v)\n}", "func (i *historyItem) getHistory() ([]*historyRow, error) {\n\trows := []*historyRow{}\n\n\tfi, err := os.Open(i.path)\n\tif err != nil {\n\t\treturn rows, err\n\t}\n\tdefer fi.Close()\n\n\tbr := bufio.NewReader(fi)\n\tfor {\n\t\ta, _, c := br.ReadLine()\n\t\tif c == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tr := &historyRow{}\n\t\t// ignore\n\t\terr := json.Unmarshal(a, r)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\trows = append(rows, r)\n\t}\n\n\treturn rows, nil\n}", "func (f *Flow) Load(cacheDir string) (err error) {\n\tif f.FlowFile == \"\" {\n\t\treturn nil\n\t}\n\tvar content []byte\n\tswitch getURLType(f.FlowFile) {\n\tcase \"local\":\n\t\tcontent, err = ioutil.ReadFile(f.FlowFile)\n\tcase \"web\":\n\t\tcontent, err = get(cacheDir, f.FlowFile)\n\t// TODO git - including the branch\n\tdefault:\n\t\treturn fmt.Errorf(\"unrecognised floe file type: <%s>\", f.FlowFile)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// unmarshal into a flow\n\tnewFlow := &Flow{}\n\terr = yaml.Unmarshal(content, &newFlow)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set up the flow, and copy bits into this flow\n\terr = newFlow.zero()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(newFlow.Name) != 0 {\n\t\tf.Name = newFlow.Name\n\t}\n\tf.ReuseSpace = newFlow.ReuseSpace\n\tif len(newFlow.HostTags) != 0 {\n\t\tf.HostTags = newFlow.HostTags\n\t}\n\tif len(newFlow.ResourceTags) != 0 {\n\t\tf.ResourceTags = newFlow.ResourceTags\n\t}\n\tif len(newFlow.Env) != 0 {\n\t\tf.Env = newFlow.Env\n\t}\n\tif len(newFlow.Tasks) != 0 {\n\t\tf.Tasks = newFlow.Tasks\n\t}\n\t// Pointless overriding triggers - as they are what caused this load\n\treturn nil\n}", "func (d *Directory) Load(file string) ([]byte, error) {\n\tfh, err := os.Open(d.Join(file))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer fh.Close()\n\treturn ioutil.ReadAll(fh)\n}", "func (s *DataStore) Load() error {\n\tfile, err := os.Open(s.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\ts.Lock()\n\tdefer s.Unlock()\n\n\terr = json.NewDecoder(file).Decode(&s.model)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *Model) Load(path string) error {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.Wrap(err, \"load model\")\n\t}\n\tif err := json.Unmarshal(data, m); err != nil {\n\t\treturn errors.Wrap(err, \"load model\")\n\t}\n\treturn nil\n}", "func Load(filepath string) error {\n\tonce.Do(func() {\n\t\tloadError = load(filepath)\n\t})\n\n\treturn loadError\n}", "func fileToHist(filePath string) models.AsciiHist {\n\tresult := models.AsciiHist{}\n\tdefer fileReadersGroup.Done()\n\tfile, err := os.Open(filePath)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn result\n\t}\n\tdefer file.Close()\n\tcontent, err := ioutil.ReadAll(file)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn result\n\t}\n\tresult.FromByteSlice(content)\n\treturn result\n}", "func (withdrawalCryptoL) LoadWithdrawalHistory(ctx context.Context, e boil.ContextExecutor, singular bool, maybeWithdrawalCrypto interface{}, mods queries.Applicator) error {\n\tvar slice []*WithdrawalCrypto\n\tvar object *WithdrawalCrypto\n\n\tif singular {\n\t\tobject = maybeWithdrawalCrypto.(*WithdrawalCrypto)\n\t} else {\n\t\tslice = *maybeWithdrawalCrypto.(*[]*WithdrawalCrypto)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &withdrawalCryptoR{}\n\t\t}\n\t\targs = append(args, object.WithdrawalHistoryID)\n\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &withdrawalCryptoR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.WithdrawalHistoryID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.WithdrawalHistoryID)\n\n\t\t}\n\t}\n\n\tif len(args) == 0 {\n\t\treturn nil\n\t}\n\n\tquery := NewQuery(qm.From(`withdrawal_history`), qm.WhereIn(`withdrawal_history.id in ?`, args...))\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load WithdrawalHistory\")\n\t}\n\n\tvar resultSlice []*WithdrawalHistory\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice WithdrawalHistory\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for withdrawal_history\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for withdrawal_history\")\n\t}\n\n\tif len(withdrawalCryptoAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.WithdrawalHistory = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &withdrawalHistoryR{}\n\t\t}\n\t\tforeign.R.WithdrawalCryptos = append(foreign.R.WithdrawalCryptos, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.WithdrawalHistoryID == foreign.ID {\n\t\t\t\tlocal.R.WithdrawalHistory = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &withdrawalHistoryR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.WithdrawalCryptos = append(foreign.R.WithdrawalCryptos, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (l *Loader) Load() ([]byte, error) {\n\treturn ioutil.ReadFile(l.filename)\n}", "func (this *Manager) load() error{\n bytes, err := ioutil.ReadFile(this.filename())\n if err != nil {\n return err\n }\n mp := dynmap.NewDynMap()\n err = mp.UnmarshalJSON(bytes)\n if err != nil {\n return err\n }\n table,err := ToRouterTable(mp)\n if err != nil {\n return err\n }\n this.SetRouterTable(table) \n return nil\n}", "func Load(path string, target interface{}) error {\n\tformatter, err := parsePath(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn load(formatter, data, target)\n}", "func (s *Store) Load() error {\n\tfReader, err := os.Open(filepath.Join(s.rwDirPath, storeName))\n\tif err != nil {\n\t\treturn errors.Wrap(err, err.Error())\n\t}\n\tdefer fReader.Close()\n\n\tdec := gob.NewDecoder(fReader)\n\n\ts.Lock()\n\tdefer s.Unlock()\n\n\terr = dec.Decode(&s.data)\n\tif err != nil {\n\t\treturn errors.Wrap(err, err.Error())\n\t}\n\treturn nil\n}", "func LoadFromFile(fileName string, data interface{}) error {\n\t// If data is not a pointer, return an error\n\tif reflect.TypeOf(data).Kind() != reflect.Ptr {\n\t\treturn errors.New(\"pointer expected\")\n\t}\n\n\t// Leemos el objeto json de un archivo.\n\tbytes, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Transformamos el objeto json a una estructura y la guardamos en la variable 'data'.\n\terr = json.Unmarshal(bytes, data)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (ws *WalletStore) Load(filename string) error {\n\tcontent, err := ioutil.ReadFile(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treader := bytes.NewReader(content)\n\tgob.Register(elliptic.P256())\n\tdecoder := gob.NewDecoder(reader)\n\terr = decoder.Decode(&ws.Wallets)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Load(filename string, v interface{}) {\n\tParse(read(filename), v)\n}", "func (a *Account) Load(filePath string) error {\n\td, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = yaml.Unmarshal(d, a)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Load(path string, v interface{}) error {\n\tlock.Lock()\n\tdefer lock.Unlock()\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\treturn Unmarshal(f, v)\n}", "func (function *Function) Load() (err error) {\n\tdefinition, err := ioutil.ReadFile(function.Path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfunction.Definition = string(definition)\n\n\treturn\n}", "func (this *PatientCase) Load(filePath string) {\n\tthis.Case = make(map[string]*EmrCase)\n\tf, err := os.Open(filePath)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer f.Close()\n\tbfRd := bufio.NewReader(f)\n\tfor {\n\t\tline, err := bfRd.ReadBytes('\\n')\n\t\twords := strings.Split(string(line), string('\\t'))\n\t\tif len(words) == 4 {\n\t\t\tvisitID := words[0]\n\t\t\tif _, ok := this.Case[visitID]; ok {\n\t\t\t\tthis.Case[visitID].load(words[3], words[1], words[2])\n\t\t\t} else {\n\t\t\t\tthis.Case[visitID] = &EmrCase{}\n\t\t\t\tthis.Case[visitID].load(words[3], words[1], words[2])\n\t\t\t}\n\t\t}\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func Load(file string, v interface{}) error {\n\tf, err := gzipf.Open(file)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\treturn json.NewDecoder(f).Decode(v)\n}", "func (ldb *Logdatabase) LoadDatabase(filename string) {\n\tfile, e := ioutil.ReadFile(filename)\n\tif e != nil {\n\t\tlog.Fatalf(\"Could not open database file: \" + filename)\n\t\tos.Exit(1)\n\t}\n\n\tvar data map[string]map[string]logrecord\n\tjson.Unmarshal(file, &data)\n\tldb.lock.Lock()\n\tdefer ldb.lock.Unlock()\n\n\tldb.db = data\n\tldb.dirty = false\n\tldb.filename = filename\n}", "func Load(fromPath string, toVar interface{}) {\n\tfile, e := ioutil.ReadFile(fromPath)\n\terr.Panic(e)\n\tfile = RemoveComment(file)\n\terr.Panic(json.Unmarshal(file, toVar))\n}", "func Load(path string) ([]*Entry, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil,err\n\t}\n\tdefer file.Close()\n\n\tlines, err := csv.NewReader(file).ReadAll()\n\tif err != nil {\n\t\treturn nil,err\n\t}\n\tvar output []*Entry\n\t// Loop through lines & turn into object\n\tfor idx, line := range lines {\n\t\tif idx == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif len (line) < 3 {\n\t\t\treturn nil, fmt.Errorf(\"malformed input error: %s\", line)\n\t\t}\n\t\tdone, err := strconv.ParseBool(line[0])\n\t\tdeadline, err := time.Parse(\"2006-01-02\",line[2])\n\t\tif err != nil {\n\t\t\treturn nil,err\n\t\t}\n\t\tvar data = Entry{\n\t\t\tDone: done,\n\t\t\tText: line[1],\n\t\t\tDeadline: deadline,\n\t\t}\n\t\toutput = append(output, &data)\n\t}\n\n\treturn output, nil\n}", "func Load(path string, v interface{}) error {\n\tlock.Lock()\n\tdefer lock.Unlock()\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn err\n\t\t}\n\t}\n\tdefer f.Close()\n\treturn Unmarshal(f, v)\n}", "func (itr *doltColDiffCommitHistoryRowItr) loadTableChanges(ctx context.Context, commit *doltdb.Commit) error {\n\ttableChanges, err := itr.calculateTableChanges(ctx, commit)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\titr.tableChanges = tableChanges\n\titr.tableChangesIdx = 0\n\tif len(tableChanges) == 0 {\n\t\treturn nil\n\t}\n\n\tmeta, err := commit.GetCommitMeta(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\titr.meta = meta\n\n\tcmHash, err := commit.HashOf()\n\tif err != nil {\n\t\treturn err\n\t}\n\titr.hash = cmHash\n\n\treturn nil\n}", "func (p *Entry) Load() (modified bool, err error) {\n\tf, err := os.Open(p.Path)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer f.Close()\n\tdata, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tinfo, err := f.Stat()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tmodified = info.ModTime() != p.ModTime\n\tp.ModTime = info.ModTime()\n\tp.Body, err = frontmatter.Unmarshal(data, p)\n\treturn modified, err\n}", "func Load(path string) ([]byte, error) {\n\tmtx.Lock()\n\tdefer mtx.Unlock()\n\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn data, nil\n}", "func (f *function) load() (err error) {\n\tdefinition, err := ioutil.ReadFile(f.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.definition = string(definition)\n\n\treturn\n}", "func (b Banai) Load(stashID string) ([]byte, error) {\n\tpath := filepath.Join(b.stashFolder, stashID)\n\t_, e := os.Stat(path)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\n\tf, e := ioutil.ReadFile(path)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\n\treturn f, nil\n\n}", "func (c *IntentClassifier) Load(filePath string) error {\n\tlog.Printf(\"Loading Classifier from %s...\", filePath)\n\tmeta := persist.Load(filePath)\n\t//get the classifier current meta data\n\tname, version := c.getMeta()\n\tif meta.Name != name {\n\t\treturn fmt.Errorf(\"This file doesn't contain a KNearestNeighbors classifier\")\n\t}\n\tif meta.Version != version {\n\t\treturn fmt.Errorf(\"Can't understand this file format\")\n\t}\n\n\tdecoder := gob.NewDecoder(bytes.NewBuffer(meta.Data))\n\terr := decoder.Decode(&c)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error decoding RNN checkpoint file: %s\", err)\n\t}\n\n\tcheckpointFile = filePath\n\treturn nil\n}", "func (c *Config) LoadFile(path string) error {\n\t_, err := toml.DecodeFile(path, &c)\n\treturn err\n}", "func (manager *basicStateManager) Load() error {\n\ts := manager.state\n\tseelog.Info(\"Loading state!\")\n\tdata, err := manager.readFile()\n\tif err != nil {\n\t\tseelog.Error(\"Error reading existing state file\", \"err\", err)\n\t\treturn err\n\t}\n\tif data == nil {\n\t\treturn nil\n\t}\n\t// Dry-run to make sure this is a version we can understand\n\terr = manager.dryRun(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Now load it into the actual state. The reason we do this with the\n\t// intermediate state is that we *must* unmarshal directly into the\n\t// \"saveable\" pointers we were given in AddSaveable; if we unmarshal\n\t// directly into a map with values of pointers, those pointers are lost.\n\t// We *must* unmarshal this way because the existing pointers could have\n\t// semi-initialized data (and are actually expected to)\n\n\tvar intermediate intermediateState\n\terr = json.Unmarshal(data, &intermediate)\n\tif err != nil {\n\t\tseelog.Debug(\"Could not unmarshal into intermediate\")\n\t\treturn err\n\t}\n\n\tfor key, rawJSON := range intermediate.Data {\n\t\tactualPointer, ok := manager.state.Data[key]\n\t\tif !ok {\n\t\t\tseelog.Error(\"Loading state: potentially malformed json key of \" + key)\n\t\t\tcontinue\n\t\t}\n\t\terr = json.Unmarshal(rawJSON, actualPointer)\n\t\tif err != nil {\n\t\t\tseelog.Debug(\"Could not unmarshal into actual\")\n\t\t\treturn err\n\t\t}\n\t}\n\n\tseelog.Debug(\"Loaded state!\", \"state\", s)\n\treturn nil\n}", "func Load(fileName string) (stu *StudentSet, err error) {\n\tbs, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(bs, &stu)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func LoadChanges() map[string]string {\n\treturn changes\n}", "func (r *Registry) Load(relPath string) (value interface{}, ok bool) {\n\t_, filename, _, _ := runtime.Caller(1)\n\tdir, _ := filepath.Split(filename)\n\treturn r.db.Load(filepath.Join(dir, relPath))\n}", "func GetHistory(store Store, datatype, realm, user, id string, r *http.Request) (*cpb.History, int, error) {\n\thlist := make([]proto.Message, 0)\n\tif err := store.ReadHistory(datatype, realm, user, id, &hlist); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\t// TODO: perhaps this should be the empty list?\n\t\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"no config history available\")\n\t\t}\n\t\treturn nil, http.StatusBadRequest, fmt.Errorf(\"service storage unavailable: %v, retry later\", err)\n\t}\n\the := make([]*cpb.HistoryEntry, len(hlist))\n\tvar ok bool\n\tfor i, e := range hlist {\n\t\the[i], ok = e.(*cpb.HistoryEntry)\n\t\tif !ok {\n\t\t\treturn nil, http.StatusInternalServerError, fmt.Errorf(\"cannot load history entry %d\", i)\n\t\t}\n\t}\n\thistory := &cpb.History{\n\t\tHistory: he,\n\t}\n\tpageToken := r.URL.Query().Get(\"pageToken\")\n\tstart, err := strconv.ParseInt(pageToken, 10, 64)\n\tif err != nil {\n\t\tstart = 0\n\t}\n\n\tpageSize := r.URL.Query().Get(\"pageSize\")\n\tsize, err := strconv.ParseInt(pageSize, 10, 64)\n\tif err != nil || size < 1 {\n\t\tsize = 50\n\t}\n\tif size > 1000 {\n\t\tsize = 1000\n\t}\n\t// Reverse order\n\ta := history.History\n\tfor i := len(a)/2 - 1; i >= 0; i-- {\n\t\topp := len(a) - 1 - i\n\t\ta[i], a[opp] = a[opp], a[i]\n\t}\n\n\tfor i, entry := range history.History {\n\t\tif entry.Revision <= start {\n\t\t\thistory.History = history.History[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif len(history.History) > int(size) {\n\t\thistory.NextPageToken = fmt.Sprintf(\"%d\", history.History[size].Revision)\n\t\thistory.History = history.History[:size]\n\t}\n\treturn history, http.StatusOK, nil\n}", "func Load(path string) *Graph {\n\tvar data Graph\n\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tos.Exit(1)\n\t}\n\tdefer f.Close()\n\n\tfz, _ := gzip.NewReader(f)\n\tdefer fz.Close()\n\n\tdecoder := gob.NewDecoder(fz)\n\n\terr = decoder.Decode(&data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tos.Exit(1)\n\t}\n\n\treturn &data\n}", "func (ts *FileTokenStorage) Load() (*Token, error) {\n\tif _,err := os.Stat(ts.tokenFileName); err == nil {\n\t\tout, err := ioutil.ReadFile(ts.tokenFileName)\n\t\tts.token = string(out)\n\t\treturn NewToken(ts.token), err\n\t}\n\ttoken := NewToken(\"\")\n\ttoken.Invalidate()\n\treturn token, nil\n}", "func LoadFile(filename string) (lines []string) {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer f.Close() //nolint\n\ts := bufio.NewScanner(f)\n\tfor s.Scan() {\n\t\tlines = append(lines, s.Text())\n\t}\n\n\treturn\n}", "func (tbl *Table) Load(tableStr string) error {\n\tbuf, err := ioutil.ReadFile(tableStr)\n\tif err == nil {\n\t\treturn tbl.LoadFromCsvString(string(buf))\n\t}\n\n\treturn tbl.LoadFromCsvString(tableStr)\n}", "func (a *addrBook) loadFromFile(filePath string) bool {\n\t// If doesn't exist, do nothing.\n\t_, err := os.Stat(filePath)\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\n\t// Load addrBookJSON{}\n\tr, err := os.Open(filePath)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error opening file %s: %v\", filePath, err))\n\t}\n\tdefer r.Close()\n\taJSON := &addrBookJSON{}\n\tdec := json.NewDecoder(r)\n\terr = dec.Decode(aJSON)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error reading file %s: %v\", filePath, err))\n\t}\n\n\t// Restore all the fields...\n\t// Restore the key\n\ta.key = aJSON.Key\n\t// Restore .bucketsNew & .bucketsOld\n\tfor _, ka := range aJSON.Addrs {\n\t\tfor _, bucketIndex := range ka.Buckets {\n\t\t\tbucket := a.getBucket(ka.BucketType, bucketIndex)\n\t\t\tbucket[ka.Addr.String()] = ka\n\t\t}\n\t\ta.addrLookup[ka.ID()] = ka\n\t\tif ka.BucketType == bucketTypeNew {\n\t\t\ta.nNew++\n\t\t} else {\n\t\t\ta.nOld++\n\t\t}\n\t}\n\treturn true\n}", "func LoadChangeStore(file string) (ChangeStore, error) {\n\tstoreFile, err := os.Open(file)\n\tif err != nil {\n\t\treturn ChangeStore{}, err\n\t}\n\tdefer storeFile.Close()\n\n\tjsonDecoder := json.NewDecoder(storeFile)\n\tvar changeStore = ChangeStore{}\n\t_ = jsonDecoder.Decode(&changeStore)\n\tif changeStore.Storetype != StoreTypeChange {\n\t\treturn ChangeStore{},\n\t\t\tfmt.Errorf(\"Store type invalid: \" + changeStore.Storetype)\n\t} else if changeStore.Version != StoreVersion {\n\t\treturn ChangeStore{},\n\t\t\tfmt.Errorf(\"Store version invalid: \" + changeStore.Version)\n\t}\n\n\treturn changeStore, nil\n}", "func (up *UserPermissions) Load() (err error) {\n\tup.file.Open(READ_ONLY)\n\tdefer up.file.Close()\n\tif up.file.size == 0 {return}\n\tup.Lock()\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tkey, upr := rec.ToUserPermissionRecord(up.debug)\n\t\t\tup.index[key] = upr // Don't need to use gateway because up is fresh\n\t\t}\n\t\treturn nil\n\t}\n\terr = up.file.Process(f, PERMISSION_RECORD, false)\n\tup.Unlock()\n\treturn\n}", "func ParseHistory(content string) (History, error) {\n\tvar history History\n\tfor _, line := range strings.Split(content, \"\\n\") {\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\top, err := ParseOp(strings.Trim(line, \" \"))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\thistory = append(history, op)\n\t}\n\treturn history, nil\n}", "func Load(filename string) (b []byte, err error) {\n\tfor i := range _loadFuncs {\n\t\tload := _loadFuncs[len(_loadFuncs)-1-i]\n\t\tb, err = load(filename)\n\t\tif err == nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func LoadHistoryDDLJobs(tiStore tidbkv.Storage) ([]*model.Job, error) {\n\tsnapMeta, err := getSnapshotMeta(tiStore)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tjobs, err := snapMeta.GetAllHistoryDDLJobs()\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\t// jobs from GetAllHistoryDDLJobs are sorted by job id, need sorted by schema version\n\tsort.Slice(jobs, func(i, j int) bool {\n\t\treturn jobs[i].BinlogInfo.FinishedTS < jobs[j].BinlogInfo.FinishedTS\n\t})\n\n\treturn jobs, nil\n}", "func (k *ScriptPlayer) Load(r io.Reader) error {\n\tbuf := new(bytes.Buffer)\n\tbuf.ReadFrom(r)\n\n\tvar es Events\n\terr := es.UnmarshalText(buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tsort.Sort(es)\n\n\tk.Script = k.alg.Actions(es)\n\treturn nil\n}", "func Load(filename string, data any, validation bool) error {\n\tisJSON := strings.HasSuffix(filename, \".json\")\n\n\tbs, err := os.ReadFile(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif validation {\n\t\terr := validate(bs, data, isJSON)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn unmarshal(bs, data, isJSON)\n}", "func (zmap *Zapmap) Load() (err error) {\n\tzmap.file.Open(READ_ONLY)\n\tdefer zmap.file.Close()\n\tif zmap.file.size == 0 {return}\n\tzmap.Lock()\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tkey, zrecs := rec.ToZapRecordList(zmap.debug)\n\t\t\tzmap.zapmap[key] = zrecs // Don't need to use gateway because zmap is fresh\n\t\t}\n\t\treturn nil\n\t}\n\terr = zmap.file.Process(f, ZAP_RECORD, true)\n\tzmap.Unlock()\n\treturn\n}", "func (l *Linenoise) HistorySave(fname string) {\n\tif len(l.history) == 0 {\n\t\treturn\n\t}\n\tf, err := os.Create(fname)\n\tif err != nil {\n\t\tlog.Printf(\"error opening %s\\n\", fname)\n\t\treturn\n\t}\n\t_, err = f.WriteString(strings.Join(l.history, \"\\n\"))\n\tif err != nil {\n\t\tlog.Printf(\"%s error writing %s\\n\", fname, err)\n\t}\n\tf.Close()\n}", "func (tasklist *TaskList) LoadFromFile(file *os.File) error {\n\t*tasklist = []Task{} // Empty task list\n\n\ttaskID := 1\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\ttext := strings.Trim(scanner.Text(), whitespaces) // Read line\n\n\t\t// Ignore blank or comment lines\n\t\tif isEmpty(text) || (IgnoreComments && strings.HasPrefix(text, \"#\")) {\n\t\t\tcontinue\n\t\t}\n\n\t\ttask, err := ParseTask(text)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttask.ID = taskID\n\n\t\t*tasklist = append(*tasklist, *task)\n\t\ttaskID++\n\t}\n\n\treturn scanner.Err()\n}", "func (d *Drawer) load() error {\n\tdata, err := ioutil.ReadFile(d.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(data) > 0 {\n\t\tvar payload interface{}\n\t\tpayload, err = d.serializer.Deserialize(data)\n\t\tif !isPointer(payload) {\n\t\t\tpanic(NonPointerErr)\n\t\t}\n\t\td.payload = payload\n\t} else {\n\t\td.payload = nil\n\t}\n\treturn err\n}", "func (bd *BigramDict) Load() error {\n\tif bd.isLoaded {\n\t\treturn nil\n\t}\n\n\tfi, err := os.Open(bd.dictPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer fi.Close()\n\n\tbr := bufio.NewReader(fi)\n\n\tfor {\n\t\ta, _, c := br.ReadLine()\n\t\tif c == io.EOF {\n\t\t\tbreak\n\t\t}\n\n\t\tres := strings.Split(string(a), \" \")\n\n\t\tf := res[1]\n\t\tfi, _ := strconv2.StrToInt(f)\n\n\t\tstrKey := res[0]\n\t\tbd.records[strKey] = fi\n\n\t\tif bd.maxF < fi {\n\t\t\tbd.maxF = fi\n\t\t}\n\t}\n\n\tbd.isLoaded = true\n\n\treturn nil\n}" ]
[ "0.76143396", "0.72454363", "0.6414545", "0.6244711", "0.6017665", "0.60162413", "0.59475034", "0.58671105", "0.58197594", "0.5788585", "0.57839835", "0.57262886", "0.56704795", "0.56589526", "0.5641737", "0.56177145", "0.55798924", "0.5569823", "0.5554513", "0.55464244", "0.5542845", "0.5529613", "0.5506825", "0.54967225", "0.54858184", "0.54829705", "0.5470338", "0.5465834", "0.54618376", "0.5458718", "0.5435207", "0.54343486", "0.5424999", "0.5415208", "0.5400105", "0.5399889", "0.5367018", "0.5362951", "0.5356157", "0.53518474", "0.534564", "0.53143007", "0.5307338", "0.5305054", "0.5305054", "0.5299065", "0.52742106", "0.5267182", "0.5262444", "0.52561843", "0.52239573", "0.5221624", "0.5218908", "0.5214287", "0.5212826", "0.52046597", "0.52010745", "0.5200592", "0.5200187", "0.5181984", "0.5181539", "0.51813376", "0.5177561", "0.51616704", "0.5151801", "0.51501465", "0.5149413", "0.51482224", "0.5140945", "0.51390684", "0.5135758", "0.5124349", "0.5122802", "0.511961", "0.51076114", "0.5092653", "0.50924927", "0.5085695", "0.50833076", "0.5080624", "0.50802857", "0.50761175", "0.5075674", "0.5067288", "0.5065705", "0.50637907", "0.5063222", "0.5062554", "0.50585866", "0.5044532", "0.5041375", "0.50359213", "0.5035018", "0.5033344", "0.50321877", "0.5027404", "0.50202125", "0.5014981", "0.50142956", "0.5009486" ]
0.8224901
0
/ 'DSP' API Frees a DSP object. This will free the DSP object. NOTE: If DSP is not removed from the Channel, ChannelGroup or System object with "Channel.RemoveDSP" or "ChannelGroup.RemoveDSP", after being added with "Channel.AddDSP" or "ChannelGroup.AddDSP", it will not release and will instead return FMOD_ERR_DSP_INUSE.
func (d *DSP) Release() error { res := C.FMOD_DSP_Release(d.cptr) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (ctx *Context) Free() {\n\tC.avfilter_free((*C.struct_AVFilterContext)(ctx))\n}", "func (x *FzCmmEngine) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzTuningContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzBandWriter) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzShaperData) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFProcessor) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzCmmInstance) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDevice) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (f *Frame) Free() {\n\tif f.cPtrAVFrame != nil {\n\t\tC.av_frame_free(&f.cPtrAVFrame)\n\t}\n}", "func (x *FzStream) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzOutputContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzScaleCache) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (d *DSP) Reset() error {\n\tres := C.FMOD_DSP_Reset(d.cptr)\n\treturn errs[res]\n}", "func (s SysExDataPtr) Free() {\n\tC.free(unsafe.Pointer(unsafe.Pointer(s.data)))\n}", "func (x *PDFOcgDescriptor) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzHalftone) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzIdContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDeviceContainerStack) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzShade) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzOutput) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFObj) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (sig Signature) Free() {\n\tC.CSignatureFree(sig.sig)\n}", "func (s *Sdr) SetDSP(state bool) error {\n\tvar v C.uint8_t\n\tif state {\n\t\tv = 1\n\t}\n\tif C.airspyhf_set_lib_dsp(s.handle, v) != C.AIRSPYHF_SUCCESS {\n\t\treturn fmt.Errorf(\"airspyhf.Sdr.SetDSP: failed to set DSP\")\n\t}\n\treturn nil\n}", "func (x *PDFWriteOptions) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzColorspaceContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDocumentHandlerContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func Close() {\n\tglobalBufferSize = 0\n\tglobalSoundBuffer.Release()\n\tglobalPrimarySoundBuffer.Release()\n\tglobalDirectSoundObject.Release()\n}", "func (x *FzJbig2Globals) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzAaContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (d Display) Free() {\n\tC.caca_free_display(d.Dp)\n}", "func (x *FzBuffer) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func (x *PDFSigner) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func Free() error {\n\treturn boolToError(C.BASS_Free())\n}", "func (x *FzSeparations) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFPattern) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFCsi) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFGstate) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzImage) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFFunction) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzPool) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDrawOptions) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzPclOptions) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (sig InsecureSignature) Free() {\n\tC.CInsecureSignatureFree(sig.sig)\n}", "func (x *FzPwgOptions) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzStyleContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzStextOptions) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (s *Stream) FreeStream() {\n\tC.FreeStream(s.sw)\n}", "func (x *PDFDaInfo) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (ops *OutOps) Free(p *Out) error {\n\treturn err(C.go_wr_free(unsafe.Pointer(ops), unsafe.Pointer(p)))\n}", "func (x *FzCookie) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFCrypt) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (self Sound) Destroy() {\n\tC.sfSound_destroy(self.Cref)\n}", "func (x *FzColorspace) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzFontContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzCalColorspace) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDocumentHandler) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzCompressedBuffer) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzErrorContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzCompressedImage) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFUnsavedSig) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzPoint) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFPortfolio) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func LinkFree(l **Link) {\n\tC.avfilter_link_free((**C.struct_AVFilterLink)(unsafe.Pointer(l)))\n}", "func (x *FzArc4) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzStrokeState) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFDesignatedName) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (tex *Image) Free() {\n\tC.sfSprite_destroy(tex.sprite)\n\tC.sfTexture_destroy(tex.tex)\n}", "func (x *FzIcclink) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzAes) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzTransition) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzStorable) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzStore) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func Free(proc *SProcess) {\n\n\t// close any open files\n\tfor _, file := range proc.files {\n\t\tfile.Close()\n\t}\n\n\t// delete the directory\n\tos.RemoveAll(\"/system/process/\" + strconv.Itoa(proc.pid))\n\n\tdelete(processes, proc.pid)\n}", "func (x *FzWarnContext) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (rater *RateLimiter) Free() {\n\trater.semaphore <- true\n}", "func (g *Geometry) Free() {\n\tgl.DeleteVertexArrays(1, &g.handle)\n\tg.IndexBuffer.free()\n\tg.PositionBuffer.free()\n\tg.NormalBuffer.free()\n\tg.TexCoordBuffer.free()\n}", "func (x *PDFLayerConfig) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (m *Mixer) Destroy() {\n\tC.al_destroy_mixer((*C.ALLEGRO_MIXER)(m))\n}", "func (x *FzPixmapImage) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzColorConverter) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDisplayList) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzDocumentWriter) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzMatrix) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFXobject) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzLink) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func Free(f freer) {\n\tf.Free()\n}", "func (x *PDFDocument) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *FzPath) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (e *Enchant) Free() {\n\tC.enchant_broker_free(e.broker)\n}", "func (x *FzBitmap) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFXrefSubsec) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func Free() {\n\tflags = nil // Any future call to Get() will panic on a nil dereference.\n}", "func (x *FzStoreType) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (s *SoundGroup) Release() error {\n\tres := C.FMOD_SoundGroup_Release(s.cptr)\n\treturn errs[res]\n}", "func (x *FzSha512) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (x *PDFJs) Free() {\n\tif x != nil {\n\t\tC.free(unsafe.Pointer(x))\n\t}\n}", "func (s *f64) Free(p *PoolAllocator) {\n\tmustSameCapacity(s.Cap(), p.Channels*p.Capacity)\n\tfor i := range s.buffer {\n\t\ts.buffer[i] = 0\n\t}\n\tp.f64.Put(s)\n}", "func (ops *InOps) Free(p *In) error {\n\treturn err(C.go_rd_free(unsafe.Pointer(ops), unsafe.Pointer(p)))\n}" ]
[ "0.6244145", "0.6076277", "0.59757036", "0.59755033", "0.59550095", "0.58852667", "0.5861734", "0.58615553", "0.58599514", "0.58489096", "0.58043706", "0.57926124", "0.57796425", "0.5775345", "0.5768878", "0.57495904", "0.5746939", "0.57458496", "0.57294965", "0.5725634", "0.57107353", "0.5688266", "0.5685857", "0.5681716", "0.56638664", "0.56501824", "0.56493956", "0.56451315", "0.56410795", "0.5637135", "0.5629839", "0.5618392", "0.56166524", "0.561387", "0.56022507", "0.55945504", "0.5593244", "0.5581707", "0.5572551", "0.5571781", "0.5571038", "0.55688334", "0.55531", "0.5547718", "0.5541347", "0.5541343", "0.5537349", "0.553407", "0.5532069", "0.5530244", "0.5511915", "0.551065", "0.55100006", "0.550398", "0.5494815", "0.5492175", "0.5470471", "0.54540515", "0.54449207", "0.54412574", "0.5401359", "0.539896", "0.5388391", "0.538822", "0.5380895", "0.5380574", "0.5374622", "0.5357546", "0.5357184", "0.5351283", "0.53454006", "0.534212", "0.533494", "0.533375", "0.53333336", "0.53306973", "0.5328318", "0.53243184", "0.5314107", "0.53021514", "0.5299487", "0.5283148", "0.5275409", "0.527357", "0.5272897", "0.5265832", "0.5261618", "0.5253654", "0.52476937", "0.52398556", "0.5226081", "0.52212435", "0.5215762", "0.5213559", "0.51906693", "0.5190192", "0.51886326", "0.51866746", "0.51850414", "0.51849186" ]
0.7037547
0
Retrieves the parent System object that was used to create this object.
func (d *DSP) SystemObject() (*System, error) { var system System res := C.FMOD_DSP_GetSystemObject(d.cptr, &system.cptr) return &system, errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (sc *BaseSmartContract) GetParent() object.Parent {\n\treturn sc.Parent\n}", "func (m *Drive) GetSystem()(SystemFacetable) {\n return m.system\n}", "func (m *List) GetSystem()(SystemFacetable) {\n return m.system\n}", "func (o *RoleWithAccess) GetSystem() bool {\n\tif o == nil || o.System == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.System\n}", "func (o *IamServiceProviderAllOf) GetSystem() IamSystemRelationship {\n\tif o == nil || o.System == nil {\n\t\tvar ret IamSystemRelationship\n\t\treturn ret\n\t}\n\treturn *o.System\n}", "func (s *SoundGroup) SystemObject() (*System, error) {\n\tvar system System\n\tres := C.FMOD_SoundGroup_GetSystemObject(s.cptr, &system.cptr)\n\treturn &system, errs[res]\n}", "func (c *Client) Sys() *Sys {\n\treturn &Sys{c: c}\n}", "func System() disko.System {\n\treturn &linuxSystem{}\n}", "func (l *Library) Parent() Parent { return l.Root }", "func (o *GstObj) GetParent() *GstObj {\n\tp := new(GstObj)\n\tp.SetPtr(glib.Pointer(C.gst_object_get_parent(o.g())))\n\treturn p\n}", "func (s *S) Parent() Surfer {\n\treturn s.parent\n}", "func (s *Service) Parent() eh.ReadRepo {\n\treturn nil\n}", "func (sc *TraceScope) Parent() *TraceScope {\n\treturn sc.parent\n}", "func (obj *GenericObject) GetParent(ctx context.Context) (*GenericObject, error) {\n\tresult := &struct {\n\t\tReturn *ObjectInterface `json:\"qReturn\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetParent\", result)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &GenericObject{obj.GetRemoteObject(result.Return)}, err\n}", "func (i *Item) Sys() interface{} { return i.directoryEntry }", "func ChosenSystem() System {\n\treturn system\n}", "func (d *device) getParent() Device {\n\treturn d.parent\n}", "func GetSystem(name string) (System, error) {\n\tswitch name {\n\tcase \"cd\":\n\t\treturn CDSystem, nil\n\tcase \"main\":\n\t\treturn MainSystem, nil\n\tcase \"public\":\n\t\treturn PublicSystem, nil\n\tcase \"publiccd\":\n\t\treturn PublicCDSystem, nil\n\t}\n\treturn System{}, fmt.Errorf(\"invalid system: %s\", name)\n}", "func (*Root) Sys() interface{} { return nil }", "func (i *Resource) Parent() (*Version, error) {\n\tversions, err := i.conn.middleware.FindVersions(\n\t\t1,\n\t\t0,\n\t\t[]*wyc.QueryDesc{\n\t\t\t{Id: i.data.Parent},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(versions) < 1 {\n\t\treturn nil, fmt.Errorf(\"version with Id %s not found\", i.data.Parent)\n\t}\n\n\treturn &Version{\n\t\tconn: i.conn,\n\t\tdata: versions[0],\n\t}, nil\n}", "func (c *Client) GetSystem(name string) (*System, error) {\n\tvar system System\n\n\tresult, err := c.Call(\"get_system\", name, c.Token)\n\tif err != nil {\n\t\treturn &system, err\n\t}\n\n\tif result == \"~\" {\n\t\treturn nil, fmt.Errorf(\"System %s not found.\", name)\n\t}\n\n\tdecodeResult, err := decodeCobblerItem(result, &system)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ts := decodeResult.(*System)\n\ts.Client = *c\n\n\treturn s, nil\n}", "func (cmd *CLI) Parent() Command {\n\treturn cmd.parent\n}", "func (o *OrgUnit) Parent() OrgUnit {\n\tpieces := strings.Split(o.DistinguishedName, \",\")\n\treturn OrgUnit{\n\t\tObject: Object{\n\t\t\tName: pieces[0],\n\t\t\tDistinguishedName: strings.Join(pieces[1:], \",\"),\n\t\t\tConnection: o.Connection,\n\t\t},\n\t}\n}", "func (c *ComponentCollection) parent() Locatable {\n\treturn c.app\n}", "func (w *Worker) Parent() *Client {\n\tw.mu.RLock()\n\tdefer w.mu.RUnlock()\n\n\treturn w.wr.parent\n}", "func (m *Descriptor) GetParent() *Descriptor { return m.Parent }", "func (s System) ID() SystemID {\n\treturn s.id\n}", "func (i *Inode) Sys() interface{} {\n\treturn nil\n}", "func (m *ParentLabelDetails) GetParent()(ParentLabelDetailsable) {\n val, err := m.GetBackingStore().Get(\"parent\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(ParentLabelDetailsable)\n }\n return nil\n}", "func (self *Events) Parent() *Sprite{\n return &Sprite{self.Object.Get(\"parent\")}\n}", "func (p *Process) Parent() (*Process, error) {\n\treturn p.ParentWithContext(context.Background())\n}", "func (o IopingSpecVolumeVolumeSourceScaleIOPtrOutput) System() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *IopingSpecVolumeVolumeSourceScaleIO) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.System\n\t}).(pulumi.StringPtrOutput)\n}", "func (p *ProcessState) Sys() interface{} {\n\treturn nil // TODO\n}", "func (r *ComponentResource) parent() Locatable {\n\treturn r.Collection.(Locatable)\n}", "func System() Env {\n\treturn New(os.Environ())\n}", "func (s *Stream) Parent() *Stream {\n\treturn s.parent\n}", "func (n *resPool) Parent() ResPool {\n\tn.RLock()\n\tdefer n.RUnlock()\n\treturn n.parent\n}", "func (nsf NamespaceFile) Parent() (*NamespaceFile, error) {\n\treturn namespaceFileFromFd(ioctl(int(nsf.Fd()), _NS_GET_PARENT))\n}", "func (c Command) Parent() *Command {\n\treturn c.parent\n}", "func (in *System) DeepCopy() *System {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(System)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func (m *Resource) Parent() string {\n\treturn m.parentresource\n}", "func (t *Transform) Parent() Transformable {\n\tt.access.RLock()\n\tp := t.parent\n\tt.access.RUnlock()\n\treturn p\n}", "func (e *Entity) GetParent(currentResourceType resource.Type) (resource.Type, string) {\n\tif e.SpecID.Valid {\n\t\tif currentResourceType == resource.APISpecFetchRequest {\n\t\t\treturn resource.APISpecification, e.SpecID.String\n\t\t} else {\n\t\t\treturn resource.EventSpecification, e.SpecID.String\n\t\t}\n\t}\n\treturn resource.Document, e.DocumentID.String\n}", "func (i *Info) Sys() interface{} {\n\treturn nil\n}", "func (r *ImageRegistryResource) parent() Locatable {\n\treturn r.collection.(Locatable)\n}", "func (selfPtr *ActorRef) Parent() *ActorRef {\n\treturn &ActorRef{\n\t\tcoreActor:selfPtr.coreActor.Parent,\n\t}\n}", "func (o FioSpecVolumeVolumeSourceScaleIOPtrOutput) System() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *FioSpecVolumeVolumeSourceScaleIO) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.System\n\t}).(pulumi.StringPtrOutput)\n}", "func (c *Client) System(method string, id interface{}, data interface{}) System {\n\tvar system System\n\n\tswitch method {\n\tcase \"GET\":\n\t\tendpoint := fmt.Sprintf(\"systems/%v\", id)\n\t\tc.invokeAPI(\"GET\", endpoint, nil, &system)\n\tcase \"CREATE\":\n\t\tendpoint := \"systems\"\n\t\tc.invokeAPI(\"POST\", endpoint, data, &system)\n\tcase \"UPDATE\":\n\t\tendpoint := fmt.Sprintf(\"systems/%v\", id)\n\t\tc.invokeAPI(\"PUT\", endpoint, data, &system)\n\tcase \"DELETE\":\n\t\tendpoint := fmt.Sprintf(\"systems/%v\", id)\n\t\tc.invokeAPI(\"DELETE\", endpoint, nil, nil)\n\t}\n\n\treturn system\n}", "func (f *FileInfo) Sys() interface{} {\n\treturn f.sys\n}", "func (l Location) ParentID() int {\n\tif l.IsStation() {\n\t\treturn l.Station.StationID\n\t} else if l.IsCitadel() {\n\t\treturn int(l.Structure.StructureID)\n\t}\n\treturn l.System.SystemID\n}", "func (client *APIClient) GetSystem(systemName string) (system System, err error) {\n\tresponse, err := client.request(\"GET\", urlSystem(systemName), nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\terr = utilities.FromJSON(response, &system)\n\treturn\n}", "func (client BaseClient) GetSystem(ctx context.Context, pathParameter string) (result System, err error) {\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: pathParameter,\n\t\t\tConstraints: []validation.Constraint{{Target: \"pathParameter\", Name: validation.Pattern, Rule: `.*`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"beacon.BaseClient\", \"GetSystem\", err.Error())\n\t}\n\n\treq, err := client.GetSystemPreparer(ctx, pathParameter)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"beacon.BaseClient\", \"GetSystem\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.GetSystemSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"beacon.BaseClient\", \"GetSystem\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult, err = client.GetSystemResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"beacon.BaseClient\", \"GetSystem\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (nsfd NamespaceFd) Parent() (*NamespaceFile, error) {\n\treturn namespaceFileFromFd(ioctl(int(nsfd), _NS_GET_PARENT))\n}", "func (r *Root) Parent() Parent { return nil }", "func (path PathImpl) Parent() Path {\n\t// path.String() can't be empty\n\tparent, _ := New(path, \"..\")\n\treturn parent\n}", "func (p *Path) Parent() (*Path, error) {\n\tpth, err := p.Absolute()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"get parent failed\")\n\t}\n\tdir := filepath.Dir(pth.Path)\n\tnewP := New(dir)\n\treturn newP, nil\n}", "func (i *FileInfo) Sys() interface{} { return i }", "func (w *WidgetImplement) Parent() Widget {\n\treturn w.parent\n}", "func (c *Channel) Parent() *Channel {\n\treturn c.parent\n}", "func (c *ImageRegistryCollection) parent() (l Locatable) {\n\treturn\n}", "func (thread *Thread) GetParentType() string {\n\treturn \"\"\n}", "func (s *baseNode) Parent() Node {\n\treturn s.parent\n}", "func (m SystemModel) FindOneSystem(systemId string) (system System, err error) {\n\terr = db.GetDB().C(\"system\").Find(bson.M{\"id\": systemId}).One(&system)\n\treturn system, err\n}", "func GetHelloSystem(w ecs.BaseWorld) *HelloSystem {\n return w.S(uuidHelloSystem).(*HelloSystem)\n}", "func NewSystem(baseRating, baseDeviation, baseVolitility, tau float64) *System {\n\treturn &System{baseRating, baseDeviation, baseVolitility, tau}\n}", "func (item *Item) Parent() IItem {\n return item.parent\n}", "func (g *Group) GetParent() Shape {\n\treturn g.parent\n}", "func (a *Client) System(params *SystemParams, authInfo runtime.ClientAuthInfoWriter) (*SystemOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewSystemParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"system\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/system\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &SystemReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*SystemOK), nil\n\n}", "func (e *ExtensionDescriptor) GetParent() *Descriptor { return e.Parent }", "func (r Virtual_Guest_Block_Device_Template_Group) GetParent() (resp datatypes.Virtual_Guest_Block_Device_Template_Group, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest_Block_Device_Template_Group\", \"getParent\", nil, &r.Options, &resp)\n\treturn\n}", "func GetSystemID() SystemID {\n\treturn SystemID(C.al_get_system_id())\n}", "func (jm JSONMeta) Parent() JSONMetaNode {\n\tif len(jm.provenance.Sources) != 1 || jm.provenance.Function != \"\" {\n\t\treturn nil\n\t}\n\treturn jm.provenance.Sources[0]\n}", "func (info *unixFileInfo) Sys() interface{} {\n\tif info == nil {\n\t\treturn nil\n\t}\n\treturn &info.sys\n}", "func (v *IADs) Parent() (path string, err error) {\n\tvar bstr *int16\n\thr, _, _ := syscall.Syscall(\n\t\tuintptr(v.VTable().Parent),\n\t\t2,\n\t\tuintptr(unsafe.Pointer(v)),\n\t\tuintptr(unsafe.Pointer(&bstr)),\n\t\t0)\n\tif bstr != nil {\n\t\tdefer ole.SysFreeString(bstr)\n\t}\n\tif hr == 0 {\n\t\tpath = ole.BstrToString((*uint16)(unsafe.Pointer(bstr)))\n\t} else {\n\t\treturn \"\", convertHresultToError(hr)\n\t}\n\treturn\n}", "func (g Galaxy) GetStarSystem(c Coordinates) (ss *StarSystem) {\n\tif c.Resolution == coord_LOCAL {\n\t\tss = g.GetSector(c.Sector.Get()).GetSubSector(c.SubSector.Get()).starSystem\n\t}\n\n\treturn\n}", "func (d *Die) Parent() Roller {\n\treturn d.parent\n}", "func System(engine *gosge.Engine, gs geometry.Scale) error {\n\tms := movementSystem{\n\t\tgs: gs,\n\t}\n\n\tengine.World().AddSystem(ms.system)\n\n\treturn nil\n}", "func (r *Reconciler) getParentSpace(memberCluster cluster.Cluster, spaceRequest *toolchainv1alpha1.SpaceRequest) (*toolchainv1alpha1.Space, error) {\n\tparentSpace := &toolchainv1alpha1.Space{}\n\tnamespace := &corev1.Namespace{}\n\terr := memberCluster.Client.Get(context.TODO(), types.NamespacedName{\n\t\tNamespace: \"\",\n\t\tName: spaceRequest.Namespace,\n\t}, namespace)\n\tif err != nil {\n\t\treturn nil, errs.Wrap(err, \"unable to get namespace\")\n\t}\n\t// get the Space name from the namespace resource\n\tparentSpaceName, found := namespace.Labels[toolchainv1alpha1.SpaceLabelKey]\n\tif !found || parentSpaceName == \"\" {\n\t\treturn nil, errs.Errorf(\"unable to find space label %s on namespace %s\", toolchainv1alpha1.SpaceLabelKey, namespace.GetName())\n\t}\n\n\t// check that parentSpace object still exists\n\terr = r.Client.Get(context.TODO(), types.NamespacedName{\n\t\tNamespace: r.Namespace,\n\t\tName: parentSpaceName,\n\t}, parentSpace)\n\tif err != nil {\n\t\treturn nil, errs.Wrap(err, \"unable to get parentSpace\")\n\t}\n\n\treturn parentSpace, nil // all good\n}", "func (s *System) Control() *SystemControl {\n\treturn (*SystemControl)(atomic.LoadPointer(&s.control))\n}", "func GetSystemByClientID(clientID string) (System, error) {\n\tvar (\n\t\tdb = GetGORMDbConnection()\n\t\tsystem System\n\t\terr error\n\t)\n\tdefer Close(db)\n\n\tif db.Find(&system, \"client_id = ?\", clientID).RecordNotFound() {\n\t\terr = fmt.Errorf(\"no System record found for client %s\", clientID)\n\t}\n\treturn system, err\n}", "func (wb *WidgetBase) Parent() Container {\n\treturn wb.parent\n}", "func (o ConditionOutput) Sys() ConditionSysPtrOutput {\n\treturn o.ApplyT(func(v Condition) *ConditionSys { return v.Sys }).(ConditionSysPtrOutput)\n}", "func (ff *File) Sys() interface{} {\n\tff.RLock()\n\tdefer ff.RUnlock()\n\treturn ff.fs\n}", "func (s *varsScope) Parent() parser.Scope {\n\treturn s.parent\n}", "func (a *_Atom) Parent() *Molecule {\n\treturn a.mol\n}", "func (s UserSet) Parent() m.PartnerSet {\n\tres, _ := s.RecordCollection.Get(models.NewFieldName(\"Parent\", \"parent_id\")).(models.RecordSet).Collection().Wrap(\"Partner\").(m.PartnerSet)\n\treturn res\n}", "func (inst *DeprecatedCreateMasterEdition) GetSystemProgramAccount() *ag_solanago.AccountMeta {\n\treturn inst.AccountMetaSlice[10]\n}", "func (obj *errorStruct) Parent() Error {\n\treturn obj.parent\n}", "func (g *GaeAccessManager) GetSystemSession(site, firstname, lastname string) (Session, error) {\n\treturn g.GetSystemSessionWithRoles(site, firstname, lastname, \"s1:s2:s3:s4\")\n}", "func (o SiaFileInfo) Sys() interface{} {\n\treturn o.FileSys\n}", "func getSystemStackPointer() uintptr {\n\t// TODO: this always returns the correct stack on Cortex-M, so don't bother\n\t// comparing against 0.\n\tsp := task.SystemStack()\n\tif sp == 0 {\n\t\tsp = getCurrentStackPointer()\n\t}\n\treturn sp\n}", "func NewSystem(blockNumber string) *System {\n\n\treturn &System{\n\t\tHeight: blockNumber,\n\t\tGoldTokenSupply: \"0\",\n\t\tTotalLockedGoldBalance: \"0\",\n\t\tNonVotingLockedGoldBalance: \"0\",\n\t\tTotalCeloUSDValue: \"0\"}\n\n}", "func (l Location) IsSystem() bool {\n\treturn l.Station == nil && l.Structure == nil\n}", "func (e *Tree) Parent() *Tree { return e.parent }", "func (j *Jail) Parent() int {\n\treturn j.parent\n}", "func (o *os) GetSystemTimeSecs() gdnative.Int {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetSystemTimeSecs()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_system_time_secs\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (d *Dentry) Parent() *Dentry {\n\treturn d.parent\n}", "func (g *Group) IsOfSystem() bool {\n\t//loadConfig()\n\n\tif g.GID > config.login.SYS_GID_MIN && g.GID < config.login.SYS_GID_MAX {\n\t\treturn true\n\t}\n\treturn false\n}", "func SystemClock() Clock {\n\treturn &systemClock{}\n}", "func (e *Event) SystemMessage() *SystemMessage {\n\tif e.Type != \"system_message\" {\n\t\treturn nil\n\t}\n\tvar sm SystemMessage\n\n\tsm.Event = *e\n\tif err := json.Unmarshal(e.SystemMessageType, &sm.SystemMessageType); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.Text, &sm.Text); err != nil {\n\t\treturn nil\n\t}\n\tif err := internal.UnmarshalOptionalRawField(e.TextVars, &sm.TextVars); err != nil {\n\t\treturn nil\n\t}\n\treturn &sm\n}" ]
[ "0.6080718", "0.6048367", "0.6017261", "0.60082644", "0.597957", "0.5912714", "0.5888304", "0.58516985", "0.57922125", "0.57917666", "0.5775844", "0.5716228", "0.57021713", "0.5666899", "0.5662998", "0.56621414", "0.56485397", "0.56330633", "0.5619349", "0.5618898", "0.55967563", "0.55858546", "0.55803984", "0.5579216", "0.5537945", "0.55343306", "0.54917085", "0.5468591", "0.5426338", "0.541343", "0.5395273", "0.53887486", "0.53870916", "0.5386505", "0.5364176", "0.534743", "0.53328747", "0.5318631", "0.53034455", "0.5300324", "0.5296074", "0.528796", "0.52764195", "0.5258405", "0.5222951", "0.520322", "0.5202092", "0.5188701", "0.5182544", "0.518157", "0.5176357", "0.5171941", "0.51624507", "0.5130198", "0.51193386", "0.5114362", "0.51011074", "0.50975364", "0.5083598", "0.5070468", "0.5053314", "0.504051", "0.5032725", "0.5031582", "0.5026041", "0.5023264", "0.50206155", "0.50096923", "0.49976844", "0.4996108", "0.498861", "0.4977854", "0.49751696", "0.49634802", "0.49555817", "0.49555784", "0.4955578", "0.49554121", "0.49468368", "0.49302578", "0.4924702", "0.49145716", "0.4910834", "0.49076936", "0.49034774", "0.49013525", "0.4888483", "0.48882335", "0.4886657", "0.48743317", "0.4862783", "0.48420152", "0.48402435", "0.48390973", "0.48346668", "0.48317078", "0.48259065", "0.48229742", "0.48185235", "0.4817077" ]
0.58831245
7
/ Connection / disconnection / input and output enumeration. Adds the specified DSP unit as an input of the DSP object. input: The DSP unit to add as an input of the current unit. connection: The connection between the 2 units. Optional. Specify 0 or NULL to ignore. typ: The type of connection between the 2 units. See "DSPConnectionType". If you want to add a unit as an output of another unit, then add 'this' unit as an input of that unit instead. Inputs are automatically mixed together, then the mixed data is sent to the unit's output(s). To find the number of inputs or outputs a unit has use "DSP.NumInputs" or "DSP.NumOutputs". Note: The connection pointer retrieved here will become invalid if you disconnect the 2 dsp units that use it.
func (d *DSP) AddInput(input DSP, typ DSPConnectionType) (DspConnection, error) { var dspConn DspConnection res := C.FMOD_DSP_AddInput(d.cptr, input.cptr, &dspConn.cptr, C.FMOD_DSPCONNECTION_TYPE(typ)) return dspConn, errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (a *acssImpl) Input(input gpa.Input) gpa.OutMessages {\n\tif a.me != a.dealer {\n\t\tpanic(errors.New(\"only dealer can initiate the sharing\"))\n\t}\n\tif input == nil {\n\t\tpanic(errors.New(\"we expect kyber.Scalar as input\"))\n\t}\n\treturn a.handleInput(input.(kyber.Scalar))\n}", "func (p *Concatenator) In() *scipipe.InPort { return p.InPort(\"in\") }", "func (in *TransferableInput) Input() Transferable { return in.In }", "func (fn *CXFunction) AddInput(prgrm *CXProgram, param *CXArgument) *CXFunction {\n\tfnInputs := fn.GetInputs(prgrm)\n\tfor _, inputIdx := range fnInputs {\n\t\tinput := prgrm.GetCXTypeSignatureFromArray(inputIdx)\n\t\tif input.Name == param.Name {\n\t\t\treturn fn\n\t\t}\n\t}\n\n\tparam.Package = fn.Package\n\tnewField := GetCXTypeSignatureRepresentationOfCXArg(prgrm, param)\n\n\tif fn.Inputs == nil {\n\t\tfn.Inputs = &CXStruct{}\n\t}\n\n\tnewFieldIdx := prgrm.AddCXTypeSignatureInArray(newField)\n\tfn.Inputs.AddField_TypeSignature(prgrm, newFieldIdx)\n\n\treturn fn\n}", "func (j *JustAddPowerReciever) SetAudioVideoInput(ctx context.Context, output, input string) error {\n\tj.Log.Debug(\"Setting receiver to transmitter\")\n\n\tgo j.checkTransmitterChannel(input)\n\n\tj.Log.Debug(\"Routing from, to\", zap.String(\"from\", j.Address), zap.String(\"to\", input))\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", input)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", input, err)\n\t}\n\n\tchannel := fmt.Sprintf(\"%v\", ipAddress.IP[3])\n\n\tj.Log.Debug(\"channel\", zap.String(\"channel\", channel))\n\n\tresult, errrr := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/command/channel\", j.Address), channel, \"POST\")\n\n\tif errrr != nil {\n\t\treturn fmt.Errorf(\"Error when making request: %w\", errrr)\n\t}\n\n\tvar jsonResult JustAddPowerChannelResult\n\terr = json.Unmarshal(result, &jsonResult)\n\n\tj.Log.Debug(\"Result\", zap.Any(\"jsonResult\", jsonResult))\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when unpacking json\")\n\t}\n\treturn nil\n}", "func (neuron *Neuron) AddInput(ni NeuronIndex) error {\n\tif neuron.Is(ni) {\n\t\treturn errors.New(\"adding a neuron as input to itself\")\n\t}\n\tif neuron.HasInput(ni) {\n\t\treturn errors.New(\"neuron already exists\")\n\t}\n\tneuron.InputNodes = append(neuron.InputNodes, ni)\n\n\treturn nil\n}", "func (s *BasevhdlListener) EnterAdding_operator(ctx *Adding_operatorContext) {}", "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func (c *Connector) AddExternalInterface(localIfID common.IFIDType, link control.LinkInfo,\n\towned bool) error {\n\n\tintf := uint16(localIfID)\n\tlog.Debug(\"Adding external interface\", \"interface\", localIfID,\n\t\t\"local_isd_as\", link.Local.IA, \"local_addr\", link.Local.Addr,\n\t\t\"remote_isd_as\", link.Remote.IA, \"remote_addr\", link.Remote.IA,\n\t\t\"owned\", owned, \"bfd\", !link.BFD.Disable)\n\n\tif !c.ia.Equal(link.Local.IA) {\n\t\treturn serrors.WithCtx(errMultiIA, \"current\", c.ia, \"new\", link.Local.IA)\n\t}\n\tif err := c.DataPlane.AddLinkType(intf, link.LinkTo); err != nil {\n\t\treturn serrors.WrapStr(\"adding link type\", err, \"if_id\", localIfID)\n\t}\n\tif err := c.DataPlane.AddNeighborIA(intf, link.Remote.IA); err != nil {\n\t\treturn serrors.WrapStr(\"adding neighboring IA\", err, \"if_id\", localIfID)\n\t}\n\n\tif !owned {\n\t\tif !link.BFD.Disable {\n\t\t\terr := c.DataPlane.AddNextHopBFD(intf, link.Local.Addr, link.Remote.Addr,\n\t\t\t\tlink.BFD, link.Instance)\n\t\t\tif err != nil {\n\t\t\t\treturn serrors.WrapStr(\"adding next hop BFD\", err, \"if_id\", localIfID)\n\t\t\t}\n\t\t}\n\t\treturn c.DataPlane.AddNextHop(intf, link.Remote.Addr)\n\t}\n\tconnection, err := conn.New(link.Local.Addr, link.Remote.Addr,\n\t\t&conn.Config{ReceiveBufferSize: receiveBufferSize})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !link.BFD.Disable {\n\t\terr := c.DataPlane.AddExternalInterfaceBFD(intf, connection, link.Local,\n\t\t\tlink.Remote, link.BFD)\n\t\tif err != nil {\n\t\t\treturn serrors.WrapStr(\"adding external BFD\", err, \"if_id\", localIfID)\n\t\t}\n\t}\n\treturn c.DataPlane.AddExternalInterface(intf, connection)\n}", "func (c *Client) Input(i Input) error {\n\t// The hash of the _current_ input\n\t// is needed for the request\n\tcur, err := c.CurrentInput()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := reqInput{\n\t\tRequest: reqModify,\n\t\tHash: cur.Hash,\n\t\tValue: i.Name,\n\t}\n\n\tvar body bytes.Buffer\n\tif err := json.NewEncoder(&body).Encode(data); err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(http.MethodPut, \"/menu_native/dynamic/tv_settings/devices/current_input\", &body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// response contains no specific fields\n\treturn c.do(req, &respWrapper{})\n}", "func (c *Compiler) RegisterInput(name string, typ types.Type) (int, error) {\n\tinputIndex := c.ctx.Builder.NewInput(typ)\n\tinputSymbol := symbol.NewInputSymbol(name, typ, inputIndex)\n\terr := c.ctx.GlobalScope.Add(inputSymbol)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn inputIndex, nil\n}", "func (gr *groupT) addInputArg(inp *inputT) {\n\tgr.Inputs = append(gr.Inputs, inp)\n}", "func add_node( conn Conn ){\n conn.expressed = false\n\n innovation_num := 0\n node := Node{ is_hidden : true }\n conn1 := Conn{ conn.inNode, node, 1, true, innovation_num }\n conn2 := Conn{ node, conn.outNode, conn.weight, true, innovation_num }\n}", "func WithInput(input ifn) Option {\n\treturn func(i *Intel8080) {\n\t\ti.ih = input\n\t}\n}", "func (n *Network) AddInputNode(node *NNode) {\n\tn.Inputs = append(n.Inputs, node)\n}", "func (self *SinglePad) Connect(rawPad interface{}) {\n self.Object.Call(\"connect\", rawPad)\n}", "func (h *DeviceHandler) DeviceAdd(c context.Context, sessionID int) error {\n\tuis := libkb.UIs{\n\t\tProvisionUI: h.getProvisionUI(sessionID),\n\t\tSecretUI: h.getSecretUI(sessionID, h.G()),\n\t\tSessionID: sessionID,\n\t}\n\tm := libkb.NewMetaContext(c, h.G()).WithUIs(uis)\n\teng := engine.NewDeviceAdd(h.G())\n\treturn engine.RunEngine2(m, eng)\n}", "func (p *Register) AddWithInOut(route *Route, inbound InChain, outbound OutChain) error {\n\tdefinition := route.proxy\n\n\thandler := p.proxy.Reverse(definition, inbound, outbound).ServeHTTP\n\tmatcher := router.NewListenPathMatcher()\n\tif matcher.Match(definition.ListenPath) {\n\t\tp.doRegister(matcher.Extract(definition.ListenPath), handler, definition.Methods, route.handlers)\n\t}\n\n\tp.doRegister(definition.ListenPath, handler, definition.Methods, route.handlers)\n\treturn nil\n}", "func HandleIn(em *Emulator, a int, b int) {\n addr := em.GetReg(b)\n \n if em.getPortAccess(addr) {\n data := em.LoadIOPort(addr)\n em.SetReg(a, data)\n em.LogInstruction(\"in %s, %s -- ports[0x%02X] = 0x%02X\", RegisterNames[a],\n RegisterNames[b], addr, data)\n \n } else {\n em.LogInstruction(\"in %s, %s -- not authorised\", RegisterNames[a], RegisterNames[b])\n }\n \n em.timer += 6;\n}", "func openIn(d Driver, number int, name string) (in In, err error) {\n\tins, err := d.Ins()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't find MIDI input ports: %v\", err)\n\t}\n\n\tif number >= 0 {\n\t\tfor _, port := range ins {\n\t\t\tif number == port.Number() {\n\t\t\t\tin = port\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", number)\n\t\t}\n\t} else {\n\t\tif name != \"\" {\n\t\t\tfor _, port := range ins {\n\t\t\t\tif strings.Contains(port.String(), name) {\n\t\t\t\t\tin = port\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", name)\n\t\t}\n\t}\n\n\t// should not happen here, since we already returned above\n\tif in == nil {\n\t\tpanic(\"unreachable\")\n\t}\n\n\terr = in.Open()\n\treturn\n}", "func (socket *MockSocket) Input() *socket.InputProtocol {\n\treturn socket.input\n}", "func InputArtnetUniverse(addr ArtnetAddress) (chan dmx.DMXFrame, error) {\n\n // Initialise the input channel list if needed \n if inputUniverseChannels == nil {\n inputUniverseChannels = make(map[uint16] chan dmx.DMXFrame)\n }\n\n // Build the Art-Net encoded address for lookup\n portAddr := addr.Encode()\n\n // Check if an output channel already exists\n _, exists := inputUniverseChannels[portAddr]\n\n if exists {\n return nil, errors.New(\"Universe already has a channel\")\n }\n\n // Build store and return a new channel\n dmx := make(chan dmx.DMXFrame)\n inputUniverseChannels[portAddr] = dmx\n return dmx, nil\n}", "func (gr *groupT) AddInput() *inputT {\n\tinp := &inputT{}\n\tgr.Inputs = append(gr.Inputs, inp)\n\tret := gr.Inputs[len(gr.Inputs)-1]\n\treturn ret\n}", "func (c *RemoteControl) Add(ctx context.Context, ch interface{}) error {\n\tchrv := reflect.ValueOf(ch)\n\tif !chrv.IsValid() || chrv.Kind() != reflect.Chan {\n\t\ttyp := \"nil\"\n\t\tif chrv.IsValid() {\n\t\t\ttyp = chrv.Type().String()\n\t\t}\n\t\treturn errors.Errorf(`a valid channel must be passed to fanout.Add (got %s)`, typ)\n\t}\n\n\tif (chrv.Type().ChanDir() & reflect.SendDir) == 0 {\n\t\treturn errors.New(`channel passed to fanout.Add must be able to sent to`)\n\t}\n\n\tif c.chType != chrv.Type().Elem() {\n\t\treturn errors.Errorf(`channel element type must be %s, but got %s`, c.chType, chrv.Type())\n\t}\n\n\t// Notify that we want to add this\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase c.addCh <- chrv.Interface():\n\t}\n\n\treturn nil\n}", "func (o *Output) Connect(in *Input) bool {\n\tstopValuePusher(in)\n\to.Lock()\n\tok := o.Add(in.Connection)\n\to.Unlock()\n\treturn ok\n}", "func (c *CvpClient) AddDevice(ipAddr string, cn string) error {\n\tlog.Printf(\"Adding device %s to container %s\\n\", ipAddr, cn)\n\tcontainer, err := c.GetContainerByName(cn)\n\tif err != nil {\n\t\treturn err\n\t}\n\telement := []AddInventoryElement{\n\t\tAddInventoryElement{\n\t\t\tContainerName: cn,\n\t\t\tContainerId: container.Key,\n\t\t\tContainerType: \"Existing\",\n\t\t\tIpAddress: ipAddr,\n\t\t\tContainerList: []ContainerListElement{},\n\t\t},\n\t}\n\taddInventory := AddInventory{\n\t\tData: element,\n\t}\n\t// In case the device is already in temp Inventory, we're purging it from there\n\tif _, err := c.SearchInventory(ipAddr); err != nil {\n\t\tc.CancelTempInventory()\n\t}\n\n\taddInventoryURL := \"/inventory/add/addToInventory.do?startIndex=0&endIndex=15\"\n\t_, err = c.Call(addInventory, addInventoryURL)\n\treturn err\n}", "func (b *Batcher) Add(t Transferable) {\n\tb.input <- t\n}", "func (c *Connector) AddInternalInterface(ia addr.IA, local net.UDPAddr) error {\n\tlog.Debug(\"Adding internal interface\", \"isd_as\", ia, \"local\", local)\n\tif !c.ia.Equal(ia) {\n\t\treturn serrors.WithCtx(errMultiIA, \"current\", c.ia, \"new\", ia)\n\t}\n\tconnection, err := conn.New(&local, nil,\n\t\t&conn.Config{ReceiveBufferSize: receiveBufferSize})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.DataPlane.AddInternalInterface(connection, local.IP)\n}", "func (p PowerControl) SetIn(in chan interface{}) {\n\tp.in = in\n}", "func AddNetPol(netpol interface{}) {}", "func SetInput(ctx context.Context, address, output, input string) *nerr.E {\n\tin, err := strconv.Atoi(input)\n\tif err != nil {\n\t\treturn nerr.Translate(err).Addf(\"error when making call: %s\", err)\n\t}\n\turl := fmt.Sprintf(\"http://%s/cgi-bin/config.cgi\", address)\n\tpayload := strings.NewReader(\"\")\n\tif output == \"1\" {\n\t\tpayload = strings.NewReader(fmt.Sprintf(`\n\t\t{\n\t\t\t\"setConfig\":{\n\t\t\t\t\"video\":{\n\t\t\t\t\t\"vidOut\":{\n\t\t\t\t\t\t\"hdmiOut\":{\n\t\t\t\t\t\t\t\"hdmiOutA\":{\n\t\t\t\t\t\t\t\t\"videoSrc\":%v\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}`, in))\n\t} else if output == \"2\" {\n\t\tpayload = strings.NewReader(fmt.Sprintf(`\n\t\t{\n\t\t\t\"setConfig\":{\n\t\t\t\t\"video\":{\n\t\t\t\t\t\"vidOut\":{\n\t\t\t\t\t\t\"hdmiOut\":{\n\t\t\t\t\t\t\t\"hdmiOutB\":{\n\t\t\t\t\t\t\t\t\"videoSrc\":%v\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}`, in))\n\t} else {\n\t\treturn nerr.Create(\"Invalid Output. Valid Output names are 1 and 2\", \"\")\n\t}\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\treq = AddHeaders(req)\n\treq = req.WithContext(ctx)\n\tres, gerr := http.DefaultClient.Do(req)\n\tif gerr != nil {\n\t\treturn nerr.Translate(gerr).Addf(\"error when making call: %s\", gerr)\n\t}\n\tdefer res.Body.Close()\n\treturn nil\n}", "func (self *Graphics) SetInputA(member interface{}) {\n self.Object.Set(\"input\", member)\n}", "func (i *inventory) Add(info *Info) error {\n\ti.lock.Lock()\n\tdefer i.lock.Unlock()\n\tif info.ID == \"\" {\n\t\treturn fmt.Errorf(\"ID in device.Info cannot be empty\")\n\t}\n\tif dev, ok := i.devices[info.ID]; ok {\n\t\tif info.Config.Device != dev.info.Config.Device {\n\t\t\treturn fmt.Errorf(\"Cannot add device '%s' (type '%s') to inventory; \"+\n\t\t\t\t\"it already exists with a different type ('%s')\",\n\t\t\t\tinfo.ID, info.Config.Device, dev.info.Config.Device)\n\t\t}\n\t\tlog.Log(info.Device).Infof(\"Device %s already exists (type '%s')\\n\",\n\t\t\tinfo.ID, info.Config.Device)\n\t\treturn nil\n\t}\n\n\tdc := i.newDeviceConn(info)\n\ti.devices[info.ID] = dc\n\n\tif err := dc.runProviders(); err != nil {\n\t\treturn err\n\t}\n\n\t// Send periodic updates of device-level metadata.\n\tdc.group.Add(1)\n\tgo func() {\n\t\terr := dc.sendPeriodicUpdates()\n\t\tif err != nil {\n\t\t\tlog.Log(info.Device).Errorf(\"Error updating device metadata: %v\", err)\n\t\t}\n\t\tdc.group.Done()\n\t}()\n\n\tif manager, ok := info.Device.(Manager); ok {\n\t\tdc.group.Add(1)\n\t\tgo func() {\n\t\t\terr := manager.Manage(i)\n\t\t\tif err != nil {\n\t\t\t\tlog.Log(info.Device).Errorf(\"Error in manager.Manage: %v\", err)\n\t\t\t}\n\t\t\tdc.group.Done()\n\t\t}()\n\t}\n\n\tlog.Log(info.Device).Infof(\"Added device %s\", info.ID)\n\treturn nil\n}", "func (vm *VM) opIn(instr []uint16) int {\n\ta := instr[0] - 32768\n\tchr, err := vm.r.ReadByte()\n\tif err != nil {\n\t\tvm.Status = err.Error()\n\t\treturn 0\n\t}\n\tvm.registers[a] = uint16(chr)\n\treturn 2\n}", "func (a aio) input(f tFunc) {\n\ta.iCh <- f\n}", "func WithInput(ch interface{}) Option {\n\treturn func(b *Builder) {\n\t\tb.inCh = ch\n\t}\n}", "func AddSNMPDevice(ctx *Context, dev config.SnmpDeviceCfg) {\n\t// swagger:operation POST /cfg/snmpdevice Config_Device AddSNMPDevice1\n\t//---\n\t// summary: Add a new Device into de config database and/or in runtime.\n\t// description: Add a new Device into de config database and/or in runtime.\n\t// tags:\n\t// - \"Devices Config\"\n\t//\n\t// parameters:\n\t// - name: SnmpDeviceCfg\n\t// in: body\n\t// description: device to add\n\t// required: true\n\t// schema:\n\t// \"$ref\": \"#/definitions/SnmpDeviceCfg\"\n\t//\n\t// responses:\n\t// '200':\n\t// description: Added Device config\n\t// schema:\n\t// \"$ref\": \"#/definitions/SnmpDeviceCfg\"\n\t// '404':\n\t// description: unexpected error\n\t// schema:\n\t// \"$ref\": \"#/responses/idOfStringResp\"\n\n\t// swagger:operation POST /cfg/snmpdevice/{mode} Config_Device AddSNMPDevice2\n\t//---\n\t// summary: Add a new Device into de config database and/or in runtime.\n\t// description: |\n\t// Add a new existing Device into de config database with specified ID and/or reload new config in runtime.\n\t// Modes:\n\t// - \"config\": Only in config database (equivalent to delete without mode parameter)\n\t// - \"runtime\": Only e in active and running devices (runtime) WARN: this config will be lost on next reload.\n\t// - \"full\": in both on database and also in runtime devices.\n\t// tags:\n\t// - \"Devices Config\"\n\t//\n\t// parameters:\n\t// - name: mode\n\t// in: path\n\t// description: Adition mode\n\t// required: true\n\t// type: string\n\t// enum: [runtime,full,config]\n\t//\n\t// - name: SnmpDeviceCfg\n\t// in: body\n\t// description: device to add\n\t// required: true\n\t// schema:\n\t// \"$ref\": \"#/definitions/SnmpDeviceCfg\"\n\t//\n\t// responses:\n\t// '200':\n\t// description: Added Device config\n\t// schema:\n\t// \"$ref\": \"#/definitions/SnmpDeviceCfg\"\n\t// '404':\n\t// description: unexpected error\n\t// schema:\n\t// \"$ref\": \"#/responses/idOfStringResp\"\n\n\tmode := ctx.Params(\":mode\")\n\tlog.Printf(\"ADDING DEVICE %+v mode(%s)\", dev, mode)\n\tswitch mode {\n\tcase \"runtime\":\n\t\terr := addDeviceOnline(\"deploy\", dev.ID, &dev)\n\t\tif err != nil {\n\t\t\tlog.Warningf(\"Error on insert for device %s , error: %s\", dev.ID, err)\n\t\t\tctx.JSON(404, err.Error())\n\t\t} else {\n\t\t\tctx.JSON(200, &dev)\n\t\t}\n\tcase \"full\":\n\t\terr := addDeviceOnline(\"add\", dev.ID, &dev)\n\t\tif err != nil {\n\t\t\tlog.Warningf(\"Error on insert for device %s , error: %s\", dev.ID, err)\n\t\t\tctx.JSON(404, err.Error())\n\t\t} else {\n\t\t\tctx.JSON(200, &dev)\n\t\t}\n\tdefault:\n\t\taffected, err := agent.MainConfig.Database.AddSnmpDeviceCfg(dev)\n\t\tif err != nil {\n\t\t\tlog.Warningf(\"Error on insert for device %s , affected : %+v , error: %s\", dev.ID, affected, err)\n\t\t\tctx.JSON(404, err.Error())\n\t\t} else {\n\t\t\t// TODO: review if needed return data or affected\n\t\t\tctx.JSON(200, &dev)\n\t\t}\n\t}\n}", "func (s *BasevhdlListener) EnterLibrary_unit(ctx *Library_unitContext) {}", "func PADDUSB(mx, x operand.Op) { ctx.PADDUSB(mx, x) }", "func (d *Drain) SetInput(in <-chan interface{}) {\n\td.input = in\n}", "func (p PowerControl) In(val interface{}) {\n\tp.in <- val\n}", "func (qd *Qdisc) Add(info *Object) error {\n\tif info == nil {\n\t\treturn ErrNoArg\n\t}\n\toptions, err := validateQdiscObject(rtmNewQdisc, info)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn qd.action(rtmNewQdisc, netlink.Create|netlink.Excl, info, options)\n}", "func (h *IPSecVppHandler) InterfaceAddSPD(spdID, swIfIdx uint32) error {\n\treturn h.interfaceAddDelSpd(spdID, swIfIdx, true)\n}", "func (w *W) setInput(input chan Request) {\n\tw.input = input\n}", "func (io IOHarness) SendInput(i int64) {\n\tio.in <- i\n}", "func (s *BasevhdlListener) EnterInterface_signal_declaration(ctx *Interface_signal_declarationContext) {\n}", "func Add(ds datastore.Datastore, a Input) (int, error) {\n\treturn add(ds, a)\n}", "func (p *Port) Connect(q *Port) (err error) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\terr = errors.New(fmt.Sprintf(\"%s\", e))\n\t\t}\n\t}()\n\n\tif q.src != nil {\n\t\tif q.src == p {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"%s -> %s: already connected\", p.String(), q.String())\n\t}\n\n\tif q.itemType == TYPE_PRIMITIVE {\n\t\treturn p.connect(q, true)\n\t}\n\n\tif q.itemType == TYPE_TRIGGER {\n\t\tif p.itemType == TYPE_MAP {\n\t\t\tfor _, sub := range p.subs {\n\t\t\t\treturn sub.Connect(q)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"%s -> %s: trigger connected with empty map\", p.Name(), q.Name())\n\t\t}\n\t\treturn p.connect(q, true)\n\t}\n\n\tif p.itemType != TYPE_PRIMITIVE && p.itemType != q.itemType || p.itemType == TYPE_PRIMITIVE && !q.PrimitiveType() {\n\t\treturn fmt.Errorf(\"%s -> %s: types don't match - %d != %d\", p.Name(), q.Name(), p.itemType, q.itemType)\n\t}\n\n\tif p.PrimitiveType() {\n\t\treturn p.connect(q, true)\n\t}\n\n\tif p.itemType == TYPE_MAP {\n\t\tif len(p.subs) != len(q.subs) {\n\t\t\treturn fmt.Errorf(\"%s -> %s: maps are incompatible - unequal lengths %d and %d\", p.Name(), q.Name(), len(p.subs), len(q.subs))\n\t\t}\n\n\t\tfor k, pe := range p.subs {\n\t\t\tqe, ok := q.subs[k]\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s -> %s: maps are incompatible - %s not present\", p.Name(), q.Name(), k)\n\t\t\t}\n\n\t\t\terr := pe.Connect(qe)\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tif p.itemType == TYPE_STREAM {\n\t\tif q.sub == nil {\n\t\t\treturn fmt.Errorf(\"%s -> %s: streams are incompatible - no sub present\", p.Name(), q.Name())\n\t\t}\n\n\t\treturn p.sub.Connect(q.sub)\n\t}\n\n\tif p.itemType == TYPE_GENERIC {\n\t\treturn fmt.Errorf(\"%s -> %s: cannot connect generic type\", p.Name(), q.Name())\n\t}\n\n\treturn fmt.Errorf(\"%s -> %s: unknown type\", p.Name(), q.Name())\n}", "func (s *BasevhdlListener) EnterInterface_quantity_declaration(ctx *Interface_quantity_declarationContext) {\n}", "func (t *splitter) OnIn(s string) {\n\tt.Out1 <- s\n\tt.Out2 <- s\n}", "func io(output update.OutputT, chs serverChannelsT) update.IoResultT {\n\tresult := update.IoResultT{}\n\tif output.MsgToPrint != \"\" {\n\t\tfmt.Println(output.MsgToPrint)\n\t}\n\tif len(output.ResponseToClient.Content) != 0 {\n\t\toutput.ResponseToClient.Ch <- output.ResponseToClient.Content\n\t}\n\tif len(output.ResponseToWatcher.Msg) != 0 {\n\t\toutput.ResponseToWatcher.Ch <- output.ResponseToWatcher.Msg\n\t}\n\tselect {\n\tcase clientRequest := <-chs.clientRequest:\n\t\tresult.ClientRequest = clientRequest\n\t\tresult.ClientOrWatcher = update.ClientRequestC\n\tcase rawWatcherInput := <-chs.watcherInput:\n\t\tresult.RawWatcherInput = rawWatcherInput\n\t\tresult.ClientOrWatcher = update.WatcherInputC\n\t}\n\treturn result\n}", "func (s *BasevhdlListener) EnterInterface_declaration(ctx *Interface_declarationContext) {}", "func NewInput(\n\tcfg *common.Config,\n\toutlet channel.Connector,\n\tcontext input.Context,\n) (input.Input, error) {\n\n\tout, err := outlet(cfg, context.DynamicFields)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tforwarder := harvester.NewForwarder(out)\n\n\tconfig := defaultConfig\n\terr = cfg.Unpack(&config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcb := func(data []byte, metadata inputsource.NetworkMetadata) {\n\t\tevent := createEvent(data, metadata)\n\t\tforwarder.Send(event)\n\t}\n\n\tsplitFunc := tcp.SplitFunc([]byte(config.LineDelimiter))\n\tif splitFunc == nil {\n\t\treturn nil, fmt.Errorf(\"unable to create splitFunc for delimiter %s\", config.LineDelimiter)\n\t}\n\n\tserver, err := tcp.New(&config.Config, splitFunc, cb)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Input{\n\t\tserver: server,\n\t\tstarted: false,\n\t\toutlet: out,\n\t\tconfig: &config,\n\t\tlog: logp.NewLogger(\"tcp input\").With(\"address\", config.Config.Host),\n\t}, nil\n}", "func (l *Libvirt) DomainAddIothread(Dom Domain, IothreadID uint32, Flags DomainModificationImpact) (err error) {\n\tvar buf []byte\n\n\targs := DomainAddIothreadArgs {\n\t\tDom: Dom,\n\t\tIothreadID: IothreadID,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(355, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (s *BasevhdlListener) EnterInterface_port_declaration(ctx *Interface_port_declarationContext) {}", "func (e *Environment) InputAdd(constructor InputConstructor, spec docs.ComponentSpec) error {\n\treturn e.inputs.Add(constructor, spec)\n}", "func Input(c *cli.Context) error {\n\tvar file string\n\tfmt.Println(\"Enter the output file name\")\n\tfmt.Scan(&file)\n\tif file == \"\" {\n\t\tfile = inputFileName\n\t}\n\n\tvar str string\n\tfmt.Println(\"Enter the music you want to play\")\n\tfmt.Scan(&str)\n\n\tvar score []uint8\n\tfor _, t := range str {\n\t\tscore = append(score, values.Scale(fmt.Sprintf(\"%c\", t)))\n\t}\n\n\tdivision, err := smf.NewDivision(ticks, smf.NOSMTPE)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmidi, err := smf.NewSMF(smf.Format0, *division)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttrack := &smf.Track{}\n\terr = midi.AddTrack(track)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar list []*smf.MIDIEvent\n\tfor i, t := range score {\n\t\tvar d uint32\n\t\tif i != 0 {\n\t\t\td = onDeltaTime\n\t\t}\n\t\ttoneOn, err := smf.NewMIDIEvent(d, smf.NoteOnStatus, 0x00, t, 0x64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlist = append(list, toneOn)\n\t\ttoneOff, err := smf.NewMIDIEvent(offDeltaTime, smf.NoteOffStatus, 0x00, t, 0x64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlist = append(list, toneOff)\n\t}\n\n\tfor _, l := range list {\n\t\tif err := track.AddEvent(l); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tmetaEvent, err := smf.NewMetaEvent(21, smf.MetaEndOfTrack, []byte{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := track.AddEvent(metaEvent); err != nil {\n\t\treturn err\n\t}\n\n\toutputMidi, err := os.Create(fmt.Sprintf(\"./%s.mid\", file))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer outputMidi.Close()\n\n\twriter := bufio.NewWriter(outputMidi)\n\tsmfio.Write(writer, midi)\n\treturn writer.Flush()\n}", "func (s *BasevhdlListener) EnterWaveform_element(ctx *Waveform_elementContext) {}", "func (self *SinglePad) ConnectI(args ...interface{}) {\n self.Object.Call(\"connect\", args)\n}", "func (e *Executor) handleAddInput(flow *FlowInfo) {\n\ttaskCtx := e.taskInstances[flow.TaskInstanceID]\n\tsubID, err := e.subscribeInputStream(taskCtx.refURL, taskCtx.TaskID, &flow.InputStream)\n\tif err == nil {\n\t\tDEBUG.Println(\"===========subscribe new input = \", flow, \" , subID = \", subID)\n\t\ttaskCtx.Subscriptions = append(taskCtx.Subscriptions, subID)\n\t\ttaskCtx.EntityID2SubID[flow.InputStream.ID] = subID\n\t} else {\n\t\tERROR.Println(err)\n\t}\n}", "func AddInto(ctx *build.Context, z, x, y ir.Int, c ir.Register) {\n\tvar cin ir.Operand = ir.Flag(0)\n\tfor i := 0; i < z.Len(); i++ {\n\t\tctx.ADD(ir.Limb(x, i), ir.Limb(y, i), cin, z.Limb(i), c)\n\t\tcin = c\n\t}\n}", "func addApInterface(iface string) error {\n\tcmd := exec.Command(\"iw\", \"phy\", \"phy0\", \"interface\", \"add\", iface, \"type\", \"__ap\")\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn err\n\t}\n\n\tif err := cmd.Wait(); err != nil {\n\t\treturn nil\n\t}\n\n\treturn nil\n}", "func (in *TransferableInput) Input() TransferableIn {\n\treturn in.In\n}", "func PAddRequest(req model.AddRequest) (data string, err error) {\n\tif strings.ToLower(req.Type) == \"computer\" {\n\t\tif _, exists := constant.COMPUTER[req.Name]; !exists {\n\t\t\tconstant.COMPUTER[req.Name] = 5 //default strength is 5\n\t\t} else {\n\t\t\terr = perror.CustomError(\"DEVICE ALREADY EXISTS\")\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tif _, exists := constant.REPEATER[req.Name]; !exists {\n\t\t\tconstant.REPEATER[req.Name] = 0 //repeaters font have any strength\n\t\t} else {\n\t\t\terr = perror.CustomError(\"DEVICE ALREADY EXISTS\")\n\t\t\treturn\n\t\t}\n\t}\n\tdata = \"DEVICE ADDED SUCCESSFULLY!!!\"\n\treturn\n}", "func (op InputOp) Add(o *op.Ops) {\n\tif op.Tag == nil {\n\t\tpanic(\"Tag must be non-nil\")\n\t}\n\tif b := op.ScrollBounds; b.Min.X > 0 || b.Max.X < 0 || b.Min.Y > 0 || b.Max.Y < 0 {\n\t\tpanic(fmt.Errorf(\"invalid scroll range value %v\", b))\n\t}\n\tif op.Types>>16 > 0 {\n\t\tpanic(fmt.Errorf(\"value in Types overflows uint16\"))\n\t}\n\tdata := ops.Write1(&o.Internal, ops.TypePointerInputLen, op.Tag)\n\tdata[0] = byte(ops.TypePointerInput)\n\tif op.Grab {\n\t\tdata[1] = 1\n\t}\n\tbo := binary.LittleEndian\n\tbo.PutUint16(data[2:], uint16(op.Types))\n\tbo.PutUint32(data[4:], uint32(op.ScrollBounds.Min.X))\n\tbo.PutUint32(data[8:], uint32(op.ScrollBounds.Min.Y))\n\tbo.PutUint32(data[12:], uint32(op.ScrollBounds.Max.X))\n\tbo.PutUint32(data[16:], uint32(op.ScrollBounds.Max.Y))\n}", "func (t *Tile) connect(inlet, outlet int) error {\n\tif inlet <= TunnelNotConnected || inlet > TunnelLeftTop {\n\t\treturn fmt.Errorf(\"inlet out of bounds: %v\", inlet)\n\t}\n\tif outlet <= TunnelNotConnected || outlet > TunnelLeftTop {\n\t\treturn fmt.Errorf(\"outlet out of bounds: %v\", outlet)\n\t}\n\n\tt.tunnels[inlet] = outlet\n\tt.tunnels[outlet] = inlet\n\n\treturn nil\n}", "func ifaceAdd(iface, ip string) error {\n\tif err := exec.Command(\"ip\", \"addr\", \"add\", addSubnet(ip), \"dev\", iface).Run(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *BasevhdlListener) EnterWaveform(ctx *WaveformContext) {}", "func (c *Context) UCOMISD(mx, x operand.Op) {\n\tc.addinstruction(x86.UCOMISD(mx, x))\n}", "func (s *slot) add(c interface{}) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\ts.elements[c] = c\n}", "func (b *MonopAmpBridge) AddDevice(ctx context.Context, id string) error {\n\treturn building.ErrOperationNotSupported\n}", "func NewAudioConfigFromMicrophoneInput(deviceName string) (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tdn := C.CString(deviceName)\n\tdefer C.free(unsafe.Pointer(dn))\n\tret := uintptr(C.audio_config_create_audio_input_from_a_microphone(&handle, dn))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func (lgc *Logic) AddCollectorConfigurationInput(id string, input *graylog.CollectorConfigurationInput) (int, error) {\n\tif id == \"\" {\n\t\treturn 400, fmt.Errorf(\"id is required\")\n\t}\n\tif err := validator.CreateValidator.Struct(input); err != nil {\n\t\treturn 400, err\n\t}\n\tif err := lgc.store.AddCollectorConfigurationInput(id, input); err != nil {\n\t\treturn 500, err\n\t}\n\t// 202 no content\n\treturn 202, nil\n}", "func (self *TileSprite) SetInputA(member interface{}) {\n self.Object.Set(\"input\", member)\n}", "func (a *Agent) StartInput(ctx context.Context, pluginName string) (string, error) {\n\tinputConfig := models.InputConfig{\n\t\tName: pluginName,\n\t}\n\n\tinput, err := a.CreateInput(pluginName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tuniqueId, err := uuid.NewUUID()\n\tif err != nil {\n\t\treturn \"\", errors.New(\"errored while generating UUID for new INPUT\")\n\t}\n\tri := models.NewRunningInput(input, &inputConfig, uniqueId.String())\n\n\terr = ri.Init()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\terr = a.RunSingleInput(ri, ctx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// add new input to inputunit\n\ta.iu.inputs = append(a.iu.inputs, ri)\n\n\terr = a.Config.UpdateConfig(\n\t\tmap[string]interface{}{\n\t\t\t\"unique_id\": uniqueId.String(),\n\t\t\t\"name\": pluginName,\n\t\t},\n\t\tuniqueId.String(), \"inputs\", \"START_PLUGIN\")\n\n\tif err != nil {\n\t\tlog.Printf(\"W! [agent] Unable to save configuration for input %s\", uniqueId.String())\n\t}\n\n\treturn uniqueId.String(), nil\n}", "func (s *BasevhdlListener) EnterDesign_unit(ctx *Design_unitContext) {}", "func (d *deviceCommon) Add() error {\n\treturn nil\n}", "func (d *Device) AddInterface(astarteInterface interfaces.AstarteInterface) error {\n\td.interfaces[astarteInterface.Name] = astarteInterface\n\treturn nil\n}", "func (_SmartTgStats *SmartTgStatsSession) AddRequest(_channel string, _postID uint32) (*types.Transaction, error) {\n\treturn _SmartTgStats.Contract.AddRequest(&_SmartTgStats.TransactOpts, _channel, _postID)\n}", "func (s *BasevhdlListener) EnterInterface_element(ctx *Interface_elementContext) {}", "func (r *Output) Add(c Connection) bool {\n\t_, ok := r.Connections[c]\n\tif ok {\n\t\treturn false\n\t}\n\tr.Connections[c] = true\n\treturn true\n}", "func (s *Structure) Register(i interface{}) error {\n\tswitch v := i.(type) {\n\tcase *source.Source:\n\t\ts.Source = v\n\tcase *sink.Sink:\n\t\ts.Sink = v\n\tdefault:\n\t\treturn fmt.Errorf(\"provided interface cannot be cast to any known type\")\n\t}\n\treturn nil\n}", "func (lhs *Readings) add(rhs *Readings) (retval Readings, err error) {\n\tif lhs.ModbusDeviceId != rhs.ModbusDeviceId {\n\t\treturn Readings{}, fmt.Errorf(\n\t\t\t\"Cannot add readings of different devices - got IDs %d and %d\",\n\t\t\tlhs.ModbusDeviceId, rhs.ModbusDeviceId)\n\t} else {\n\t\tretval = Readings{\n\t\t\tUniqueId: lhs.UniqueId,\n\t\t\tModbusDeviceId: lhs.ModbusDeviceId,\n\t\t\tVoltage: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Voltage.L1) + Fp2f(rhs.Voltage.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Voltage.L2) + Fp2f(rhs.Voltage.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Voltage.L3) + Fp2f(rhs.Voltage.L3)),\n\t\t\t},\n\t\t\tCurrent: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Current.L1) + Fp2f(rhs.Current.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Current.L2) + Fp2f(rhs.Current.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Current.L3) + Fp2f(rhs.Current.L3)),\n\t\t\t},\n\t\t\tPower: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Power.L1) + Fp2f(rhs.Power.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Power.L2) + Fp2f(rhs.Power.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Power.L3) + Fp2f(rhs.Power.L3)),\n\t\t\t},\n\t\t\tCosphi: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Cosphi.L1) + Fp2f(rhs.Cosphi.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Cosphi.L2) + Fp2f(rhs.Cosphi.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Cosphi.L3) + Fp2f(rhs.Cosphi.L3)),\n\t\t\t},\n\t\t\tImport: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Import.L1) + Fp2f(rhs.Import.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Import.L2) + Fp2f(rhs.Import.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Import.L3) + Fp2f(rhs.Import.L3)),\n\t\t\t},\n\t\t\tTotalImport: F2fp(Fp2f(lhs.TotalImport) +\n\t\t\t\tFp2f(rhs.TotalImport)),\n\t\t\tExport: ThreePhaseReadings{\n\t\t\t\tL1: F2fp(Fp2f(lhs.Export.L1) + Fp2f(rhs.Export.L1)),\n\t\t\t\tL2: F2fp(Fp2f(lhs.Export.L2) + Fp2f(rhs.Export.L2)),\n\t\t\t\tL3: F2fp(Fp2f(lhs.Export.L3) + Fp2f(rhs.Export.L3)),\n\t\t\t},\n\t\t\tTotalExport: F2fp(Fp2f(lhs.TotalExport) +\n\t\t\t\tFp2f(rhs.TotalExport)),\n\t\t\tTHD: THDInfo{\n\t\t\t\tVoltageNeutral: ThreePhaseReadings{\n\t\t\t\t\tL1: F2fp(Fp2f(lhs.THD.VoltageNeutral.L1) +\n\t\t\t\t\t\tFp2f(rhs.THD.VoltageNeutral.L1)),\n\t\t\t\t\tL2: F2fp(Fp2f(lhs.THD.VoltageNeutral.L2) +\n\t\t\t\t\t\tFp2f(rhs.THD.VoltageNeutral.L2)),\n\t\t\t\t\tL3: F2fp(Fp2f(lhs.THD.VoltageNeutral.L3) +\n\t\t\t\t\t\tFp2f(rhs.THD.VoltageNeutral.L3)),\n\t\t\t\t},\n\t\t\t\tAvgVoltageNeutral: F2fp(Fp2f(lhs.THD.AvgVoltageNeutral) +\n\t\t\t\t\tFp2f(rhs.THD.AvgVoltageNeutral)),\n\t\t\t},\n\t\t\tFrequency: F2fp(Fp2f(lhs.Frequency) +\n\t\t\t\tFp2f(rhs.Frequency)),\n\t\t}\n\t\tif lhs.Timestamp.After(rhs.Timestamp) {\n\t\t\tretval.Timestamp = lhs.Timestamp\n\t\t\tretval.Unix = lhs.Unix\n\t\t} else {\n\t\t\tretval.Timestamp = rhs.Timestamp\n\t\t\tretval.Unix = rhs.Unix\n\t\t}\n\t\treturn retval, nil\n\t}\n}", "func (net *Network) AddConnection(a, b *Neuron) error {\n\tif a == b {\n\t\treturn errors.New(\"can't connect to self\")\n\t}\n\t// Sort the nodes by where they place in the diagram\n\ta, b = net.LeftRight(a, b)\n\tif a == net.OutputNode {\n\t\t// Swap a and b\n\t\ttmp := a\n\t\tb = a\n\t\ta = tmp\n\t}\n\tif a == net.OutputNode {\n\t\t// If now, after swapping, a is an output node, return with an error\n\t\treturn errors.New(\"will not insert a node between the output node and another node\")\n\t}\n\tif a.distanceFromOutputNode > b.distanceFromOutputNode {\n\t\t// Swap a and b\n\t\ttmp := a\n\t\tb = a\n\t\ta = tmp\n\t}\n\tif b.In(net.InputNodes) {\n\t\treturn errors.New(\"b is an input node\")\n\t}\n\t//if b.Value != nil {\n\t//return errors.New(\"b is a value node/input node\"\n\t//}\n\treturn b.AddInput(a)\n}", "func (_ConsortiumManagement *ConsortiumManagementTransactor) AddOperator(opts *bind.TransactOpts, operator common.Address, endpoint string) (*types.Transaction, error) {\n\treturn _ConsortiumManagement.contract.Transact(opts, \"addOperator\", operator, endpoint)\n}", "func (bus *fakeBus) addDevice(addr uint8) *fakeDev {\n\tdev := &fakeDev{\n\t\tc: bus.c,\n\t\taddr: addr,\n\t\tRegisters: [registerCount]uint8{\n\t\t\t// IODIRA and IODIRB are all ones by default.\n\t\t\trIODIR: 0xff,\n\t\t\trIODIR | portB: 0xff,\n\t\t},\n\t}\n\tbus.devs = append(bus.devs, dev)\n\treturn dev\n}", "func addUnitBySerial(a adapters.Adapter, serial string) {\n\t// add a unit serial record\n\tserialModel := models.SerialModel{\n\t\tAdapter: a.Code(),\n\t\tSerialNo: serial,\n\t}\n\tinfo, err := a.Info(serial)\n\tif err == nil {\n\t\tserialModel.UnitNo, err = a.UnitNo(serial, info)\n\t}\n\tif err != nil || serialModel.UnitNo == \"\" {\n\t\tlog.Debug().Msgf(\"[%s] %s -> %v\", a.Code(), serial, err)\n\t\treturn\n\t}\n\tserialModel.Operator, err = adapters.Operator(a, serial, info)\n\tif err != nil || serialModel.Operator == \"\" {\n\t\tserialModel.Operator = \"?\"\n\t}\n\tserialModel.Add()\n\tserialModel.AddTrainOperationLogs(info)\n}", "func (o *operatorRef) In() reflect.Type {\n\treturn o.in\n}", "func (_SmartTgStats *SmartTgStatsTransactorSession) AddRequest(_channel string, _postID uint32) (*types.Transaction, error) {\n\treturn _SmartTgStats.Contract.AddRequest(&_SmartTgStats.TransactOpts, _channel, _postID)\n}", "func InputSource(in Input) sound.Source {\n\treturn &chn{\n\t\tForm: in,\n\t\tin: in,\n\t\tch: in.C()}\n}", "func AddDeviceInRuntime(k string, cfg *config.SnmpDeviceCfg) {\n\t// Initialize each SNMP device and put pointer to the global map devices\n\tdev := device.New(cfg)\n\tdev.AttachToBus(Bus)\n\tdev.InitCatalogVar(DBConfig.VarCatalog)\n\tdev.SetSelfMonitoring(selfmonProc)\n\n\t// send a db map to initialize each one its own db if needed\n\toutdb, _ := dev.GetOutSenderFromMap(influxdb)\n\toutdb.Init()\n\toutdb.StartSender(&senderWg)\n\n\tmutex.Lock()\n\tdevices[k] = dev\n\t// Start gather goroutine for device and add it to the wait group for gather goroutines\n\tgatherWg.Add(1)\n\tgo func() {\n\t\tdefer gatherWg.Done()\n\t\tdev.StartGather()\n\t\tlog.Infof(\"Device %s finished\", cfg.ID)\n\t\t// If device goroutine has finished, leave the bus so it won't get blocked trying\n\t\t// to send messages to a not running device.\n\t\tdev.LeaveBus(Bus)\n\t}()\n\tmutex.Unlock()\n}", "func (_SmartTgStats *SmartTgStatsTransactor) AddRequest(opts *bind.TransactOpts, _channel string, _postID uint32) (*types.Transaction, error) {\n\treturn _SmartTgStats.contract.Transact(opts, \"AddRequest\", _channel, _postID)\n}", "func (m *moduleService) Input() *dpdk.Ring {\n\treturn m.input\n}", "func (ch *RingChannel) In() chan<- interface{} {\n\treturn ch.input\n}", "func (s *Switch) RegisterDirectProtocolWithChannel(protocol string, ingressChannel chan service.DirectMessage) chan service.DirectMessage {\n\tif s.started == 1 {\n\t\tlog.Panic(\"attempting to register direct protocol with channel after p2p has started\")\n\t}\n\ts.directProtocolHandlers[protocol] = ingressChannel\n\treturn ingressChannel\n}", "func (net Network) initInput() {\n\tfor i := range net[0] {\n\t\tnet[0][i] = &Neuron{value: 0}\n\t}\n}", "func (o *operator) In() reflect.Type {\n\treturn o.in\n}", "func UCOMISD(mx, x operand.Op) { ctx.UCOMISD(mx, x) }", "func COMISD(mx, x operand.Op) { ctx.COMISD(mx, x) }" ]
[ "0.5624008", "0.4930372", "0.49055094", "0.48159757", "0.47735038", "0.4769872", "0.45192832", "0.45080334", "0.44526583", "0.445226", "0.44361445", "0.44183317", "0.4409027", "0.4395565", "0.43943202", "0.43803808", "0.43727273", "0.43714926", "0.43645203", "0.43591833", "0.4356376", "0.43484837", "0.4346692", "0.4346152", "0.43435538", "0.43375802", "0.43234178", "0.4318203", "0.4306041", "0.43025327", "0.43023145", "0.42965055", "0.42939708", "0.42875588", "0.4286894", "0.42794782", "0.42700157", "0.4269713", "0.42601824", "0.424413", "0.4230695", "0.4222813", "0.42128766", "0.41987813", "0.41983017", "0.41847998", "0.41788042", "0.4163398", "0.41490626", "0.41338235", "0.4128176", "0.41223413", "0.41164598", "0.41158766", "0.41118246", "0.4090864", "0.4090807", "0.4090097", "0.40897644", "0.4075518", "0.40689087", "0.40594813", "0.40589643", "0.40550628", "0.40468043", "0.40451273", "0.4041801", "0.40381074", "0.40332684", "0.40095523", "0.4007816", "0.40075225", "0.40047157", "0.39954147", "0.39919966", "0.39898875", "0.39898217", "0.39871624", "0.3984497", "0.39830545", "0.39764786", "0.39756557", "0.39743558", "0.39702472", "0.39546543", "0.3950618", "0.39468902", "0.3941005", "0.3940961", "0.39268053", "0.3923803", "0.3923448", "0.39229062", "0.39196995", "0.39194188", "0.39182293", "0.391193", "0.3909306", "0.39075747", "0.39059487" ]
0.73367494
0
Disconnect the DSP unit from the specified target. target: The unit that this unit is to be removed from. Specify 0 or NULL to disconnect the unit from all outputs and inputs. connection: If there is more than one connection between 2 dsp units, this can be used to define which of the connections should be disconnected. Note that when you disconnect a unit, it is up to you to reconnect the network so that data flow can continue. Important note: If you have a handle to the connection pointer that binds these 2 DSP units, then it will become invalid. The connection is then sent back to a freelist to be reused again by a later addInput command.
func (d *DSP) DisconnectFrom(target DSP, connection DspConnection) error { res := C.FMOD_DSP_DisconnectFrom(d.cptr, target.cptr, connection.cptr) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *MockConnection) Disconnect() {\n\tif other := c.Target.(*MockConnection); other == nil {\n\t\tpanic(\"Source connection not connected.\")\n\t} else if other.Target != c {\n\t\tpanic(\"Target connection not connected to source connection.\")\n\t} else {\n\t\tc.Target, other.Target = nil, nil\n\t}\n}", "func (p *Port) Disconnect(q *Port) error {\n\tif !p.Connected(q) {\n\t\treturn errors.New(\"not connected\")\n\t}\n\tq.src = nil\n\tdelete(p.dests, q)\n\treturn nil\n}", "func (s *SimpleDriver) DisconnectDevice(address *models.Addressable) error {\n\treturn nil\n}", "func (d *DirectMemifConnector) Disconnect(crossConnect *crossconnect.CrossConnect) {\n\tvalue, exist := d.proxyMap.Load(crossConnect.GetId())\n\tif !exist {\n\t\tlogrus.Warnf(\"Proxy for cross connect with id=%s doesn't exist. Nothing to stop\", crossConnect.GetId())\n\t\treturn\n\t}\n\n\tproxy := value.(memifproxy.Proxy)\n\tproxy.Stop()\n\n\td.proxyMap.Delete(crossConnect.Id)\n}", "func (d *Decoder) Disconnect(h FrameHandler) {\n\t// Delete handler\n\td.d.delHandler(h)\n\n\t// Disconnect nodes\n\tastiencoder.DisconnectNodes(d, h)\n}", "func (r *FrameRateEmulator) Disconnect(h FrameHandler) {\n\t// Delete handler\n\tr.d.delHandler(h)\n\n\t// Disconnect nodes\n\tastiencoder.DisconnectNodes(r, h)\n}", "func (ch *InternalChannel) Disconnect(c *Client) {}", "func (client *Client) RemoveTarget(target Target) (id string, err error) {\n\tif target == client.status {\n\t\treturn \"\", ErrTargetIsStatus\n\t}\n\n\tclient.mutex.Lock()\n\tdefer client.mutex.Unlock()\n\n\tfor i := range client.targets {\n\t\tif target == client.targets[i] {\n\t\t\tid = target.ID()\n\n\t\t\tevent := NewEvent(\"hook\", \"remove_target\")\n\t\t\tevent.Args = []string{target.ID(), target.Kind(), target.Name()}\n\t\t\tclient.EmitNonBlocking(event)\n\n\t\t\tclient.targets[i] = client.targets[len(client.targets)-1]\n\t\t\tclient.targets = client.targets[:len(client.targets)-1]\n\n\t\t\t// Ensure the channel has been parted\n\t\t\tif channel, ok := target.(*Channel); ok && !channel.parted {\n\t\t\t\tclient.SendQueuedf(\"PART %s\", channel.Name())\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\t}\n\n\terr = ErrTargetNotFound\n\treturn\n}", "func (self *SinglePad) Disconnect() {\n self.Object.Call(\"disconnect\")\n}", "func (b *Bluez) Disconnect(adapterName, deviceMac string) error {\n\treturn b.CallDevice(adapterName, deviceMac, \"Disconnect\", 0).Store()\n}", "func (o *Output) Disconnect(c Connection) bool {\n\to.Lock()\n\tok := o.Remove(c)\n\to.Unlock()\n\treturn ok\n}", "func (mn *MockNetwork) Disconnect(string) error {\n\treturn nil\n}", "func (gw *Gateway) Disconnect(gnetID uint64) error {\n\tvar err error\n\tgw.strand(\"Disconnect\", func() {\n\t\tc := gw.d.connections.getByGnetID(gnetID)\n\t\tif c == nil {\n\t\t\terr = ErrConnectionNotExist\n\t\t\treturn\n\t\t}\n\n\t\terr = gw.d.Disconnect(c.Addr, ErrDisconnectRequestedByOperator)\n\t})\n\treturn err\n}", "func (ch *ServerChannel) Disconnect(c *Client) {}", "func Disconnect(w http.ResponseWriter, r *http.Request) {\n\truntime := r.Context().Value(\"runtime\").(*libpod.Runtime)\n\n\tvar netDisconnect types.NetworkDisconnect\n\tif err := json.NewDecoder(r.Body).Decode(&netDisconnect); err != nil {\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, errors.Wrap(err, \"Decode()\"))\n\t\treturn\n\t}\n\n\tname := utils.GetName(r)\n\terr := runtime.DisconnectContainerFromNetwork(netDisconnect.Container, name, netDisconnect.Force)\n\tif err != nil {\n\t\tif errors.Cause(err) == define.ErrNoSuchCtr {\n\t\t\tutils.Error(w, \"container not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tif errors.Cause(err) == define.ErrNoSuchNetwork {\n\t\t\tutils.Error(w, \"network not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tutils.WriteResponse(w, http.StatusOK, \"OK\")\n}", "func (r *RateEnforcer) Disconnect(h FrameHandler) {\n\t// Delete handler\n\tr.d.delHandler(h)\n\n\t// Disconnect nodes\n\tastiencoder.DisconnectNodes(r, h)\n}", "func (l *Logic) Disconnect(c context.Context, mid int64, key, server string) (has bool, err error) {\n\tif has, err = l.dao.DelMapping(c, mid, key, server); err != nil {\n\t\tlog.Errorf(\"l.dao.DelMapping(%d,%s) error(%v)\", mid, key, err)\n\t\treturn\n\t}\n\terr = l.dao.DeviceOffline(mid)\n\tlog.Infof(\"conn disconnected key:%s server:%s mid:%d\", key, server, mid)\n\treturn\n}", "func (bi *BaseInstance) disconnect(match VswMatch, param interface{}) error {\n\treturn bi.rules.remove(match, param)\n}", "func (bi *BaseInstance) disconnect(match VswMatch, param interface{}) error {\n\treturn bi.rules.remove(match, param)\n}", "func (t *TargetCollection) RemoveTarget(host string) {\n\tif host == \"\" {\n\t\treturn\n\t}\n\n\tt.mux.Lock()\n\tdefer t.mux.Unlock()\n\n\tdelete(t.entries, host)\n}", "func (d *Device) Disconnect() error {\n\td.cm.CancelConnect(d.prph)\n\treturn nil\n}", "func (o OfflineNotaryRepository) RemoveTarget(string, ...data.RoleName) error {\n\treturn nil\n}", "func (c *localController) DisconnectNetwork(name string, containerPid int) error {\n\tlogrus.Debugf(\"disconnecting %d from networks %s\", containerPid, name)\n\n\tpeer, err := c.ds.GetNetworkPeer(name, containerPid)\n\tif err != nil {\n\t\tif err == ds.ErrNetworkPeerDoesNotExist {\n\t\t\treturn fmt.Errorf(\"container %d is not connected to network %s\", containerPid, name)\n\t\t}\n\n\t\treturn err\n\t}\n\ttmpConfDir, err := ioutil.TempDir(\"\", \"circuit-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer os.RemoveAll(tmpConfDir)\n\n\tcninet, nc, rt, err := c.getCniConfig(name, tmpConfDir, containerPid, peer.IfaceName)\n\tif err != nil {\n\t\tlogrus.Warnf(\"unable to detect peer: %s\", err)\n\t}\n\n\tif err := cninet.DelNetwork(nc, rt); err != nil {\n\t\tlogrus.Warnf(\"unable to disconnect: %s\", err)\n\t}\n\n\tif err := c.ds.DeleteNetworkPeer(name, containerPid); err != nil {\n\t\tlogrus.Fatal(err)\n\t}\n\n\treturn nil\n}", "func (t *thing) Disconnect(ctx context.Context) {\n\tif t.client != nil {\n\t\tt.client.Unsubscribe(ctx, t.configTopic())\n\t\tif t.client.IsConnected() {\n\t\t\tt.infof(\"Disconnecting\")\n\t\t\tt.client.Disconnect(ctx)\n\t\t}\n\t}\n}", "func (*GenericFramework) PeerDisconnect(ctx *PeerContext) {}", "func (k *KernelForwarder) deleteRemoteConnection(connID string, localConnection, remoteConnection *connection.Connection, direction uint8) (map[string]monitoring.Device, error) {\n\tlogrus.Info(\"remote: deleting connection...\")\n\n\tifaceName := localConnection.GetMechanism().GetParameters()[common2.InterfaceNameKey]\n\tvar xconName string\n\tif direction == INCOMING {\n\t\txconName = \"DST-\" + connID\n\t} else {\n\t\txconName = \"SRC-\" + connID\n\t}\n\n\t/* Lock the OS thread so we don't accidentally switch namespaces */\n\truntime.LockOSThread()\n\tdefer runtime.UnlockOSThread()\n\n\tnsInode, localErr := ClearInterfaceSetup(ifaceName, localConnection)\n\tremoteErr := k.remoteConnect.DeleteInterface(ifaceName, remoteConnection)\n\n\tif localErr != nil || remoteErr != nil {\n\t\treturn nil, errors.Errorf(\"remote: %v - %v\", localErr, remoteErr)\n\t}\n\n\tlogrus.Infof(\"remote: deletion completed for device - %s\", ifaceName)\n\treturn map[string]monitoring.Device{nsInode: {Name: ifaceName, XconName: xconName}}, nil\n}", "func (a *NullAdapter) Disconnect(srv *Server, ca ClientAdapter, err error) {\n}", "func (ch *Channel) Disconnect(c *Client) {\n ch.Clients.Delete(c.Id)\n}", "func (w *SimU) DisconnectWorld() error {\n\tc := &ups.Commands{\n\t\tDisconnect: proto.Bool(true),\n\t}\n\treturn w.WriteProto(c)\n}", "func Disconnect(uname string) {\n\tif roomID, ok := paired.Get(uname).(string); ok {\n\t\tpair := roomMap.Get(roomID).(Pair)\n\t\tpaired.Remove(pair.Male)\n\t\tpaired.Remove(pair.Female)\n\t\troomMap.Remove(roomID)\n\t} else {\n\t\tlog.Println(\"WARNING:Disconnect:User not found\")\n\t}\n}", "func (u *Unit) KillUnit() error {\n\tconn, err := sd.NewSystemdConnection()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get systemd bus connection: %v\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\tsignal, err := strconv.ParseInt(u.Value, 10, 64)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to parse signal number '%s': %s\", u.Value, err)\n\t\treturn err\n\t}\n\n\tconn.KillUnit(u.Unit, int32(signal))\n\n\treturn nil\n}", "func (c *Communicator) Disconnect() error {\n\tc.client = nil\n\treturn nil\n}", "func (self *discovery) disconnect() error {\n\tself.Lock()\n\tdefer self.Unlock()\n\n\tif self.connected {\n\t\treturn self.callDiscoveryService(\"unregister\", false)\n\t}\n\n\treturn nil\n}", "func (g *Graph) Disconnect(from, to Node) {\n\tg.l.Lock()\n\tg.connect(from, to)\n\tg.l.Unlock()\n}", "func (p *Pod) Disconnect() {\n\t// stop future messages from being sent and then indicate to the bus that disconnection is desired\n\t// The bus will close the busChan, which will cause the onFunc listener to quit.\n\tp.dead.Store(true)\n\tp.feedbackChan <- podFeedbackMsgDisconnect\n}", "func (s *BasevhdlListener) ExitTarget(ctx *TargetContext) {}", "func (h *Hub) doUnregister(c *connection) {\n\th.Lock()\n\tdefer h.Unlock()\n\n\t// get the subscription\n\ts, ok := h.connections[c]\n\tif !ok {\n\t\th.log.Println(\n\t\t\t\"[WARN] cannot unregister connection, it is not registered.\",\n\t\t)\n\t\treturn\n\t}\n\n\tif s != nil {\n\t\th.log.Printf(\n\t\t\t\"[DEBUG] unregistering one of subscribers: %s connections\\n\",\n\t\t\ts.Topic,\n\t\t)\n\t\t// delete the connection from subscriber's connections\n\t\tdelete(s.connections, c)\n\t\tif len(s.connections) == 0 {\n\t\t\t// there are no more open connections for this subscriber\n\t\t\th.log.Printf(\n\t\t\t\t\"[DEBUG] unsub: %s, no more open connections\\n\",\n\t\t\t\ts.Topic,\n\t\t\t)\n\t\t\tdelete(h.subscribers, s.Topic)\n\t\t\t// unsubscribe from redis topic\n\t\t\terr := h.subconn.Unsubscribe(s.Topic)\n\t\t\tif err != nil {\n\t\t\t\th.log.Printf(\n\t\t\t\t\t\"[WARN] Unable to unsub topic: %s from redis\\n\",\n\t\t\t\t\ts.Topic,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\th.log.Printf(\n\t\t\t\t\t\"[DEBUG] Unsubscribed topic %s from redis\\n\",\n\t\t\t\t\ts.Topic,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\th.log.Println(\"[DEBUG] unregistering socket connection\")\n\tc.close()\n\tdelete(h.connections, c)\n}", "func (c *INDIClient) Disconnect() error {\n\t// Clear out all devices\n\tc.delProperty(&DelProperty{})\n\n\tif c.conn == nil {\n\t\treturn nil\n\t}\n\n\terr := c.conn.Close()\n\tc.conn = nil\n\n\tif c.read != nil {\n\t\tclose(c.read)\n\t\tc.read = nil\n\t}\n\n\tif c.write != nil {\n\t\tclose(c.write)\n\t\tc.write = nil\n\t}\n\n\treturn err\n}", "func (n *Node) disconnect() *NodeErr {\n\t// Send an error to Node.Error channel if the node is not connected\n\tif !n.IsConnected() {\n\t\treturn ConnErr(\"node not connected\", nil)\n\t}\n\n\t// Warn to other network peers about the disconnection\n\tmsg := new(message.Message).SetType(message.DisconnectType).SetFrom(n.Self)\n\tif err := n.broadcast(msg); err != nil {\n\t\treturn err\n\t}\n\n\t// Clean current member list\n\tn.Members = peer.NewMembers()\n\tn.setConnected(false)\n\treturn nil\n}", "func (w *Wrapper) Unlink(first, second interface{}) (err error) {\n\t//grab the read lock\n\tw.connLock.RLock()\n\tdefer w.connLock.RUnlock()\n\n\t//make sure we have a connection\n\tif w.connection == nil {\n\t\treturn fmt.Errorf(\"No connection. Bootstrap a connection first.\")\n\t}\n\n\t//grab the id of the first object\n\tfid, err := getId(reflect.ValueOf(first))\n\tif err != nil {\n\t\treturn\n\t}\n\n\t//grab the id of the second object\n\tsid, err := getId(reflect.ValueOf(second))\n\tif err != nil {\n\t\treturn\n\t}\n\n\t//delete the pair\n\t_, err = w.exec(`DELETE FROM object_links WHERE\n\t\t (origin_id = $1 AND target_id = $2)\n\t\tOR (origin_id = $3 AND target_id = $4)`, fid, sid, sid, fid)\n\n\treturn\n}", "func (m *Mux) Disconnect() error {\n\t// TODO(seanc@): Test to see make sure the descriptor has the mutate bit set.\n\n\tif err := vpc.Ctl(m.h, vpc.Cmd(_MuxUnderlayDisconnectCmd), nil, nil); err != nil {\n\t\treturn errors.Wrap(err, \"unable to disconnect VPC Mux to to VPC Interface\")\n\t}\n\n\treturn nil\n}", "func (pushbots *PushBots) UnTagDevice(token, platform, alias, tag string) error {\n\tif err := checkForArgErrorsWithAlias(token, platform, alias); err != nil {\n\t\treturn err\n\t}\n\n\targs := apiRequest{\n\t\tToken: token,\n\t\tAlias: alias,\n\t\tPlatform: platform,\n\t\tTag: tag,\n\t}\n\n\treturn checkAndReturn(pushbots.sendToEndpoint(\"untagdevice\", args))\n}", "func Disconnect(g *gocui.Gui, v *gocui.View) error {\n\tconnection.Close()\n\treturn gocui.ErrQuit\n}", "func (MGO) Disconnect() error {\n\treturn client.Disconnect(context.TODO())\n}", "func Disconnect(mt int, player *models.Player) {\n\tif player.RoomID != nil {\n\t\tr := models.Rooms.GetRoom(player.RoomID.Hex())\n\t\terr := r.RemovePlayer(player)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t}\n\tmodels.Players.RemovePlayer(player)\n\tutils.LogToConsole(\"Connected Players:\", models.Players.GetPlayerCount())\n}", "func (s *Switch) Disconnect(peer p2pcrypto.PublicKey) {\n\ts.inpeersMutex.Lock()\n\tif _, ok := s.inpeers[peer]; ok {\n\t\tdelete(s.inpeers, peer)\n\t\ts.inpeersMutex.Unlock()\n\t\ts.publishDelPeer(peer)\n\t\tmetrics.InboundPeers.Add(-1)\n\t\treturn\n\t}\n\ts.inpeersMutex.Unlock()\n\n\ts.outpeersMutex.Lock()\n\tif _, ok := s.outpeers[peer]; ok {\n\t\tdelete(s.outpeers, peer)\n\t} else {\n\t\ts.outpeersMutex.Unlock()\n\t\treturn\n\t}\n\ts.outpeersMutex.Unlock()\n\ts.publishDelPeer(peer)\n\tmetrics.OutboundPeers.Add(-1)\n\n\t// todo: don't remove if we know this is a valid peer for later\n\t// s.discovery.Remove(peer) // address doesn't matter because we only check dhtid\n\n\tselect {\n\tcase s.morePeersReq <- struct{}{}:\n\tcase <-s.shutdownCtx.Done():\n\t}\n}", "func DisconnectNode(nodeName string, otherNodes []string, method string) {\n\tfor _, targetIP := range otherNodes {\n\t\tcmd := exec.Command(\"bash\", \"../lib/io_connect_node.sh\", nodeName, targetIP, \"DISCONNECT\", method)\n\t\tcmd.Dir = \"./\"\n\t\t_, err := cmd.CombinedOutput()\n\t\tExpect(err).ToNot(HaveOccurred())\n\t}\n}", "func (c *MockConnection) TargetConnection() block.Connection {\n\treturn c.Target\n}", "func (pulse *Pulse) SinkRemoved(path dbus.ObjectPath) {\n\tlogger.Infof(\"dbus: sink removed, reconnecting\")\n\n\terr := pulse.Reconnect()\n\tif err != nil {\n\t\tlogger.Error(karma.Format(err, \"unable to reconnect to pulseaudio\"))\n\t}\n}", "func (s *PairingService) UnregisterDevice(realm string, deviceID string) error {\n\tcallURL, _ := url.Parse(s.pairingURL.String())\n\tcallURL.Path = path.Join(callURL.Path, fmt.Sprintf(\"/v1/%s/agent/devices/%s\", realm, deviceID))\n\n\terr := s.client.genericJSONDataAPIDelete(callURL.String(), 204)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (l *Lock) Disconnect(ctx context.Context) (err error) {\n\tif l.client == nil {\n\t\terr = fmt.Errorf(\"node %s not connected\", l.id)\n\t\treturn\n\t}\n\n\tl.client = nil\n\treturn\n}", "func (ms *MqttSocket) Disconnect() {\n\tms.client.Disconnect(0)\n}", "func (Noop) Drop(ctx context.Context, node string, srcNode string) error { return nil }", "func (tr *TestRunner) Disconnect(imsi, calledStationID string) (*radius.Packet, error) {\n\tfmt.Printf(\"************* Sending a disconnect request UE with IMSI: %s\\n\", imsi)\n\tres, err := uesim.Disconnect(&cwfprotos.DisconnectRequest{Imsi: imsi, CalledStationID: calledStationID})\n\tif err != nil {\n\t\treturn &radius.Packet{}, err\n\t}\n\tencoded := res.GetRadiusPacket()\n\tradiusP, err := radius.Parse(encoded, []byte(Secret))\n\tif err != nil {\n\t\terr = errors.Wrap(err, \"Error while parsing encoded Radius packet\")\n\t\tfmt.Println(err)\n\t\treturn &radius.Packet{}, err\n\t}\n\tfmt.Println(\"Finished Disconnecting UE\")\n\treturn radiusP, nil\n}", "func (c *client) Disconnect() error {\n\tif c.conn != nil {\n\t\terr := c.conn.Close()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tc.services.kvc = nil\n\tc.services.mapc = nil\n\tc.services.queuec = nil\n\tc.conn = nil\n\n\treturn nil\n}", "func (node *Node) Disconnect() error {\n\tnode.Lock()\n\tdefer node.Unlock()\n\tnode.allowNetwork = false\n\treturn nil\n}", "func (c *MQTTClient) Disconnect(pending uint) {\n\tc.client.Disconnect(pending)\n}", "func (h *Handler) Disconnect(ctx context.Context, in *backend.StatusRequest, out *backend.StatusResponse) error {\n\tuid := in.Meta[\"uid\"]\n\trid, _ := h.manager.GetMemberRoomID(uid)\n\tsvid, err := h.manager.GetRoomServerID(rid)\n\tlog.Debugf(\"Current server id:%s <==> Room server id:%s\", h.manager.GetService().Server().ID(), svid)\n\tif err != nil {\n\t\tlog.Error(\"Failed to get room server id:\", err)\n\t\treturn err\n\t}\n\tif svid != h.manager.GetService().Server().ID() { // forward to another server\n\t\tlog.Debugf(\"Forwad status request to other server\")\n\t\tcli := backend.NewBackendService(\"chat-demo.chat\", h.manager.GetService().Client())\n\t\tcli.Disconnect(ctx, in, client.WithSelectOption(selector.WithIDFilter([]string{svid})))\n\t\treturn nil\n\t}\n\th.manager.Disconnect(rid, uid)\n\treturn nil\n}", "func UnlockDevice(deviceID string) error {\n\tclient, err := NewPacketClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, e := client.Devices.Unlock(deviceID)\n\treturn e\n}", "func (mounter *csiProxyMounterV1Beta) Unmount(target string) error {\n\tklog.V(4).Infof(\"Unmount: %s\", target)\n\treturn mounter.Rmdir(target)\n}", "func (this User) disconnect() {\n disconnected := Message {this.Name, this.Id, \"disconnected\"}\n this.broadcast(disconnected)\n mu.Lock()\n delete(clients, this.Id)\n mu.Unlock()\n}", "func (vc *VirtualCenter) Disconnect(ctx context.Context) error {\n\tlog := logger.GetLogger(ctx)\n\tif vc.Client == nil {\n\t\tlog.Info(\"Client wasn't connected, ignoring\")\n\t\treturn nil\n\t}\n\tif err := vc.Client.Logout(ctx); err != nil {\n\t\tlog.Errorf(\"failed to logout with err: %v\", err)\n\t\treturn err\n\t}\n\tvc.Client = nil\n\treturn nil\n}", "func (n *mockAgent) disconnect() error {\n\treturn nil\n}", "func (self *SinglePad) DisconnectI(args ...interface{}) {\n self.Object.Call(\"disconnect\", args)\n}", "func (c *TestCluster) Disconnect(from, to string, err error) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tc.errors[c.peerKey(from, to)] = err\n}", "func DeleteDeviceTargetTemp(c *gin.Context) {\n\tdeviceName := c.Param(\"device_name\")\n\terr := database.DeleteDeviceTargetTemp(c, deviceName)\n\tif err != nil {\n\t\tc.Status(http.StatusNotFound)\n\t} else {\n\t\tc.Status(http.StatusOK)\n\t}\n}", "func (st *Tools) CloseUnitControllerConnection() error {\n\t// unlock the dbus connection no matter what\n\tdefer st.Unlock()\n\tif st.dcon != nil {\n\t\tst.dcon.Close()\n\t\t// since dbus api does not provide a way to check that the connection is closed, we'd nil it.\n\t\tst.dcon = nil\n\t\treturn nil\n\t}\n\treturn errors.New(\"dbus connection is closed\")\n}", "func (sf *SingleFlowNode) DisconnectPort(portIndex uint16, direction int) {\n\tswitch direction {\n\tcase FlowPortInput:\n\t\tC.sol_flow_single_disconnect_port_in(sf.FlowNode.cnode, C.uint16_t(portIndex))\n\tcase FlowPortOutput:\n\t\tC.sol_flow_single_disconnect_port_out(sf.FlowNode.cnode, C.uint16_t(portIndex))\n\t}\n}", "func (d *Device) Disconnect(result chan<- error) {\n\t// Wait 2 seconds and die\n\td.m.Disconnect(2000)\n}", "func (plugin *IscsiPlugin) LogoutTarget(targetName string) error {\n\tlog.Tracef(\">>>>> LogoutTarget, TargetName=%v\", targetName)\n\tdefer log.Traceln(\"<<<<< LogoutTarget\")\n\n\t// Call platform specific module\n\treturn plugin.logoutTarget(targetName)\n}", "func (mounter *Mounter) Unmount(target string) error {\n\treturn mounter.unmount(target, UMOUNT_COMMAND)\n}", "func TestDisconnect(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\tg := newTestingGateway(t)\n\tdefer g.Close()\n\tg2 := newNamedTestingGateway(t, \"2\")\n\tdefer g2.Close()\n\t// Try disconnecting from a peer that doesn't exist.\n\tif err := g.Disconnect(\"bar.com:123\"); err == nil {\n\t\tt.Fatal(\"disconnect removed unconnected peer\")\n\t}\n\n\t// Connect two peers to eachother.\n\terr := g.Connect(g2.myAddr)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tg.mu.Lock()\n\t_, exists := g.nodes[g2.myAddr]\n\tif !exists {\n\t\tt.Error(\"peer never made it into node list\")\n\t}\n\tg.mu.Unlock()\n\n\t// Disconnect the peer.\n\tif err := g.Disconnect(g2.myAddr); err != nil {\n\t\tt.Fatal(\"disconnect failed:\", err)\n\t}\n\tg2.Disconnect(g.myAddr) // Prevents g2 from connecting back to g\n\tpeers := g.Peers()\n\tfor _, peer := range peers {\n\t\tif peer.NetAddress == g2.myAddr {\n\t\t\tt.Error(\"disconnect seems to have failed - still have this peer\")\n\t\t}\n\t}\n\tg.mu.Lock()\n\t_, exists = g.nodes[g2.myAddr]\n\tif exists {\n\t\tt.Error(\"should be dropping peer from nodelist after disconnect\")\n\t}\n\tg.mu.Unlock()\n}", "func (this *DtNavMesh) unconnectLinks(tile, target *DtMeshTile) {\n\tif tile == nil || target == nil {\n\t\treturn\n\t}\n\n\ttargetNum := this.DecodePolyIdTile(DtPolyRef(this.GetTileRef(target)))\n\n\tfor i := 0; i < int(tile.Header.PolyCount); i++ {\n\t\tpoly := &tile.Polys[i]\n\t\tj := poly.FirstLink\n\t\tpj := DT_NULL_LINK\n\t\tfor j != DT_NULL_LINK {\n\t\t\tif this.DecodePolyIdTile(tile.Links[j].Ref) == targetNum {\n\t\t\t\t// Remove link.\n\t\t\t\tnj := tile.Links[j].Next\n\t\t\t\tif pj == DT_NULL_LINK {\n\t\t\t\t\tpoly.FirstLink = nj\n\t\t\t\t} else {\n\t\t\t\t\ttile.Links[pj].Next = nj\n\t\t\t\t}\n\t\t\t\tfreeLink(tile, j)\n\t\t\t\tj = nj\n\t\t\t} else {\n\t\t\t\t// Advance\n\t\t\t\tpj = j\n\t\t\t\tj = tile.Links[j].Next\n\t\t\t}\n\t\t}\n\t}\n}", "func (g *Gateway) Disconnect(addr modules.NetAddress) error {\n\tid := g.mu.RLock()\n\tp, exists := g.peers[addr]\n\tg.mu.RUnlock(id)\n\tif !exists {\n\t\treturn errors.New(\"not connected to that node\")\n\t}\n\tp.sess.Close()\n\tid = g.mu.Lock()\n\tdelete(g.peers, addr)\n\tg.mu.Unlock(id)\n\n\tg.log.Println(\"INFO: disconnected from peer\", addr)\n\treturn nil\n}", "func (c *Client) DeleteDirectConnect(request *DeleteDirectConnectRequest) (response *DeleteDirectConnectResponse, err error) {\n if request == nil {\n request = NewDeleteDirectConnectRequest()\n }\n response = NewDeleteDirectConnectResponse()\n err = c.Send(request, response)\n return\n}", "func (devices *DeviceSet) unregisterDevice(hash string) error {\n\tlogrus.Debugf(\"devmapper: unregisterDevice(%v)\", hash)\n\tinfo := &devInfo{\n\t\tHash: hash,\n\t}\n\n\tdelete(devices.Devices, hash)\n\n\tif err := devices.removeMetadata(info); err != nil {\n\t\tlogrus.Debugf(\"devmapper: Error removing metadata: %s\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (u *UnityServer) disconnect() {\n\tu.Logger.Info(\"Disconnecting unity\")\n\tu.conn.Close()\n\tu.connected = false\n}", "func Disconnect() {\n\tif pool != nil {\n\t\t_ = pool.Close() //todo: handle this error?\n\t}\n\tpool = nil\n}", "func (tester *TransportTesting) DisconnectTransport() {\n\terr := tester.manager.transport.underlyingTransport().Close()\n\tif !assert.NoError(tester.tb, err, \"close underlying livesOnce\") {\n\t\ttester.tb.FailNow()\n\t}\n}", "func (p *Persistence) Disconnect() {\n\n}", "func ChainDataDel(target string) {\n\tutil.TitlePrint(\"delete\", target)\n\tswitch target {\n\tcase \"local\":\n\t\tworkingDir := os.Getenv(\"CELO_ACCOUNT_DIR\")\n\t\tutil.ChangeDir(workingDir)\n\t\tcmd.ExecuteCmd(\"sudo rm -rf geth*\")\n\tcase \"validator\":\n\t\tworkingDir := os.Getenv(\"CELO_VALIDATOR_DIR\")\n\t\tutil.ChangeDir(workingDir)\n\t\tcmd.ExecuteCmd(\"sudo rm -rf geth*\")\n\t\tcmd.ExecuteCmd(\"sudo rm static-nodes.json\")\n\tcase \"proxy\":\n\t\tworkingDir := os.Getenv(\"CELO_PROXY_DIR\")\n\t\tutil.ChangeDir(workingDir)\n\t\tcmd.ExecuteCmd(\"mv geth/nodekey nodekey\")\n\t\tcmd.ExecuteCmd(\"sudo rm -rf geth*\")\n\t\tcmd.ExecuteCmd(\"sudo rm static-nodes.json\")\n\t\tcmd.ExecuteCmd(\"mkdir geth\")\n\t\tcmd.ExecuteCmd(\"mv nodekey geth/nodekey\")\n\tcase \"attestation\":\n\t\tworkingDir := os.Getenv(\"CELO_ATTESTATION_DIR\")\n\t\tutil.ChangeDir(workingDir)\n\t\tcmd.ExecuteCmd(\"sudo rm -rf geth*\")\n\t\tcmd.ExecuteCmd(\"sudo rm static-nodes.json\")\n\t}\n}", "func (r *ProtocolIncus) Disconnect() {\n\tif r.ctxConnected.Err() != nil {\n\t\tr.ctxConnectedCancel()\n\t}\n}", "func (room *RoomRecorder) actionDisconnect(msg synced.Msg) {\n\tif conn, ok := room.connectionCheck(msg); ok {\n\t\troom.Disconnect(conn)\n\t}\n}", "func (d *usbDevice) unreference() {\n\tC.libusb_unref_device(d.ptr())\n}", "func (e Manager) UnregisterConnection(id int) {\n\te.index.unregister(id)\n}", "func (p *pool) Del(connectionString string) {\n\tkey, err := makeKey(connectionString)\n\tif err != nil {\n\t\treturn\n\t}\n\tdelete(p.clients, key)\n}", "func (c *client) Disconnect(ifi *Interface) error {\n\t// Ask nl80211 to disconnect.\n\t_, err := c.get(\n\t\tunix.NL80211_CMD_DISCONNECT,\n\t\tnetlink.Acknowledge,\n\t\tifi,\n\t\tnil,\n\t)\n\treturn err\n}", "func (cmd *commandDisconn) run() error {\n\treturn cmd.cli.Disconnect()\n}", "func (nd *NetworkDisconnectCommand) runNetworkDisconnect(args []string) error {\n\tnetwork := args[0]\n\tcontainer := args[1]\n\n\tif network == \"\" {\n\t\treturn fmt.Errorf(\"network name cannot be empty\")\n\t}\n\tif container == \"\" {\n\t\treturn fmt.Errorf(\"container name cannot be empty\")\n\t}\n\n\tctx := context.Background()\n\tapiClient := nd.cli.Client()\n\n\terr := apiClient.NetworkDisconnect(ctx, network, container, nd.force)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"container %s is disconnected from network %s\\n successfully\", container, network)\n\n\treturn nil\n}", "func (communication *Wrapper) Unregister() common.SyncServiceError {\n\tif common.Configuration.CommunicationProtocol == \"http\" {\n\t\tcomm, err := communication.selectCommunicator(common.Configuration.CommunicationProtocol, \"\", \"\", \"\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn comm.Unregister()\n\t}\n\n\treturn &Error{\"ESS unregister only support in http communication protocol\\n\"}\n}", "func (s *Server) DisconnectNode(w http.ResponseWriter, req *http.Request) {\n\tnode := req.Context().Value(\"node\").(*peer.Node)\n\tpeer := req.Context().Value(\"peer\").(*peer.Node)\n\n\tif err := s.network.Disconnect(node.ID, peer.ID); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\ts.JSON(w, http.StatusOK, node.ID)\n}", "func (s *Signal) Disconnect(recv Ki) {\n\ts.Mu.Lock()\n\tdelete(s.Cons, recv)\n\ts.Mu.Unlock()\n}", "func (o MrScalarCoreScalingDownPolicyOutput) Target() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v MrScalarCoreScalingDownPolicy) *string { return v.Target }).(pulumi.StringPtrOutput)\n}", "func (w *Websocket) Disconnect() error {\n\tm := message.Message{\n\t\tChannel: transport.MetaDisconnect,\n\t\tClientId: w.clientID,\n\t\tId: w.nextMsgID(),\n\t}\n\n\tw.stopCh <- nil\n\tclose(w.stopCh)\n\tw.subscriptionsMu.Lock()\n\tfor i := range w.subscriptions {\n\t\t//close all listeners\n\t\tfor j := range w.subscriptions[i] {\n\t\t\tclose(w.subscriptions[i][j].MsgChannel())\n\t\t}\n\t\tdelete(w.subscriptions, i)\n\t}\n\tw.subscriptionsMu.Unlock()\n\n\treturn w.sendMessage(&m)\n}", "func (s *Service) Disconnect(ctx context.Context) error {\n\treturn s.Call(ctx, \"Disconnect\").Err\n}", "func (s *TCPConn) DelTCPRequest(targetAddr string) {\n\ts.server.lock.Lock()\n\tdefer s.server.lock.Unlock()\n\trequest := s.server.TCPRequestMap[targetAddr]\n\tif request != nil {\n\t\tif request.TargetConn != nil {\n\t\t\trequest.TargetConn.Close()\n\t\t}\n\t}\n\tdelete(s.server.TCPRequestMap, targetAddr)\n\n}", "func (s *Service) NetworkDisconnect(ctx context.Context, c *container.Container, net *yaml.Network, oneOff bool) error {\n\tcontainerID := c.ID()\n\tclient := s.clientFactory.Create(s)\n\treturn client.NetworkDisconnect(ctx, net.RealName, containerID, true)\n}", "func (f *freeClientPool) disconnect(address string) {\n\tf.lock.Lock()\n\tdefer f.lock.Unlock()\n\n\tif f.closed {\n\t\treturn\n\t}\n\te := f.addressMap[address]\n\tnow := f.clock.Now()\n\tif !e.connected {\n\t\tlog.Debug(\"Client already disconnected\", \"address\", address)\n\t\treturn\n\t}\n\n\tf.connPool.Remove(e.index)\n\tf.calcLogUsage(e, now)\n\te.connected = false\n\tf.disconnPool.Push(e, -e.logUsage)\n\tlog.Debug(\"Client disconnected\", \"address\", address)\n}", "func (u *Unit) StopUnit() error {\n\tconn, err := sd.NewSystemdConnection()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get systemd bus connection: %s\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\treschan := make(chan string)\n\t_, err = conn.StopUnit(u.Unit, \"fail\", reschan)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to stop unit %s: %v\", u.Unit, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *ConnectionManager) Disconnect(ctx context.Context) error {\n\tc.cancelCtx()\n\tselect {\n\tcase <-c.done: // wait for goroutine to exit\n\t\treturn nil\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\t}\n}" ]
[ "0.57582474", "0.5404482", "0.52955854", "0.5107216", "0.50436527", "0.49388117", "0.48889676", "0.48836368", "0.48642766", "0.48550525", "0.48419273", "0.483969", "0.47666347", "0.47615525", "0.47527686", "0.47031555", "0.46745664", "0.46656075", "0.46656075", "0.4643877", "0.464357", "0.4643246", "0.46153483", "0.4597859", "0.4593937", "0.45543385", "0.45299128", "0.4475159", "0.44460967", "0.44438866", "0.4429883", "0.44261515", "0.442395", "0.4414557", "0.44026333", "0.43891165", "0.43822646", "0.43563944", "0.4348266", "0.43464103", "0.4327625", "0.4312831", "0.4305058", "0.42963773", "0.4295775", "0.42942363", "0.42877686", "0.42819327", "0.4277567", "0.4273861", "0.42704397", "0.42599282", "0.42569464", "0.4238784", "0.42373693", "0.42369965", "0.4234213", "0.42322528", "0.42310572", "0.42279208", "0.42246762", "0.42233083", "0.4222384", "0.42204168", "0.42198697", "0.42147294", "0.42127445", "0.42125735", "0.4206147", "0.41887632", "0.418036", "0.4180115", "0.41783237", "0.4171192", "0.41645384", "0.41589594", "0.41579264", "0.4146306", "0.41460904", "0.4145062", "0.4140464", "0.41332", "0.41240993", "0.41137403", "0.4109833", "0.4109287", "0.41092333", "0.41092217", "0.41087234", "0.4105899", "0.41031694", "0.41028115", "0.40986416", "0.40912795", "0.40737265", "0.40683874", "0.4065098", "0.40631258", "0.40626085", "0.40543067" ]
0.58859473
0
Helper function to disconnect either all inputs or all outputs of a dsp unit. inputs: true = disconnect all inputs to this DSP unit. false = leave input connections alone. outputs: true = disconnect all outputs to this DSP unit. false = leave output connections alone. This function is optimized to be faster than disconnecting inputs and outputs manually one by one. Important note: If you have a handle to DSPConnection pointers that bind any of the inputs or outputs to this DSP unit, then they will become invalid. The connections are sent back to a freelist to be reused again by a later addInput command.
func (d *DSP) DisconnectAll(inputs, outputs bool) error { res := C.FMOD_DSP_DisconnectAll(d.cptr, getBool(inputs), getBool(outputs)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (w *Wire) DisconnectOutputs() {\n\tw.SetNumOutputs(0)\n\tw.outputs = w.outputs[0:0]\n}", "func (s *Signal) DisconnectAll() {\n\ts.Mu.Lock()\n\ts.Cons = make(map[Ki]RecvFunc)\n\ts.Mu.Unlock()\n}", "func (o *Output) Disconnect(c Connection) bool {\n\to.Lock()\n\tok := o.Remove(c)\n\to.Unlock()\n\treturn ok\n}", "func (p *Port) Disconnect(q *Port) error {\n\tif !p.Connected(q) {\n\t\treturn errors.New(\"not connected\")\n\t}\n\tq.src = nil\n\tdelete(p.dests, q)\n\treturn nil\n}", "func (self *SinglePad) DisconnectI(args ...interface{}) {\n self.Object.Call(\"disconnect\", args)\n}", "func filterOutDs(ds domainSet) {\n\tfor k, _ := range ds {\n\t\tif blockedDs.domainSet[k] {\n\t\t\tdelete(blockedDs.domainSet, k)\n\t\t\tblockedDomainChanged = true\n\t\t}\n\t\tif directDs.domainSet[k] {\n\t\t\tdelete(directDs.domainSet, k)\n\t\t\tdirectDomainChanged = true\n\t\t}\n\t}\n}", "func (sO *ScreenOutput) Stop() {\n\tfor _, channel := range sO.DataInput {\n\t\tclose(channel)\n\t}\n\tsO.wg.Wait()\n}", "func (m *lispMachine) UnbindAll() {\n\t// if m.dealloc() {\n\tfor _, n := range m.sorted {\n\t\tm.logf(\"dealloc n; %v %x %p\", n, n.Hashcode(), n)\n\t\tif !n.isInput() {\n\t\t\tn.unbind()\n\t\t}\n\t}\n\t// }\n}", "func (self *SinglePad) Disconnect() {\n self.Object.Call(\"disconnect\")\n}", "func (cfg *config) disconnect(i int) {\r\n\t// fmt.Printf(\"disconnect(%d)\\n\", i)\r\n\r\n\tcfg.connected[i] = false\r\n\r\n\t// outgoing ClientEnds\r\n\tfor j := 0; j < cfg.n; j++ {\r\n\t\tif cfg.endnames[i] != nil {\r\n\t\t\tendname := cfg.endnames[i][j]\r\n\t\t\tcfg.net.Enable(endname, false)\r\n\t\t}\r\n\t}\r\n\r\n\t// incoming ClientEnds\r\n\tfor j := 0; j < cfg.n; j++ {\r\n\t\tif cfg.endnames[j] != nil {\r\n\t\t\tendname := cfg.endnames[j][i]\r\n\t\t\tcfg.net.Enable(endname, false)\r\n\t\t}\r\n\t}\r\n}", "func disconnectAll(clients []Client) {\n\tfor _, c := range clients {\n\t\tc.Disconnect()\n\t}\n}", "func DisconnectedLinks(stopchan chan struct{}) bool {\n\tl := len(linkBridges.unconnected)\n\tputOffers := make(chan dynamic.DHTPutReturn, l)\n\tfor _, link := range linkBridges.unconnected {\n\t\tif link.State == StateInit {\n\t\t\tutil.Info.Println(\"DisconnectedLinks for\", link.LinkParticipants(), link.LinkID())\n\t\t\tvar linkBridge = NewLinkBridge(link.LinkAccount, link.MyAccount, accounts)\n\t\t\tlinkBridge.SessionID = link.SessionID\n\t\t\tlinkBridge.Get = link.Get\n\t\t\tpc, err := ConnectToIceServices(config)\n\t\t\tif err != nil {\n\t\t\t\tutil.Error.Println(\"DisconnectedLinks error connecting tot ICE services\", err)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tlinkBridge.PeerConnection = pc\n\t\t\t\tdataChannel, err := linkBridge.PeerConnection.CreateDataChannel(link.LinkParticipants(), nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\tutil.Error.Println(\"DisconnectedLinks error creating dataChannel for\", link.LinkAccount, link.LinkID())\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tlinkBridge.DataChannel = dataChannel\n\t\t\t}\n\t\t\tlinkBridge.Offer, _ = linkBridge.PeerConnection.CreateOffer(nil)\n\t\t\tlinkBridge.Answer = link.Answer\n\t\t\tencoded, err := util.EncodeObject(linkBridge.Offer)\n\t\t\tif err != nil {\n\t\t\t\tutil.Info.Println(\"DisconnectedLinks error EncodeObject\", err)\n\t\t\t}\n\t\t\tdynamicd.PutLinkRecord(linkBridge.MyAccount, linkBridge.LinkAccount, encoded, putOffers)\n\t\t\tlinkBridge.State = StateWaitForAnswer\n\t\t\tlinkBridges.unconnected[linkBridge.LinkID()] = &linkBridge\n\t\t} else {\n\t\t\tl--\n\t\t}\n\t}\n\tfor i := 0; i < l; i++ {\n\t\tselect {\n\t\tdefault:\n\t\t\toffer := <-putOffers\n\t\t\tlinkBridge := NewLinkBridge(offer.Sender, offer.Receiver, accounts)\n\t\t\tlink := linkBridges.unconnected[linkBridge.LinkID()]\n\t\t\tlink.Put = offer.DHTPutJSON\n\t\t\tutil.Info.Println(\"DisconnectedLinks Offer saved\", offer)\n\t\tcase <-stopchan:\n\t\t\tutil.Info.Println(\"DisconnectedLinks stopped\")\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func DisconnectNodes(parent, child Node) {\n\tparent.DelChild(child)\n\tchild.DelParent(parent)\n}", "func (x *Root) ClearOutputDrivers() {\n\tfor _, o := range x.outputdrivers {\n\t\to.Detach()\n\t}\n\tx.outputdrivers = make([]OutputDriver, 0, 1)\n}", "func (cfg *config) disconnect(i int) {\n\t//fmt.Printf(\"disconnect(%d)\\n\\n\\n\", i)\n\n\tcfg.connected[i] = false\n\n\t// outgoing ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.endnames[i] != nil {\n\t\t\tendname := cfg.endnames[i][j]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n\n\t// incoming ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.endnames[j] != nil {\n\t\t\tendname := cfg.endnames[j][i]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n}", "func InoutFree(i **Input) {\n\tC.avfilter_inout_free((**C.struct_AVFilterInOut)(unsafe.Pointer(i)))\n}", "func Disconnect() {\n\tif pool != nil {\n\t\t_ = pool.Close() //todo: handle this error?\n\t}\n\tpool = nil\n}", "func (d *DSP) DisconnectFrom(target DSP, connection DspConnection) error {\n\tres := C.FMOD_DSP_DisconnectFrom(d.cptr, target.cptr, connection.cptr)\n\treturn errs[res]\n}", "func filterOutBlockedDsInDirectDs() {\n\tfor k, _ := range blockedDs.domainSet {\n\t\tif directDs.domainSet[k] {\n\t\t\tdelete(directDs.domainSet, k)\n\t\t\tdirectDomainChanged = true\n\t\t}\n\t}\n\tfor k, _ := range alwaysBlockedDs {\n\t\tif alwaysDirectDs[k] {\n\t\t\terrl.Printf(\"%s in both always blocked and direct domain lists, taken as blocked.\\n\", k)\n\t\t\tdelete(alwaysDirectDs, k)\n\t\t}\n\t}\n}", "func (net Network) ClearInput() {\n\tfor i := range net[0] {\n\t\tnet[0][i].value = 0\n\t}\n}", "func DisconnectAllVoiceConnections(s Connectable) error {\n\tfor _, channel := range s.GetVoiceConnections() {\n\t\terr := channel.Disconnect()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tActiveVoiceChannels[channel.GetGuildID()].RemoveNowPlaying()\n\t}\n\tlog.Println(\"Disconnected from voice channel...\")\n\treturn nil\n}", "func (c *INDIClient) Disconnect() error {\n\t// Clear out all devices\n\tc.delProperty(&DelProperty{})\n\n\tif c.conn == nil {\n\t\treturn nil\n\t}\n\n\terr := c.conn.Close()\n\tc.conn = nil\n\n\tif c.read != nil {\n\t\tclose(c.read)\n\t\tc.read = nil\n\t}\n\n\tif c.write != nil {\n\t\tclose(c.write)\n\t\tc.write = nil\n\t}\n\n\treturn err\n}", "func (p *Pipe) broadcastToSinks(in <-chan message) []<-chan error {\n\t//init errcList for sinks error channels\n\terrcList := make([]<-chan error, 0, len(p.sinks))\n\t//list of channels for broadcast\n\tbroadcasts := make([]chan message, len(p.sinks))\n\tfor i := range broadcasts {\n\t\tbroadcasts[i] = make(chan message)\n\t}\n\n\t//start broadcast\n\tfor i, s := range p.sinks {\n\t\terrc := s.run(p.cancel, p.ID(), broadcasts[i], p.sampleRate, p.metric)\n\t\terrcList = append(errcList, errc)\n\t}\n\n\tgo func() {\n\t\t//close broadcasts on return\n\t\tdefer func() {\n\t\t\tfor i := range broadcasts {\n\t\t\t\tclose(broadcasts[i])\n\t\t\t}\n\t\t}()\n\t\tfor msg := range in {\n\t\t\tfor i := range broadcasts {\n\t\t\t\tm := message{\n\t\t\t\t\tsourceID: msg.sourceID,\n\t\t\t\t\tBuffer: msg.Buffer,\n\t\t\t\t\tparams: msg.params.detach(p.sinks[i].ID()),\n\t\t\t\t\tfeedback: msg.feedback.detach(p.sinks[i].ID()),\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase broadcasts[i] <- m:\n\t\t\t\tcase <-p.cancel:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn errcList\n}", "func stopServiceInputs(inputs []*models.RunningInput) {\n\tfor _, input := range inputs {\n\t\tif si, ok := input.Input.(telegraf.ServiceInput); ok {\n\t\t\tsi.Stop()\n\t\t}\n\t}\n}", "func (d *DirectMemifConnector) Disconnect(crossConnect *crossconnect.CrossConnect) {\n\tvalue, exist := d.proxyMap.Load(crossConnect.GetId())\n\tif !exist {\n\t\tlogrus.Warnf(\"Proxy for cross connect with id=%s doesn't exist. Nothing to stop\", crossConnect.GetId())\n\t\treturn\n\t}\n\n\tproxy := value.(memifproxy.Proxy)\n\tproxy.Stop()\n\n\td.proxyMap.Delete(crossConnect.Id)\n}", "func (sO *ScreenOutput) Abort() {\n\tfor _, channel := range sO.DataInput {\n\t\tclose(channel)\n\t}\n}", "func (l *Libvirt) Disconnect() error {\n\t// close event streams\n\tfor id := range l.events {\n\t\tif err := l.removeStream(id); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// inform libvirt we're done\n\tif err := l.disconnect(); err != nil {\n\t\treturn err\n\t}\n\n\treturn l.conn.Close()\n}", "func (vm *vmQemu) cleanupDevices() {\n\tfor _, dev := range vm.expandedDevices.Sorted() {\n\t\t// Use the device interface if device supports it.\n\t\terr := vm.deviceStop(dev.Name, dev.Config)\n\t\tif err == device.ErrUnsupportedDevType {\n\t\t\tcontinue\n\t\t} else if err != nil {\n\t\t\tlogger.Errorf(\"Failed to stop device '%s': %v\", dev.Name, err)\n\t\t}\n\t}\n}", "func (ch *InternalChannel) Disconnect(c *Client) {}", "func TestDeviceUpdates(t *testing.T) {\n\tfo := NewFanOut()\n\tidd1, d1 := fo.SubscribeDeviceUpdates()\n\tidd2, d2 := fo.SubscribeDeviceUpdates()\n\tvar m1 *common.MsgDeviceUpdate\n\tvar m2 *common.MsgDeviceUpdate\n\td1Exited := false\n\td2Exited := false\n\n\tgo func() {\n\t\tfor m := range d1 {\n\t\t\tm1 = m\n\t\t}\n\n\t\td1Exited = true\n\t}()\n\n\tgo func() {\n\t\tfor m := range d2 {\n\t\t\tm2 = m\n\t\t}\n\n\t\td2Exited = true\n\t}()\n\n\tfo.ChannelInDeviceUpdates() <- &common.MsgDeviceUpdate{}\n\ttime.Sleep(1 * time.Second)\n\tassert.NotNil(t, m1, \"channel 1\")\n\tassert.NotNil(t, m2, \"channel 2\")\n\n\tm1 = nil\n\tm2 = nil\n\n\tfo.UnSubscribeDeviceUpdates(idd1)\n\tfo.UnSubscribeTriggerUpdates(idd1)\n\tfo.ChannelInDeviceUpdates() <- &common.MsgDeviceUpdate{}\n\ttime.Sleep(1 * time.Second)\n\n\tassert.Nil(t, m1, \"unsubscribe channel 1\")\n\tassert.NotNil(t, m2, \"unsubscribe channel 2\")\n\tassert.True(t, d1Exited, \"exit channel 1\")\n\n\tm1 = nil\n\tm2 = nil\n\n\tfo.UnSubscribeDeviceUpdates(idd2)\n\tfo.UnSubscribeTriggerUpdates(idd2)\n\tfo.ChannelInDeviceUpdates() <- &common.MsgDeviceUpdate{}\n\ttime.Sleep(1 * time.Second)\n\n\tassert.Nil(t, m1, \"full unsubscribe channel 1\")\n\tassert.Nil(t, m2, \"full unsubscribe channel 2\")\n\tassert.True(t, d2Exited, \"exit channel 2\")\n}", "func closePorts() {\n\tlog.Println(\"Closing ports...\")\n\tinPort.Close()\n\tzmq.Term()\n}", "func closePorts() {\n\tlog.Println(\"Closing ports...\")\n\toptionsPort.Close()\n\tinPort.Close()\n\toutPort.Close()\n\tzmq.Term()\n}", "func (d *Decoder) drainOutput() {\n\tif d.current.cancel != nil {\n\t\tif debugDecoder {\n\t\t\tprintln(\"cancelling current\")\n\t\t}\n\t\td.current.cancel()\n\t\td.current.cancel = nil\n\t}\n\tif d.current.d != nil {\n\t\tif debugDecoder {\n\t\t\tprintf(\"re-adding current decoder %p, decoders: %d\", d.current.d, len(d.decoders))\n\t\t}\n\t\td.decoders <- d.current.d\n\t\td.current.d = nil\n\t\td.current.b = nil\n\t}\n\tif d.current.output == nil || d.current.flushed {\n\t\tprintln(\"current already flushed\")\n\t\treturn\n\t}\n\tfor v := range d.current.output {\n\t\tif v.d != nil {\n\t\t\tif debugDecoder {\n\t\t\t\tprintf(\"re-adding decoder %p\", v.d)\n\t\t\t}\n\t\t\td.decoders <- v.d\n\t\t}\n\t}\n\td.current.output = nil\n\td.current.flushed = true\n}", "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func (c *MockConnection) Disconnect() {\n\tif other := c.Target.(*MockConnection); other == nil {\n\t\tpanic(\"Source connection not connected.\")\n\t} else if other.Target != c {\n\t\tpanic(\"Target connection not connected to source connection.\")\n\t} else {\n\t\tc.Target, other.Target = nil, nil\n\t}\n}", "func (s *Sima) Disconnect(receiver ReceiverType, senderName string) bool {\n\tif s.receivers.Len() == 0 {\n\t\treturn false\n\t}\n\n\t_, senderKey := getSenderKeyValue(senderName, s)\n\treceiverKey := HashValue(receiver)\n\n\tif senderName == \"\" {\n\t\treturn s.disconnectAllByReceiver(senderKey, receiverKey)\n\t} else {\n\t\treturn s.disconnect(senderKey, receiverKey)\n\t}\n}", "func (si *ServerInstance) DisconnectAll() {\n\t\n\tfor id, conn := range si.Clients {\n\t\tconn.Close()\n\t\tdelete(si.Clients, id)\n\t}\n}", "func (o *UPNP) ClearDevices() {\n\t//log.Println(\"Calling UPNP.ClearDevices()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"UPNP\", \"clear_devices\")\n\n\t// Call the parent method.\n\t// void\n\tretPtr := gdnative.NewEmptyVoid()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n}", "func NetDisconnect(ipAddress string) bool {\n\tresult := true\n\n\tc := exec.Command(\"net\", \"use\", `\\\\`+ipAddress, \"/delete\", \"2>&1>null\")\n\tc.Stdout = os.Stdout\n\terr := c.Run()\n\n\tif err != nil {\n\t\tresult = false\n\t}\n\t// else {\n\t// \tresult = strings.Contains(string(out), \"successfully\")\n\t// }\n\treturn result\n}", "func (d *Device) DisconnectClients() {\n\td.clientsMtx.Lock()\n\tclientsCopy := make([]Client, 0, len(d.clients))\n\tfor _, client := range d.clients {\n\t\tclientsCopy = append(clientsCopy, client)\n\t}\n\td.clientsMtx.Unlock()\n\tfor _, client := range clientsCopy {\n\t\tclient.OnDeviceDisconnected()\n\t}\n}", "func (em *EventMgr) DisconnectAllEvents(recv ki.Ki, pri EventPris) {\n\tif pri == AllPris {\n\t\tfor et := oswin.EventType(0); et < oswin.EventTypeN; et++ {\n\t\t\tfor p := HiPri; p < EventPrisN; p++ {\n\t\t\t\tem.EventSigs[et][p].Disconnect(recv)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor et := oswin.EventType(0); et < oswin.EventTypeN; et++ {\n\t\t\tem.EventSigs[et][pri].Disconnect(recv)\n\t\t}\n\t}\n}", "func (net *NetworkComponentInput) DetachIgws(con aws.EstablishConnectionInput) error {\n\n\tec2, seserr := con.EstablishConnection()\n\tif seserr != nil {\n\t\treturn seserr\n\t}\n\tfor _, igw := range net.IgwIds {\n\t\terr := ec2.DetachIgw(\n\t\t\t&aws.DescribeNetworkInput{\n\t\t\t\tIgwIds: []string{igw},\n\t\t\t\tVpcIds: net.VpcIds,\n\t\t\t},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (biu *BlockInstanceUpdate) ClearOutputs() *BlockInstanceUpdate {\n\tbiu.mutation.ClearOutputs()\n\treturn biu\n}", "func (s *InputNotifier) unregisterAll() {\n\ts.observers = []InputDetector{}\n}", "func (o *os) CloseMidiInputs() {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.CloseMidiInputs()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"close_midi_inputs\")\n\n\t// Call the parent method.\n\t// void\n\tretPtr := gdnative.NewEmptyVoid()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n}", "func (biuo *BlockInstanceUpdateOne) ClearOutputs() *BlockInstanceUpdateOne {\n\tbiuo.mutation.ClearOutputs()\n\treturn biuo\n}", "func (p *Input) Stop() {\n\tdefer p.outlet.Close()\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tp.log.Info(\"Stopping TCP input\")\n\tp.server.Stop()\n\tp.started = false\n}", "func (queueWriter *QueueWriter) Disconnect() {\n\tqueueWriter.isConnected = false\n\tqueueWriter.connection.Disconnect()\n\n\tlog.Printf(\"Disconnected\")\n}", "func (a *NullAdapter) Disconnect(srv *Server, ca ClientAdapter, err error) {\n}", "func (o *OutputManager) AwaitOutputsToBeSolid(outputs []string, clt Client, maxGoroutines int) (allSolid bool) {\n\twg := sync.WaitGroup{}\n\tsemaphore := make(chan bool, maxGoroutines)\n\tallSolid = true\n\n\tfor _, outID := range outputs {\n\t\twg.Add(1)\n\t\tgo func(outID string) {\n\t\t\tdefer wg.Done()\n\t\t\tsemaphore <- true\n\t\t\tdefer func() {\n\t\t\t\t<-semaphore\n\t\t\t}()\n\t\t\terr := o.AwaitOutputToBeSolid(outID, clt, waitForSolidification)\n\t\t\tif err != nil {\n\t\t\t\tallSolid = false\n\t\t\t\treturn\n\t\t\t}\n\t\t}(outID)\n\t}\n\twg.Wait()\n\treturn\n}", "func (ch *ServerChannel) Disconnect(c *Client) {}", "func (pf *PortForwarder) StopAll(ctx context.Context, req *empty_pb.Empty) (*empty_pb.Empty, error) {\n\tpf.sessionsMutex.Lock()\n\tdefer pf.sessionsMutex.Unlock()\n\n\tlog.Printf(\"Stopping all ...\\n\")\n\n\tfor _, s := range pf.sessions {\n\t\ts.cancel()\n\t\ts.lis.Close()\n\t}\n\tpf.sessions = make(map[string]*forwardSession)\n\n\treturn &empty_pb.Empty{}, nil\n}", "func (pf *PortForwarder) StopAll(ctx context.Context, req *empty_pb.Empty) (*empty_pb.Empty, error) {\n\tpf.sessionsMutex.Lock()\n\tdefer pf.sessionsMutex.Unlock()\n\n\tlog.Printf(\"Stopping all ...\\n\")\n\n\tfor _, s := range pf.sessions {\n\t\ts.cancel()\n\t\ts.lis.Close()\n\t}\n\tpf.sessions = make(map[string]*forwardSession)\n\n\treturn &empty_pb.Empty{}, nil\n}", "func unconnectedDCR(ctx context.Context, logger dex.Logger) *DCRBackend {\n\tdcr := &DCRBackend{\n\t\tctx: ctx,\n\t\tblockChans: make([]chan uint32, 0),\n\t\tblockCache: newBlockCache(logger),\n\t\tanyQ: make(chan interface{}, 128), // way bigger than needed.\n\t\tlog: logger,\n\t}\n\tgo dcr.superQueue()\n\treturn dcr\n}", "func DisableOutputs(off Outputs) (*exec.Cmd, error) {\n\tif len(off) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tcommand := \"xrandr\"\n\targs := []string{}\n\n\tvar outputs []string\n\tfor _, output := range off {\n\t\toutputs = append(outputs, output.Name)\n\t\targs = append(args, \"--output\", output.Name, \"--off\")\n\t}\n\n\tV(\"disable outputs: %v\\n\", outputs)\n\n\treturn exec.Command(command, args...), nil\n}", "func (p *Port) DirectlyConnected() error {\n\tif p.direction != DIRECTION_IN {\n\t\treturn errors.New(\"can only check in ports\")\n\t}\n\n\tif p.PrimitiveType() {\n\t\tif p.src == nil {\n\t\t\treturn errors.New(p.Name() + \" not connected\")\n\t\t}\n\t\tif p.src.direction != DIRECTION_OUT && p.src.operator.name != \"\" {\n\t\t\treturn errors.New(p.Name() + \" only out ports can be connected with in ports\")\n\t\t}\n\t\tif p.src.src != nil {\n\t\t\treturn errors.New(p.Name() + \" has connected source \" + p.src.Name() + \": \" + p.src.src.Name())\n\t\t}\n\t\tfor dest := range p.src.dests {\n\t\t\tif dest == p {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn errors.New(p.Name() + \" not connected back from \" + p.src.Name())\n\t}\n\n\tif p.sub != nil {\n\t\tif err := p.sub.DirectlyConnected(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor _, sub := range p.subs {\n\t\tif err := sub.DirectlyConnected(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *Decoder) Disconnect(h FrameHandler) {\n\t// Delete handler\n\td.d.delHandler(h)\n\n\t// Disconnect nodes\n\tastiencoder.DisconnectNodes(d, h)\n}", "func (biu *BlockInstanceUpdate) ClearInputs() *BlockInstanceUpdate {\n\tbiu.mutation.ClearInputs()\n\treturn biu\n}", "func (s *StorageSpec) ClearUseAllDevices() {\n\tclear := false\n\ts.Selection.UseAllDevices = &clear\n\tfor i := range s.Nodes {\n\t\ts.Nodes[i].Selection.UseAllDevices = &clear\n\t}\n}", "func (t *TaskService) Disconnect() {\n\tt.taskServiceObj.Release()\n\tt.rootFolderObj.Release()\n\tole.CoUninitialize()\n\n\tt.isInitialized = false\n\tt.isConnected = false\n}", "func (d *DSP) NumOutputs() (int, error) {\n\tvar numoutputs C.int\n\tres := C.FMOD_DSP_GetNumOutputs(d.cptr, &numoutputs)\n\treturn int(numoutputs), errs[res]\n}", "func (ipc *AdaIPC) Disconnect() (err error) {\n\treturn nil\n}", "func (d *DynamicSelect) drainChannels() {\n\tgo func() {\n\t\tfor {\n\t\t\t_, ok := <-d.aggregator\n\t\t\tif ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tfor {\n\t\t\t_, ok := <-d.priorityAggregator\n\t\t\tif ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tfor {\n\t\t\tx, ok := <-d.onClose\n\t\t\tif ok {\n\t\t\t\td.handleOnClose(x.Index)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\n\t// We know that killHeard is set to true so:\n\tgo func() {\n\n\t\tfor {\n\t\t\t_, ok := <-d.kill\n\t\t\tif ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\n\t// At this point, any call to d.Load will return an error, so we can safely\n\t// Discard these as outstanding requests that will never be filled.\n\tgo func() {\n\t\tfor {\n\t\t\t_, ok := <-d.load\n\t\t\tif ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}()\n\n\t// Stack any outstanding attempts to call kill or load\n\tgo func() {\n\t\ttime.Sleep(time.Second)\n\t\t// Then close all channels that don't point internally.\n\t\tclose(d.kill)\n\t\tclose(d.killGuard)\n\t\tclose(d.load)\n\t}()\n}", "func (c *client) Disconnect() error {\n\tif c.conn != nil {\n\t\terr := c.conn.Close()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tc.services.kvc = nil\n\tc.services.mapc = nil\n\tc.services.queuec = nil\n\tc.conn = nil\n\n\treturn nil\n}", "func (s *SimpleDriver) DisconnectDevice(address *models.Addressable) error {\n\treturn nil\n}", "func Dmux() gate.Chip {\n\tand1 := gate.And()\n\tand2 := gate.And()\n\tnot := gate.Not()\n\n\tnot.Out(and1.In2)\n\n\treturn gate.NewChip(demuxMap, 2, 2, and1, and2, not)\n}", "func (nodes *List) DisconnectInactive() {\n\tfor _, node := range *nodes {\n\t\tif node.Connection != nil && !node.activated {\n\t\t\tnode.Connection.Close()\n\t\t}\n\t}\n}", "func (p *Pod) Disconnect() {\n\t// stop future messages from being sent and then indicate to the bus that disconnection is desired\n\t// The bus will close the busChan, which will cause the onFunc listener to quit.\n\tp.dead.Store(true)\n\tp.feedbackChan <- podFeedbackMsgDisconnect\n}", "func disconnect(a, b *PathNode) {\n\tif a != nil {\n\t\tif a.AdjL == b {\n\t\t\ta.AdjL = nil\n\t\t}\n\t\tif a.AdjR == b {\n\t\t\ta.AdjR = nil\n\t\t}\n\t\tif a.AdjU == b {\n\t\t\ta.AdjU = nil\n\t\t}\n\t\tif a.AdjD == b {\n\t\t\ta.AdjD = nil\n\t\t}\n\t}\n\tif b != nil {\n\t\tif b.AdjL == a {\n\t\t\tb.AdjL = nil\n\t\t}\n\t\tif b.AdjR == a {\n\t\t\tb.AdjR = nil\n\t\t}\n\t\tif b.AdjU == a {\n\t\t\tb.AdjU = nil\n\t\t}\n\t\tif b.AdjD == a {\n\t\t\tb.AdjD = nil\n\t\t}\n\t}\n}", "func (s *Server) handleConnections(system server.System) {\n\ts.instruments.Log(octo.LOGINFO, s.info.UUID, \"udp.Server.handleConnections\", \"Started : %#v\", s.Attr)\n\n\tdefer s.wg.Done()\n\n\ts.instruments.NotifyEvent(octo.Event{\n\t\tType: octo.GoroutineOpened,\n\t\tClient: s.info.UUID,\n\t\tServer: s.info.SUUID,\n\t\tLocalAddr: s.info.Local,\n\t\tRemoteAddr: s.info.Remote,\n\t\tData: octo.NewGoroutineInstrument(),\n\t\tDetails: map[string]interface{}{\n\t\t\t\"Addr\": s.info.Addr,\n\t\t},\n\t})\n\n\tdefer s.instruments.NotifyEvent(octo.Event{\n\t\tType: octo.GoroutineClosed,\n\t\tClient: s.info.UUID,\n\t\tServer: s.info.SUUID,\n\t\tLocalAddr: s.info.Local,\n\t\tRemoteAddr: s.info.Remote,\n\t\tData: octo.NewGoroutineInstrument(),\n\t\tDetails: map[string]interface{}{\n\t\t\t\"Addr\": s.info.Addr,\n\t\t},\n\t})\n\n\tblock := make([]byte, consts.MinDataSize)\n\n\tfor s.IsRunning() {\n\t\tif s.stopRunning() {\n\t\t\ts.instruments.Log(octo.LOGERROR, s.info.UUID, \"udp.Server.handleConnections\", \"Closing\")\n\t\t\tbreak\n\t\t}\n\n\t\tn, addr, err := s.conn.ReadFromUDP(block)\n\t\ts.instruments.Log(octo.LOGTRANSMITTED, s.info.UUID, \"udp.Server.handleConnections\", \"Received : %+q : %+q\", block[:n], addr.String())\n\t\ts.instruments.Log(octo.LOGTRANSMITTED, s.info.UUID, \"udp.Server.handleConnections\", \"Completed\")\n\n\t\tif err != nil {\n\t\t\ts.instruments.Log(octo.LOGERROR, s.info.UUID, \"udp.Server.handleConnections\", \"Read Error : %+s\", err)\n\t\t\tif netErr, ok := err.(net.Error); ok && netErr.Timeout() {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// TODO: Do we wish to break here or continue?\n\t\t\t// break\n\t\t\tcontinue\n\t\t}\n\n\t\t// Retrieve the client with the provided addr and serve the respone in a go\n\t\t// routine.\n\t\ts.rg.Add(1)\n\n\t\ts.instruments.Log(octo.LOGINFO, s.info.UUID, \"udp.Server.handleConnections\", \"Initiaiting Client Connection : %+q\", addr)\n\n\t\t(func(data []byte, tx *Client) {\n\t\t\ts.instruments.Log(octo.LOGINFO, s.info.UUID, \"udp.Server.handleConnections\", \"Client Init : %+q\", tx.info)\n\t\t\tdefer s.rg.Done()\n\n\t\t\ttx.pub.Notify(server.ConnectHandler, tx.info, tx, nil)\n\n\t\t\tif s.Attr.Authenticate {\n\n\t\t\t\t// NOTE: We dont need to this here because the Client.authenticate method handles.\n\t\t\t\tvar authenticated bool\n\n\t\t\t\ts.cwl.Lock()\n\t\t\t\t{\n\t\t\t\t\tauthenticated = s.clientAuthenticated[addr.String()]\n\t\t\t\t}\n\t\t\t\ts.cwl.Unlock()\n\n\t\t\t\tif !authenticated {\n\t\t\t\t\tif err := tx.authenticate(data); err != nil {\n\t\t\t\t\t\ts.instruments.Log(octo.LOGERROR, s.info.UUID, \"udp.Server.handleConnections\", \"UDP Client Auth : Authentication Failed : Error : %+s\", err)\n\t\t\t\t\t\tgo tx.Close()\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif err := s.base.Serve(data, tx); err != nil {\n\t\t\t\ts.instruments.Log(octo.LOGERROR, s.info.UUID, \"udp.Server.handleConnections\", \"UDP Base System : Fails Parsing : Error : %+s\", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}(block[:n], s.retrieveOrAdd(addr)))\n\n\t\t// TODO: Do we need the expansion algorithmn here?\n\t\tif n == len(block) && len(block) < consts.MaxDataWrite {\n\t\t\tblock = make([]byte, len(block)*2)\n\t\t}\n\n\t\tif n < len(block)/2 && len(block) > consts.MaxDataWrite {\n\t\t\tblock = make([]byte, len(block)/2)\n\t\t}\n\t}\n\n\ts.instruments.Log(octo.LOGINFO, s.info.UUID, \"udp.Server.handleConnections\", \"Completed\")\n}", "func (m *Machine) Close() {\n\tallChans := make(map[chan<- gorgonia.Value]struct{}, 0)\n\tfor _, pub := range m.pubsub.publishers {\n\t\tfor i := range pub.subscribers {\n\t\t\tallChans[pub.subscribers[i]] = struct{}{}\n\t\t}\n\t}\n\tfor ch := range allChans {\n\t\tclose(ch)\n\t}\n\tfor _, n := range m.nodes {\n\t\tif n.inputC != nil {\n\t\t\tclose(n.inputC)\n\t\t}\n\t\tif n.outputC != nil {\n\t\t\tclose(n.outputC)\n\t\t}\n\t}\n}", "func (f *FakeOutput) SetOutputs(_ []operator.Operator) error { return nil }", "func (s *Stream) Disconnect() {\n\ts.stop <- true\n\ts.base.Disconnect()\n}", "func (mon *SocketMonitor) Disconnect() error {\n\tatomic.StoreInt32(mon.listeners, 0)\n\terr := mon.c.Close()\n\n\tif mon.stream != nil {\n\t\tfor range mon.stream {\n\t\t}\n\t}\n\n\treturn err\n}", "func (a *Agent) runInputs(\n\tctx context.Context,\n\tstartTime time.Time,\n\tunit *inputUnit,\n) error {\n\n\tfor _, input := range unit.inputs {\n\t\terr := a.RunSingleInput(input, ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tlog.Printf(\"D! [agent] Stopping service inputs\")\n\t\t\tstopServiceInputs(a.Config.Inputs)\n\n\t\t\tclose(unit.dst)\n\t\t\tlog.Printf(\"D! [agent] Input channel closed\")\n\t\t\treturn nil\n\t\t}\n\t}\n}", "func disconnectTransactions(txStore TxStore, block *massutil.Block) error {\n\tfor _, tx := range block.Transactions() {\n\t\tif txD, exists := txStore[*tx.Hash()]; exists {\n\t\t\ttxD.Tx = nil\n\t\t\ttxD.BlockHeight = 0\n\t\t\ttxD.Spent = nil\n\t\t\ttxD.Err = database.ErrTxShaMissing\n\t\t}\n\n\t\tfor _, txIn := range tx.MsgTx().TxIn {\n\t\t\toriginHash := &txIn.PreviousOutPoint.Hash\n\t\t\toriginIndex := txIn.PreviousOutPoint.Index\n\t\t\toriginTx, exists := txStore[*originHash]\n\t\t\tif exists && originTx.Tx != nil && originTx.Err == nil {\n\t\t\t\tif originIndex > uint32(len(originTx.Spent)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\toriginTx.Spent[originIndex] = false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func Disconnect() error {\n\treturn SQL.Close()\n}", "func (r *PeerResolver) ShouldDisconnect(peers []fab.Peer, connectedPeer fab.Peer) bool {\n\treturn false\n}", "func (biuo *BlockInstanceUpdateOne) ClearInputs() *BlockInstanceUpdateOne {\n\tbiuo.mutation.ClearInputs()\n\treturn biuo\n}", "func (o TransferJobTransferSpecTransferOptionsPtrOutput) DeleteObjectsUniqueInSink() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *TransferJobTransferSpecTransferOptions) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.DeleteObjectsUniqueInSink\n\t}).(pulumi.BoolPtrOutput)\n}", "func (s *Swarm) filterKnownUndialables(p peer.ID, addrs []ma.Multiaddr) []ma.Multiaddr {\n\tlisAddrs, _ := s.InterfaceListenAddresses()\n\tvar ourAddrs []ma.Multiaddr\n\tfor _, addr := range lisAddrs {\n\t\tprotos := addr.Protocols()\n\t\t// we're only sure about filtering out /ip4 and /ip6 addresses, so far\n\t\tif protos[0].Code == ma.P_IP4 || protos[0].Code == ma.P_IP6 {\n\t\t\tourAddrs = append(ourAddrs, addr)\n\t\t}\n\t}\n\n\treturn maybeRemoveWebTransportAddrs(ma.FilterAddrs(addrs,\n\t\tfunc(addr ma.Multiaddr) bool { return !ma.Contains(ourAddrs, addr) },\n\t\ts.canDial,\n\t\t// TODO: Consider allowing link-local addresses\n\t\tfunc(addr ma.Multiaddr) bool { return !manet.IsIP6LinkLocal(addr) },\n\t\tfunc(addr ma.Multiaddr) bool {\n\t\t\treturn s.gater == nil || s.gater.InterceptAddrDial(p, addr)\n\t\t},\n\t))\n}", "func (c *connPool) DelFromPool(in interface{}) bool {\n\tdefer c.nextMutex.Unlock()\n\tc.nextMutex.Lock()\n\tfor i := range c.pool {\n\t\tif c.pool[i] == in {\n\t\t\tc.pool[i] = c.pool[len(c.pool)-1]\n\t\t\tc.pool = c.pool[:len(c.pool)-1]\n\t\t\tc.total = len(c.pool)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func Remove_int(input <-chan int, output chan<- int, f func(int) bool) {\n\tfor x := range input {\n\t\tif !f(x) {\n\t\t\toutput <- x\n\t\t}\n\t}\n\tclose(output)\n}", "func (p *Persistence) Disconnect() {\n\n}", "func (i *InteractiveMode) Cleanup(congress *lassie.Client, app lassie.Application, gw lassie.Gateway) {\n\tif !i.Config.KeepDevices {\n\t\tfor _, v := range i.devices {\n\t\t\tcongress.DeleteDevice(app.EUI, v.device.EUI)\n\t\t}\n\t}\n}", "func DisconnectNode(nodeName string, otherNodes []string, method string) {\n\tfor _, targetIP := range otherNodes {\n\t\tcmd := exec.Command(\"bash\", \"../lib/io_connect_node.sh\", nodeName, targetIP, \"DISCONNECT\", method)\n\t\tcmd.Dir = \"./\"\n\t\t_, err := cmd.CombinedOutput()\n\t\tExpect(err).ToNot(HaveOccurred())\n\t}\n}", "func (ops *OutOps) Free(p *Out) error {\n\treturn err(C.go_wr_free(unsafe.Pointer(ops), unsafe.Pointer(p)))\n}", "func (u *Input) Stop() error {\n\tif u.cancel == nil {\n\t\treturn nil\n\t}\n\tu.cancel()\n\tif u.connection != nil {\n\t\tif err := u.connection.Close(); err != nil {\n\t\t\tu.Errorf(\"failed to close UDP connection: %s\", err)\n\t\t}\n\t}\n\tu.wg.Wait()\n\tif u.resolver != nil {\n\t\tu.resolver.Stop()\n\t}\n\treturn nil\n}", "func (mn *MockNetwork) Disconnect(string) error {\n\treturn nil\n}", "func Disconnect(w http.ResponseWriter, r *http.Request) {\n\truntime := r.Context().Value(\"runtime\").(*libpod.Runtime)\n\n\tvar netDisconnect types.NetworkDisconnect\n\tif err := json.NewDecoder(r.Body).Decode(&netDisconnect); err != nil {\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, errors.Wrap(err, \"Decode()\"))\n\t\treturn\n\t}\n\n\tname := utils.GetName(r)\n\terr := runtime.DisconnectContainerFromNetwork(netDisconnect.Container, name, netDisconnect.Force)\n\tif err != nil {\n\t\tif errors.Cause(err) == define.ErrNoSuchCtr {\n\t\t\tutils.Error(w, \"container not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tif errors.Cause(err) == define.ErrNoSuchNetwork {\n\t\t\tutils.Error(w, \"network not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tutils.WriteResponse(w, http.StatusOK, \"OK\")\n}", "func DeleteFromPool(pool []Card, out []Card) []Card {\n\tvar ans []Card\n\tfor i := 0; i < len(pool); i++ {\n\t\tcheck := true\n\t\tfor j := 0; j < len(out); j++ {\n\t\t\tif (pool[i].Num == out[j].Num) && (pool[i].Color == out[j].Color) {\n\t\t\t\tcheck = false\n\t\t\t}\n\t\t}\n\t\tif check {\n\t\t\tans = append(ans, pool[i])\n\t\t}\n\t}\n\treturn ans\n}", "func (b *Bluez) Disconnect(adapterName, deviceMac string) error {\n\treturn b.CallDevice(adapterName, deviceMac, \"Disconnect\", 0).Store()\n}", "func (d *Device) Disconnect(result chan<- error) {\n\t// Wait 2 seconds and die\n\td.m.Disconnect(2000)\n}", "func (a *Agent) startOutputs(\n\tctx context.Context,\n\toutputs []*models.RunningOutput,\n) (chan<- telegraf.Metric, *outputUnit, error) {\n\tsrc := make(chan telegraf.Metric, 100)\n\tunit := &outputUnit{src: src}\n\tfor _, output := range outputs {\n\t\terr := a.connectOutput(ctx, output)\n\t\tif err != nil {\n\t\t\tfor _, output := range unit.outputs {\n\t\t\t\toutput.Close()\n\t\t\t}\n\t\t\treturn nil, nil, fmt.Errorf(\"connecting output %s: %w\", output.LogName(), err)\n\t\t}\n\t\tunit.outputs = append(unit.outputs, output)\n\t}\n\n\treturn src, unit, nil\n}", "func CloseConnectionFromInterfaces(ctx context.Context, generic []interface{}) (metadata Metadata, err error) {\n\tclosers := make([]connectionProviders, 0)\n\tfor _, elem := range generic {\n\t\ttemp := connectionProviders{name: getProviderName(elem)}\n\t\tswitch p := elem.(type) {\n\t\tcase Closer:\n\t\t\ttemp.closer = p\n\t\t\tclosers = append(closers, temp)\n\t\tdefault:\n\t\t\te := fmt.Sprintf(\"not a Closer implementation: %T\", p)\n\t\t\terr = multierror.Append(err, errors.New(e))\n\t\t}\n\t}\n\tif len(closers) == 0 {\n\t\treturn metadata, multierror.Append(err, errors.New(\"no Closer implementations found\"))\n\t}\n\treturn CloseConnection(ctx, closers)\n}", "func (o TransferJobTransferSpecTransferOptionsOutput) DeleteObjectsUniqueInSink() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v TransferJobTransferSpecTransferOptions) *bool { return v.DeleteObjectsUniqueInSink }).(pulumi.BoolPtrOutput)\n}", "func merge(fromSource, fromTarget <-chan Hop) <-chan struct{Hop; bool} {\n out := make(chan struct{Hop; bool})\n stoppedMutex := sync.RWMutex{}\n stopped := false\n\n output := func(c <-chan Hop, isFromSource bool) {\n for hop := range c {\n stoppedMutex.RLock()\n if !stopped {\n out <- struct{Hop; bool}{hop, isFromSource}\n }\n stoppedMutex.RUnlock()\n }\n\n stoppedMutex.Lock()\n stopped = true\n stoppedMutex.Unlock()\n close(out)\n }\n\n go output(fromSource, true)\n go output(fromTarget, false)\n\n return out\n}", "func (s *Signal) Disconnect(recv Ki) {\n\ts.Mu.Lock()\n\tdelete(s.Cons, recv)\n\ts.Mu.Unlock()\n}", "func mainLoop() {\n\topenPorts()\n\tdefer closePorts()\n\n\twaitCh := make(chan bool)\n\tgo func() {\n\t\ttotal := 0\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase v := <-inCh:\n\t\t\t\tif !v {\n\t\t\t\t\tlog.Println(\"IN port is closed. Interrupting execution\")\n\t\t\t\t\texitCh <- syscall.SIGTERM\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\ttotal++\n\t\t\t\t}\n\t\t\tcase v := <-outCh:\n\t\t\t\tif !v {\n\t\t\t\t\tlog.Println(\"OUT port is closed. Interrupting execution\")\n\t\t\t\t\texitCh <- syscall.SIGTERM\n\t\t\t\t\tbreak\n\t\t\t\t} else {\n\t\t\t\t\ttotal++\n\t\t\t\t}\n\t\t\t}\n\t\t\tif total >= 2 && waitCh != nil {\n\t\t\t\twaitCh <- true\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Println(\"Waiting for port connections to establish... \")\n\tselect {\n\tcase <-waitCh:\n\t\tlog.Println(\"Ports connected\")\n\t\twaitCh = nil\n\tcase <-time.Tick(30 * time.Second):\n\t\tlog.Println(\"Timeout: port connections were not established within provided interval\")\n\t\texitCh <- syscall.SIGTERM\n\t\treturn\n\t}\n\n\tlog.Println(\"Waiting for options...\")\n\tvar (\n\t\tip [][]byte\n\t)\n\tfor {\n\t\tip, err = optionsPort.RecvMessageBytes(0)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif !runtime.IsValidIP(ip) {\n\t\t\tlog.Println(\"Invalid IP:\", ip)\n\t\t\tcontinue\n\t\t}\n\t\terr = json.Unmarshal(ip[1], &opts)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Failed to resolve options:\", err.Error())\n\t\t\tcontinue\n\t\t}\n\t\tlog.Printf(\"Using options: %#v\", opts)\n\t\tbreak\n\t}\n\toptionsPort.Close()\n\n\t/*\n\t\tif err = opts.Validate(); err != nil {\n\t\t\tlog.Println(\"ERROR: Invalid options:\", err.Error())\n\t\t\tch <- syscall.SIGTERM\n\t\t\treturn\n\t\t}\n\t*/\n\n\tlocalCache = NewCache(time.Duration(opts.DefaultExpiration)*time.Second, time.Duration(opts.CleanupInterval)*time.Second)\n\tif opts.IsPersistent() {\n\t\tlog.Println(\"Cache is persistent. Using file\", opts.File)\n\t\terr = localCache.LoadFile(opts.File)\n\t\tif err != nil {\n\t\t\tlog.Println(\"WARNING: Failed to load cache from file\", opts.File)\n\t\t}\n\t}\n\n\tlog.Println(\"Started...\")\nloop:\n\tfor {\n\t\tip, err = inPort.RecvMessageBytes(zmq.DONTWAIT)\n\t\tif err != nil {\n\t\t\tselect {\n\t\t\tcase <-loopCh:\n\t\t\t\tlog.Println(\"Main loop shutdown requested\")\n\t\t\t\tbreak loop\n\t\t\tdefault:\n\t\t\t}\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t\tcontinue\n\t\t}\n\n\t\tif !runtime.IsValidIP(ip) {\n\t\t\tlog.Println(\"Invalid IP:\", ip)\n\t\t\tcontinue\n\t\t}\n\n\t\tkey := fmt.Sprintf(\"%x\", md5.Sum(ip[1]))\n\t\tif _, found := localCache.Get(key); found {\n\t\t\tlog.Println(\"Cache HIT. Not forwarding this IP\")\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Println(\"Cache MISS. Forwarding\")\n\n\t\toutPort.SendMessage(ip)\n\n\t\tlocalCache.Add(key, 1, 0)\n\t}\n\n\tif opts.IsPersistent() {\n\t\tlog.Println(\"Saving current cache to\", opts.File)\n\t\terr = localCache.SaveFile(opts.File)\n\t\tif err != nil {\n\t\t\tlog.Println(\"ERROR saving cache to file:\", err.Error())\n\t\t}\n\t}\n}", "func (l *Logic) Disconnect(c context.Context, mid int64, key, server string) (has bool, err error) {\n\tif has, err = l.dao.DelMapping(c, mid, key, server); err != nil {\n\t\tlog.Errorf(\"l.dao.DelMapping(%d,%s) error(%v)\", mid, key, err)\n\t\treturn\n\t}\n\terr = l.dao.DeviceOffline(mid)\n\tlog.Infof(\"conn disconnected key:%s server:%s mid:%d\", key, server, mid)\n\treturn\n}" ]
[ "0.6069437", "0.5197452", "0.49850973", "0.47833794", "0.47574034", "0.47144872", "0.46668392", "0.46572712", "0.4615023", "0.45892963", "0.45662084", "0.45424485", "0.45418474", "0.45253637", "0.4495936", "0.44708145", "0.4461583", "0.44280642", "0.43790534", "0.43696007", "0.43402487", "0.43396375", "0.43389162", "0.4335323", "0.43259037", "0.4309942", "0.4280716", "0.42796874", "0.42613807", "0.4254319", "0.42387542", "0.42114103", "0.4206391", "0.41994804", "0.4196514", "0.41951004", "0.41900113", "0.41751626", "0.41698423", "0.4168877", "0.4168297", "0.41536033", "0.4153473", "0.4144272", "0.41432062", "0.41410893", "0.41375458", "0.4137255", "0.41357505", "0.41344866", "0.4125648", "0.4114357", "0.4114357", "0.41097927", "0.4109218", "0.41067284", "0.41008273", "0.40729487", "0.4063962", "0.40633804", "0.4060353", "0.4041071", "0.4038804", "0.40345055", "0.40328634", "0.40316322", "0.40289974", "0.40262365", "0.40137118", "0.40128106", "0.40118477", "0.40113294", "0.40014705", "0.40013573", "0.39989007", "0.3996562", "0.3994511", "0.3972458", "0.39669913", "0.39628822", "0.3958236", "0.39571962", "0.39366835", "0.3935891", "0.39352858", "0.39336088", "0.39297152", "0.39287353", "0.39268982", "0.3924983", "0.39211726", "0.3919537", "0.39169616", "0.39141828", "0.39134806", "0.3907845", "0.3904953", "0.3901724", "0.389128", "0.38887957" ]
0.66034466
0
Retrieves the number of inputs connected to the DSP unit. Inputs are units that feed data to this unit. When there are multiple inputs, they are mixed together. Performance warning! Because this function needs to flush the dsp queue before it can determine how many units are available, this function may block significantly while the background mixer thread operates.
func (d *DSP) NumInputs() (int, error) { var numinputs C.int res := C.FMOD_DSP_GetNumInputs(d.cptr, &numinputs) return int(numinputs), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (tx *Tx) InputCount() int {\r\n\treturn len(tx.Inputs)\r\n}", "func (x *MetricsWorkload) GetNumInputs() int32 {\n\tif x != nil {\n\t\treturn x.NumInputs\n\t}\n\treturn 0\n}", "func (dev *PMX) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (p Plexer) NumChannels() int {\n\treturn len(p.channels)\n}", "func (dev *E36xx) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (a *DS345) OutputCount() int {\n\treturn len(a.Channels)\n}", "func (q *Queue) GetInputLength() int64 {\n\treturn q.redisClient.LLen(queueInputKey(q.Name)).Val()\n}", "func (q *TransmitLimitedQueue) NumQueued() int {\n\tq.mu.Lock()\n\tdefer q.mu.Unlock()\n\treturn q.lenLocked()\n}", "func (queue *Queue) GetInputLength() int64 {\n\treturn queue.redisClient.LLen(queueInputKey(queue.Name)).Val()\n}", "func (ctx Context) Count(input chan float64) (n uint) {\n\tfor _ = range input {\n\t\tn++\n\t}\n\n\treturn n\n}", "func (d *DSP) NumParameters() (int, error) {\n\tvar numparams C.int\n\tres := C.FMOD_DSP_GetNumParameters(d.cptr, &numparams)\n\treturn int(numparams), errs[res]\n}", "func (c *connection) getQueueLength(inputs input) (int, error) {\n\n\tif inputs.limit > 0 {\n\t\treturn inputs.limit, nil\n\t}\n\n\tqLength, err := redis.Int(conn.redis.Do(\"LLEN\", inputs.source))\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif qLength < 1 {\n\t\treturn 0, fmt.Errorf(\"Source queue is empty\")\n\t}\n\n\treturn qLength, nil\n}", "func (h *clientHub) NumChannels() int {\n\th.RLock()\n\tdefer h.RUnlock()\n\treturn len(h.subs)\n}", "func (d *DSP) NumOutputs() (int, error) {\n\tvar numoutputs C.int\n\tres := C.FMOD_DSP_GetNumOutputs(d.cptr, &numoutputs)\n\treturn int(numoutputs), errs[res]\n}", "func GetDeviceQueueItemCountForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (int, error) {\n\tvar count int\n\terr := sqlx.Get(db, &count, `\n\t\tselect\n\t\t\tcount(*)\n\t\tfrom\n\t\t\tdevice_queue\n\t\twhere\n\t\t\tdev_eui = $1\n\t`, devEUI)\n\tif err != nil {\n\t\treturn 0, handlePSQLError(err, \"select error\")\n\t}\n\n\treturn count, nil\n}", "func (self Source) BuffersQueued() int32 {\n\treturn self.Geti(AlBuffersQueued)\n}", "func (h *InputHost) GetNumConnections() int {\n\treturn int(h.hostMetrics.Get(load.HostMetricNumOpenConns))\n}", "func (p *FuncInfo) NumIn() int {\n\treturn len(p.in)\n}", "func (in Inputs) Len() int { return len(in) }", "func (o ElastigroupIntegrationEcsAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationEcsAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationDockerSwarmAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationDockerSwarmAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (a *AudioData) SampleCount() int {\n\treturn len(a.samples) / a.SampleSize()\n}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationNomadAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (ct *cpuTracker) Len() int {\n\tct.lock.Lock()\n\tdefer ct.lock.Unlock()\n\n\treturn len(ct.cpuSpenders)\n}", "func (o *MDRaid) GetNumDevices(ctx context.Context) (numDevices uint32, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceMDRaid, \"NumDevices\").Store(&numDevices)\n\treturn\n}", "func (o ElastigroupIntegrationEcsAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationEcsAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationNomadAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationDockerSwarmAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationDockerSwarmAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (c *QueuedChan) Len() int { return int(atomic.LoadInt32(&c.len)) }", "func (s *SharedMemory) NumReadingElements() int {\n\treturn int(s.shmem.dwNumReadingElements)\n}", "func (o *os) GetAudioDriverCount() gdnative.Int {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetAudioDriverCount()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_audio_driver_count\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func GetDevicePluginCount(pluginKind string) int {\n\treturn bKeeper.count(pluginKind)\n}", "func (o NetworkInterfaceOutput) QueueCount() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v NetworkInterface) *int { return v.QueueCount }).(pulumi.IntPtrOutput)\n}", "func (o GroupContainerGpuOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v GroupContainerGpu) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (qi *Items) Len() int {\n\tqi.RLock()\n\tc := qi.Length\n\tlog.Printf(\"queue length: %d\\n\", c)\n\tqi.RUnlock()\n\treturn c\n}", "func (o *UPNP) GetDeviceCount() gdnative.Int {\n\t//log.Println(\"Calling UPNP.GetDeviceCount()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"UPNP\", \"get_device_count\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (ctx *Context) NumDevices() int {\n\treturn int(C.freenect_num_devices(ctx.ptr()))\n}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func GetJoystickCount() int {\n\treturn len(activeSticks)\n}", "func (psc *PubSubChannel) NumSubscriptions() int {\n psc.subsMutex.RLock()\n defer psc.subsMutex.RUnlock()\n return len(psc.subscriptions)\n}", "func (m *ItemWindowsInformationProtectionDeviceRegistrationsRequestBuilder) Count()(*ItemWindowsInformationProtectionDeviceRegistrationsCountRequestBuilder) {\n return NewItemWindowsInformationProtectionDeviceRegistrationsCountRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (o *V0037DiagRpcm) GetCount() int32 {\n\tif o == nil || o.Count == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Count\n}", "func (gq *Dispatch) Len() int {\n return gq.queue.Len()\n}", "func (d *Devices) Len() int {\n\treturn len(*d)\n}", "func (m *Mixer) Frequency() uint {\n\treturn uint(C.al_get_mixer_frequency((*C.ALLEGRO_MIXER)(m)))\n}", "func (o GroupContainerGpuPtrOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *GroupContainerGpu) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Count\n\t}).(pulumi.IntPtrOutput)\n}", "func (s *FabricInterfaceSet) NumNetDevices() int {\n\tif s == nil {\n\t\treturn 0\n\t}\n\treturn len(s.byNetDev)\n}", "func (s *stmt) NumInput() int {\n\treturn len(s.parameters)\n}", "func (otuTable *otuTable) GetNumSamples() int {\n\treturn len(otuTable.sampleNames)\n}", "func (s *stmt) NumInput() (n int) {\n\tif trace {\n\t\tdefer func() {\n\t\t\ttracer(s, \"NumInput(): %v\", n)\n\t\t}()\n\t}\n\treturn -1\n}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o GroupContainerGpuLimitOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v GroupContainerGpuLimit) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (s *SoundGroup) NumSounds() (int, error) {\n\tvar numsounds C.int\n\tres := C.FMOD_SoundGroup_GetNumSounds(s.cptr, &numsounds)\n\treturn int(numsounds), errs[res]\n}", "func (s *ImageSpec) NumChannels() int {\n\tret := int(C.ImageSpec_nchannels(s.ptr))\n\truntime.KeepAlive(s)\n\treturn ret\n}", "func (q *Queue) Len() uint {\n\tif q.State() != lifecycle.StateStarted {\n\t\treturn 0\n\t}\n\n\tq.mutex.RLock()\n\tdefer q.mutex.RUnlock()\n\n\treturn uint(len(q.pending))\n}", "func (m *WindowsMalwareCategoryCount) GetDeviceCount()(*int32) {\n val, err := m.GetBackingStore().Get(\"deviceCount\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "func (s *MemoryStore) NumSubscriptions() int {\n\ts.subsMux.RLock()\n\tdefer s.subsMux.RUnlock()\n\n\treturn len(s.subscriptions)\n}", "func Length(q Interface) (int, error) {\n\tconn := RedisPool.Get()\n\tdefer conn.Close()\n\treturn redis.Int(conn.Do(\"LLEN\", redisQueueKey(q)))\n}", "func (q *PushQueue) Count() int {\n\treturn len(q.items)\n}", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (h *clientHub) NumSubscribers(ch string) int {\n\th.RLock()\n\tdefer h.RUnlock()\n\tconns, ok := h.subs[ch]\n\tif !ok {\n\t\treturn 0\n\t}\n\treturn len(conns)\n}", "func (o GroupContainerGpuLimitPtrOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *GroupContainerGpuLimit) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Count\n\t}).(pulumi.IntPtrOutput)\n}", "func (this *Stats) PlayedAudioBuffers() int { return int(this.ptr.i_played_abuffers) }", "func (q *queue) Count() int {\n\tq.Lock()\n\tdefer q.Unlock()\n\n\treturn q.count\n}", "func (s *InternalSender) Len() int {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn len(s.output)\n}", "func (f *FilterLimit) Count(ctx context.Context, in <-chan int) <-chan int {\n\tout := make(chan int, 1)\n\n\tgo func() {\n\t\tdefer close(out)\n\t\tvar total int\n\t\tselect {\n\t\tcase total = <-in:\n\t\tcase <-ctx.Done():\n\t\t}\n\n\t\t// calculate the correct total count\n\t\tif total > f.Max {\n\t\t\ttotal = f.Max\n\t\t}\n\n\t\tselect {\n\t\tcase out <- total:\n\t\tcase <-ctx.Done():\n\t\t}\n\t}()\n\n\treturn out\n}", "func (mtr *Dppdpp0intfifoMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.PhvFfOverflow.Size()\n\n\tsz += mtr.OhiFfOverflow.Size()\n\n\tsz += mtr.PktSizeFfOvflow.Size()\n\n\tsz += mtr.PktSizeFfUndflow.Size()\n\n\tsz += mtr.CsumPhvFfOvflow.Size()\n\n\tsz += mtr.CsumPhvFfUndflow.Size()\n\n\treturn sz\n}", "func GetDeviceCount() (count int) {\n\treturn int(C.rtlsdr_get_device_count())\n\n}", "func (m *MetricsProvider) LoopDevices() int {\n\treturn 0\n}", "func (f *Sink) Count() int {\n\treturn len(f.endpoints)\n}", "func (mtr *Dprdpr1intfifoMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.PhvFfOvflow.Size()\n\n\tsz += mtr.OhiFfOvflow.Size()\n\n\tsz += mtr.PktinFfOvflow.Size()\n\n\tsz += mtr.PktoutFfUndflow.Size()\n\n\tsz += mtr.CsumFfOvflow.Size()\n\n\tsz += mtr.PtrFfOvflow.Size()\n\n\treturn sz\n}", "func (mtr *Dppdpp1intfifoMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.PhvFfOverflow.Size()\n\n\tsz += mtr.OhiFfOverflow.Size()\n\n\tsz += mtr.PktSizeFfOvflow.Size()\n\n\tsz += mtr.PktSizeFfUndflow.Size()\n\n\tsz += mtr.CsumPhvFfOvflow.Size()\n\n\tsz += mtr.CsumPhvFfUndflow.Size()\n\n\treturn sz\n}", "func (t *Topology) NumDevices() int {\n\tdevices := 0\n\tfor _, n := range t.Cluster.StorageNodes {\n\t\tdevices += len(n.Devices)\n\t}\n\treturn devices\n}", "func (q *Queue) Count() int {\n\tq.m.Lock()\n\tdefer q.m.Unlock()\n\treturn q.j - q.i\n}", "func (q *Queue) Count() int {\n\treturn q.front - q.back + 1\n}", "func GetNumberOfConsoleInputEvents(hConsoleInput HANDLE, lpNumberOfEvents *uint32) bool {\n\tret1 := syscall3(getNumberOfConsoleInputEvents, 2,\n\t\tuintptr(hConsoleInput),\n\t\tuintptr(unsafe.Pointer(lpNumberOfEvents)),\n\t\t0)\n\treturn ret1 != 0\n}", "func (q *Queue) Len() int {\n\tlength := 0\n\n\tfor _, current := range q.Items {\n\t\tif !current.IsReserved() {\n\t\t\tlength++\n\t\t}\n\t}\n\n\treturn length\n}", "func (ch *RingChannel) Len() int {\n\treturn len(ch.output)\n}", "func (_HbSwap *HbSwapCallerSession) InputmaskCnt() (*big.Int, error) {\n\treturn _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts)\n}", "func (q *queue) Len() int {\n\tq.lock.RLock()\n\tdefer q.lock.RUnlock()\n\tc := q.tail - q.head\n\tif c < 0 {\n\t\tc = 0\n\t}\n\n\treturn c\n}", "func (multi_queue *MultiQueue) Length() (int, error) {\n\tcount := 0\n\tfor _, q := range multi_queue.HealthyQueues() {\n\t\tconn := q.pooledConnection.Get()\n\t\tdefer conn.Close()\n\n\t\trep, err := redis.Int(conn.Do(\"LLEN\", multi_queue.key))\n\t\tif err == nil {\n\t\t\tcount = count + rep\n\t\t} else {\n\t\t\treturn count, err\n\t\t}\n\t}\n\treturn count, nil\n}", "func (l *sampleList) Len() int { return len(l.samples) - len(l.free) }", "func (_HbSwap *HbSwapSession) InputmaskCnt() (*big.Int, error) {\n\treturn _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts)\n}", "func (strg *inMemoryStorage) NumConnected() int {\n\tstrg.lock.RLock()\n\tdefer strg.lock.RUnlock()\n\treturn len(strg.connected)\n}", "func (s *StanServer) numSubs() int {\n\ttotal := 0\n\ts.channels.RLock()\n\tfor _, c := range s.channels.channels {\n\t\tc.ss.RLock()\n\t\ttotal += len(c.ss.psubs)\n\t\t// Need to add offline durables\n\t\tfor _, sub := range c.ss.durables {\n\t\t\tif sub.ClientID == \"\" {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t}\n\t\tfor _, qsub := range c.ss.qsubs {\n\t\t\tqsub.RLock()\n\t\t\ttotal += len(qsub.subs)\n\t\t\t// If this is a durable queue subscription and all members\n\t\t\t// are offline, qsub.shadow will be not nil. Report this one.\n\t\t\tif qsub.shadow != nil {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t\tqsub.RUnlock()\n\t\t}\n\t\tc.ss.RUnlock()\n\t}\n\ts.channels.RUnlock()\n\treturn total\n}", "func (q *LLQueue) Size() int {\n\tvar cnt int\n\tfor i := q.head; i != nil; i = i.next {\n\t\tcnt++\n\t}\n\treturn cnt\n}", "func (l *ChannelList) Count() int {\n\tc := 0\n\tfor i := 0; i < Conf.ChannelBucketCount; i++ {\n\t\tc += len(l.channels[i].data)\n\t}\n\treturn c\n}", "func (c *MQCache) Len() (totalLen int64, queuesLen []int64) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tfor i := 0; i < c.queues; i++ {\n\t\tc.queuesLen[i] = c.q[i].len()\n\t\ttotalLen += c.queuesLen[i]\n\t}\n\treturn totalLen, c.queuesLen\n}", "func (i *Input) Len() int {\n\treturn i.Buffer.Len()\n}", "func (c Command) Count() int {\n\treturn int(uint32(c) >> 3)\n}", "func (f *Flash) Count() int {\n\treturn len(f.v)\n}", "func (s *PacketDurationQueue) Size() int {\n\treturn len(s.items)\n}", "func (xmlmc *XmlmcInstStruct) GetCount() uint64 {\n\n\treturn xmlmc.count\n}", "func (self Source) BuffersProcessed() int32 {\n\treturn self.Geti(AlBuffersProcessed)\n}", "func (q *Queue) Size() (int) {\r\n\t\treturn q.count\r\n}", "func (mtr *Dppdpp0intsramseccMetrics) Size() int {\n\tsz := 0\n\n\tsz += mtr.DppPhvFifoUncorrectable.Size()\n\n\tsz += mtr.DppPhvFifoCorrectable.Size()\n\n\tsz += mtr.DppOhiFifoUncorrectable.Size()\n\n\tsz += mtr.DppOhiFifoCorrectable.Size()\n\n\treturn sz\n}", "func (q *Queue) Len() int {\n\tq.lock.Lock()\n\tdefer q.lock.Unlock()\n\n\treturn len(q.items)\n}", "func (o OceanLaunchSpecAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecAutoscaleHeadroom) int { return v.NumOfUnits }).(pulumi.IntOutput)\n}", "func (s *SharedMemory) NumSensorElements() int {\n\treturn int(s.shmem.dwNumSensorElements)\n}", "func (s *UniformSample) Count() int64 {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\treturn s.count\n}" ]
[ "0.5830321", "0.5769346", "0.5714112", "0.5667743", "0.56345236", "0.56075567", "0.55987066", "0.5582188", "0.5524571", "0.54868436", "0.547775", "0.54391843", "0.53569084", "0.5351818", "0.5319162", "0.5289214", "0.5280871", "0.5266696", "0.5263865", "0.5246616", "0.5207028", "0.52037853", "0.52007043", "0.51844174", "0.5179884", "0.5138462", "0.5111517", "0.5108974", "0.50958955", "0.5091419", "0.5079234", "0.506279", "0.50502783", "0.50352675", "0.50328636", "0.5022035", "0.50155765", "0.5014754", "0.50122887", "0.49947146", "0.49882048", "0.49830297", "0.4982588", "0.49702403", "0.49510515", "0.49419427", "0.49399972", "0.49127945", "0.49061364", "0.4901876", "0.4890262", "0.48874965", "0.4885641", "0.48793235", "0.48780876", "0.48774314", "0.487127", "0.486961", "0.48660675", "0.4862294", "0.4851484", "0.48495844", "0.48483625", "0.4846795", "0.4842481", "0.48420137", "0.4841567", "0.4841036", "0.48361927", "0.48254386", "0.48058012", "0.47985804", "0.47930145", "0.47879335", "0.47813016", "0.47696808", "0.47651637", "0.47626436", "0.47593462", "0.47540605", "0.4750312", "0.47450027", "0.4736985", "0.47341797", "0.47320762", "0.47243765", "0.4718817", "0.47138518", "0.47135693", "0.47047994", "0.46915364", "0.46902934", "0.46858555", "0.46819073", "0.46784404", "0.4674688", "0.4667972", "0.46646813", "0.4661002", "0.46569535" ]
0.690844
0
Retrieves the number of outputs connected to the DSP unit. Outputs are units that this unit feeds data to. When there are multiple outputs, the data is split and sent to each unit individually. Performance warning! Because this function needs to flush the dsp queue before it can determine how many units are available, this function may block significantly while the background mixer thread operates.
func (d *DSP) NumOutputs() (int, error) { var numoutputs C.int res := C.FMOD_DSP_GetNumOutputs(d.cptr, &numoutputs) return int(numoutputs), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (a *DS345) OutputCount() int {\n\treturn len(a.Channels)\n}", "func (dev *E36xx) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (dev *PMX) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (o GroupContainerGpuOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v GroupContainerGpu) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (p Plexer) NumChannels() int {\n\treturn len(p.channels)\n}", "func (w *Wire) NumOutputs() uint32 {\n\treturn w.ovnum & numMask\n}", "func (o NetworkInterfaceOutput) QueueCount() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v NetworkInterface) *int { return v.QueueCount }).(pulumi.IntPtrOutput)\n}", "func (h *clientHub) NumChannels() int {\n\th.RLock()\n\tdefer h.RUnlock()\n\treturn len(h.subs)\n}", "func (o ElastigroupIntegrationDockerSwarmAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationDockerSwarmAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationNomadAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationEcsAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationEcsAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationDockerSwarmAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationDockerSwarmAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (ch *RingChannel) Len() int {\n\treturn len(ch.output)\n}", "func (o ElastigroupIntegrationNomadAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationNomadAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (o ElastigroupIntegrationEcsAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationEcsAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func (s *InternalSender) Len() int {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn len(s.output)\n}", "func (o *UPNP) GetDeviceCount() gdnative.Int {\n\t//log.Println(\"Calling UPNP.GetDeviceCount()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"UPNP\", \"get_device_count\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (o *os) GetAudioDriverCount() gdnative.Int {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetAudioDriverCount()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_audio_driver_count\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (p *FuncInfo) NumOut() int {\n\treturn len(p.out)\n}", "func (o GroupContainerGpuPtrOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *GroupContainerGpu) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Count\n\t}).(pulumi.IntPtrOutput)\n}", "func (o *MDRaid) GetNumDevices(ctx context.Context) (numDevices uint32, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceMDRaid, \"NumDevices\").Store(&numDevices)\n\treturn\n}", "func GetDeviceCount() (count int) {\n\treturn int(C.rtlsdr_get_device_count())\n\n}", "func (q *TransmitLimitedQueue) NumQueued() int {\n\tq.mu.Lock()\n\tdefer q.mu.Unlock()\n\treturn q.lenLocked()\n}", "func (f *Sink) Count() int {\n\treturn len(f.endpoints)\n}", "func (s *StanServer) numSubs() int {\n\ttotal := 0\n\ts.channels.RLock()\n\tfor _, c := range s.channels.channels {\n\t\tc.ss.RLock()\n\t\ttotal += len(c.ss.psubs)\n\t\t// Need to add offline durables\n\t\tfor _, sub := range c.ss.durables {\n\t\t\tif sub.ClientID == \"\" {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t}\n\t\tfor _, qsub := range c.ss.qsubs {\n\t\t\tqsub.RLock()\n\t\t\ttotal += len(qsub.subs)\n\t\t\t// If this is a durable queue subscription and all members\n\t\t\t// are offline, qsub.shadow will be not nil. Report this one.\n\t\t\tif qsub.shadow != nil {\n\t\t\t\ttotal++\n\t\t\t}\n\t\t\tqsub.RUnlock()\n\t\t}\n\t\tc.ss.RUnlock()\n\t}\n\ts.channels.RUnlock()\n\treturn total\n}", "func GetDevicePluginCount(pluginKind string) int {\n\treturn bKeeper.count(pluginKind)\n}", "func (o GroupContainerGpuLimitOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v GroupContainerGpuLimit) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (psc *PubSubChannel) NumSubscriptions() int {\n psc.subsMutex.RLock()\n defer psc.subsMutex.RUnlock()\n return len(psc.subscriptions)\n}", "func (c *QueuedChan) Len() int { return int(atomic.LoadInt32(&c.len)) }", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int { return v.NumOfUnits }).(pulumi.IntPtrOutput)\n}", "func (h *clientHub) NumSubscribers(ch string) int {\n\th.RLock()\n\tdefer h.RUnlock()\n\tconns, ok := h.subs[ch]\n\tif !ok {\n\t\treturn 0\n\t}\n\treturn len(conns)\n}", "func (o *FactoryContainer) CountOutput() float64 {\n\tvar output float64 = 0.0\n\tfor i, _ := range o.Factories {\n\t\toutput = output + o.Factories[i].Production*o.Factories[i].ProductionModifier\n\t}\n\treturn output\n}", "func GetDeviceQueueItemCountForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (int, error) {\n\tvar count int\n\terr := sqlx.Get(db, &count, `\n\t\tselect\n\t\t\tcount(*)\n\t\tfrom\n\t\t\tdevice_queue\n\t\twhere\n\t\t\tdev_eui = $1\n\t`, devEUI)\n\tif err != nil {\n\t\treturn 0, handlePSQLError(err, \"select error\")\n\t}\n\n\treturn count, nil\n}", "func (o ElastigroupIntegrationKubernetesAutoscaleHeadroomPtrOutput) NumOfUnits() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *ElastigroupIntegrationKubernetesAutoscaleHeadroom) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.NumOfUnits\n\t}).(pulumi.IntPtrOutput)\n}", "func GetJoystickCount() int {\n\treturn len(activeSticks)\n}", "func (this *Stats) PlayedAudioBuffers() int { return int(this.ptr.i_played_abuffers) }", "func (d *Devices) Len() int {\n\treturn len(*d)\n}", "func (d *DSP) NumInputs() (int, error) {\n\tvar numinputs C.int\n\tres := C.FMOD_DSP_GetNumInputs(d.cptr, &numinputs)\n\treturn int(numinputs), errs[res]\n}", "func (m *Mixer) Frequency() uint {\n\treturn uint(C.al_get_mixer_frequency((*C.ALLEGRO_MIXER)(m)))\n}", "func (o NetworkInterfaceResponseOutput) QueueCount() pulumi.IntOutput {\n\treturn o.ApplyT(func(v NetworkInterfaceResponse) int { return v.QueueCount }).(pulumi.IntOutput)\n}", "func (h *InputHost) GetNumConnections() int {\n\treturn int(h.hostMetrics.Get(load.HostMetricNumOpenConns))\n}", "func (o OceanLaunchSpecAutoscaleHeadroomOutput) NumOfUnits() pulumi.IntOutput {\n\treturn o.ApplyT(func(v OceanLaunchSpecAutoscaleHeadroom) int { return v.NumOfUnits }).(pulumi.IntOutput)\n}", "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func (otuTable *otuTable) GetNumSamples() int {\n\treturn len(otuTable.sampleNames)\n}", "func (nc NvmeController) Free() (tb uint64) {\n\tfor _, d := range nc.SmdDevices {\n\t\ttb += d.AvailBytes\n\t}\n\treturn\n}", "func (sm sharedMap) Count() int {\n\tcallback := make(chan interface{})\n\tsm.c <- command{action: count, result: callback}\n\treturn (<-callback).(int)\n}", "func (ct *cpuTracker) Len() int {\n\tct.lock.Lock()\n\tdefer ct.lock.Unlock()\n\n\treturn len(ct.cpuSpenders)\n}", "func (a *AudioData) SampleCount() int {\n\treturn len(a.samples) / a.SampleSize()\n}", "func (v *SrsMp4Sample) size() uint32 {\n if v.handlerType == SrsMp4HandlerTypeSOUN {\n if v.codec == SrsAudioCodecIdAAC {\n return v.nbSample + 2\n }\n return v.nbSample + 1\n }\n if v.codec == SrsVideoCodecIdAVC {\n return v.nbSample + 5\n }\n return v.nbSample + 1\n}", "func (m *MetricsProvider) LoopDevices() int {\n\treturn 0\n}", "func GetTotalDeviceNum() int {\n\tvar count int\n\tDB.Table(\"devices\").Count(&count)\n\treturn count\n}", "func (o *V0037DiagRpcm) GetCount() int32 {\n\tif o == nil || o.Count == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Count\n}", "func (s *MemoryStore) NumSubscriptions() int {\n\ts.subsMux.RLock()\n\tdefer s.subsMux.RUnlock()\n\n\treturn len(s.subscriptions)\n}", "func (o GroupContainerGpuLimitPtrOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *GroupContainerGpuLimit) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Count\n\t}).(pulumi.IntPtrOutput)\n}", "func (self Source) BuffersQueued() int32 {\n\treturn self.Geti(AlBuffersQueued)\n}", "func (ctx *Context) NumDevices() int {\n\treturn int(C.freenect_num_devices(ctx.ptr()))\n}", "func (sm safeMap) Len() int {\n\treply := make(chan interface{})\n\tsm <- commandData{action: COUNT, result: reply}\n\treturn (<-reply).(int)\n}", "func (c *MQCache) LenQout() int {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\treturn c.qOut.len()\n}", "func (strg *inMemoryStorage) NumConnected() int {\n\tstrg.lock.RLock()\n\tdefer strg.lock.RUnlock()\n\treturn len(strg.connected)\n}", "func (d *DSP) NumParameters() (int, error) {\n\tvar numparams C.int\n\tres := C.FMOD_DSP_GetNumParameters(d.cptr, &numparams)\n\treturn int(numparams), errs[res]\n}", "func (ctx Context) Count(input chan float64) (n uint) {\n\tfor _ = range input {\n\t\tn++\n\t}\n\n\treturn n\n}", "func (hub *WSHub) Len() int {\n\thub.mu.Lock()\n\tdefer hub.mu.Unlock()\n\treturn len(hub.connections)\n}", "func (o IntegrationRuntimeManagedOutput) NumberOfNodes() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *IntegrationRuntimeManaged) pulumi.IntPtrOutput { return v.NumberOfNodes }).(pulumi.IntPtrOutput)\n}", "func (c Command) Count() int {\n\treturn int(uint32(c) >> 3)\n}", "func (s16le *S16LE) Len() int {\n\treturn len(s16le.pcm)\n}", "func (m *ManagedDeviceOverview) GetEnrolledDeviceCount()(*int32) {\n return m.enrolledDeviceCount\n}", "func (s *Worker) Usage() int {\n\treturn len(s.queueNotification)\n}", "func (m *WindowsMalwareCategoryCount) GetDeviceCount()(*int32) {\n val, err := m.GetBackingStore().Get(\"deviceCount\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "func (t *Topology) NumDevices() int {\n\tdevices := 0\n\tfor _, n := range t.Cluster.StorageNodes {\n\t\tdevices += len(n.Devices)\n\t}\n\treturn devices\n}", "func (o ClusterNodeGroupSystemDiskOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ClusterNodeGroupSystemDisk) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (c *connection) getQueueLength(inputs input) (int, error) {\n\n\tif inputs.limit > 0 {\n\t\treturn inputs.limit, nil\n\t}\n\n\tqLength, err := redis.Int(conn.redis.Do(\"LLEN\", inputs.source))\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif qLength < 1 {\n\t\treturn 0, fmt.Errorf(\"Source queue is empty\")\n\t}\n\n\treturn qLength, nil\n}", "func (o DebugSessionOutput) Count() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *DebugSession) pulumi.IntOutput { return v.Count }).(pulumi.IntOutput)\n}", "func (d *state) Size() int { return d.outputLen }", "func (s *Sink) OutputDim() int {\n\treturn s.outputDim\n}", "func (c *counter) Count() (int, int) {\n\treturn c.messages, c.samples\n}", "func (c *counter) Count() (int, int) {\n\treturn c.messages, c.samples\n}", "func (h *Hub) StreamsSize() int {\n\th.streamsMu.RLock()\n\tdefer h.streamsMu.RUnlock()\n\n\treturn len(h.streams)\n}", "func (gq *Dispatch) Len() int {\n return gq.queue.Len()\n}", "func (o ClusterNodeGroupDataDiskOutput) Count() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v ClusterNodeGroupDataDisk) *int { return v.Count }).(pulumi.IntPtrOutput)\n}", "func (s *sizeTracker) numWrites() int {\n\treturn len(s.keyToSize)\n}", "func (subr *SRCountersData) Len() (l uint16) {\n\tencoded, _ := subr.Encode()\n\tl = uint16(len(encoded))\n\treturn l\n}", "func (pipe *pipe) Write(b Samples) (int, error) {\n\tif err := pipe.getErr(); err != nil {\n\t\treturn 0, err\n\t}\n\n\t// TODO(paultag): Thread safety.\n\n\tif b.Format() != pipe.format {\n\t\treturn 0, ErrSampleFormatMismatch\n\t}\n\n\tvar n int\n\n\tfor b.Length() > 0 {\n\t\tselect {\n\t\tcase pipe.samplesCh <- b:\n\t\t\tnumWritten := <-pipe.readSamplesCh\n\t\t\tb = b.Slice(numWritten, b.Length())\n\t\t\tn += numWritten\n\t\tcase <-pipe.context.Done():\n\t\t\treturn n, pipe.getErr()\n\t\t}\n\t}\n\n\treturn n, nil\n}", "func (s *Stentor) Count() int {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn len(s.subscribers)\n}", "func (multi_queue *MultiQueue) Length() (int, error) {\n\tcount := 0\n\tfor _, q := range multi_queue.HealthyQueues() {\n\t\tconn := q.pooledConnection.Get()\n\t\tdefer conn.Close()\n\n\t\trep, err := redis.Int(conn.Do(\"LLEN\", multi_queue.key))\n\t\tif err == nil {\n\t\t\tcount = count + rep\n\t\t} else {\n\t\t\treturn count, err\n\t\t}\n\t}\n\treturn count, nil\n}", "func (p *Pump) WavNumChannels() phono.NumChannels {\n\treturn p.wavNumChannels\n}", "func (gscv *GridSearchCV) GetNOutputs() int {\n\treturn gscv.NOutputs\n}", "func (xmlmc *XmlmcInstStruct) GetCount() uint64 {\n\n\treturn xmlmc.count\n}", "func (mp *Mempool) CountInUse() int {\n\treturn int(C.rte_mempool_in_use_count(mp.ptr()))\n}", "func (m *WindowsInformationProtectionAppLearningSummary) GetDeviceCount()(*int32) {\n return m.deviceCount\n}", "func (nc NvmeController) Total() (tb uint64) {\n\tfor _, d := range nc.SmdDevices {\n\t\ttb += d.TotalBytes\n\t}\n\treturn\n}", "func (o *OSS) ReturnSize(groupID int64) error {\n\n partLine := partLine()\n\n totalData := map[string]map[string]int{}\n wg := &sync.WaitGroup{}\n ch := make(chan base.BaseInfo, 1000)\n wg.Add(2)\n go register(groupID, ch, wg)\n go fileCalc(groupID, ch, wg, o, totalData)\n\n time.Sleep(2 * time.Second)\n wg.Wait()\n\n for t := range totalData {\n ts := strconv.Itoa(totalData[t][\"totalSize\"])\n\n write.CreateFile(t, partLine + \"\\n\")\n write.CreateFile(t, fmt.Sprintf(\"Total: RecordCount: %d ; FileCount: %d ; FileSize: %s .\\n\",totalData[t][\"RecordCount\"],totalData[t][\"totalCount\"], utils.FormatSize(ts) ))\n }\n return nil\n}", "func (m *MeterSnapshot) Count() int64 { return m.count }", "func (c *HWStatsHandler) GetConnectionCount() int {\n\tc.mutex.RLock()\n\tval := c.connCount\n\tc.mutex.RUnlock()\n\n\treturn val\n}", "func (m *ManagedDeviceOverview) GetDualEnrolledDeviceCount()(*int32) {\n return m.dualEnrolledDeviceCount\n}", "func (m *Manager) Len() int {\n\treturn m.hub.len()\n}", "func (c *Сounter) Count(url string, objectiveString string, totalValue *int64, outputChan chan string) {\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\tif err != nil {\n\t\tc.logger.Println(c.errorMessage, err)\n\t\treturn\n\t}\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\tc.logger.Println(c.errorMessage, err)\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\terr = resp.Body.Close()\n\t\tif err != nil {\n\t\t\tc.logger.Println(c.errorMessage, err)\n\t\t}\n\t}()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tc.logger.Println(c.errorMessage, err)\n\t\treturn\n\t}\n\n\tcountInBody := int64(bytes.Count(body, []byte(objectiveString)))\n\n\tatomic.AddInt64(totalValue, countInBody)\n\n\tres := fmt.Sprintf(c.outputPhrase, url, countInBody)\n\n\toutputChan <- res\n}", "func (cli *FakeConfigAgentClient) DataPumpExportCalledCnt() int {\n\treturn int(atomic.LoadInt32(&cli.dataPumpExportCalledCnt))\n}", "func getNetworkStats() {\n\n\tnetMutex.Lock()\n\tdefer netMutex.Unlock()\n\n\tvar numNonSleepingClients uint\n\n\tfor k, netconn := range outSockets {\n\t\tqueueBytes := 0\n\t\tfor _, msg := range netconn.messageQueue {\n\t\t\tqueueBytes += len(msg)\n\t\t}\n\t\tif globalSettings.DEBUG {\n\t\t\tlog.Printf(\"On %s:%d, Queue length = %d messages / %d bytes\\n\", netconn.Ip, netconn.Port, len(netconn.messageQueue), queueBytes)\n\t\t}\n\t\tipAndPort := strings.Split(k, \":\")\n\t\tif len(ipAndPort) != 2 {\n\t\t\tcontinue\n\t\t}\n\t\tip := ipAndPort[0]\n\t\tif pingRespTime, ok := pingResponse[ip]; ok {\n\t\t\t// Don't count the ping time if it is the same as stratuxClock epoch.\n\t\t\t// If the client has responded to a ping in the last 15 minutes, count it as \"connected\" or \"recent\".\n\t\t\tif !pingRespTime.Equal(time.Time{}) && stratuxClock.Since(pingRespTime) < 15*time.Minute {\n\t\t\t\tnumNonSleepingClients++\n\t\t\t}\n\t\t}\n\t}\n\n\tglobalStatus.Connected_Users = numNonSleepingClients\n}", "func (p *MemProvider) Count() int {\n\treturn p.list.Len()\n}", "func (mq MetricsQueue) Len() int { return len(mq) }" ]
[ "0.7081156", "0.7014924", "0.6916046", "0.55712736", "0.55679405", "0.5543376", "0.54933316", "0.54702884", "0.5448055", "0.5412375", "0.5366185", "0.5353234", "0.5335579", "0.53230476", "0.53093386", "0.5305061", "0.53026456", "0.5299839", "0.52460974", "0.5220774", "0.5217817", "0.5213348", "0.5184256", "0.516238", "0.5159711", "0.51468927", "0.5133242", "0.50973505", "0.5094786", "0.5082717", "0.50787723", "0.50787145", "0.50735354", "0.50506264", "0.5042923", "0.50147253", "0.50026035", "0.4996917", "0.4990921", "0.4973893", "0.49546194", "0.49242532", "0.49212486", "0.49137208", "0.49070662", "0.4904468", "0.4895086", "0.4885078", "0.48830137", "0.48620263", "0.4860562", "0.4859586", "0.48558775", "0.48344848", "0.48295993", "0.48143965", "0.48141894", "0.4808905", "0.47894773", "0.47890258", "0.47843415", "0.47797573", "0.4777773", "0.4776589", "0.47751206", "0.47647732", "0.4760908", "0.47572744", "0.47520092", "0.47466722", "0.47379735", "0.4736978", "0.47258794", "0.47077507", "0.4705836", "0.4705836", "0.46981418", "0.46938175", "0.46921122", "0.4687172", "0.46834677", "0.46827033", "0.46815184", "0.4679774", "0.46780822", "0.46740666", "0.46636903", "0.46602407", "0.46591005", "0.46583706", "0.46483117", "0.46419638", "0.4639376", "0.46209866", "0.4618641", "0.46135604", "0.46115372", "0.46048093", "0.46018964", "0.45888138" ]
0.6333659
3
Retrieves a pointer to a DSP unit which is acting as an input to this unit. index: Index of the input unit to retrieve. An input is a unit which feeds audio data to this unit. If there are more than 1 input to this unit, the inputs will be mixed, and the current unit processes the mixed result. Find out the number of input units to this unit by calling "DSP.NumInputs". Performance warning! Because this function needs to flush the dsp queue before it can determine if the specified numerical input is available or not, this function may block significantly while the background mixer thread operates. Note: The connection pointer retrieved here will become invalid if you disconnect the 2 dsp units that use it.
func (d *DSP) Input(index int) (DSP, DspConnection, error) { var input DSP var inputconnection DspConnection res := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr) return input, inputconnection, errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func (p *program) doReadInput(i *instruction) {\n var input int64\n channelReadOk := false\n\n if p.inChannel != nil {\n select {\n case <-time.After(10 * time.Second):\n fmt.Println(\"waiting for input timed-out, trying to read from dataStack\")\n case input = <-p.inChannel:\n channelReadOk = true\n }\n }\n\n if !channelReadOk {\n if len(p.dataStack) > 0 {\n input = p.dataStack[len(p.dataStack)-1]\n p.dataStack = p.dataStack[:len(p.dataStack)-1]\n } else {\n reader := bufio.NewReader(os.Stdin)\n fmt.Print(\"Enter value: \")\n value, err := reader.ReadString('\\n')\n\n if err != nil {\n fmt.Println(err)\n }\n\n inputInt, err := strconv.Atoi(strings.TrimSuffix(value, \"\\n\"))\n\n if err != nil {\n fmt.Println(err)\n }\n\n input = int64(inputInt)\n }\n }\n\n p.memory[i.params[0].value] = input\n p.position += i.length\n}", "func (a *acssImpl) Input(input gpa.Input) gpa.OutMessages {\n\tif a.me != a.dealer {\n\t\tpanic(errors.New(\"only dealer can initiate the sharing\"))\n\t}\n\tif input == nil {\n\t\tpanic(errors.New(\"we expect kyber.Scalar as input\"))\n\t}\n\treturn a.handleInput(input.(kyber.Scalar))\n}", "func (p *Payload) GetInDev() uint32 {\n\treturn uint32(C.nfq_get_indev(p.nfad))\n}", "func (p *AsyncProducer) Input() chan<- *sarama.ProducerMessage { return p.input }", "func (q *chunkQueue) GetSender(index uint32) p2p.ID {\n\tq.Lock()\n\tdefer q.Unlock()\n\treturn q.chunkSenders[index]\n}", "func (d *DSP) AddInput(input DSP, typ DSPConnectionType) (DspConnection, error) {\n\tvar dspConn DspConnection\n\tres := C.FMOD_DSP_AddInput(d.cptr, input.cptr, &dspConn.cptr, C.FMOD_DSPCONNECTION_TYPE(typ))\n\treturn dspConn, errs[res]\n}", "func (swp *SourceWorkerPool) GetInputChannel() (chan map[string]interface{}, error) {\n\treturn nil, ErrInputChanDoesNotExist\n}", "func (socket *MockSocket) Input() *socket.InputProtocol {\n\treturn socket.input\n}", "func (m *Manager) InputChannel() chan []byte {\n\treturn m.byteStream\n}", "func (m *moduleService) Input() *dpdk.Ring {\n\treturn m.input\n}", "func (kcp *KCP) Input(data []byte, regular, ackNoDelay bool) int {\n\tsnd_una := kcp.snd_una\n\t//if len(data) < IKCP_OVERHEAD {\n\t//\treturn -1\n\t//}\n\n\tvar latest uint32 // the latest ack packet\n\tvar flag int\n\tfor {\n\t\tvar ts, sn, una, conv uint32\n\t\tvar length, wnd uint16\n\t\tvar cmd, frg uint8\n\t\tleft_size := len(data)\n\n\t\tif left_size < int(IKCP_MINHEAD) {\n\t\t\tbreak\n\t\t}\n\n\t\tdata = ikcp_decode32u(data, &conv)\n\t\tif conv != kcp.conv {\n\t\t\treturn -1\n\t\t}\n\t\tdata = ikcp_decode8u(data, &cmd)\n\t\tif !(cmd > IKCP_CMD_BEG && cmd < IKCP_CMD_END) {\n\t\t\treturn -3\n\t\t}\n\n\t\tif cmd == IKCP_CMD_SYN || cmd == IKCP_CMD_PUSH {\n\t\t\tif left_size < int(IKCP_OVERHEAD) {\n\t\t\t\tfmt.Println(\"error recv err data cmd\", cmd, \"len\", len(data), \"too short\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdata = ikcp_decode8u(data, &frg)\n\t\t\tdata = ikcp_decode16u(data, &wnd)\n\t\t\tdata = ikcp_decode32u(data, &ts)\n\t\t\tdata = ikcp_decode32u(data, &sn)\n\t\t\tdata = ikcp_decode32u(data, &una)\n\t\t\tdata = ikcp_decode16u(data, &length)\n\t\t\tif len(data) < int(length) {\n\t\t\t\treturn -2\n\t\t\t}\n\t\t} else {\n\t\t\tdata = ikcp_decode16u(data, &wnd)\n\t\t\tdata = ikcp_decode32u(data, &ts)\n\t\t\tdata = ikcp_decode32u(data, &sn)\n\t\t\tdata = ikcp_decode32u(data, &una)\n\t\t}\n\n\t\t// only trust window updates from regular packets. i.e: latest update\n\t\tif regular {\n\t\t\tkcp.rmt_wnd = uint32(wnd)\n\t\t}\n\t\tkcp.parse_una(una)\n\t\tkcp.shrink_buf()\n\n\t\tif cmd == IKCP_CMD_ACK {\n\t\t\tkcp.parse_ack(sn)\n\t\t\tkcp.parse_fastack(sn, ts)\n\t\t\tflag |= 1\n\t\t\tlatest = ts\n\t\t} else if cmd == IKCP_CMD_PUSH {\n\t\t\tif _itimediff(sn, kcp.rcv_nxt+kcp.rcv_wnd) < 0 {\n\t\t\t\tkcp.ack_push(sn, ts)\n\t\t\t\tif _itimediff(sn, kcp.rcv_nxt) >= 0 {\n\t\t\t\t\tseg := kcp.newSegment(int(length))\n\t\t\t\t\tseg.conv = conv\n\t\t\t\t\tseg.cmd = cmd\n\t\t\t\t\tseg.frg = frg\n\t\t\t\t\tseg.wnd = wnd\n\t\t\t\t\tseg.ts = ts\n\t\t\t\t\tseg.sn = sn\n\t\t\t\t\tseg.una = una\n\t\t\t\t\tseg.data.Write(data[:length]) // delayed data copying\n\t\t\t\t\tkcp.parse_data(seg)\n\t\t\t\t\t//repeat = kcp.parse_data(seg)\n\t\t\t\t}\n\t\t\t}\n\t\t\t//if regular && repeat {\n\t\t\t//\tatomic.AddUint64(&DefaultSnmp.RepeatSegs, 1)\n\t\t\t//}\n\t\t} else if cmd == IKCP_CMD_WASK {\n\t\t\t// ready to send back IKCP_CMD_WINS in Ikcp_flush\n\t\t\t// tell remote my window size\n\t\t\tkcp.probe |= IKCP_ASK_TELL\n\t\t} else if cmd == IKCP_CMD_WINS {\n\t\t\t// do nothing\n\t\t} else if cmd == IKCP_CMD_SYN {\n\t\t\tfmt.Println(\"recv SYN\")\n\t\t\t//kcp.ack_push(sn, ts)\n\t\t\tif !kcp.syn {\n\t\t\t\tkcp.syn = true\n\t\t\t\tkcp.rcv_nxt++\n\t\t\t}\n\t\t} else if cmd == IKCP_CMD_CLOSE {\n\t\t\tkcp.close_second = true\n\t\t\tif kcp.close_first {\n\t\t\t\tkcp.close_confirm = true\n\t\t\t}\n\t\t} else if cmd == IKCP_CMD_CLOSE_CONFIRM {\n\t\t\tif kcp.close_confirm {\n\t\t\t\tkcp.close_final = true\n\t\t\t\tkcp.state = IKCP_STATE_EOF\n\t\t\t} else {\n\t\t\t\tkcp.close_confirm = true\n\t\t\t}\n\t\t\treturn 0\n\t\t} else if cmd == IKCP_CMD_RESET {\n\t\t\tkcp.close_final = true\n\t\t\tkcp.state = -IKCP_STATE_RESET\n\t\t} else {\n\t\t\treturn -3\n\t\t}\n\n\t\tdata = data[length:]\n\t}\n\t//atomic.AddUint64(&DefaultSnmp.InSegs, inSegs)\n\n\t// update rtt with the latest ts\n\t// ignore the FEC packet\n\tif flag != 0 && regular {\n\t\tcurrent := currentMs()\n\t\tif _itimediff(current, latest) >= 0 {\n\t\t\tkcp.update_ack(_itimediff(current, latest))\n\t\t}\n\t}\n\n\t// cwnd update when packet arrived\n\tif kcp.nocwnd == 0 {\n\t\tif _itimediff(kcp.snd_una, snd_una) > 0 {\n\t\t\tif kcp.cwnd < kcp.rmt_wnd {\n\t\t\t\tmss := kcp.mss\n\t\t\t\tif kcp.cwnd < kcp.ssthresh {\n\t\t\t\t\tkcp.cwnd++\n\t\t\t\t\tkcp.incr += mss\n\t\t\t\t} else {\n\t\t\t\t\tif kcp.incr < mss {\n\t\t\t\t\t\tkcp.incr = mss\n\t\t\t\t\t}\n\t\t\t\t\tkcp.incr += (mss*mss)/kcp.incr + (mss / 16)\n\t\t\t\t\tif (kcp.cwnd+1)*mss <= kcp.incr {\n\t\t\t\t\t\tkcp.cwnd++\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif kcp.cwnd > kcp.rmt_wnd {\n\t\t\t\t\tkcp.cwnd = kcp.rmt_wnd\n\t\t\t\t\tkcp.incr = kcp.rmt_wnd * mss\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif !kcp.syn {\n\t\treturn 0\n\t}\n\n\treturn 0\n}", "func (io IOHarness) SendInput(i int64) {\n\tio.in <- i\n}", "func makeInputDevice(phaseSetting uint, ch <-chan int) func() int {\n\tcallCount := 0\n\treturn func() (n int) {\n\t\tdefer func() { callCount++ }()\n\t\tif callCount == 0 {\n\t\t\tn = int(phaseSetting)\n\t\t} else {\n\t\t\tn = <-ch\n\t\t}\n\t\treturn\n\t}\n}", "func (k *ProducerNode) Input() chan<- []*ProducerMsg {\n\treturn k.incoming\n}", "func (d *DSP) NumInputs() (int, error) {\n\tvar numinputs C.int\n\tres := C.FMOD_DSP_GetNumInputs(d.cptr, &numinputs)\n\treturn int(numinputs), errs[res]\n}", "func (tv TV) GetInput() (string, error) {\n\treturn tv.send(\"IAVD\", \"?\")\n}", "func (in *TransferableInput) Input() Transferable { return in.In }", "func (c *Client) CurrentInput() (Input, error) {\n\treq, err := http.NewRequest(http.MethodGet, \"/menu_native/dynamic/tv_settings/devices/current_input\", nil)\n\tif err != nil {\n\t\treturn Input{}, err\n\t}\n\n\tvar resp respCurrentInput\n\tif err = c.do(req, &resp); err != nil {\n\t\treturn Input{}, err\n\t}\n\n\treturn resp.input(), nil\n}", "func (module *OscModule) DSP(timestamp int64) {\n\tbuflen := module.GetBufferLength()\n\tsr := module.GetSampleRate()\n\n\tvar pmodInput []float64\n\tvar fmodInput []float64\n\tvar ampInput []float64\n\n\toutput := module.Outlets[0].Buffer\n\n\t// Check if inlet is connected for phase modulation\n\tif module.Inlets[0].Connections.Len() > 0 {\n\t\tpmodInput = module.Inlets[0].Buffer\n\t}\n\n\tif module.Inlets[1].Connections.Len() > 0 {\n\t\tfmodInput = module.Inlets[1].Buffer\n\t}\n\n\tif module.Inlets[2].Connections.Len() > 0 {\n\t\tampInput = module.Inlets[2].Buffer\n\t}\n\n\tfor i := int32(0); i < buflen; i++ {\n\t\tpmod := 0.0\n\n\t\tif pmodInput != nil {\n\t\t\tpmod = pmodInput[i]\n\t\t}\n\n\t\tif fmodInput != nil {\n\t\t\tinc := fmodInput[i] / sr\n\t\t\tmodule.Inc = inc\n\t\t}\n\n\t\tif ampInput != nil {\n\t\t\tamp := ampInput[i]\n\t\t\tmodule.Amplitude = amp\n\t\t}\n\n\t\toutput[i] = module.Process(pmod)\n\t}\n}", "func (s *Sink) InputDim() int {\n\treturn s.inputDim\n}", "func (e *Engine) DefaultInputDevice() *portaudio.DeviceInfo {\n\tif !e.initialized {\n\t\treturn nil\n\t}\n\tif defaultInputDeviceInfo, err := portaudio.DefaultInputDevice(); err != nil {\n\t\treturn nil\n\t} else {\n\t\treturn defaultInputDeviceInfo\n\t}\n}", "func (q *Queue) GetInputLength() int64 {\n\treturn q.redisClient.LLen(queueInputKey(q.Name)).Val()\n}", "func (queue *Queue) GetInputLength() int64 {\n\treturn queue.redisClient.LLen(queueInputKey(queue.Name)).Val()\n}", "func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uint32 {\n\tret, _, _ := syscall.Syscall(sendInput.Addr(), 3,\n\t\tuintptr(nInputs),\n\t\tuintptr(pInputs),\n\t\tuintptr(cbSize))\n\n\treturn uint32(ret)\n}", "func (a *Action) GetInput(i string) (*ActionInputItem, bool) {\n\tinput, ok := a.Input[i]\n\treturn input, ok\n}", "func (s ConsoleIndexStore) GetIndex(string) (i Index, e error) {\n\treturn IndexFromReader(os.Stdin)\n}", "func (c *Client) Input(i Input) error {\n\t// The hash of the _current_ input\n\t// is needed for the request\n\tcur, err := c.CurrentInput()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := reqInput{\n\t\tRequest: reqModify,\n\t\tHash: cur.Hash,\n\t\tValue: i.Name,\n\t}\n\n\tvar body bytes.Buffer\n\tif err := json.NewEncoder(&body).Encode(data); err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(http.MethodPut, \"/menu_native/dynamic/tv_settings/devices/current_input\", &body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// response contains no specific fields\n\treturn c.do(req, &respWrapper{})\n}", "func (ch *RingChannel) In() chan<- interface{} {\n\treturn ch.input\n}", "func (v *VpxEncoder) GetInputChan() chan *image.RGBA {\n\treturn v.Input\n}", "func (reader *Reader) GetInputMetadataAt(idx int) MetadataInterface {\n\treturn &reader.InputMetadata[idx]\n}", "func (bi *BaseInstance) Input() *dpdk.Ring {\n\treturn bi.input\n}", "func (bi *BaseInstance) Input() *dpdk.Ring {\n\treturn bi.input\n}", "func (p *pipe) inputAdvance(count int) {\n\tp.inPos += int32(count)\n\tif p.inPos >= p.size {\n\t\tp.inPos -= p.size\n\t}\n\tatomic.AddInt32(&p.free, -int32(count))\n\n\tselect {\n\tcase p.outWake <- struct{}{}:\n\tdefault:\n\t}\n}", "func (s *RC522Sensor) Input(common.Input) error {\n\treturn nil\n}", "func (self Source) BuffersQueued() int32 {\n\treturn self.Geti(AlBuffersQueued)\n}", "func (in *TransferableInput) Input() TransferableIn {\n\treturn in.In\n}", "func openIn(d Driver, number int, name string) (in In, err error) {\n\tins, err := d.Ins()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't find MIDI input ports: %v\", err)\n\t}\n\n\tif number >= 0 {\n\t\tfor _, port := range ins {\n\t\t\tif number == port.Number() {\n\t\t\t\tin = port\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", number)\n\t\t}\n\t} else {\n\t\tif name != \"\" {\n\t\t\tfor _, port := range ins {\n\t\t\t\tif strings.Contains(port.String(), name) {\n\t\t\t\t\tin = port\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", name)\n\t\t}\n\t}\n\n\t// should not happen here, since we already returned above\n\tif in == nil {\n\t\tpanic(\"unreachable\")\n\t}\n\n\terr = in.Open()\n\treturn\n}", "func (c *connection) getQueueLength(inputs input) (int, error) {\n\n\tif inputs.limit > 0 {\n\t\treturn inputs.limit, nil\n\t}\n\n\tqLength, err := redis.Int(conn.redis.Do(\"LLEN\", inputs.source))\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif qLength < 1 {\n\t\treturn 0, fmt.Errorf(\"Source queue is empty\")\n\t}\n\n\treturn qLength, nil\n}", "func ReadDeviceIndex(index int) (*Device, error) {\n\tdevices, err := ReadDeviceAll()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif n := len(devices) - 1; index < 0 || index > n {\n\t\treturn nil, errors.New(\"invalid index \" + strconv.Itoa(index))\n\t}\n\treturn devices[index], err\n}", "func (s *PacketDurationQueue) Front() float32 {\n\ts.lock.RLock()\n\titem := s.items[0]\n\ts.lock.RUnlock()\n\treturn item\n}", "func (n *NetworkInterface) Get() (string, error) {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\t//fmt.Println(\"qu len: \", len(n.Queue))\n\tif len(n.Queue) > 0 {\n\t\ttoReturn := n.Queue[0]\n\t\tn.Queue = n.Queue[1:]\n\t\treturn toReturn, nil\n\t}\n\treturn \"\", errors.New(\"Empty\")\n}", "func (mcq *MyCircularQueue) Front() int {\n\tif mcq.length == 0 {\n\t\treturn -1\n\t}\n\treturn mcq.dummyHead.Next.Val\n}", "func GetNextDeviceQueueItemForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, bool, error) {\n\tvar items []DeviceQueueItem\n\terr := sqlx.Select(db, &items, `\n select\n *\n from\n device_queue\n where\n dev_eui = $1\n order by\n f_cnt\n limit 2`,\n\t\tdevEUI[:],\n\t)\n\tif err != nil {\n\t\treturn DeviceQueueItem{}, false, handlePSQLError(err, \"select error\")\n\t}\n\n\tif len(items) == 0 {\n\t\treturn DeviceQueueItem{}, false, ErrDoesNotExist\n\t}\n\n\t// we are interested in the first item\n\tqi := items[0]\n\n\t// In case the transmission is pending and hasn't timed-out yet, do not\n\t// return it.\n\tif qi.IsPending && qi.TimeoutAfter != nil && qi.TimeoutAfter.After(time.Now()) {\n\t\treturn DeviceQueueItem{}, false, ErrDoesNotExist\n\t}\n\n\treturn qi, len(items) > 1, nil\n}", "func (self *Graphics) Input() interface{}{\n return self.Object.Get(\"input\")\n}", "func receiveInput(ctx context.Context, n *node) stateFn {\n\tif n.inputC == nil { // OMIT\n\t\treturn computeFwd // OMIT\n\t} // OMIT\n\tselect {\n\tcase <-ctx.Done():\n\t\tn.err = ctx.Err()\n\t\treturn nil // HL\n\tcase input := <-n.inputC:\n\t\tif input.pos >= len(n.inputValues) { // OMIT\n\t\t\tn.err = errors.New(\"bad arity\") // OMIT\n\t\t\treturn nil // OMIT\n\t\t} // OMIT\n\t\tn.receivedValues++ // OMIT\n\t\tn.inputValues[input.pos] = input.v // OMIT\n\t\tif !n.hasAllInput {\n\t\t\tif n.receivedValues < len(n.inputValues) { // OMIT\n\t\t\t\treturn receiveInput\n\t\t\t}\n\t\t} // OMIT\n\t}\n\treturn computeFwd\n}", "func GetInput(ctx context.Context, fd int) (<-chan Event, func() error, error) {\n\tch := make(chan Event, 1000)\n\tst, err := terminal.GetState(fd)\n\tif err != nil {\n\t\treturn nil, func() error { return nil }, err\n\t}\n\trestore := func() error { return terminal.Restore(fd, st) }\n\n\t_, err = terminal.MakeRaw(fd)\n\tif err != nil {\n\t\treturn nil, restore, err\n\t}\n\n\tib := inputBuf{b: make([]byte, 0, 9)}\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase ev := <-ib.readEvent(fd):\n\t\t\t\tch <- ev\n\t\t\t}\n\t\t}\n\t}()\n\treturn ch, restore, nil\n}", "func Input(ctx context.Context, s *testing.State) {\n\ttconn := s.FixtValue().(*utils.FixtureData).Tconn\n\n\t// Since virtual keyboard with BUS_USB (0x03) doesn't work yet, use BUS_I2C (0x18).\n\t// See https://crrev.com/c/1407138 for more discussion.\n\tvkb, err := input.VirtualKeyboardWithBusType(ctx, 0x18)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to create a virtual keyboard: \", err)\n\t}\n\tdefer vkb.Close()\n\n\t// Find the Input navigation item and the keyboard list heading.\n\tconst timeout = 10 * time.Second\n\tpollOpts := testing.PollOptions{Interval: time.Second, Timeout: timeout}\n\tui := uiauto.New(tconn)\n\tinputTab := da.DxInput.Ancestor(da.DxRootNode)\n\tkeyboardListHeading := da.DxKeyboardHeading.Ancestor(da.DxRootNode)\n\tif err := uiauto.Combine(\"find the keyboard list heading\",\n\t\tui.WithTimeout(timeout).WaitUntilExists(inputTab),\n\t\tui.WithPollOpts(pollOpts).LeftClick(inputTab),\n\t\tui.WithTimeout(timeout).WaitUntilExists(keyboardListHeading),\n\t)(ctx); err != nil {\n\t\ts.Fatal(\"Failed to find the keyboard list heading: \", err)\n\t}\n}", "func (w *RecvWindow) Input(msg *protobuf.Message) error {\n\tw.Lock()\n\tdefer w.Unlock()\n\n\toffset := int(msg.MessageNonce - w.messageNonce)\n\n\tif offset < 0 || offset >= w.size {\n\t\treturn errors.Errorf(\"Local message nonce is %d while received %d\", w.messageNonce, msg.MessageNonce)\n\t}\n\n\t*w.buffer.Index(offset) = msg\n\treturn nil\n}", "func (o *OscSync) Process(Frq float32, Syn float32, Pse float32) (Out float32) {\n\tif Pse > 1 {\n\t\tPse = 1\n\t} else if Pse < -1 {\n\t\tPse = -1\n\t}\n\n\tindex := o.currentSample + Pse*o.sampleRate\n\tif index >= o.sampleRate {\n\t\tindex -= o.sampleRate\n\t} else if index < 0 {\n\t\tindex += o.sampleRate\n\t}\n\n\tOut = o.waveTable[o.Waveform][int(index)]\n\n\to.currentSample += Frq\n\tif o.currentSample >= o.sampleRate {\n\t\to.currentSample -= o.sampleRate\n\t\t// fmt.Println(o.currentSample, Pse*Frq)\n\t}\n\n\treturn\n}", "func (mq *MediaQuery) FirstIDX(ctx context.Context) int {\n\tid, err := mq.FirstID(ctx)\n\tif err != nil && !IsNotFound(err) {\n\t\tpanic(err)\n\t}\n\treturn id\n}", "func (e *EventQueue) FireInput(m *message.NetworkInput) {\n\trequest := &InputRequest{\n\t\tpayload: m,\n\t\tsubscribers: e.InputListeners,\n\t}\n\te.secondaryQ <- request\n}", "func (v *VRF) Input() *dpdk.Ring {\n\treturn v.router.base.Input()\n}", "func (q *SliceQueue) Front() interface{} {\n\tif q.IsEmpty() {\n\t\treturn nil\n\t}\n\n\treturn q.Data[0]\n}", "func UDPIn() chan<- *inbound.PacketAdapter {\n\treturn udpQueue\n}", "func (this *MyQueue) Peek() int {\n\tif this.out.Len() == 0 {\n\t\tfor v := this.in.Pop(); v != nil; v = this.in.Pop() {\n\t\t\tthis.out.Push(v)\n\t\t}\n\t}\n\treturn this.out.Peek().(int)\n}", "func (n *noise) Play(index int) {\n\tif n.loaded && index >= 0 && index < len(n.snds) {\n\t\tsnd := n.snds[index]\n\t\tif p, ok := n.eng.povs[n.eid]; ok {\n\t\t\tx, y, z := p.Location()\n\t\t\tgo func(sid uint64, x, y, z float64) {\n\t\t\t\tn.eng.machine <- &playSound{sid: sid, x: x, y: y, z: z}\n\t\t\t}(snd.sid, x, y, z)\n\t\t}\n\t}\n}", "func (memif *Memif) GetQueueInterruptChan(queueID uint8) (ch <-chan struct{}, err error) {\n\tif int(queueID) >= len(memif.queueIntCh) {\n\t\treturn nil, ErrQueueID\n\t}\n\treturn memif.queueIntCh[queueID], nil\n}", "func (p *ConcurrentServer) InputTransportFactory() TransportFactory {\n\treturn p.inputTransportFactory\n}", "func reader() {\n\n\tvar err error\n\n\tdefer func() {\n\t\tclose(EncodeChan)\n\t\tWaitGroup.Done()\n\t}()\n\n\t// Create a 16KB input buffer\n\tstdin := bufio.NewReaderSize(os.Stdin, 16384)\n\n\t// Loop over the stdin input and pass the data to the encoder.\n\tfor {\n\n\t\tbuf := make([]int16, AudioFrameSize*AudioChannels)\n\n\t\terr = binary.Read(stdin, binary.LittleEndian, &buf)\n\t\tif err == io.EOF {\n\t\t\t// Okay! There's nothing left, time to quit.\n\t\t\treturn\n\t\t}\n\n\t\tif err == io.ErrUnexpectedEOF {\n\t\t\t// Well there's just a tiny bit left, lets encode it, then quit.\n\t\t\tEncodeChan <- buf\n\t\t\treturn\n\t\t}\n\n\t\tif err != nil {\n\t\t\t// Oh no, something went wrong!\n\t\t\tlog.Println(\"error reading from stdin,\", err)\n\t\t\treturn\n\t\t}\n\n\t\t// write pcm data to the EncodeChan\n\t\tEncodeChan <- buf\n\t}\n\n}", "func (this *Handler) Chan() chan inputs.Data {\n\treturn this.in\n}", "func InputArtnetUniverse(addr ArtnetAddress) (chan dmx.DMXFrame, error) {\n\n // Initialise the input channel list if needed \n if inputUniverseChannels == nil {\n inputUniverseChannels = make(map[uint16] chan dmx.DMXFrame)\n }\n\n // Build the Art-Net encoded address for lookup\n portAddr := addr.Encode()\n\n // Check if an output channel already exists\n _, exists := inputUniverseChannels[portAddr]\n\n if exists {\n return nil, errors.New(\"Universe already has a channel\")\n }\n\n // Build store and return a new channel\n dmx := make(chan dmx.DMXFrame)\n inputUniverseChannels[portAddr] = dmx\n return dmx, nil\n}", "func (dq *Dqueue) Front() (value interface{}, ok bool) {\n\tvalue, ok = dq.dqueue.Get(0)\n\treturn\n}", "func (mb *client) ReadDiscreteInputs(address, quantity uint16) (results []byte, err error) {\n\tif quantity < 1 || quantity > 2000 {\n\t\terr = fmt.Errorf(\"modbus: quantity '%v' must be between '%v' and '%v',\", quantity, 1, 2000)\n\t\treturn\n\t}\n\trequest := ProtocolDataUnit{\n\t\tFunctionCode: FuncCodeReadDiscreteInputs,\n\t\tData: dataBlock(address, quantity),\n\t}\n\tresponse, err := mb.send(&request)\n\tif err != nil {\n\t\treturn\n\t}\n\tcount := int(response.Data[0])\n\tlength := len(response.Data) - 1\n\tif count != length {\n\t\terr = fmt.Errorf(\"modbus: response data size '%v' does not match count '%v'\", length, count)\n\t\treturn\n\t}\n\tresults = response.Data[1:]\n\treturn\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func (signer *TxSigner) Input(nInput int, signData *InputSignData) (*InputSigner, error) {\n\tsigner.Lock()\n\tdefer signer.Unlock()\n\n\tif inputSigner, exists := signer.vSigner[nInput]; exists {\n\t\treturn inputSigner, nil\n\t}\n\n\tnumInputs := len(signer.tx.TxIn)\n\tif nInput < 0 || nInput > numInputs {\n\t\treturn nil, errors.Errorf(\"Requested out of range input %d, but transaction has %d\", nInput, numInputs)\n\t}\n\n\tinputSigner, err := signer.makeInput(nInput, signData)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsigner.vSigner[nInput] = inputSigner\n\n\treturn inputSigner, nil\n}", "func (rb *RingBuffer) Get(index int) (ans stats.Record) {\n\trb.lock.RLock()\n\tdefer rb.lock.RUnlock()\n\tif index < 0 {\n\t\tindex = len(rb.data) + index\n\t}\n\treturn rb.data[(rb.seq+uint64(index))%uint64(len(rb.data))]\n}", "func GetInputProgram() []int {\n\treturn ProcessInput(input)\n}", "func (w *Wire) Input() *Gate {\n\treturn w.input\n}", "func (p *pipe) inputWait() (int32, error) {\n\tfor {\n\t\tsafeFree := atomic.LoadInt32(&p.free)\n\n\t\t// If the buffer is full, spin lock to give it another chance\n\t\tfor i := 0; safeFree == 0 && i < maxSpin; i++ {\n\t\t\truntime.Gosched()\n\t\t\tsafeFree = atomic.LoadInt32(&p.free)\n\t\t}\n\t\t// If still full, go down into deep sleep\n\t\tif safeFree == 0 {\n\t\t\tselect {\n\t\t\tcase <-p.inWake: // wake signal from output, retry\n\t\t\t\tcontinue\n\n\t\t\tcase <-p.outQuit: // output dead, return\n\t\t\t\treturn safeFree, ErrClosedPipe\n\n\t\t\tcase <-p.inQuit: // input closed prematurely\n\t\t\t\treturn safeFree, ErrClosedPipe\n\t\t\t}\n\t\t}\n\t\treturn safeFree, nil\n\t}\n}", "func (o *AudioStreamSample) GetMixRate() gdnative.Int {\n\t//log.Println(\"Calling AudioStreamSample.GetMixRate()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"AudioStreamSample\", \"get_mix_rate\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (memif *Memif) GetInterruptChan() (ch <-chan uint8 /* queue ID */) {\n\treturn memif.intCh\n}", "func (q *queue) Front() (interface{}, error) {\n\tif q.Empty() {\n\t\treturn nil, errors.New(\"error: can not get element from empty queue\")\n\t}\n\treturn q.items[q.head].Data, nil\n}", "func (queueslice *QueueSlice) QueueFront() int {\n\tlength := len(queueslice.Q)\n\tif length == 0 {\n\t\tfmt.Println(\"Q is empty\")\n\t\treturn -1\n\t}\n\n\treturn queueslice.Q[0]\n}", "func (m *Processor) Process(pipeID string, sampleRate signal.SampleRate, numChannels int) (func(signal.Float64) error, error) {\n\treturn func(b signal.Float64) error {\n\t\tif m.ErrorOnCall != nil {\n\t\t\treturn m.ErrorOnCall\n\t\t}\n\t\tm.advance(b.Size())\n\t\treturn nil\n\t}, nil\n}", "func(q *Queue)GetFront()int{\n\tif q.IsEmpty() {\n\t\tpanic(\"Get front error.queue is empty\")\n\t}\n\treturn q.arr[q.front]\n}", "func FirstRunningDevice(ctx context.Context, streamType audio.StreamType) (string, error) {\n\tvar re *regexp.Regexp\n\tif streamType == audio.InputStream {\n\t\tre = regexp.MustCompile(\"Input dev: (.*)\")\n\t} else if streamType == audio.OutputStream {\n\t\tre = regexp.MustCompile(\"Output dev: (.*)\")\n\t} else {\n\t\treturn \"\", errors.Errorf(\"unsupported StreamType %d\", streamType)\n\t}\n\n\tvar devName string\n\tif err := testing.Poll(ctx, func(ctx context.Context) error {\n\t\ttesting.ContextLog(ctx, \"Dump audio thread to check running devices\")\n\t\tdump, err := testexec.CommandContext(ctx, \"cras_test_client\", \"--dump_audio_thread\").Output()\n\t\tif err != nil {\n\t\t\treturn testing.PollBreak(errors.Errorf(\"failed to dump audio thread: %s\", err))\n\t\t}\n\n\t\tdev := re.FindStringSubmatch(string(dump))\n\t\tif dev == nil {\n\t\t\treturn errors.New(\"no such device\")\n\t\t}\n\n\t\tdevName = dev[1]\n\t\treturn nil\n\t}, &testing.PollOptions{Timeout: 3 * time.Second}); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn devName, nil\n}", "func (k Keyboard) ProcessInput() Input {\n\tinput := Input{0,0,0,0}\n\n\t// Thrust\n\tif k.keyState.Pressed(window.KeyA){\n\t\tinput.Thrust++\n\t}\n\tif k.keyState.Pressed(window.KeyZ){\n\t\tinput.Thrust--\n\t}\n\n\t// Pitch\n\tif k.keyState.Pressed(window.KeyUp){\n\t\tinput.Pitch++\n\t}\n\tif k.keyState.Pressed(window.KeyDown){\n\t\tinput.Pitch--\n\t}\n\n\t// Yaw\n\tif k.keyState.Pressed(window.KeyE){\n\t\tinput.Yaw++\n\t}\n\tif k.keyState.Pressed(window.KeyQ){\n\t\tinput.Yaw--\n\t}\n\n\t// Roll\n\tif k.keyState.Pressed(window.KeyRight){\n\t\tinput.Roll++\n\t}\n\tif k.keyState.Pressed(window.KeyLeft){\n\t\tinput.Roll--\n\t}\n\n\treturn input\n}", "func (c *Comics) Index(comicNum int) int {\n\tresult, _ := c.Get(comicNum)\n\n\treturn result\n}", "func InoutAlloc() *Input {\n\treturn (*Input)(C.avfilter_inout_alloc())\n}", "func getInput(input chan string) {\n for {\n reader := bufio.NewReader(os.Stdin)\n d,_ := reader.ReadString('\\n')\n input <- d\n }\n}", "func (s *BasevhdlListener) EnterWaveform_element(ctx *Waveform_elementContext) {}", "func (_Casper *CasperCaller) Index(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Casper.contract.Call(opts, out, \"index\")\n\treturn *ret0, err\n}", "func sq(in <-chan int) <-chan int {\n\tout := make(chan int)\n\tgo func() {\n\t\tfor n := range in {\n\t\t\tout <- n * n\n\t\t}\n\t\tclose(out)\n\t}()\n\treturn out\n}", "func InputSource(in Input) sound.Source {\n\treturn &chn{\n\t\tForm: in,\n\t\tin: in,\n\t\tch: in.C()}\n}", "func (fmp *FlatMap) InputChan() chan<- interface{} {\n\treturn fmp.in\n}", "func (ps *PrimeStore) GetByIndex(nth uint64) (n uint64) {\n\tdefer Tracer(NewTrace(\"GetByIndex\"))\n\n\tn = 0\n\tif nth < ps.base || nth >= (ps.base+ps.count) {\n\t\tlog.Print(\"out of range.\", nth, \" \", ps)\n\t\treturn\n\t}\n\n\tn = ps.index[nth-ps.base]\n\treturn\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 get_song_selection() (int, string) {\n\tsongs := strings.Split(master_list, \"\\n\")\n\tvar ip string\n\n\tui := &input.UI{\n\t\tWriter: os.Stdout,\n\t\tReader: os.Stdin,\n\t}\n\tquery := \"Select a song\"\n\tid, _ := ui.Ask(query, &input.Options{\n\t\tValidateFunc: func(id string) error {\n\t\t\tfor _, s := range songs {\n\t\t\t\tsong_id := strings.Split(s, \":\")[0]\n\t\t\t\tif song_id == id {\n\t\t\t\t\tip = strings.SplitN(s, \":\", 3)[1][1:]\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"song id not here\")\n\t\t},\n\t\tLoop: true,\n\t})\n\tret, _ := strconv.ParseInt(id, 10, 32)\n\treturn int(ret), ip + \":\"\n}", "func (c *FromCommand) Index() int {\n\treturn c.cmd.index\n}", "func (d *DSP) Type() (DSPType, error) {\n\tvar typ C.FMOD_DSP_TYPE\n\tres := C.FMOD_DSP_GetType(d.cptr, &typ)\n\treturn DSPType(typ), errs[res]\n}", "func (device *SilentStepperBrick) GetExternalInputVoltage() (voltage uint16, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetExternalInputVoltage), buf.Bytes())\n\tif err != nil {\n\t\treturn voltage, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 10 {\n\t\t\treturn voltage, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 10)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn voltage, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &voltage)\n\n\t}\n\n\treturn voltage, nil\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func sq(in <-chan int) chan int {\n\tout := make(chan int)\n\tgo func() {\n\t\tfor n := range in {\n\t\t\tout <- n * n\n\t\t}\n\t\tclose(out)\n\t}()\n\treturn out\n}", "func (d *Dev) ReadContinuous() <-chan analog.Sample {\n\td.mu.Lock()\n\tdefer d.mu.Unlock()\n\tif d.done != nil {\n\t\treturn nil\n\t}\n\tdone := make(chan struct{})\n\tret := make(chan analog.Sample)\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\tclose(ret)\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tvalue, err := d.ReadTimeout(time.Second)\n\t\t\t\tif err == nil {\n\t\t\t\t\tret <- analog.Sample{Raw: value}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\td.done = done\n\treturn ret\n}", "func (p *Payload) GetOutDev() uint32 {\n\treturn uint32(C.nfq_get_outdev(p.nfad))\n}", "func (j *JustAddPowerReciever) AudioVideoInputs(ctx context.Context) (map[string]string, error) {\n\ttoReturn := make(map[string]string)\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", j.Address)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tj.Log.Debug(\"ip address\", zap.Any(\"IP\", ipAddress.IP))\n\n\tif err != nil {\n\t\treturn toReturn, fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", j.Address, err)\n\t}\n\n\tresult, err := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/details/channel\", j.Address), \"\", \"GET\")\n\n\tif err != nil {\n\t\tj.Log.Debug(\"error when making request\", zap.Error(err))\n\t\treturn toReturn, fmt.Errorf(\"error when making request: %w\", err)\n\t}\n\n\tvar jsonResult JustAddPowerChannelIntResult\n\tgerr := json.Unmarshal(result, &jsonResult)\n\tif gerr != nil {\n\t\tj.Log.Debug(\"error unmarshaling response\", zap.Error(gerr))\n\t\treturn toReturn, fmt.Errorf(\"error when unmarshaling response: %w\", gerr)\n\t}\n\n\tj.Log.Debug(\"Result\", zap.Any(\"result\", result), zap.Any(\"jsonResult\", jsonResult))\n\tj.Log.Debug(\"len of IP\", zap.Int(\"lenght\", len(ipAddress.IP)))\n\n\ttransmissionChannel := fmt.Sprintf(\"%v.%v.%v.%v\",\n\t\tipAddress.IP[0], ipAddress.IP[1], ipAddress.IP[2], jsonResult.Data)\n\n\ttoReturn[\"\"] = transmissionChannel\n\treturn toReturn, nil\n}", "func (p *Concatenator) In() *scipipe.InPort { return p.InPort(\"in\") }", "func (this *MyCircularQueue) Front() int {\n\tif this.Count == 0 {\n\t\treturn -1\n\t}\n\treturn this.Queue[this.Head]\n}", "func (this *MyQueue) Peek() int {\n\tif len(this.out) != 0 {\n\t\treturn this.out[len(this.out)-1]\n\t}\n\tfor len(this.in) > 0 {\n\t\tthis.out.Push(this.in.Pop())\n\t}\n\treturn this.out[len(this.out)-1]\n}" ]
[ "0.554022", "0.49184617", "0.4911302", "0.48565173", "0.48452535", "0.4843511", "0.48085755", "0.47639212", "0.46928218", "0.45798331", "0.45692715", "0.45388374", "0.45336694", "0.45282397", "0.45144767", "0.45136064", "0.44995886", "0.449156", "0.44863084", "0.44710955", "0.44417417", "0.44315267", "0.4431334", "0.4398865", "0.43936607", "0.4347959", "0.43360293", "0.43317562", "0.43293542", "0.43180004", "0.42436516", "0.42427883", "0.42427883", "0.4229684", "0.42068547", "0.41824427", "0.41776592", "0.41690308", "0.4137312", "0.41292018", "0.41290677", "0.4108031", "0.41027296", "0.4097668", "0.4077704", "0.4065513", "0.40639788", "0.40612137", "0.4048364", "0.40419158", "0.40374228", "0.40296233", "0.40243563", "0.40229756", "0.40218544", "0.4019832", "0.40178892", "0.4003192", "0.39997473", "0.39904666", "0.39876416", "0.39825064", "0.3982142", "0.39759332", "0.39732292", "0.39651126", "0.39633307", "0.39511964", "0.39468393", "0.3942059", "0.39393932", "0.3935552", "0.39306274", "0.3927965", "0.39194143", "0.391544", "0.39134118", "0.39107078", "0.39069152", "0.3906026", "0.39059502", "0.3904094", "0.3901867", "0.38975114", "0.38909787", "0.38782492", "0.38768896", "0.38766587", "0.38746792", "0.38712683", "0.38707665", "0.38634542", "0.3862029", "0.3861296", "0.3850715", "0.38502303", "0.38486144", "0.38478154", "0.38470674", "0.38463432" ]
0.7636755
0
Retrieves a pointer to a DSP unit which is acting as an output to this unit. index: Index of the output unit to retrieve. An output is a unit which this unit will feed data too once it has processed its data. Find out the number of output units to this unit by calling "DSP.NumOutputs". Performance warning! Because this function needs to flush the dsp queue before it can determine if the specified numerical output is available or not, this function may block significantly while the background mixer thread operates. Note: The connection pointer retrieved here will become invalid if you disconnect the 2 dsp units that use it.
func (d *DSP) Output(index int) (DSP, DspConnection, error) { var output DSP var outputconnection DspConnection res := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr) return output, outputconnection, errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (a *DS345) OutputCount() int {\n\treturn len(a.Channels)\n}", "func (e *Engine) DefaultOutputDevice() *portaudio.DeviceInfo {\n\tif !e.initialized {\n\t\treturn nil\n\t}\n\tif defaultOutputDeviceInfo, err := portaudio.DefaultOutputDevice(); err != nil {\n\t\treturn nil\n\t} else {\n\t\treturn defaultOutputDeviceInfo\n\t}\n}", "func (md *MassDns) GetOutput() <-chan dns.RR {\n\toc := md.output\n\treturn oc\n}", "func (dev *E36xx) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (dev *PMX) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func (d *Drain) GetOutput() <-chan interface{} {\n\treturn d.output\n}", "func (self *ResTransaction)GetOutputAt(i int)*TrOutput{\n return &self.Output\n}", "func (n *Net) Out(i int) float64 {\n\treturn n.out[len(n.lsize)-1][i]\n}", "func (d *Dry) OuputChannel() <-chan string {\n\treturn d.output\n}", "func (d *Dry) OuputChannel() <-chan string {\n\treturn d.output\n}", "func (v *VpxEncoder) GetOutputChan() chan []byte {\n\treturn v.Output\n}", "func (io IOHarness) GetOutput(errc chan error) (int64, bool, error) {\n\tselect {\n\tcase value, ok := <-io.out:\n\t\tif !ok {\n\t\t\terr := fmt.Errorf(\"output closed unexpectedly\")\n\t\t\treturn -1, false, err\n\t\t}\n\t\treturn value, true, nil\n\tcase err, ok := <-errc:\n\t\tif !ok {\n\t\t\terr = fmt.Errorf(\"errc closed unexpectedly\")\n\t\t}\n\t\treturn -1, false, err\n\t}\n}", "func (net Network) GetOutputValue() float64 {\n\treturn net[len(net)-1][0].value\n}", "func (p *Payload) GetOutDev() uint32 {\n\treturn uint32(C.nfq_get_outdev(p.nfad))\n}", "func makeOutputDevice(ch chan<- int) func(int) {\n\treturn func(n int) {\n\t\tch <- n\n\t}\n}", "func (sub *BufferedSubscription[T]) Out() <-chan T {\n\treturn sub.result\n}", "func (out *TransferableOutput) Output() Transferable { return out.Out }", "func HandleOut(em *Emulator, a int, b int) {\n data := em.GetReg(a)\n addr := em.GetReg(b)\n \n if em.getPortAccess(addr) {\n em.StoreIOPort(addr, data)\n em.LogInstruction(\"out %s, %s -- ports[0x%02X] = 0x%02X\", RegisterNames[b],\n RegisterNames[a], addr, data)\n \n } else {\n em.LogInstruction(\"out %s, %s -- not authorised\", RegisterNames[b], RegisterNames[a])\n }\n \n em.timer += 5;\n}", "func (self *Script) getOutputIdxByName(name string) int {\n for i, def := range self.OutputDefs {\n if def.Name == name {\n return i\n }\n }\n return -1\n}", "func (a aio) output() float64 {\n\tsCh := make(chan float64)\n\ta.oCh <- sCh\n\treturn <-sCh\n}", "func (p *FuncInfo) Out(i int) exec.Var {\n\treturn p.out[i]\n}", "func (s *Sink) OutputDim() int {\n\treturn s.outputDim\n}", "func OutByNumber(portNumber int) (out Out, err error) {\n\tdrv := Get()\n\tif drv == nil {\n\t\treturn nil, fmt.Errorf(\"no driver registered\")\n\t}\n\treturn openOut(drv, portNumber, \"\")\n}", "func (c *NetClient) OutQueue() chan<- []byte {\n\treturn c.outQueue\n}", "func (o ElastigroupNetworkInterfaceOutput) DeviceIndex() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupNetworkInterface) string { return v.DeviceIndex }).(pulumi.StringOutput)\n}", "func (a *AxonShiftDelay) Output() int {\n\t// Capture output first\n\tif a.delay == 1 {\n\t\treturn int(a.register)\n\t}\n\n\tif int(a.register&a.delay) > 0 {\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func openOut(d Driver, number int, name string) (out Out, err error) {\n\touts, err := d.Outs()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't find MIDI output ports: %v\", err)\n\t}\n\n\tif number >= 0 {\n\t\tfor _, port := range outs {\n\t\t\tif number == port.Number() {\n\t\t\t\tout = port\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif out == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI output port %v\", number)\n\t\t}\n\t} else {\n\t\tif name != \"\" {\n\t\t\tfor _, port := range outs {\n\t\t\t\tif strings.Contains(port.String(), name) {\n\t\t\t\t\tout = port\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif out == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI output port %v\", name)\n\t\t}\n\t}\n\n\t// should not happen here, since we already returned above\n\tif out == nil {\n\t\tpanic(\"unreachable\")\n\t}\n\n\terr = out.Open()\n\treturn\n}", "func (module *OscModule) DSP(timestamp int64) {\n\tbuflen := module.GetBufferLength()\n\tsr := module.GetSampleRate()\n\n\tvar pmodInput []float64\n\tvar fmodInput []float64\n\tvar ampInput []float64\n\n\toutput := module.Outlets[0].Buffer\n\n\t// Check if inlet is connected for phase modulation\n\tif module.Inlets[0].Connections.Len() > 0 {\n\t\tpmodInput = module.Inlets[0].Buffer\n\t}\n\n\tif module.Inlets[1].Connections.Len() > 0 {\n\t\tfmodInput = module.Inlets[1].Buffer\n\t}\n\n\tif module.Inlets[2].Connections.Len() > 0 {\n\t\tampInput = module.Inlets[2].Buffer\n\t}\n\n\tfor i := int32(0); i < buflen; i++ {\n\t\tpmod := 0.0\n\n\t\tif pmodInput != nil {\n\t\t\tpmod = pmodInput[i]\n\t\t}\n\n\t\tif fmodInput != nil {\n\t\t\tinc := fmodInput[i] / sr\n\t\t\tmodule.Inc = inc\n\t\t}\n\n\t\tif ampInput != nil {\n\t\t\tamp := ampInput[i]\n\t\t\tmodule.Amplitude = amp\n\t\t}\n\n\t\toutput[i] = module.Process(pmod)\n\t}\n}", "func (out *TransferableOutput) Output() TransferableOut {\n\treturn out.Out\n}", "func (swp *SourceWorkerPool) GetOutputChannel() (chan map[string]interface{}, error) {\n\treturn swp.outputChannel, nil\n}", "func (d *DSP) NumOutputs() (int, error) {\n\tvar numoutputs C.int\n\tres := C.FMOD_DSP_GetNumOutputs(d.cptr, &numoutputs)\n\treturn int(numoutputs), errs[res]\n}", "func (ch *RingChannel) Out() <-chan interface{} {\n\treturn ch.output\n}", "func (m *Notify) Output(id types.CheckID) string {\n\tm.RLock()\n\tdefer m.RUnlock()\n\treturn m.output[id]\n}", "func DefaultOutputDevice() (*DeviceInfo, error) {\n\tdevs, err := Devices()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ti := C.Pa_GetDefaultOutputDevice()\n\tif i == C.paNoDevice {\n\t\treturn nil, NoDefaultOutputDevice\n\t}\n\tif i < 0 {\n\t\treturn nil, newError(C.PaError(i))\n\t}\n\treturn devs[i], nil\n}", "func (c *ConnectionMock) Out() chan []byte {\n\targs := c.Called()\n\treturn args.Get(0).(chan []byte)\n}", "func (o *DataExportQuery) GetUnitReference() int32 {\n\tif o == nil || o.UnitReference == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.UnitReference\n}", "func (m *Outpoint) GetValue() uint64 {\n\tif m != nil {\n\t\treturn m.Value\n\t}\n\treturn 0\n}", "func (_m *MockBackend) GetOutput(ctx context.Context, token common.Address, index uint64) (*types.UTXOOutputData, error) {\n\tret := _m.Called(ctx, token, index)\n\n\tvar r0 *types.UTXOOutputData\n\tif rf, ok := ret.Get(0).(func(context.Context, common.Address, uint64) *types.UTXOOutputData); ok {\n\t\tr0 = rf(ctx, token, index)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*types.UTXOOutputData)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, common.Address, uint64) error); ok {\n\t\tr1 = rf(ctx, token, index)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (o ArgoCDExportSpecStoragePtrOutput) Backend() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDExportSpecStorage) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Backend\n\t}).(pulumi.StringPtrOutput)\n}", "func (s *Server) txGetOutput(symbol string, txId string, height int64) *blocc.TxOut {\n\ttx, err := s.blockChainStore.GetTxByTxId(symbol, txId, blocc.TxIncludeOut)\n\tif err != nil {\n\t\treturn nil\n\t}\n\tif int64(len(tx.Out)) > height {\n\t\treturn tx.Out[height]\n\t}\n\treturn nil\n}", "func (o *OutputManager) GetOutput(outputID utxo.OutputID) (output *Output) {\n\toutput = o.getOutputFromWallet(outputID)\n\n\t// get output info via web api\n\tif output == nil {\n\t\tclt := o.connector.GetClient()\n\t\tout := clt.GetOutput(outputID)\n\t\tif out == nil {\n\t\t\treturn nil\n\t\t}\n\t\toutput = &Output{\n\t\t\tOutputID: out.ID(),\n\t\t\tAddress: out.Address(),\n\t\t\tBalance: out.Balances(),\n\t\t}\n\t}\n\n\treturn output\n}", "func (o SavedAttachedDiskResponseOutput) Index() pulumi.IntOutput {\n\treturn o.ApplyT(func(v SavedAttachedDiskResponse) int { return v.Index }).(pulumi.IntOutput)\n}", "func (o *KinesisOutput) GetOutputChannel() chan []byte {\n\treturn o.outputChannel\n}", "func (s Sequence) Output(c SeqChan) {s.Do(func(el El){c <- el})}", "func (q *chunkQueue) GetSender(index uint32) p2p.ID {\n\tq.Lock()\n\tdefer q.Unlock()\n\treturn q.chunkSenders[index]\n}", "func (p *Plexer) Out() <-chan []byte {\n\treturn p.output\n}", "func (sdkLogger SdkLogger) Output(calldepth int, s string) error {\n\tlog.WithField(\"type\", \"nsq driver\").Info(s)\n\treturn nil\n}", "func (p *Payload) GetPhysOutDev() uint32 {\n\treturn uint32(C.nfq_get_physoutdev(p.nfad))\n}", "func (all *Widgets) Output() *OutputWidget { return all.widgets[OutputWidgetName].(*OutputWidget) }", "func (o ArgoCDExportSpecStorageOutput) Backend() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDExportSpecStorage) *string { return v.Backend }).(pulumi.StringPtrOutput)\n}", "func outputData(outputChannel chan string) {\n\n\tfor {\n\t\tdata := <-outputChannel\n\t\tfmt.Println(data)\n\t}\n}", "func (self *Output) GetOutAction() openflow13.Action {\n\tswitch self.outputType {\n\tcase \"drop\":\n\t\treturn nil\n\tcase \"toController\":\n\t\toutputAct := openflow13.NewActionOutput(openflow13.P_CONTROLLER)\n\t\t// Dont buffer the packets being sent to controller\n\t\toutputAct.MaxLen = openflow13.OFPCML_NO_BUFFER\n\n\t\treturn outputAct\n\tcase \"normal\":\n\t\tfallthrough\n\tcase \"port\":\n\t\treturn openflow13.NewActionOutput(self.portNo)\n\t}\n\n\treturn nil\n}", "func (n *NetworkInterface) Get() (string, error) {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\t//fmt.Println(\"qu len: \", len(n.Queue))\n\tif len(n.Queue) > 0 {\n\t\ttoReturn := n.Queue[0]\n\t\tn.Queue = n.Queue[1:]\n\t\treturn toReturn, nil\n\t}\n\treturn \"\", errors.New(\"Empty\")\n}", "func (s *store) afterIndex(index uint64) <-chan struct{} {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\n\tif index < s.data.Data.Index {\n\t\t// Client needs update so return a closed channel.\n\t\tch := make(chan struct{})\n\t\tclose(ch)\n\t\treturn ch\n\t}\n\n\treturn s.dataChanged\n}", "func (res *SendResult) GetIndex() int64 {\n\treturn res.index\n}", "func (o *Block) GetDeviceNumber(ctx context.Context) (deviceNumber uint64, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceBlock, \"DeviceNumber\").Store(&deviceNumber)\n\treturn\n}", "func OutputSelector(outputType uint32) (serializer.Serializable, error) {\n\tvar seri serializer.Serializable\n\tswitch byte(outputType) {\n\tcase OutputSigLockedSingleOutput:\n\t\tseri = &SigLockedSingleOutput{}\n\tcase OutputSigLockedDustAllowanceOutput:\n\t\tseri = &SigLockedDustAllowanceOutput{}\n\tcase OutputTreasuryOutput:\n\t\tseri = &TreasuryOutput{}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%w: type %d\", ErrUnknownOutputType, outputType)\n\t}\n\treturn seri, nil\n}", "func (o *AudioStreamPlayer) GetBus() gdnative.String {\n\t//log.Println(\"Calling AudioStreamPlayer.GetBus()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"AudioStreamPlayer\", \"get_bus\")\n\n\t// Call the parent method.\n\t// String\n\tretPtr := gdnative.NewEmptyString()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewStringFromPointer(retPtr)\n\treturn ret\n}", "func (ch *Channel) OutputImpedance() (float64, error) {\n\treturn 50.0, nil\n}", "func makeLoopingOutputDevice(loop chan<- int, output chan<- int) func(int) {\n\treturn func(n int) {\n\t\tloop <- n\n\t\toutput <- n\n\t}\n}", "func (a *abaImpl) Output() gpa.Output {\n\tif a.output == nil {\n\t\treturn nil // Untyped nil\n\t}\n\treturn a.output\n}", "func (r *RemoteIO) SendOutput(outp ,errp io.ReadCloser) {\n\tdefer outp.Close()\n\tdefer errp.Close()\n//\tbuf := make([]byte, 1024, 4096)\n\tchbuf:=make(chan []byte)\n\tgo getOut(chbuf,outp)\n\tgo getOut(chbuf,errp)\n\tfor {\n/*\t\tvar(\n\t\t\tn int\n\t\t\terr error\n\t\t)\n\t\tselect{\n\t\t\tcase n, err = outp.Read(buf):\n\t\t\tcase n, err =errp.Read(buf):\n\t\t\t\n\t\t}\n\t\tif err != nil {\n\t\t\t//fmt.Println(\"Read pipe over:\",err)\n\t\t\tbreak\n\t\t} else {\n*/\n\t\tbuf:= <-chbuf\n\t\tif len(buf)==0 && cap(buf)==0{\n\t\t\tbreak\n\t\t}\n\t\tif _, err := r.wtr.Write(buf); err != nil {\n\t\t\t//\tfmt.Println(\"Send output to client failed:\",err)\n\t\t\tbreak\n\t\t}\n///\t\t}\n\t}\n}", "func (pw *PixelWand) GetIndex() IndexPacket {\n\tcip := C.PixelGetIndex(pw.pw)\n\truntime.KeepAlive(pw)\n\treturn IndexPacket(cip)\n}", "func (o NetworkInterfaceOutput) QueueCount() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v NetworkInterface) *int { return v.QueueCount }).(pulumi.IntPtrOutput)\n}", "func (device *ServoBrick) GetOutputVoltage() (voltage uint16, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetOutputVoltage), buf.Bytes())\n\tif err != nil {\n\t\treturn voltage, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 10 {\n\t\t\treturn voltage, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 10)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn voltage, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &voltage)\n\n\t}\n\n\treturn voltage, nil\n}", "func (sc *SwayConnection) GetActiveOutput() (*Output, error) {\n\tvar output *Output\n\n\to, err := sc.GetOutputs()\n\tif err != nil {\n\t\treturn output, err\n\t}\n\n\tfor i := range o {\n\t\tif o[i].Focused {\n\t\t\toutput = o[i]\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn output, nil\n}", "func (n *Net) OutputDim() int {\n\treturn n.outputDim\n}", "func (client JobClient) GetOutputSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (_m *Task) OutputIndex() int32 {\n\tret := _m.Called()\n\n\tvar r0 int32\n\tif rf, ok := ret.Get(0).(func() int32); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tr0 = ret.Get(0).(int32)\n\t}\n\n\treturn r0\n}", "func (tm *ServiceTracerouteManager) GetOutChan() chan string {\n\treturn tm.OutChan\n}", "func (wh *WholeNet) GetOutput() t.Tensor {\n\treturn (*wh).Layers[len((*wh).Layers)-1].GetOutput()\n}", "func (g *SCCGraph) Out(cid int) []int {\n\tif g.out == nil {\n\t\treturn nil\n\t}\n\treturn g.out[g.outIndexes[cid]:g.outIndexes[cid+1]]\n}", "func (out *StdOutput) Destination() chan<- []byte {\n\treturn out.data\n}", "func (o AttachedDiskResponseOutput) Index() pulumi.IntOutput {\n\treturn o.ApplyT(func(v AttachedDiskResponse) int { return v.Index }).(pulumi.IntOutput)\n}", "func (m *DeviceComplianceScriptDeviceState) GetScriptOutput()(*string) {\n val, err := m.GetBackingStore().Get(\"scriptOutput\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (o *out) Number() int {\n\treturn int(o.id)\n}", "func (this *MCP342X) GetMeasurement() (int, error) {\n\tlog.Print(\"Starting polling for the result.\")\n\tresult := make([]byte, 3)\n\n\tfor {\n\t\terr := this.i2c.Read(result)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\n\t\tif (result[2] & MCP342X_START) == 0x00 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// TODO: support all resolutions, it is only for 12 bit\n\tmeasurement := ((int(result[0]) & 0x3F) << 8) | int(result[1])\n\n\tif measurement > 2048-1 {\n\t\tmeasurement = measurement - 4096 - 1\n\t}\n\n\treturn measurement, nil\n}", "func (w *Writer) Ptr(index int64)", "func (pub *Publisher) GetOutputByID(outputID string) *types.OutputDiscoveryMessage {\n\treturn pub.registeredOutputs.GetOutputByID(outputID)\n}", "func (p *Participant) AudioOutput() *webrtc.Track {\n\tif p.outAudioTrack == nil {\n\t\t// Create a new Mixed Video Track if not exists\n\t\tmixedAudioTrack, newTrackErr := p.Peer.NewTrack(webrtc.DefaultPayloadTypeOpus, rand.Uint32(), \"audio\", \"audio-pipe\")\n\t\tif newTrackErr != nil {\n\t\t\tLogger.Error(newTrackErr)\n\t\t}\n\t\tLogger.Infof(\"Participant => %v create output AudioTrack: Code: %v Payload: %v\", p.Name, mixedAudioTrack.Codec().Name, mixedAudioTrack.Codec().PayloadType)\n\t\tp.outAudioTrack = mixedAudioTrack\n\t}\n\treturn p.outAudioTrack\n}", "func (o MrScalarTerminationPolicyStatementOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v MrScalarTerminationPolicyStatement) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func GetElementAtIndex(scope *Scope, dataset tf.Output, index tf.Output, output_types []tf.DataType, output_shapes []tf.Shape) (components []tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"output_types\": output_types, \"output_shapes\": output_shapes}\n\topspec := tf.OpSpec{\n\t\tType: \"GetElementAtIndex\",\n\t\tInput: []tf.Input{\n\t\t\tdataset, index,\n\t\t},\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tvar idx int\n\tvar err error\n\tif components, idx, err = makeOutputList(op, idx, \"components\"); err != nil {\n\t\tscope.UpdateErr(\"GetElementAtIndex\", err)\n\t\treturn\n\t}\n\treturn components\n}", "func (c *NetClient) controlOutQueue() error {\n\tc.log.Debugf(\"Queue controller started\")\n\tfor {\n\t\tselect {\n\t\tcase realPacket := <-c.outQueue:\n\t\t\tresponse, err := c.send(realPacket, c.Provider.Host, c.Provider.Port)\n\t\t\tif err != nil {\n\t\t\t\tc.log.Errorf(\"Could not send real packet: %v\", err)\n\t\t\t}\n\t\t\tc.log.Debugf(\"Real packet was sent\")\n\t\t\tc.log.Debugf(\"Received response: %v\", response)\n\t\tdefault:\n\t\t\tif !c.cfg.Debug.RateCompliantCoverMessagesDisabled {\n\t\t\t\tdummyPacket, err := c.createLoopCoverMessage()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tresponse, err := c.send(dummyPacket, c.Provider.Host, c.Provider.Port)\n\t\t\t\tif err != nil {\n\t\t\t\t\tc.log.Errorf(\"Could not send dummy packet: %v\", err)\n\t\t\t\t}\n\t\t\t\tc.log.Debugf(\"Dummy packet was sent\")\n\t\t\t\tc.log.Debugf(\"Received response: %v\", response)\n\t\t\t}\n\t\t}\n\t\terr := delayBeforeContinue(c.cfg.Debug.MessageSendingRate)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n}", "func (a *Action) GetOutput(o string) (*ActionOutputItem, bool) {\n\toutput, ok := a.Output[o]\n\treturn output, ok\n}", "func (d *DSP) OutputChannelFormat(inmask ChannelMask, inchannels int, inspeakermode SpeakerMode) (ChannelMask, int, SpeakerMode, error) {\n\tvar outmask C.FMOD_CHANNELMASK\n\tvar outchannels C.int\n\tvar outspeakermode C.FMOD_SPEAKERMODE\n\tres := C.FMOD_DSP_GetOutputChannelFormat(d.cptr, C.FMOD_CHANNELMASK(inmask), C.int(inchannels), C.FMOD_SPEAKERMODE(inspeakermode), &outmask, &outchannels, &outspeakermode)\n\treturn ChannelMask(outmask), int(outchannels), SpeakerMode(outspeakermode), errs[res]\n}", "func (fmp *FlatMap) OutputChan() <-chan interface{} {\n\treturn fmp.out\n}", "func DefaultMixer() *Mixer {\n\treturn (*Mixer)(C.al_get_default_mixer())\n}", "func (m *MemCmd) Output() ([]byte, error) {\n\tif m.OutputCallback != nil {\n\t\treturn m.OutputCallback(m)\n\t}\n\treturn make([]byte, 0), nil\n}", "func (o ElastigroupMultipleMetricsMetricOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupMultipleMetricsMetric) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func (s *Session) GetConnection(index int) *Connection {\n\ts.connectionsMu.Lock()\n\tdefer s.connectionsMu.Unlock()\n\n\tif index >= len(s.connections) {\n\t\treturn nil\n\t}\n\n\treturn s.connections[index]\n}", "func OutByName(portName string) (out Out, err error) {\n\tdrv := Get()\n\tif drv == nil {\n\t\treturn nil, fmt.Errorf(\"no driver registered\")\n\t}\n\treturn openOut(drv, -1, portName)\n}", "func SDAccel(index int32) Device {\n return Device{KDLSDAccel, index}\n}", "func (rb *RingBuffer) Get(index int) (ans stats.Record) {\n\trb.lock.RLock()\n\tdefer rb.lock.RUnlock()\n\tif index < 0 {\n\t\tindex = len(rb.data) + index\n\t}\n\treturn rb.data[(rb.seq+uint64(index))%uint64(len(rb.data))]\n}", "func (c *client3E) Write(deviceName string, offset, numPoints int64, writeData []byte) ([]byte, error) {\n\trequestStr := c.stn.BuildWriteRequest(deviceName, offset, numPoints, writeData)\n\tpayload, err := hex.DecodeString(requestStr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconn, err := net.DialTCP(\"tcp\", nil, c.tcpAddr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer conn.Close()\n\n\t// Send message\n\tif _, err = conn.Write(payload); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Receive message\n\treadBuff := make([]byte, 22) // 22 is response header size. [sub header + network num + unit i/o num + unit station num + response length + response code]\n\n\treadLen, err := conn.Read(readBuff)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn readBuff[:readLen], nil\n}", "func (e *Expr) Out(i int) xr.Type {\n\tif i == 0 && e.Types == nil {\n\t\treturn e.Type\n\t}\n\treturn e.Types[i]\n}", "func (me *Meter) Write(p []byte) (n int, err error) {\n\tme.m.lock.Lock()\n\tdefer me.m.lock.Unlock()\n\n\t// Make a copy of the meter, so we don't worry about it\n\t// changing by the user.\n\tvar newMeter []byte\n\tif p != nil {\n\t\tnewMeter = make([]byte, len(p))\n\t\tcopy(newMeter, p)\n\t}\n\n\tnow := time.Now()\n\tif now.Before(me.next) {\n\t\tme.m.meter = newMeter\n\t\t// Not enough time, don't show the meter.\n\t\treturn len(p), nil\n\t}\n\n\tme.next = now.Add(me.delay)\n\n\terr = me.m.clear()\n\tif err != nil {\n\t\treturn\n\t}\n\tme.m.meter = newMeter\n\n\t// The return isn't quite right here, but I'm not sure we're\n\t// going to handle errors writing to Stdout anyway.\n\treturn len(p), me.m.redraw()\n}", "func (pub *Publisher) GetOutputByNodeHWID(nodeHWID string, outputType types.OutputType, instance string) *types.OutputDiscoveryMessage {\n\treturn pub.registeredOutputs.GetOutputByNodeHWID(nodeHWID, outputType, instance)\n}", "func (o BackendOutput) MaxRate() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v Backend) *int { return v.MaxRate }).(pulumi.IntPtrOutput)\n}", "func (client *NativeClient) Output(command string) (string, error) {\n\tsession, err := client.session(command)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\toutput, err := session.CombinedOutput(command)\n\tdefer session.Close()\n\n\treturn string(bytes.TrimSpace(output)), wrapError(err)\n}" ]
[ "0.5448426", "0.5216238", "0.51698977", "0.51465654", "0.5072772", "0.49458998", "0.4847666", "0.48280278", "0.47968405", "0.47689453", "0.47689453", "0.47063503", "0.46706727", "0.46692526", "0.46689245", "0.4657443", "0.46326956", "0.45541793", "0.45270175", "0.45129877", "0.45124456", "0.45083895", "0.4502109", "0.4441557", "0.44236928", "0.44166398", "0.4416402", "0.4413642", "0.44081378", "0.44005656", "0.43909937", "0.43745288", "0.4363367", "0.43203", "0.4320005", "0.43197104", "0.4300984", "0.42809203", "0.42747954", "0.42610523", "0.42577586", "0.42334077", "0.4231971", "0.42312092", "0.42303124", "0.4228348", "0.42242923", "0.4221508", "0.4216412", "0.41966686", "0.41930777", "0.41730416", "0.41723597", "0.41715473", "0.41672936", "0.41568887", "0.4142651", "0.41419163", "0.4138592", "0.41282967", "0.41248277", "0.4118325", "0.4111785", "0.41106203", "0.41000265", "0.40994817", "0.40862828", "0.40618944", "0.40616068", "0.40611738", "0.4059094", "0.4054599", "0.4046237", "0.40435907", "0.4038445", "0.4038338", "0.40379035", "0.40344873", "0.40342137", "0.40228495", "0.4021851", "0.4020464", "0.4017128", "0.40100157", "0.400304", "0.40022498", "0.3998398", "0.39877647", "0.3985135", "0.3984492", "0.39715323", "0.39573663", "0.39529422", "0.3950498", "0.39502352", "0.39461637", "0.39368632", "0.39332986", "0.39291692", "0.39195094" ]
0.71421915
0
/ DSP unit control. Enables or disables a unit for being processed. active: true = unit is activated, false = unit is deactivated. This does not connect or disconnect a unit in any way, it just disables it so that it is not processed. If a unit is disabled, and has inputs, they will also cease to be processed. To disable a unit but allow the inputs of the unit to continue being processed, use "DSP.SetBypass" instead.
func (d *DSP) SetActive(active bool) error { res := C.FMOD_DSP_SetActive(d.cptr, getBool(active)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *CmdBuff) SetActive(b bool) {\n\tc.mx.Lock()\n\t{\n\t\tc.active = b\n\t}\n\tc.mx.Unlock()\n\n\tc.fireActive(c.active)\n}", "func DUTActive(ctx context.Context, servoInst *servo.Servo) (bool, error) {\n\tstate, err := servoInst.GetECSystemPowerState(ctx)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"failed to get ec_system_power_state\")\n\t}\n\ttesting.ContextLog(ctx, \"state: \", state)\n\tif state == \"S0\" {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (c *Component) SetActive(active bool) {\n\tc.active = active\n}", "func (self *PhysicsP2) Enable1O(object interface{}, debug bool) {\n self.Object.Call(\"enable\", object, debug)\n}", "func (this *channelMeterStruct) setEnabled(value bool) {\n\tthis.mutex.Lock()\n\tenabled := this.enabled\n\n\t/*\n\t * Check if status of meter must be changed.\n\t */\n\tif value != enabled {\n\n\t\t/*\n\t\t * If level meter should be disabled, clear state.\n\t\t */\n\t\tif !value {\n\t\t\tthis.currentValue = 0.0\n\t\t\tthis.peakValue = 0.0\n\t\t\tthis.sampleCounter = 0\n\t\t}\n\n\t\tthis.enabled = value\n\t}\n\n\tthis.mutex.Unlock()\n}", "func (w *WidgetBase) SetActive(a bool) {\n\tw.active = a\n}", "func (d *DSP) IsActive() (bool, error) {\n\tvar active C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetActive(d.cptr, &active)\n\treturn setBool(active), errs[res]\n}", "func (guo *GroupUpdateOne) SetActive(b bool) *GroupUpdateOne {\n\tguo.mutation.SetActive(b)\n\treturn guo\n}", "func (self Context) SetActive(active bool) {\n\tif active {\n\t\tC.sfContext_setActive(self.Cref, C.sfBool(1))\n\t} else {\n\t\tC.sfContext_setActive(self.Cref, C.sfBool(0))\n\t}\n}", "func (p *PortForwarder) SetActive(b bool) {\n\tp.active = b\n}", "func (u *Unit) StartUnit() error {\n\tconn, err := sd.NewSystemdConnection()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get systemd bus connection: %v\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\treschan := make(chan string)\n\t_, err = conn.StartUnit(u.Unit, \"replace\", reschan)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to start unit %s: %v\", u.Unit, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (self *TileSprite) SetInputEnabledA(member bool) {\n self.Object.Set(\"inputEnabled\", member)\n}", "func (this *meterStruct) SetEnabled(value bool) {\n\tthis.mutex.Lock()\n\tenabled := this.enabled\n\n\t/*\n\t * Check if value must be changed.\n\t */\n\tif value != enabled {\n\t\tchannelMeters := this.channelMeters\n\n\t\t/*\n\t\t * Enable or disable each channel meter.\n\t\t */\n\t\tfor _, channelMeter := range channelMeters {\n\t\t\tchannelMeter.setEnabled(value)\n\t\t}\n\n\t\tthis.enabled = value\n\t}\n\n\tthis.mutex.Unlock()\n}", "func (self *Graphics) SetInputEnabledA(member bool) {\n self.Object.Set(\"inputEnabled\", member)\n}", "func (d *DSP) Bypass() (bool, error) {\n\tvar bypass C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetBypass(d.cptr, &bypass)\n\treturn setBool(bypass), errs[res]\n}", "func (_UsersData *UsersDataTransactor) SetActive(opts *bind.TransactOpts, uuid [16]byte, active bool) (*types.Transaction, error) {\n\treturn _UsersData.contract.Transact(opts, \"setActive\", uuid, active)\n}", "func (_UsersData *UsersDataTransactorSession) SetActive(uuid [16]byte, active bool) (*types.Transaction, error) {\n\treturn _UsersData.Contract.SetActive(&_UsersData.TransactOpts, uuid, active)\n}", "func (gu *GroupUpdate) SetActive(b bool) *GroupUpdate {\n\tgu.mutation.SetActive(b)\n\treturn gu\n}", "func (sv *Unit) Active() unit.Activation {\n\tlog.WithField(\"sv\", sv).Debugf(\"sv.Active\")\n\n\t// based of Systemd transtition table found in https://goo.gl/oEjikJ\n\tswitch sv.Sub() {\n\tcase dead:\n\t\treturn unit.Inactive\n\tcase failed:\n\t\treturn unit.Failed\n\tcase reload:\n\t\treturn unit.Reloading\n\tcase running, exited:\n\t\treturn unit.Active\n\tcase start, startPre, startPost, autoRestart:\n\t\treturn unit.Activating\n\tcase stop, stopSigabrt, stopPost, stopSigkill, stopSigterm, finalSigkill, finalSigterm:\n\t\treturn unit.Deactivating\n\tdefault:\n\t\tpanic(\"Unknown service sub state\")\n\t}\n}", "func (t MagneticFieldStrength) Unit() *Unit {\n\treturn New(float64(t), Dimensions{\n\t\tCurrentDim: -1,\n\t\tMassDim: 1,\n\t\tTimeDim: -2,\n\t})\n}", "func (m *WorkforceIntegration) SetIsActive(value *bool)() {\n m.isActive = value\n}", "func (gt *myGoTickle) Active() bool {\n\treturn gt.avtive\n}", "func (self *PhysicsP2) EnableI(args ...interface{}) {\n self.Object.Call(\"enable\", args)\n}", "func (c *ChessClock) toggleActive() {\n\tswitch c.active {\n\tcase White:\n\t\tc.active = Black\n\tcase Black:\n\t\tc.active = White\n\t}\n}", "func (_UsersData *UsersDataSession) SetActive(uuid [16]byte, active bool) (*types.Transaction, error) {\n\treturn _UsersData.Contract.SetActive(&_UsersData.TransactOpts, uuid, active)\n}", "func (filterdev *NetworkTap) SetImmediate(m int) error {\n\t_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(filterdev.device.Fd()), syscall.BIOCIMMEDIATE, uintptr(unsafe.Pointer(&m)))\n\tif err != 0 {\n\t\treturn syscall.Errno(err)\n\t}\n\treturn nil\n}", "func (o *RuleActionStore) SetActive(v bool) {\n\to.Active = &v\n}", "func (s *PutSourceServerActionOutput) SetActive(v bool) *PutSourceServerActionOutput {\n\ts.Active = &v\n\treturn s\n}", "func enableDisable(status, device int, name string) {\n\tvar request RpcRequest\n\n\tswitch status {\n\tcase 0:\n\t\trequest = RpcRequest{fmt.Sprintf(\"{\\\"command\\\":\\\"gpudisable\\\",\\\"parameter\\\":\\\"%v\\\"}\", device), make(chan []byte), name}\n\tcase 1:\n\t\trequest = RpcRequest{fmt.Sprintf(\"{\\\"command\\\":\\\"gpuenable\\\",\\\"parameter\\\":\\\"%v\\\"}\", device), make(chan []byte), name}\n\t}\n\n\trequest.Send()\n}", "func (self *PhysicsP2) Enable(object interface{}) {\n self.Object.Call(\"enable\", object)\n}", "func (m *EntityMutation) SetActive(b bool) {\n\tm.active = &b\n}", "func (c *EEBus) Enable(enable bool) error {\n\t// if the ev is unplugged or the state is unknown, there is nothing to be done\n\tif state, err := c.updateState(); err != nil || state == api.StatusA {\n\t\tc.expectedEnableUnpluggedState = enable\n\t\treturn nil\n\t}\n\n\t// if we disable charging with a potential but not yet known communication standard ISO15118\n\t// this would set allowed A value to be 0. And this would trigger ISO connections to switch to IEC!\n\tif !enable {\n\t\tcomStandard, err := c.emobility.EVCommunicationStandard()\n\t\tif err != nil || comStandard == emobility.EVCommunicationStandardTypeUnknown {\n\t\t\treturn api.ErrMustRetry\n\t\t}\n\t}\n\n\tvar current float64\n\n\tif enable {\n\t\tcurrent = c.current\n\t}\n\n\treturn c.writeCurrentLimitData([]float64{current, current, current})\n}", "func Enable(cap GLenum) {\n\tC.glEnable(C.GLenum(cap))\n}", "func (s *PutSourceServerActionInput) SetActive(v bool) *PutSourceServerActionInput {\n\ts.Active = &v\n\treturn s\n}", "func (d UserData) SetActive(value bool) m.UserData {\n\td.ModelData.Set(models.NewFieldName(\"Active\", \"active\"), value)\n\treturn d\n}", "func (d *DSP) SetBypass(bypass bool) error {\n\tres := C.FMOD_DSP_SetBypass(d.cptr, getBool(bypass))\n\treturn errs[res]\n}", "func (this *Window) SetActive(active bool) bool {\n\tglobalMutex.Lock()\n\tsuccess := sfBool2Go(C.sfWindow_setActive(this.cptr, goBool2C(active)))\n\tglobalMutex.Unlock()\n\treturn success\n}", "func (o DeviceDexTestOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *DeviceDexTest) pulumi.BoolOutput { return v.Enabled }).(pulumi.BoolOutput)\n}", "func (s *PutTemplateActionOutput) SetActive(v bool) *PutTemplateActionOutput {\n\ts.Active = &v\n\treturn s\n}", "func enable(t Type, delay time.Duration) error {\n\tstartCollecting()\n\n\tvar err error\n\tdone := make(chan struct{})\n\tinout <- inOut{\n\t\tin: enableSignal{t: t, delay: delay, err: &err},\n\t\tout: done,\n\t}\n\t<-done\n\treturn err\n}", "func (m *IntervalMutation) SetActive(b bool) {\n\tm.active = &b\n}", "func (dn *Daemon) enableUnits(units []string) error {\n\targs := append([]string{\"enable\"}, units...)\n\tstdouterr, err := exec.Command(\"systemctl\", args...).CombinedOutput()\n\tif err != nil {\n\t\tif !dn.os.IsLikeTraditionalRHEL7() {\n\t\t\treturn fmt.Errorf(\"error enabling units: %s\", stdouterr)\n\t\t}\n\t\t// In RHEL7, the systemd version is too low, so it is unable to handle broken\n\t\t// symlinks during enable. Do a best-effort removal of potentially broken\n\t\t// hard coded symlinks and try again.\n\t\t// See: https://bugzilla.redhat.com/show_bug.cgi?id=1913536\n\t\twantsPathSystemd := \"/etc/systemd/system/multi-user.target.wants/\"\n\t\tfor _, unit := range units {\n\t\t\tunitLinkPath := filepath.Join(wantsPathSystemd, unit)\n\t\t\tfi, fiErr := os.Lstat(unitLinkPath)\n\t\t\tif fiErr != nil {\n\t\t\t\tif !os.IsNotExist(fiErr) {\n\t\t\t\t\treturn fmt.Errorf(\"error trying to enable unit, fallback failed with %s (original error %s)\",\n\t\t\t\t\t\tfiErr, stdouterr)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif fi.Mode()&os.ModeSymlink == 0 {\n\t\t\t\treturn fmt.Errorf(\"error trying to enable unit, a non-symlink file exists at %s (original error %s)\",\n\t\t\t\t\tunitLinkPath, stdouterr)\n\t\t\t}\n\t\t\tif _, evalErr := filepath.EvalSymlinks(unitLinkPath); evalErr != nil {\n\t\t\t\t// this is a broken symlink, remove\n\t\t\t\tif rmErr := os.Remove(unitLinkPath); rmErr != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error trying to enable unit, cannot remove broken symlink: %s (original error %s)\",\n\t\t\t\t\t\trmErr, stdouterr)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tstdouterr, err := exec.Command(\"systemctl\", args...).CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error enabling units: %s\", stdouterr)\n\t\t}\n\t}\n\tklog.Infof(\"Enabled systemd units: %v\", units)\n\treturn nil\n}", "func (c *FritzDECT) Enable(enable bool) error {\n\tcmd := \"setswitchoff\"\n\tif enable {\n\t\tcmd = \"setswitchon\"\n\t}\n\n\t// on 0/1 - DECT Switch state off/on (empty if unknown or error)\n\tresp, err := c.conn.ExecCmd(cmd)\n\n\tvar on bool\n\tif err == nil {\n\t\ton, err = strconv.ParseBool(resp)\n\t\tif err == nil && enable != on {\n\t\t\terr = errors.New(\"switch failed\")\n\t\t}\n\t}\n\n\treturn err\n}", "func (m *sineOsc) Stop() {\n}", "func (p *PWMPin) SetEnabled(e bool) error {\n\tif err := p.writeFile(fmt.Sprintf(\"pwm%s/enable\", p.fn), fmt.Sprintf(\"%v\", bool2int(e))); err != nil {\n\t\treturn err\n\t}\n\tp.enabled = e\n\treturn nil\n}", "func (t Trigger) Activate() {\n\tif t.Audio != nil {\n\t\t_ = t.Audio.player.Seek(0)\n\t\tt.Audio.player.Play()\n\t}\n}", "func (module *OscModule) DSP(timestamp int64) {\n\tbuflen := module.GetBufferLength()\n\tsr := module.GetSampleRate()\n\n\tvar pmodInput []float64\n\tvar fmodInput []float64\n\tvar ampInput []float64\n\n\toutput := module.Outlets[0].Buffer\n\n\t// Check if inlet is connected for phase modulation\n\tif module.Inlets[0].Connections.Len() > 0 {\n\t\tpmodInput = module.Inlets[0].Buffer\n\t}\n\n\tif module.Inlets[1].Connections.Len() > 0 {\n\t\tfmodInput = module.Inlets[1].Buffer\n\t}\n\n\tif module.Inlets[2].Connections.Len() > 0 {\n\t\tampInput = module.Inlets[2].Buffer\n\t}\n\n\tfor i := int32(0); i < buflen; i++ {\n\t\tpmod := 0.0\n\n\t\tif pmodInput != nil {\n\t\t\tpmod = pmodInput[i]\n\t\t}\n\n\t\tif fmodInput != nil {\n\t\t\tinc := fmodInput[i] / sr\n\t\t\tmodule.Inc = inc\n\t\t}\n\n\t\tif ampInput != nil {\n\t\t\tamp := ampInput[i]\n\t\t\tmodule.Amplitude = amp\n\t\t}\n\n\t\toutput[i] = module.Process(pmod)\n\t}\n}", "func (c *Easee) Enabled() (bool, error) {\n\tc.mux.Lock()\n\tdefer c.mux.Unlock()\n\n\tdisabled := c.opMode == easee.ModeDisconnected ||\n\t\tc.opMode == easee.ModeCompleted ||\n\t\t(c.opMode == easee.ModeAwaitingStart && c.reasonForNoCurrent == 52)\n\treturn !disabled && c.dynamicChargerCurrent > 0, nil\n}", "func Active() bool {\n\treturn isActive\n}", "func (m *Mode) Enable() {\n\tm.enabled = true\n}", "func (self *PhysicsP2) SetSleepModeA(member int) {\n self.Object.Set(\"sleepMode\", member)\n}", "func Use(b blas.Complex128) {\n\tcblas128 = b\n}", "func (d *Device) UseLowPower(power bool) {\n\tif power {\n\t\td.bwRate.lowPower = 1\n\t} else {\n\t\td.bwRate.lowPower = 0\n\t}\n\td.bus.WriteRegister(uint8(d.Address), REG_BW_RATE, []byte{d.bwRate.toByte()})\n}", "func (d *DSbusStruct) StartUnit(unitName string) (err error) {\n\tvar path dbus.ObjectPath\n\tif err = d.o.Call(startUnit, 0, unitName, startMode).Store(&path); err != nil {\n\t\tlog.Infof(\"dbus.StartUnit %v\", err)\n\t}\n\treturn\n}", "func (s *PutTemplateActionInput) SetActive(v bool) *PutTemplateActionInput {\n\ts.Active = &v\n\treturn s\n}", "func (pwm *pwmGroup) enable(enable bool) {\n\tpwm.CSR.ReplaceBits(boolToBit(enable)<<rp.PWM_CH0_CSR_EN_Pos, rp.PWM_CH0_CSR_EN_Msk, 0)\n}", "func (uqs InstantprofileUpdateQS) SetActive(v bool) InstantprofileUpdateQS {\n\treturn uqs.update(`\"active\"`, v)\n}", "func (e *GT) Unit() *GT {\n\tif e.p == nil {\n\t\te.p = &gfP12{}\n\t}\n\te.p.SetOne()\n\treturn e\n}", "func (o NodeDriverOutput) Active() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *NodeDriver) pulumi.BoolOutput { return v.Active }).(pulumi.BoolOutput)\n}", "func (s *FulfillmentCodeHookSettings) SetActive(v bool) *FulfillmentCodeHookSettings {\n\ts.Active = &v\n\treturn s\n}", "func (m MagneticFlux) Unit() *Unit {\n\treturn New(float64(m), Dimensions{\n\t\tCurrentDim: -1,\n\t\tLengthDim: 2,\n\t\tMassDim: 1,\n\t\tTimeDim: -2,\n\t})\n}", "func (d *DSP) SetMeteringEnabled(inputEnabled, outputEnabled bool) error {\n\tres := C.FMOD_DSP_SetMeteringEnabled(d.cptr, getBool(inputEnabled), getBool(outputEnabled))\n\treturn errs[res]\n}", "func (m *UserMutation) SetActive(b bool) {\n\tm.active = &b\n}", "func (o *DriveAta) SmartSetEnabled(ctx context.Context, value bool, options map[string]dbus.Variant) (err error) {\n\terr = o.object.CallWithContext(ctx, InterfaceDriveAta+\".SmartSetEnabled\", 0, value, options).Store()\n\treturn\n}", "func (s *Sdr) SetDSP(state bool) error {\n\tvar v C.uint8_t\n\tif state {\n\t\tv = 1\n\t}\n\tif C.airspyhf_set_lib_dsp(s.handle, v) != C.AIRSPYHF_SUCCESS {\n\t\treturn fmt.Errorf(\"airspyhf.Sdr.SetDSP: failed to set DSP\")\n\t}\n\treturn nil\n}", "func COMISD(mx, x operand.Op) { ctx.COMISD(mx, x) }", "func (c Computer) work(usb Usber) {\r\n\tusb.start()\r\n\tusb.stop()\r\n}", "func (srv *CentralSessionController) Enable(\n\tctx context.Context,\n\tvoid *orcprotos.Void,\n) (*orcprotos.Void, error) {\n\terrs := &multierror.Error{}\n\tif !srv.cfg.DisableGx {\n\t\terr := srv.policyClient.EnableConnections()\n\t\tif err != nil {\n\t\t\terrs = multierror.Append(errs, fmt.Errorf(\"An error occurred while enabling connections; policyClient err: %s\", err))\n\t\t}\n\t}\n\tif !srv.cfg.DisableGy {\n\t\terr := srv.creditClient.EnableConnections()\n\t\tif err != nil {\n\t\t\terrs = multierror.Append(errs, fmt.Errorf(\"An error occurred while enabling connections; creditClient err: %s\", err))\n\t\t}\n\t}\n\treturn &orcprotos.Void{}, errs.ErrorOrNil()\n}", "func (o ArgoCDSpecPrometheusOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecPrometheus) bool { return v.Enabled }).(pulumi.BoolOutput)\n}", "func (s *WaitAndContinueSpecification) SetActive(v bool) *WaitAndContinueSpecification {\n\ts.Active = &v\n\treturn s\n}", "func (o EciScalingConfigurationOutput) Active() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *EciScalingConfiguration) pulumi.BoolPtrOutput { return v.Active }).(pulumi.BoolPtrOutput)\n}", "func UCOMISD(mx, x operand.Op) { ctx.UCOMISD(mx, x) }", "func (dn *Daemon) disableUnits(units []string) error {\n\targs := append([]string{\"disable\"}, units...)\n\tstdouterr, err := exec.Command(\"systemctl\", args...).CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error disabling unit: %s\", stdouterr)\n\t}\n\tklog.Infof(\"Disabled systemd units %v\", units)\n\treturn nil\n}", "func (s *IntentClosingSetting) SetActive(v bool) *IntentClosingSetting {\n\ts.Active = &v\n\treturn s\n}", "func (s *Layer) Use(phase string, handler ...interface{}) {\n\ts.register(phase, Normal, handler...)\n}", "func (s *Stopwatch) active() bool {\n\treturn s.stop.IsZero()\n}", "func (device *SilentStepperBrick) Enable() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionEnable), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (s *SourceServerActionDocument) SetActive(v bool) *SourceServerActionDocument {\n\ts.Active = &v\n\treturn s\n}", "func (self *PhysicsP2) Enable2O(object interface{}, debug bool, children bool) {\n self.Object.Call(\"enable\", object, debug, children)\n}", "func (j *Joystick) Active() bool {\n\treturn bool(C.al_get_joystick_active((*C.ALLEGRO_JOYSTICK)(j)))\n}", "func (b *CCSBuilder) Enabled(value bool) *CCSBuilder {\n\tb.enabled = value\n\tb.bitmap_ |= 16\n\treturn b\n}", "func createSignalGenerator() Unit {\n\n\t/*\n\t * Create effects unit.\n\t */\n\tu := signalGenerator{\n\t\tunitStruct: unitStruct{\n\t\t\tunitType: UNIT_SIGNALGENERATOR,\n\t\t\tparams: []Parameter{\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"input_amplitude\",\n\t\t\t\t\tType: PARAMETER_TYPE_NUMERIC,\n\t\t\t\t\tPhysicalUnit: \"%\",\n\t\t\t\t\tMinimum: 0,\n\t\t\t\t\tMaximum: 100,\n\t\t\t\t\tNumericValue: 100,\n\t\t\t\t\tDiscreteValueIndex: -1,\n\t\t\t\t\tDiscreteValues: nil,\n\t\t\t\t},\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"input_gain\",\n\t\t\t\t\tType: PARAMETER_TYPE_NUMERIC,\n\t\t\t\t\tPhysicalUnit: \"dB\",\n\t\t\t\t\tMinimum: -60,\n\t\t\t\t\tMaximum: 0,\n\t\t\t\t\tNumericValue: 0,\n\t\t\t\t\tDiscreteValueIndex: -1,\n\t\t\t\t\tDiscreteValues: nil,\n\t\t\t\t},\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"signal_type\",\n\t\t\t\t\tType: PARAMETER_TYPE_DISCRETE,\n\t\t\t\t\tPhysicalUnit: \"\",\n\t\t\t\t\tMinimum: -1,\n\t\t\t\t\tMaximum: -1,\n\t\t\t\t\tNumericValue: -1,\n\t\t\t\t\tDiscreteValueIndex: 0,\n\t\t\t\t\tDiscreteValues: []string{\n\t\t\t\t\t\t\"sine\",\n\t\t\t\t\t\t\"triangle\",\n\t\t\t\t\t\t\"square\",\n\t\t\t\t\t\t\"sawtooth\",\n\t\t\t\t\t\t\"noise\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"signal_frequency\",\n\t\t\t\t\tType: PARAMETER_TYPE_NUMERIC,\n\t\t\t\t\tPhysicalUnit: \"Hz\",\n\t\t\t\t\tMinimum: 1,\n\t\t\t\t\tMaximum: 20000,\n\t\t\t\t\tNumericValue: 440,\n\t\t\t\t\tDiscreteValueIndex: -1,\n\t\t\t\t\tDiscreteValues: nil,\n\t\t\t\t},\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"signal_amplitude\",\n\t\t\t\t\tType: PARAMETER_TYPE_NUMERIC,\n\t\t\t\t\tPhysicalUnit: \"%\",\n\t\t\t\t\tMinimum: 0,\n\t\t\t\t\tMaximum: 100,\n\t\t\t\t\tNumericValue: 100,\n\t\t\t\t\tDiscreteValueIndex: -1,\n\t\t\t\t\tDiscreteValues: nil,\n\t\t\t\t},\n\t\t\t\tParameter{\n\t\t\t\t\tName: \"signal_gain\",\n\t\t\t\t\tType: PARAMETER_TYPE_NUMERIC,\n\t\t\t\t\tPhysicalUnit: \"dB\",\n\t\t\t\t\tMinimum: -60,\n\t\t\t\t\tMaximum: 0,\n\t\t\t\t\tNumericValue: 0,\n\t\t\t\t\tDiscreteValueIndex: -1,\n\t\t\t\t\tDiscreteValues: nil,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\treturn &u\n}", "func (a *Adapter) Enable() error {\n\tif a.poweredChan != nil {\n\t\treturn errors.New(\"already calling Enable function\")\n\t}\n\n\t// wait until powered\n\ta.poweredChan = make(chan error, 1)\n\n\ta.cmd = &centralManagerDelegate{a: a}\n\ta.cm.SetDelegate(a.cmd)\n\n\tif a.cm.State() != cbgo.ManagerStatePoweredOn {\n\t\tselect {\n\t\tcase <-a.poweredChan:\n\t\tcase <-time.NewTimer(10 * time.Second).C:\n\t\t\treturn errors.New(\"timeout enabling CentralManager\")\n\t\t}\n\t}\n\n\t// drain any extra powered-on events from channel\n\tfor len(a.poweredChan) > 0 {\n\t\t<-a.poweredChan\n\t}\n\n\t// wait until powered?\n\ta.pmd = &peripheralManagerDelegate{a: a}\n\ta.pm.SetDelegate(a.pmd)\n\n\treturn nil\n}", "func (d *Device) startOutputEnableTimer() {\n\tcount := d.brightness << d.colorBit\n\tfor i := uint32(0); i < count; i++ {\n\t\td.oe.Low()\n\t}\n\td.oe.High()\n}", "func (s IOStreams) SpinnerActive() bool {\n\treturn s.sp.Active()\n}", "func (o *InlineResponse20075StatsBilling) SetActive(v string) {\n\to.Active = &v\n}", "func (o *IntrospectedOAuth2Token) SetActive(v bool) {\n\to.Active = v\n}", "func (c *Cooler) Active() bool {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\tif c.active {\n\t\treturn true\n\t}\n\n\tc.active = true\n\n\treturn false\n}", "func (bot *Engine) SetSubsystem(subSystemName string, enable bool) error {\n\tif bot == nil {\n\t\treturn errNilBot\n\t}\n\n\tif bot.Config == nil {\n\t\treturn errNilConfig\n\t}\n\n\tvar err error\n\tswitch strings.ToLower(subSystemName) {\n\tcase CommunicationsManagerName:\n\t\tif enable {\n\t\t\tif bot.CommunicationsManager == nil {\n\t\t\t\tcommunicationsConfig := bot.Config.GetCommunicationsConfig()\n\t\t\t\tbot.CommunicationsManager, err = SetupCommunicationManager(&communicationsConfig)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.CommunicationsManager.Start()\n\t\t}\n\t\treturn bot.CommunicationsManager.Stop()\n\tcase ConnectionManagerName:\n\t\tif enable {\n\t\t\tif bot.connectionManager == nil {\n\t\t\t\tbot.connectionManager, err = setupConnectionManager(&bot.Config.ConnectionMonitor)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.connectionManager.Start()\n\t\t}\n\t\treturn bot.connectionManager.Stop()\n\tcase OrderManagerName:\n\t\tif enable {\n\t\t\tif bot.OrderManager == nil {\n\t\t\t\tbot.OrderManager, err = SetupOrderManager(\n\t\t\t\t\tbot.ExchangeManager,\n\t\t\t\t\tbot.CommunicationsManager,\n\t\t\t\t\t&bot.ServicesWG,\n\t\t\t\t\tbot.Config.OrderManager.Verbose,\n\t\t\t\t\tbot.Config.OrderManager.ActivelyTrackFuturesPositions,\n\t\t\t\t\tbot.Config.OrderManager.FuturesTrackingSeekDuration)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.OrderManager.Start()\n\t\t}\n\t\treturn bot.OrderManager.Stop()\n\tcase PortfolioManagerName:\n\t\tif enable {\n\t\t\tif bot.portfolioManager == nil {\n\t\t\t\tbot.portfolioManager, err = setupPortfolioManager(bot.ExchangeManager, bot.Settings.PortfolioManagerDelay, &bot.Config.Portfolio)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.portfolioManager.Start(&bot.ServicesWG)\n\t\t}\n\t\treturn bot.portfolioManager.Stop()\n\tcase NTPManagerName:\n\t\tif enable {\n\t\t\tif bot.ntpManager == nil {\n\t\t\t\tbot.ntpManager, err = setupNTPManager(\n\t\t\t\t\t&bot.Config.NTPClient,\n\t\t\t\t\t*bot.Config.Logging.Enabled)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.ntpManager.Start()\n\t\t}\n\t\treturn bot.ntpManager.Stop()\n\tcase DatabaseConnectionManagerName:\n\t\tif enable {\n\t\t\tif bot.DatabaseManager == nil {\n\t\t\t\tbot.DatabaseManager, err = SetupDatabaseConnectionManager(&bot.Config.Database)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.DatabaseManager.Start(&bot.ServicesWG)\n\t\t}\n\t\treturn bot.DatabaseManager.Stop()\n\tcase SyncManagerName:\n\t\tif enable {\n\t\t\tif bot.currencyPairSyncer == nil {\n\t\t\t\tcfg := bot.Config.SyncManagerConfig\n\t\t\t\tcfg.SynchronizeTicker = bot.Settings.EnableTickerSyncing\n\t\t\t\tcfg.SynchronizeOrderbook = bot.Settings.EnableOrderbookSyncing\n\t\t\t\tcfg.SynchronizeContinuously = bot.Settings.SyncContinuously\n\t\t\t\tcfg.SynchronizeTrades = bot.Settings.EnableTradeSyncing\n\t\t\t\tcfg.Verbose = bot.Settings.Verbose || cfg.Verbose\n\n\t\t\t\tif cfg.TimeoutREST != bot.Settings.SyncTimeoutREST &&\n\t\t\t\t\tbot.Settings.SyncTimeoutREST != config.DefaultSyncerTimeoutREST {\n\t\t\t\t\tcfg.TimeoutREST = bot.Settings.SyncTimeoutREST\n\t\t\t\t}\n\t\t\t\tif cfg.TimeoutWebsocket != bot.Settings.SyncTimeoutWebsocket &&\n\t\t\t\t\tbot.Settings.SyncTimeoutWebsocket != config.DefaultSyncerTimeoutWebsocket {\n\t\t\t\t\tcfg.TimeoutWebsocket = bot.Settings.SyncTimeoutWebsocket\n\t\t\t\t}\n\t\t\t\tif cfg.NumWorkers != bot.Settings.SyncWorkersCount &&\n\t\t\t\t\tbot.Settings.SyncWorkersCount != config.DefaultSyncerWorkers {\n\t\t\t\t\tcfg.NumWorkers = bot.Settings.SyncWorkersCount\n\t\t\t\t}\n\t\t\t\tbot.currencyPairSyncer, err = setupSyncManager(\n\t\t\t\t\t&cfg,\n\t\t\t\t\tbot.ExchangeManager,\n\t\t\t\t\t&bot.Config.RemoteControl,\n\t\t\t\t\tbot.Settings.EnableWebsocketRoutine)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.currencyPairSyncer.Start()\n\t\t}\n\t\treturn bot.currencyPairSyncer.Stop()\n\tcase dispatch.Name:\n\t\tif enable {\n\t\t\treturn dispatch.Start(bot.Settings.DispatchMaxWorkerAmount, bot.Settings.DispatchJobsLimit)\n\t\t}\n\t\treturn dispatch.Stop()\n\tcase DeprecatedName:\n\t\tif enable {\n\t\t\tif bot.apiServer == nil {\n\t\t\t\tvar filePath string\n\t\t\t\tfilePath, err = config.GetAndMigrateDefaultPath(bot.Settings.ConfigFile)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbot.apiServer, err = setupAPIServerManager(&bot.Config.RemoteControl, &bot.Config.Profiler, bot.ExchangeManager, bot, bot.portfolioManager, filePath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.apiServer.StartRESTServer()\n\t\t}\n\t\treturn bot.apiServer.StopRESTServer()\n\tcase WebsocketName:\n\t\tif enable {\n\t\t\tif bot.apiServer == nil {\n\t\t\t\tvar filePath string\n\t\t\t\tfilePath, err = config.GetAndMigrateDefaultPath(bot.Settings.ConfigFile)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tbot.apiServer, err = setupAPIServerManager(&bot.Config.RemoteControl, &bot.Config.Profiler, bot.ExchangeManager, bot, bot.portfolioManager, filePath)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.apiServer.StartWebsocketServer()\n\t\t}\n\t\treturn bot.apiServer.StopWebsocketServer()\n\tcase grpcName, grpcProxyName:\n\t\treturn errGRPCManagementFault\n\tcase dataHistoryManagerName:\n\t\tif enable {\n\t\t\tif bot.dataHistoryManager == nil {\n\t\t\t\tbot.dataHistoryManager, err = SetupDataHistoryManager(bot.ExchangeManager, bot.DatabaseManager, &bot.Config.DataHistoryManager)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.dataHistoryManager.Start()\n\t\t}\n\t\treturn bot.dataHistoryManager.Stop()\n\tcase vm.Name:\n\t\tif enable {\n\t\t\tif bot.gctScriptManager == nil {\n\t\t\t\tbot.gctScriptManager, err = vm.NewManager(&bot.Config.GCTScript)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.gctScriptManager.Start(&bot.ServicesWG)\n\t\t}\n\t\treturn bot.gctScriptManager.Stop()\n\tcase strings.ToLower(CurrencyStateManagementName):\n\t\tif enable {\n\t\t\tif bot.currencyStateManager == nil {\n\t\t\t\tbot.currencyStateManager, err = SetupCurrencyStateManager(\n\t\t\t\t\tbot.Config.CurrencyStateManager.Delay,\n\t\t\t\t\tbot.ExchangeManager)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn bot.currencyStateManager.Start()\n\t\t}\n\t\treturn bot.currencyStateManager.Stop()\n\t}\n\treturn fmt.Errorf(\"%s: %w\", subSystemName, errSubsystemNotFound)\n}", "func (tuo *TimingUpdateOne) SetUnit(s string) *TimingUpdateOne {\n\ttuo.mutation.SetUnit(s)\n\treturn tuo\n}", "func (v *Switch) SetActive(isActive bool) {\n\tC.gtk_switch_set_active(v.native(), gbool(isActive))\n}", "func (o *OscSync) Start(sampleRate int, connectedMask int) {\n\tif sampleRate > maxSamples {\n\t\tpanic(\"sample rate is out of range\")\n\t}\n\n\to.sampleRate = float32(sampleRate)\n\n\tfor i := 0; i < sampleRate; i++ {\n\t\to.waveTable[Sin][i] = float32(math.Sin(float64(2*math.Pi*float64(i)) / float64(sampleRate)))\n\t\to.waveTable[Saw][i] = (float32(i) / (float32(sampleRate) / 2)) - 1\n\t\to.waveTable[Square][i] = -1\n\t\tif i < sampleRate/2 {\n\t\t\to.waveTable[Square][i] = 1\n\t\t}\n\n\t\tif i < sampleRate/2 {\n\t\t\to.waveTable[Triangle][i] = (float32(i) / (float32(sampleRate) / 4)) - 1\n\t\t}\n\t}\n}", "func (s *DialogCodeHookInvocationSetting) SetActive(v bool) *DialogCodeHookInvocationSetting {\n\ts.Active = &v\n\treturn s\n}", "func and(c *CPU) {\nc.registers.a = c.registers.a & c.\n}", "func (dn *Daemon) writeUnits(units []ign3types.Unit) error {\n\tvar enabledUnits []string\n\tvar disabledUnits []string\n\n\tisCoreOSVariant := dn.os.IsCoreOSVariant()\n\n\tfor _, u := range units {\n\t\tif err := writeUnit(u, pathSystemd, isCoreOSVariant); err != nil {\n\t\t\treturn fmt.Errorf(\"daemon could not write systemd unit: %w\", err)\n\t\t}\n\t\t// if the unit doesn't note if it should be enabled or disabled then\n\t\t// honour system presets. This to account for an edge case where you\n\t\t// deleted a MachineConfig that enabled/disabled the unit to revert,\n\t\t// but the unit itself is referenced in other MCs. deleteStaleData() will\n\t\t// catch fully deleted units.\n\t\t// if the unit should be enabled/disabled, then enable/disable it.\n\t\t// this is a no-op if the system wasn't change this iteration\n\t\t// Also, enable and disable as one command, as if any operation fails\n\t\t// we'd bubble up the error anyways, and we save a lot of time doing this.\n\t\t// Presets must be done individually as we don't consider a failed preset\n\t\t// as an error, but it would cause other presets that would have succeeded\n\t\t// to not go through.\n\n\t\tif u.Enabled != nil {\n\t\t\tif *u.Enabled {\n\t\t\t\tenabledUnits = append(enabledUnits, u.Name)\n\t\t\t} else {\n\t\t\t\tdisabledUnits = append(disabledUnits, u.Name)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := dn.presetUnit(u); err != nil {\n\t\t\t\t// Don't fail here, since a unit may have a dropin referencing a nonexisting actual unit\n\t\t\t\tklog.Infof(\"Could not reset unit preset for %s, skipping. (Error msg: %v)\", u.Name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(enabledUnits) > 0 {\n\t\tif err := dn.enableUnits(enabledUnits); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif len(disabledUnits) > 0 {\n\t\tif err := dn.disableUnits(disabledUnits); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *TargetableRemarketingListsListCall) Active(active bool) *TargetableRemarketingListsListCall {\n\tc.urlParams_.Set(\"active\", fmt.Sprint(active))\n\treturn c\n}", "func (g *Gini) Deactivate(m z.Lit) {\n\tg.xo.Deactivate(m)\n}", "func (ag *AccountService) EnableSMS(enable bool) (err error) {\n\topts := NewOptionals()\n\tif enable {\n\t\topts.Add(\"device\", \"sms\")\n\t} else {\n\t\topts.Add(\"device\", \"none\")\n\t}\n\terr = ag.Call(\"POST\", \"account/update_delivery_device\", opts, nil)\n\treturn\n}", "func (t *AudioPlayer) Start(a *app.App) {\n\n\tvar err error\n\tt.pc1, err = NewPlayerControl(a, \"bomb1.wav\")\n\tt.pc1.player.SetLooping(false)\n\tif err != nil {\n\t\ta.Log().Fatal(\"%s\", err)\n\t}\n\tt.pc1.SetPosition(40, 10)\n\ta.DemoPanel().Add(t.pc1)\n\n\tt.pc2, err = NewPlayerControl(a, \"Vivaldi1.wav\")\n\tif err != nil {\n\t\ta.Log().Fatal(\"%s\", err)\n\t}\n\tt.pc2.SetPosition(40, t.pc1.Position().Y+t.pc1.Height()+20)\n\ta.DemoPanel().Add(t.pc2)\n\n\tt.pc3, err = NewPlayerControl(a, \"bomb2.ogg\")\n\tt.pc3.player.SetLooping(false)\n\tif err != nil {\n\t\ta.Log().Fatal(\"%s\", err)\n\t}\n\tt.pc3.SetPosition(40, t.pc2.Position().Y+t.pc2.Height()+40)\n\ta.DemoPanel().Add(t.pc3)\n\n\tt.pc4, err = NewPlayerControl(a, \"Bach1.ogg\")\n\tif err != nil {\n\t\ta.Log().Fatal(\"%s\", err)\n\t}\n\tt.pc4.SetPosition(40, t.pc3.Position().Y+t.pc3.Height()+20)\n\ta.DemoPanel().Add(t.pc4)\n}", "func (o Output) Active() bool {\n\tfor _, mode := range o.Modes {\n\t\tif mode.Active {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}" ]
[ "0.53334343", "0.51506", "0.502237", "0.49990132", "0.49359998", "0.49289322", "0.4865619", "0.4845351", "0.48290035", "0.47790095", "0.47710362", "0.47578385", "0.47541368", "0.4745318", "0.4735954", "0.46489817", "0.4642632", "0.46341166", "0.46273163", "0.4612431", "0.45916343", "0.45882288", "0.45825854", "0.4564361", "0.45505548", "0.45483536", "0.45353666", "0.4518251", "0.45098075", "0.4472148", "0.44695702", "0.44661805", "0.44548917", "0.44505596", "0.44493067", "0.44399053", "0.44390363", "0.4434755", "0.44322783", "0.4420098", "0.44194788", "0.44177568", "0.44147015", "0.441305", "0.44039354", "0.44002455", "0.43915668", "0.4383737", "0.4382576", "0.43783498", "0.437546", "0.4374819", "0.4368064", "0.4367925", "0.4367846", "0.43628404", "0.43552673", "0.43404755", "0.43365747", "0.4333541", "0.43214273", "0.43204832", "0.43203276", "0.43013614", "0.4292113", "0.42742875", "0.42702234", "0.4268837", "0.42582822", "0.42574766", "0.424271", "0.42397103", "0.42395774", "0.42360163", "0.4234815", "0.4233493", "0.42300886", "0.42298582", "0.42236754", "0.42198354", "0.4214558", "0.42128807", "0.42054808", "0.42018247", "0.42009786", "0.41907686", "0.41893756", "0.41892812", "0.41887936", "0.41835693", "0.4182142", "0.41634157", "0.41562018", "0.415445", "0.4154416", "0.4149669", "0.41495296", "0.4145207", "0.41345453", "0.41329208" ]
0.6280715
0
Retrieves the active state of a DSP unit.
func (d *DSP) IsActive() (bool, error) { var active C.FMOD_BOOL res := C.FMOD_DSP_GetActive(d.cptr, &active) return setBool(active), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *Swapspace) GetActive(ctx context.Context) (active bool, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceSwapspace, \"Active\").Store(&active)\n\treturn\n}", "func (sv *Unit) Active() unit.Activation {\n\tlog.WithField(\"sv\", sv).Debugf(\"sv.Active\")\n\n\t// based of Systemd transtition table found in https://goo.gl/oEjikJ\n\tswitch sv.Sub() {\n\tcase dead:\n\t\treturn unit.Inactive\n\tcase failed:\n\t\treturn unit.Failed\n\tcase reload:\n\t\treturn unit.Reloading\n\tcase running, exited:\n\t\treturn unit.Active\n\tcase start, startPre, startPost, autoRestart:\n\t\treturn unit.Activating\n\tcase stop, stopSigabrt, stopPost, stopSigkill, stopSigterm, finalSigkill, finalSigterm:\n\t\treturn unit.Deactivating\n\tdefault:\n\t\tpanic(\"Unknown service sub state\")\n\t}\n}", "func (m *DeviceManagementIntentDeviceState) GetState()(*ComplianceStatus) {\n val, err := m.GetBackingStore().Get(\"state\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*ComplianceStatus)\n }\n return nil\n}", "func GetActiveUniform(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tsyscall.Syscall9(gpGetActiveUniform, 7, uintptr(program), uintptr(index), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(xtype)), uintptr(unsafe.Pointer(name)), 0, 0)\n}", "func GetCurrentState() {\n\n}", "func (m *InMemory) Current() (qaclana.State, error) {\n\treturn m.s, nil\n}", "func (r *DeviceManagementScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceManagementScriptDeviceState, 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 (s *System) State() []float32 {\n\treturn s.stateVector\n}", "func (m *DeviceEnrollmentWindowsHelloForBusinessConfiguration) GetState()(*Enablement) {\n val, err := m.GetBackingStore().Get(\"state\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*Enablement)\n }\n return nil\n}", "func (c *Component) GetActive() bool {\n\treturn c.active\n}", "func GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {\n\tvar length, si int32\n\tvar typ uint32\n\tname = strings.Repeat(\"\\x00\", 256)\n\tcname := gl.Str(name)\n\tgl.GetActiveUniform(p.Value, uint32(index), int32(len(name)-1), &length, &si, &typ, cname)\n\tname = name[:strings.IndexRune(name, 0)]\n\treturn name, int(si), Enum(typ)\n}", "func GetActiveUniform(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveUniform(gpGetActiveUniform, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func GetActiveUniform(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveUniform(gpGetActiveUniform, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func assertSystemdActiveState(unitName string) error {\n\tfetchSystemdActiveState := func() error {\n\t\tus, err := cAPI.UnitState(unitName)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error getting unit state of %s: %v\", unitName, err)\n\t\t}\n\n\t\t// Get systemd state and check the state is active & loaded.\n\t\tif us.SystemdActiveState != \"active\" || us.SystemdLoadState != \"loaded\" {\n\t\t\treturn fmt.Errorf(\"Failed to find an active unit %s\", unitName)\n\t\t}\n\t\treturn nil\n\t}\n\n\ttimeout, err := waitForState(fetchSystemdActiveState)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to find an active unit %s within %v, err: %v\",\n\t\t\tunitName, timeout, err)\n\t}\n\n\treturn nil\n}", "func DUTActive(ctx context.Context, servoInst *servo.Servo) (bool, error) {\n\tstate, err := servoInst.GetECSystemPowerState(ctx)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"failed to get ec_system_power_state\")\n\t}\n\ttesting.ContextLog(ctx, \"state: \", state)\n\tif state == \"S0\" {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (m *DeviceHealthAttestationState) GetDeviceHealthAttestationStatus()(*string) {\n val, err := m.GetBackingStore().Get(\"deviceHealthAttestationStatus\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func GetActiveUniform(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *int8) {\n C.glowGetActiveUniform(gpGetActiveUniform, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func (m *MacOSSoftwareUpdateStateSummary) GetState()(*MacOSSoftwareUpdateState) {\n val, err := m.GetBackingStore().Get(\"state\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*MacOSSoftwareUpdateState)\n }\n return nil\n}", "func (m *Device) GetState() (val map[string]Property, set bool) {\n\tif m.State == nil {\n\t\treturn\n\t}\n\n\treturn *m.State, true\n}", "func (v *Switch) GetActive() bool {\n\tc := C.gtk_switch_get_active(v.native())\n\treturn gobool(c)\n}", "func (c current) Active() prometheus.Gauge {\n\treturn c.active\n}", "func (sm *State52) CurrentState() string {\n\tsm.stateMutex.RLock()\n\tdefer sm.stateMutex.RUnlock()\n\treturn sm.currentState\n}", "func (f *Machine) State() uint8 {\n\treturn f.state\n}", "func (i *Incarnation) State() string {\n\treturn string(i.status.State.Current)\n}", "func GetActiveUniform(program Uint, index Uint, bufSize Sizei, length *Sizei, size *Int, kind *Enum, name []byte) {\n\tcprogram, _ := (C.GLuint)(program), cgoAllocsUnknown\n\tcindex, _ := (C.GLuint)(index), cgoAllocsUnknown\n\tcbufSize, _ := (C.GLsizei)(bufSize), cgoAllocsUnknown\n\tclength, _ := (*C.GLsizei)(unsafe.Pointer(length)), cgoAllocsUnknown\n\tcsize, _ := (*C.GLint)(unsafe.Pointer(size)), cgoAllocsUnknown\n\tckind, _ := (*C.GLenum)(unsafe.Pointer(kind)), cgoAllocsUnknown\n\tcname, _ := (*C.GLchar)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&name)).Data)), cgoAllocsUnknown\n\tC.glGetActiveUniform(cprogram, cindex, cbufSize, clength, csize, ckind, cname)\n}", "func (t *SmartTripper) State() State {\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\n\treturn t.state\n}", "func (m *Machine) State() State {\n\treturn m.currentState\n}", "func (r *DeviceHealthScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceHealthScriptDeviceState, 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 (r *DeviceHealthScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceHealthScriptDeviceState, 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 (u *Unit) GetUnitStatus(w http.ResponseWriter) error {\n\tconn, err := sd.NewSystemdConnection()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get systemd bus connection: %v\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\tunits, err := conn.ListUnitsByNames([]string{u.Unit})\n\tif err != nil {\n\t\tlog.Errorf(\"Failed get unit '%s' status: %v\", u.Unit, err)\n\t\treturn err\n\t}\n\n\tstatus := UnitStatus{\n\t\tStatus: units[0].ActiveState,\n\t\tUnit: u.Unit,\n\t}\n\n\tjson.NewEncoder(w).Encode(status)\n\n\treturn nil\n}", "func (m *WorkforceIntegration) GetIsActive()(*bool) {\n return m.isActive\n}", "func GetState(key string) interface{} {\n\tmu.Lock()\n\tdefer mu.Unlock()\n\treturn state[key]\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *int8) {\n C.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func (m *DeviceHealthAttestationState) GetHealthAttestationSupportedStatus()(*string) {\n val, err := m.GetBackingStore().Get(\"healthAttestationSupportedStatus\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (gt *myGoTickle) Active() bool {\n\treturn gt.avtive\n}", "func GetActiveSignal(context echo.Context) error {\n\tresponse, err := helpers.GetActiveSignal(context.Param(\"address\"), context.Param(\"port\"))\n\tif err != nil {\n\t\treturn context.JSON(http.StatusInternalServerError, err.Error())\n\t}\n\n\treturn context.JSON(http.StatusOK, response)\n}", "func (g *Gameboi) GetState() string {\n\treturn fmt.Sprintf(\"Acc: %d Ptr: %d Instr: %#v\\n\", g.acc, g.instrPointer, g.program[g.instrPointer])\n}", "func (device *Device) deviceState() deviceState {\n\treturn deviceState(device.state.state.Load())\n}", "func (s *SecretManager) getCurrentState(namespace string, name string) (map[string][]byte, error) {\n\tcurrentState, err := s.kubernetes.ReadSecret(namespace, name)\n\tif err != nil {\n\t\tlogger.Debugf(\"failed to read '%s/%s' secret from kubernetes api: %v\", namespace, name, err)\n\t}\n\treturn currentState, err\n}", "func (rf *Raft) GetState() (int, bool) {\n\n var term int\n var isleader bool\n // Your code here (2A).\n rf.mu.Lock()\n defer rf.mu.Unlock()\n term = rf.currentTerm\n isleader = false\n if rf.state == LEADER {\n isleader = true\n }\n return term, isleader\n}", "func (h *Harness) State() *gmon.Ganglia {\n\taddr := fmt.Sprintf(\"%s:%d\", localhostIP, h.port)\n\tganglia, err := gmon.RemoteRead(\"tcp\", addr)\n\tif err != nil {\n\t\th.t.Fatal(err)\n\t}\n\treturn ganglia\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func idle() State_t {\n\t\n}", "func (state *JoystickState) Get() {\n\tC.al_get_joystick_state((*C.ALLEGRO_JOYSTICK)(state.joystick), &state.ptr)\n\tfor i := 0; i < len(state.Button); i++ {\n\t\tstate.Button[i] = int(state.ptr.button[C.int(i)])\n\t}\n\tfor i := 0; i < len(state.Stick); i++ {\n\t\tfor j := 0; j < len(state.Stick[i].Axis); j++ {\n\t\t\tstate.Stick[i].Axis[j] = float32(state.ptr.stick[C.int(i)].axis[C.int(j)])\n\t\t}\n\t}\n}", "func (obj *Device) GetSamplerState(\n\tsampler uint32,\n\ttyp SAMPLERSTATETYPE,\n) (value uint32, err Error) {\n\tret, _, _ := syscall.Syscall6(\n\t\tobj.vtbl.GetSamplerState,\n\t\t4,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(sampler),\n\t\tuintptr(typ),\n\t\tuintptr(unsafe.Pointer(&value)),\n\t\t0,\n\t\t0,\n\t)\n\terr = toErr(ret)\n\treturn\n}", "func (d *Driver) GetState() (state.State, error) {\n\tif err := d.verifyRootPermissions(); err != nil {\n\t\treturn state.Error, err\n\t}\n\n\tp, err := d.findHyperkitProcess()\n\tif err != nil {\n\t\treturn state.Error, err\n\t}\n\tif p == nil {\n\t\treturn state.Stopped, nil\n\t}\n\treturn state.Running, nil\n}", "func (cs *ConnectivityState) GetCurrentState() int64 {\n\treturn cs.state\n}", "func (m *TimeOffReason) GetIsActive()(*bool) {\n val, err := m.GetBackingStore().Get(\"isActive\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tsyscall.Syscall9(gpGetActiveAttrib, 7, uintptr(program), uintptr(index), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(xtype)), uintptr(unsafe.Pointer(name)), 0, 0)\n}", "func (m *ProgramControl) GetStatus()(*string) {\n val, err := m.GetBackingStore().Get(\"status\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (b *Backend) Status() (State, error) {\n\tb.mutex.Lock()\n\tdefer b.mutex.Unlock()\n\tb.init()\n\treturn b.state, b.lastFail\n}", "func GetActiveUniformsiv(program uint32, uniformCount int32, uniformIndices *uint32, pname uint32, params *int32) {\n\tsyscall.Syscall6(gpGetActiveUniformsiv, 5, uintptr(program), uintptr(uniformCount), uintptr(unsafe.Pointer(uniformIndices)), uintptr(pname), uintptr(unsafe.Pointer(params)), 0)\n}", "func (dm *DCOSMetadata) getState(ctx context.Context, cli calls.Sender) (*agent.Response_GetState,\n\terror) {\n\tresp, err := cli.Send(ctx, calls.NonStreaming(calls.GetState()))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr, err := processResponse(resp, agent.Response_GET_STATE)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tgs := r.GetGetState()\n\tif gs == nil {\n\t\treturn nil, errors.New(\"the getState response from the mesos agent was empty\")\n\t}\n\treturn gs, nil\n}", "func (se *StateEngine) State() *state.State {\n\treturn se.state\n}", "func (c *ConsoleWrapper) CurrentState() string {\n\treturn c.state.String()\n}", "func (c *ConsoleWrapper) CurrentState() string {\n\treturn c.state.String()\n}", "func GetActiveUniformName(program uint32, uniformIndex uint32, bufSize int32, length *int32, uniformName *uint8) {\n\tsyscall.Syscall6(gpGetActiveUniformName, 5, uintptr(program), uintptr(uniformIndex), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(uniformName)), 0)\n}", "func (p *PhidgetDigitalOutput) GetState() (bool, error) {\n\tvar r C.int\n\tcerr := C.PhidgetDigitalOutput_getState(p.handle, &r)\n\tif cerr != C.EPHIDGET_OK {\n\t\treturn false, p.phidgetError(cerr)\n\t}\n\treturn r != 0, nil\n}", "func (machine *Machine) Current() StateType {\n\tmachine.lock.Lock()\n\tdefer machine.lock.Unlock()\n\treturn machine.current\n}", "func (rf *Raft) GetState() (int, bool) {\n\n var term int\n var isleader bool\n // Your code here (2A).\n rf.mu.Lock()\n term = rf.currentTerm\n isleader = (rf.state == StateLeader)\n rf.mu.Unlock()\n return term, isleader\n}", "func (r *DeviceManagementIntentDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceManagementIntentDeviceState, 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 (l unitList) State() string {\n\tif len(l) == 0 {\n\t\treturn \"\"\n\t}\n\tstate := l[0].State\n\tfor i := 1; i < len(l); i++ {\n\t\tif l[i].State != state {\n\t\t\treturn \"\"\n\t\t}\n\t}\n\treturn state\n}", "func GetActiveUniformsiv(program uint32, uniformCount int32, uniformIndices *uint32, pname uint32, params *int32) {\n\tC.glowGetActiveUniformsiv(gpGetActiveUniformsiv, (C.GLuint)(program), (C.GLsizei)(uniformCount), (*C.GLuint)(unsafe.Pointer(uniformIndices)), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func GetActiveUniformsiv(program uint32, uniformCount int32, uniformIndices *uint32, pname uint32, params *int32) {\n\tC.glowGetActiveUniformsiv(gpGetActiveUniformsiv, (C.GLuint)(program), (C.GLsizei)(uniformCount), (*C.GLuint)(unsafe.Pointer(uniformIndices)), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func (o JobStatusPtrOutput) Active() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v JobStatus) *int { return v.Active }).(pulumi.IntPtrOutput)\n}", "func (d *Driver) GetState() (state.State, error) {\n\terr := d.connectAPI()\n\tif err != nil {\n\t\treturn state.Paused, err\n\t}\n\n\tif d.ping() {\n\t\treturn state.Running, nil\n\t}\n\treturn state.Paused, nil\n}", "func GetActiveUniformsiv(program uint32, uniformCount int32, uniformIndices *uint32, pname uint32, params *int32) {\n C.glowGetActiveUniformsiv(gpGetActiveUniformsiv, (C.GLuint)(program), (C.GLsizei)(uniformCount), (*C.GLuint)(unsafe.Pointer(uniformIndices)), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func (m *SecurityActionState) GetStatus()(*OperationStatus) {\n val, err := m.GetBackingStore().Get(\"status\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*OperationStatus)\n }\n return nil\n}", "func (b Bot) CurrentState() RobotState {\n\tb.mu.Lock()\n\tdefer b.mu.Unlock()\n\tlog.Println(b.state)\n\treturn b.state\n}", "func (s *State) Active() bool {\n\treturn atomic.LoadInt64(&s.active) == 1\n}", "func (s *StateMgr) State(n State) State {\n\treturn s.current\n}", "func (svr *TMServer) GetState(ctx context.Context, _ *pb.Empty) (*pb.TuringMachine, error) {\n\treturn svr.TuringMachine, nil\n}", "func GetActiveAttrib(program Uint, index Uint, bufSize Sizei, length *Sizei, size *Int, kind *Enum, name []byte) {\n\tcprogram, _ := (C.GLuint)(program), cgoAllocsUnknown\n\tcindex, _ := (C.GLuint)(index), cgoAllocsUnknown\n\tcbufSize, _ := (C.GLsizei)(bufSize), cgoAllocsUnknown\n\tclength, _ := (*C.GLsizei)(unsafe.Pointer(length)), cgoAllocsUnknown\n\tcsize, _ := (*C.GLint)(unsafe.Pointer(size)), cgoAllocsUnknown\n\tckind, _ := (*C.GLenum)(unsafe.Pointer(kind)), cgoAllocsUnknown\n\tcname, _ := (*C.GLchar)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&name)).Data)), cgoAllocsUnknown\n\tC.glGetActiveAttrib(cprogram, cindex, cbufSize, clength, csize, ckind, cname)\n}", "func GetActiveUniformName(program uint32, uniformIndex uint32, bufSize int32, length *int32, uniformName *uint8) {\n\tC.glowGetActiveUniformName(gpGetActiveUniformName, (C.GLuint)(program), (C.GLuint)(uniformIndex), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLchar)(unsafe.Pointer(uniformName)))\n}", "func GetActiveUniformName(program uint32, uniformIndex uint32, bufSize int32, length *int32, uniformName *uint8) {\n\tC.glowGetActiveUniformName(gpGetActiveUniformName, (C.GLuint)(program), (C.GLuint)(uniformIndex), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLchar)(unsafe.Pointer(uniformName)))\n}", "func (e HybridKFEstimate) State() *mat64.Vector {\n\treturn e.state\n}", "func (self Sound) Getstatus() SoundStatus { \n switch C.sfSound_getStatus(self.Cref) {\n\tcase 0: return Stopped\n\tcase 1: return Paused\n\tcase 2: return Playing\n\t}\n\treturn UnknownSoundStatus\n}", "func (c *CmdBuff) IsActive() bool {\n\tc.mx.RLock()\n\tdefer c.mx.RUnlock()\n\n\treturn c.active\n}", "func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {\n\tvar length, si int32\n\tvar typ uint32\n\tname = strings.Repeat(\"\\x00\", 256)\n\tcname := gl.Str(name)\n\tgl.GetActiveAttrib(p.Value, uint32(index), int32(len(name)-1), &length, &si, &typ, cname)\n\tname = name[:strings.IndexRune(name, 0)]\n\treturn name, int(si), Enum(typ)\n}", "func (d *DSP) Idle() (bool, error) {\n\tvar idle C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetIdle(d.cptr, &idle)\n\treturn setBool(idle), errs[res]\n}", "func (o *RuleActionStore) GetActive() bool {\n\tif o == nil || o.Active == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Active\n}", "func Active() bool {\n\treturn isActive\n}", "func GetActiveAtomicCounterBufferiv(program uint32, bufferIndex uint32, pname uint32, params *int32) {\n\tsyscall.Syscall6(gpGetActiveAtomicCounterBufferiv, 4, uintptr(program), uintptr(bufferIndex), uintptr(pname), uintptr(unsafe.Pointer(params)), 0, 0)\n}", "func (o *EquipmentBaseSensor) GetState() string {\n\tif o == nil || o.State == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.State\n}", "func (m *ScheduleItem) GetStatus()(*FreeBusyStatus) {\n val, err := m.GetBackingStore().Get(\"status\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*FreeBusyStatus)\n }\n return nil\n}", "func (q *Queue) Active() (uint, error) {\n\treturn q.getAcker().Active()\n}", "func GetActiveAtomicCounterBufferiv(program uint32, bufferIndex uint32, pname uint32, params *int32) {\n\tC.glowGetActiveAtomicCounterBufferiv(gpGetActiveAtomicCounterBufferiv, (C.GLuint)(program), (C.GLuint)(bufferIndex), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func GetActiveAtomicCounterBufferiv(program uint32, bufferIndex uint32, pname uint32, params *int32) {\n\tC.glowGetActiveAtomicCounterBufferiv(gpGetActiveAtomicCounterBufferiv, (C.GLuint)(program), (C.GLuint)(bufferIndex), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func GetActiveAtomicCounterBufferiv(program uint32, bufferIndex uint32, pname uint32, params *int32) {\n C.glowGetActiveAtomicCounterBufferiv(gpGetActiveAtomicCounterBufferiv, (C.GLuint)(program), (C.GLuint)(bufferIndex), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))\n}", "func (o *InlineResponse20075StatsBilling) GetActive() string {\n\tif o == nil || o.Active == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Active\n}", "func (r *Radio) State() string {\n\treturn \"idle\"\n}", "func (a *BackoffTimerValue) GetUnitTimerValue() (unitTimerValue uint8) {}", "func (r *DeviceManagementScriptUserStateRequest) Get(ctx context.Context) (resObj *DeviceManagementScriptUserState, 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 GetActiveUniformBlockiv(program uint32, uniformBlockIndex uint32, pname uint32, params *int32) {\n\tsyscall.Syscall6(gpGetActiveUniformBlockiv, 4, uintptr(program), uintptr(uniformBlockIndex), uintptr(pname), uintptr(unsafe.Pointer(params)), 0, 0)\n}", "func (p *Processus) Active(body string) (interface{}, int, error) {\n\treturn p.engine.Active(), -1, nil\n}", "func (l *RelayDriver) State() bool {\n\treturn l.high\n}", "func (se *StateEngine) State() States {\n\tco := se.curr\n\n\tif co == nil {\n\t\t// return se.owner\n\t\treturn nil\n\t}\n\n\treturn co.Engine().State()\n}", "func (_DelegationController *DelegationControllerSession) GetState(delegationId *big.Int) (uint8, error) {\n\treturn _DelegationController.Contract.GetState(&_DelegationController.CallOpts, delegationId)\n}", "func (s *stateMachine) State() (*State, time.Time) {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn s.state, s.ts\n}" ]
[ "0.6023611", "0.5778541", "0.57009274", "0.55964816", "0.5577327", "0.5517794", "0.5509092", "0.550754", "0.5505832", "0.5490959", "0.5471798", "0.5457392", "0.5457392", "0.5454368", "0.543068", "0.5400681", "0.53836554", "0.5362608", "0.535319", "0.52928674", "0.52850723", "0.52759767", "0.52542144", "0.5253564", "0.52450055", "0.52332306", "0.52235323", "0.52196544", "0.52196544", "0.52016455", "0.5194295", "0.5167541", "0.51664144", "0.51570576", "0.5148734", "0.5146986", "0.5143746", "0.51396084", "0.5128443", "0.51261747", "0.5123939", "0.5120239", "0.5120239", "0.508419", "0.5081314", "0.5077927", "0.5076967", "0.5072663", "0.5068253", "0.5066519", "0.5059168", "0.50574845", "0.5052706", "0.50304824", "0.50289905", "0.50260526", "0.50260526", "0.5018189", "0.50104266", "0.5005825", "0.5005789", "0.5004578", "0.50017303", "0.49927703", "0.49927703", "0.4989954", "0.49867818", "0.49797794", "0.49794522", "0.49764198", "0.4975839", "0.4974265", "0.49714732", "0.49644873", "0.49638054", "0.49638054", "0.49453634", "0.49441573", "0.4938681", "0.49355048", "0.49343997", "0.49300057", "0.49284503", "0.49277532", "0.4926671", "0.4909097", "0.4901801", "0.49009344", "0.49009344", "0.48999804", "0.48981124", "0.48952556", "0.48926786", "0.4889656", "0.4889379", "0.48867232", "0.48852506", "0.4881633", "0.4880255", "0.48779765" ]
0.5368361
17
Enables or disables the read callback of a DSP unit so that it does or doesn't process the data coming into it. A DSP unit that is disabled still processes its inputs, it will just be 'dry'. bypass: Boolean to cause the read callback of the DSP unit to be bypassed or not. Default = false. If a unit is bypassed, it will still process its inputs. To disable the unit and all of its inputs, use "DSP.SetActive" instead.
func (d *DSP) SetBypass(bypass bool) error { res := C.FMOD_DSP_SetBypass(d.cptr, getBool(bypass)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) Bypass() (bool, error) {\n\tvar bypass C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetBypass(d.cptr, &bypass)\n\treturn setBool(bypass), errs[res]\n}", "func SPIDelayRead(v bool) func(*options) error {\n\treturn func(o *options) error { return o.setSPIDelayRead(v) }\n}", "func (d *dependencySleepAfterInitializeSubscribe) enable() {\n\td.f = true\n}", "func (r *Router) UseBypass(mwf ...gorillamux.MiddlewareFunc) {\n\tr.mux.Use(mwf...)\n}", "func (device *SilentStepperBrick) Disable() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionDisable), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func DisableEffects() {\n\n\tgl.UseProgram(0)\n\tpaunchEffect = nil\n}", "func EnableClock(lp bool) {\n\tRCC := rcc.RCC\n\tif lp {\n\t\tRCC.FMCLPEN().AtomicSet()\n\t} else {\n\t\tRCC.FMCLPEN().AtomicClear()\n\n\t}\n\tRCC.FMCEN().AtomicSet()\n}", "func (device *SilentStepperBrick) Enable() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionEnable), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (self *PhysicsP2) Enable1O(object interface{}, debug bool) {\n self.Object.Call(\"enable\", object, debug)\n}", "func (o NetworkRuleSetResponseOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v NetworkRuleSetResponse) *string { return v.Bypass }).(pulumi.StringPtrOutput)\n}", "func (o NetworkRuleSetResponsePtrOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *NetworkRuleSetResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Bypass\n\t}).(pulumi.StringPtrOutput)\n}", "func GetBypass(conn io.ReadWriter) (bypass Bypass, err error) {\n\n\tresp, err := getQuery(getBypass, conn)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn *resp.(*Bypass), err\n}", "func (o NetworkRuleSetPtrOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *NetworkRuleSet) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Bypass\n\t}).(pulumi.StringPtrOutput)\n}", "func enable(t Type, delay time.Duration) error {\n\tstartCollecting()\n\n\tvar err error\n\tdone := make(chan struct{})\n\tinout <- inOut{\n\t\tin: enableSignal{t: t, delay: delay, err: &err},\n\t\tout: done,\n\t}\n\t<-done\n\treturn err\n}", "func (p *Port) EnableClock(lp bool) {\n\tenableClock(p, lp)\n}", "func (o *Manager) LoopSetup(ctx context.Context, fd dbus.UnixFD, options map[string]dbus.Variant) (resultingDevice dbus.ObjectPath, err error) {\n\terr = o.object.CallWithContext(ctx, InterfaceManager+\".LoopSetup\", 0, fd, options).Store(&resultingDevice)\n\treturn\n}", "func (o NetworkRuleSetOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v NetworkRuleSet) *string { return v.Bypass }).(pulumi.StringPtrOutput)\n}", "func (d *Device) UseLowPower(power bool) {\n\tif power {\n\t\td.bwRate.lowPower = 1\n\t} else {\n\t\td.bwRate.lowPower = 0\n\t}\n\td.bus.WriteRegister(uint8(d.Address), REG_BW_RATE, []byte{d.bwRate.toByte()})\n}", "func (c *FritzDECT) Enable(enable bool) error {\n\tcmd := \"setswitchoff\"\n\tif enable {\n\t\tcmd = \"setswitchon\"\n\t}\n\n\t// on 0/1 - DECT Switch state off/on (empty if unknown or error)\n\tresp, err := c.conn.ExecCmd(cmd)\n\n\tvar on bool\n\tif err == nil {\n\t\ton, err = strconv.ParseBool(resp)\n\t\tif err == nil && enable != on {\n\t\t\terr = errors.New(\"switch failed\")\n\t\t}\n\t}\n\n\treturn err\n}", "func (d *Device) SoftReset(wait bool) error {\n\treturn d.resetUntilReady(\n\t\tfunc() error {\n\t\t\t// set reset-enable register field\n\t\t\tif err := d.writeRegister(REG_RESET_CTRL,\n\t\t\t\t(&regControlReset{reset: true}).format()[0]); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\t// start measuring time once we initiated reset\n\t\t\tstart := time.Now()\n\t\t\t// clear alerts, updating port status\n\t\t\tif err := d.updateStatus(); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\t// sleep for the remaining reset duration (if any), after subtracting the\n\t\t\t// duration it took to clear the alert registers\n\t\t\tif remaining := softResetDuration - time.Now().Sub(start); remaining > 0 {\n\t\t\t\ttime.Sleep(remaining)\n\t\t\t}\n\t\t\t// clear reset-enable register field\n\t\t\tif err := d.writeRegister(REG_RESET_CTRL,\n\t\t\t\t(&regControlReset{reset: false}).format()[0]); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\twait)\n}", "func (d *Device) startOutputEnableTimer() {\n\tcount := d.brightness << d.colorBit\n\tfor i := uint32(0); i < count; i++ {\n\t\td.oe.Low()\n\t}\n\td.oe.High()\n}", "func (usbAdapter *UsbAdapter) StartReading(device IosDevice, receiver UsbDataReceiver, stopSignal chan interface{}) error {\n\tctx, cleanUp := createContext()\n\tdefer cleanUp()\n\n\tusbDevice, err := OpenDevice(ctx, device)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !device.IsActivated() {\n\t\treturn errors.New(\"device not activated for screen mirroring\")\n\t}\n\n\tconfignum, _ := usbDevice.ActiveConfigNum()\n\tlog.Debugf(\"Config is active: %d, QT config is: %d\", confignum, device.QTConfigIndex)\n\n\tconfig, err := usbDevice.Config(device.QTConfigIndex)\n\tif err != nil {\n\t\treturn errors.New(\"Could not retrieve config\")\n\t}\n\n\tlog.Debugf(\"QT Config is active: %s\", config.String())\n\n\tiface, err := findAndClaimQuickTimeInterface(config)\n\tif err != nil {\n\t\tlog.Debug(\"could not get Quicktime Interface\")\n\t\treturn err\n\t}\n\tlog.Debugf(\"Got QT iface:%s\", iface.String())\n\n\tinboundBulkEndpointIndex, inboundBulkEndpointAddress, err := findBulkEndpoint(iface.Setting, gousb.EndpointDirectionIn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toutboundBulkEndpointIndex, outboundBulkEndpointAddress, err := findBulkEndpoint(iface.Setting, gousb.EndpointDirectionOut)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = clearFeature(usbDevice, inboundBulkEndpointAddress, outboundBulkEndpointAddress)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tinEndpoint, err := iface.InEndpoint(inboundBulkEndpointIndex)\n\tif err != nil {\n\t\tlog.Error(\"couldnt get InEndpoint\")\n\t\treturn err\n\t}\n\tlog.Debugf(\"Inbound Bulk: %s\", inEndpoint.String())\n\n\toutEndpoint, err := iface.OutEndpoint(outboundBulkEndpointIndex)\n\tif err != nil {\n\t\tlog.Error(\"couldnt get OutEndpoint\")\n\t\treturn err\n\t}\n\tlog.Debugf(\"Outbound Bulk: %s\", outEndpoint.String())\n\tusbAdapter.outEndpoint = outEndpoint\n\n\tstream, err := inEndpoint.NewStream(4096, 5)\n\tif err != nil {\n\t\tlog.Fatal(\"couldnt create stream\")\n\t\treturn err\n\t}\n\tlog.Debug(\"Endpoint claimed\")\n\tlog.Infof(\"Device '%s' USB connection ready, waiting for ping..\", device.SerialNumber)\n\tgo func() {\n\t\tlengthBuffer := make([]byte, 4)\n\t\tfor {\n\t\t\tn, err := io.ReadFull(stream, lengthBuffer)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed reading 4bytes length with err:%s only received: %d\", err, n)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t//the 4 bytes header are included in the length, so we need to subtract them\n\t\t\t//here to know how long the payload will be\n\t\t\tlength := binary.LittleEndian.Uint32(lengthBuffer) - 4\n\t\t\tdataBuffer := make([]byte, length)\n\n\t\t\tn, err = io.ReadFull(stream, dataBuffer)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed reading payload with err:%s only received: %d/%d bytes\", err, n, length)\n\t\t\t\tvar signal interface{}\n\t\t\t\tstopSignal <- signal\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif usbAdapter.Dump {\n\t\t\t\t_, err := usbAdapter.DumpInWriter.Write(dataBuffer)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatalf(\"Failed dumping data:%v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\treceiver.ReceiveData(dataBuffer)\n\t\t}\n\t}()\n\n\t<-stopSignal\n\treceiver.CloseSession()\n\tlog.Info(\"Closing usb stream\")\n\n\terr = stream.Close()\n\tif err != nil {\n\t\tlog.Error(\"Error closing stream\", err)\n\t}\n\tlog.Info(\"Closing usb interface\")\n\tiface.Close()\n\n\tsendQTDisableConfigControlRequest(usbDevice)\n\tlog.Debug(\"Resetting device config\")\n\t_, err = usbDevice.Config(device.UsbMuxConfigIndex)\n\tif err != nil {\n\t\tlog.Warn(err)\n\t}\n\n\treturn nil\n}", "func (self *TileSprite) SetInputEnabledA(member bool) {\n self.Object.Set(\"inputEnabled\", member)\n}", "func (self *Graphics) SetInputEnabledA(member bool) {\n self.Object.Set(\"inputEnabled\", member)\n}", "func (self *PhysicsP2) EnableI(args ...interface{}) {\n self.Object.Call(\"enable\", args)\n}", "func (p *Periph) DisableClock() {\n\tinternal.APB_SetEnabled(unsafe.Pointer(p), false)\n}", "func DisableClock() {\n\trcc.RCC.FMCEN().AtomicClear()\n}", "func (tv *TV) Disable3D() bool {\n\tif tv.Current3DState == \"off\" {\n\t\treturn true\n\t}\n\tdisableResponse := tv.SendCommand(\"400\")\n\tif disableResponse == true {\n\t\ttv.Current3DState = \"off\"\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *channelMeterStruct) setEnabled(value bool) {\n\tthis.mutex.Lock()\n\tenabled := this.enabled\n\n\t/*\n\t * Check if status of meter must be changed.\n\t */\n\tif value != enabled {\n\n\t\t/*\n\t\t * If level meter should be disabled, clear state.\n\t\t */\n\t\tif !value {\n\t\t\tthis.currentValue = 0.0\n\t\t\tthis.peakValue = 0.0\n\t\t\tthis.sampleCounter = 0\n\t\t}\n\n\t\tthis.enabled = value\n\t}\n\n\tthis.mutex.Unlock()\n}", "func (u *LDSUnit) AcceptWave(wave *wavefront.Wavefront, now sim.VTimeInSec) {\n\tu.toRead = wave\n}", "func (d *Device) doConfigure(cfg Configuration) (err error) {\n\n\t// Verify unit communication\n\tif !d.Connected() {\n\t\treturn errNotConnected\n\t}\n\n\tif cfg.AccelRange != 0 {\n\t\td.accelRange = cfg.AccelRange\n\t} else {\n\t\td.accelRange = ACCEL_2G\n\t}\n\n\tif cfg.AccelSampleRate != 0 {\n\t\td.accelSampleRate = cfg.AccelSampleRate\n\t} else {\n\t\td.accelSampleRate = ACCEL_SR_104\n\t}\n\n\tif cfg.GyroRange != 0 {\n\t\td.gyroRange = cfg.GyroRange\n\t} else {\n\t\td.gyroRange = GYRO_2000DPS\n\t}\n\n\tif cfg.GyroSampleRate != 0 {\n\t\td.gyroSampleRate = cfg.GyroSampleRate\n\t} else {\n\t\td.gyroSampleRate = GYRO_SR_104\n\t}\n\n\tdata := d.buf[:1]\n\n\t// Configure accelerometer\n\tdata[0] = uint8(d.accelRange) | uint8(d.accelSampleRate)\n\terr = d.bus.WriteRegister(uint8(d.Address), CTRL1_XL, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Set ODR bit\n\terr = d.bus.ReadRegister(uint8(d.Address), CTRL4_C, data)\n\tif err != nil {\n\t\treturn\n\t}\n\tdata[0] = data[0] &^ BW_SCAL_ODR_ENABLED\n\tdata[0] |= BW_SCAL_ODR_ENABLED\n\terr = d.bus.WriteRegister(uint8(d.Address), CTRL4_C, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Configure gyroscope\n\tdata[0] = uint8(d.gyroRange) | uint8(d.gyroSampleRate)\n\terr = d.bus.WriteRegister(uint8(d.Address), CTRL2_G, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn nil\n}", "func (d *Device) startWrite() {\n\tif d.csPin != machine.NoPin {\n\t\td.csPin.Low()\n\t}\n}", "func (self *PhysicsP2) Enable(object interface{}) {\n self.Object.Call(\"enable\", object)\n}", "func (d *Device) Off() {\n\turl := fmt.Sprintf(\"%s?token=%s\", d.AppServerURL, token)\n\n\tpassThroughRequest := PassThroughRequest{\n\t\tMethod: \"passthrough\",\n\t\tParams: PassThroughRequestParams{\n\t\t\tDeviceID: d.DeviceID,\n\t\t\tRequestData: `{\"system\":{\"set_relay_state\":{\"state\":0}}}`,\n\t\t},\n\t}\n\n\tpayload, _ := json.Marshal(passThroughRequest)\n\n\treq, _ := http.NewRequest(\"POST\", url, bytes.NewReader(payload))\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n}", "func (w *Writer) Bypass() io.Writer {\n\treturn &bypass{writer: w}\n}", "func (p *Periph) DisableClock() {\n\tapb.DisableClock(unsafe.Pointer(p))\n}", "func (p *Periph) EnableClock(lp bool) {\n\tapb.EnableClock(unsafe.Pointer(p), lp)\n}", "func (mtr *Dprdpr1intflopfifo1Metrics) SetDataMuxForceBypassCrcFlopFfUndflow(val metrics.Counter) error {\n\tmtr.metrics.SetCounter(val, mtr.getOffset(\"DataMuxForceBypassCrcFlopFfUndflow\"))\n\treturn nil\n}", "func (b *TestDriver) ClawControl(id uint8, mode uint8) (err error) {\n\tlog.Printf(\"Claw mode: %d\", mode)\n\treturn\n}", "func (p PowerControl) Do() {\n\tgo func() {\n\t\tvar (\n\t\t\tinterval = 1 * time.Second\n\t\t)\n\t\t_in := debounce(interval, p.in)\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-_in:\n\t\t\t\t//out <- val\n\t\t\t\tp.status = !p.status\n\t\t\t\tif p.status {\n\t\t\t\t\tmack.Say(\"power on. Welcome? o c?!\", \"Victoria\") //, \"-v\", \"Victoria\")\n\t\t\t\t} else {\n\t\t\t\t\tmack.Say(\"power off. Buy?buy! o c!?\", \"Victoria\") //, \"-v\", \"Victoria\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n}", "func Disable() {\n\tEnable = false\n}", "func (mtr *Dprdpr0intflopfifo1Metrics) SetDataMuxForceBypassCrcFlopFfUndflow(val metrics.Counter) error {\n\tmtr.metrics.SetCounter(val, mtr.getOffset(\"DataMuxForceBypassCrcFlopFfUndflow\"))\n\treturn nil\n}", "func (this *TEncCfg) SetLoopFilterDisable(b bool) { this.m_bLoopFilterDisable = b }", "func (l *LaunchControl) Run(ctx context.Context) error {\n\tctx, cancel := context.WithCancel(ctx)\n\n\tdefer cancel()\n\tch := make(chan Event, ReadBufferDepth)\n\twg := sync.WaitGroup{}\n\n\tfor i := 0; i < NumChannels; i++ {\n\t\tif err := l.Reset(i); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// The first swap enables double buffering.\n\t\tif err := l.SwapBuffers(i); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := l.SetTemplate(0); err != nil {\n\t\treturn err\n\t}\n\n\tlcfg := drivers.ListenConfig{\n\t\tTimeCode: false,\n\t\tActiveSense: false,\n\t\tSysEx: true,\n\t\tOnErr: func(err error) {\n\t\t\t_ = l.handleError(err)\n\t\t},\n\t}\n\n\tvar err error\n\tl.stopFn, err = l.inputDriver.Listen(func(msg []byte, milliseconds int32) {\n\t\tif len(msg) == 3 {\n\t\t\tch <- Event{\n\t\t\t\tTimestamp: milliseconds,\n\t\t\t\tStatus: msg[0],\n\t\t\t\tData1: msg[1],\n\t\t\t\tData2: msg[2],\n\t\t\t}\n\t\t} else {\n\t\t\tl.sysexEvent(msg)\n\t\t}\n\t}, lcfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase evt := <-ch:\n\t\t\t\tl.event(evt)\n\t\t\t}\n\t\t}\n\t}()\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\n\t\tticker := time.NewTicker(FlashPeriod)\n\t\tdefer ticker.Stop()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tcase <-ticker.C:\n\t\t\t\tl.lock.Lock()\n\t\t\t\tl.flashes++\n\t\t\t\tch := l.currentChannel\n\t\t\t\tl.lock.Unlock()\n\n\t\t\t\t_ = l.SwapBuffers(ch)\n\t\t\t}\n\t\t}\n\t}()\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase err := <-l.errorChan:\n\t\treturn err\n\t}\n}", "func NewBypassingLicenseCheck(c *proxy.Client) *DataSource {\n\tds := New(c)\n\tds.bypassLicenseCheck = true\n\treturn ds\n}", "func (a *AxonShiftDelay) Input(spike int) {\n\t// Place spike in register at LSB\n\ta.register = a.register | uint64(spike&1)\n}", "func (p Pin) enableClock() {\n\tswitch p / 16 {\n\tcase 0:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPAEN)\n\tcase 1:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPBEN)\n\tcase 2:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPCEN)\n\tcase 3:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPDEN)\n\tcase 4:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPEEN)\n\tcase 5:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPFEN)\n\tcase 6:\n\t\tstm32.RCC.APB2ENR.SetBits(stm32.RCC_APB2ENR_IOPGEN)\n\tdefault:\n\t\tpanic(\"machine: unknown port\")\n\t}\n}", "func bypass(w http.ResponseWriter, r *http.Request, url string, method string, body map[string]interface{}) {\n\tresPayload := make([]byte, 0)\n\n\tlog.Infof(\"Bypassing request\")\n\tif method == \"GET\" {\n\t\tresPayload = makeGetRequest(url, r.Header)\n\t} else if method == \"POST\" {\n\t\tresPayload = makePostRequest(url, body, r.Header)\n\t} else {\n\t\tlog.Errorf(\"Method not supported for bypass\")\n\t}\n\t// Use interface to dynamically get different response JSON structures.\n\tq := make(map[string]interface{})\n\tjson.Unmarshal(resPayload, &q)\n\tif len(q) == 0 {\n\t\tl := make([]interface{}, 0)\n\t\tjson.Unmarshal(resPayload, &l)\n\t\trespondJSON(w, http.StatusOK, l)\n\t} else {\n\t\trespondJSON(w, http.StatusOK, q)\n\t}\n}", "func (p *Periph) EnableClock(lp bool) {\n\taddr := unsafe.Pointer(p)\n\tinternal.APB_SetLPEnabled(addr, lp)\n\tinternal.APB_SetEnabled(addr, true)\n}", "func (tv *TV) Enable3D() bool {\n\tif tv.Current3DState == \"on\" {\n\t\tfmt.Printf(\"%s 3D Already Enabled\\n\", tv.Name)\n\t\treturn true\n\t}\n\tvar okResponse bool\n\n\tenableResponse := tv.SendCommand(\"400\")\n\t//only send the second command if the first has sent successfuly\n\tif enableResponse == true {\n\t\ttime.Sleep(1)\n\t\tokResponse = tv.SendCommand(\"412\")\n\t}\n\n\tif enableResponse && okResponse == true {\n\t\ttv.Current3DState = \"on\"\n\t\tfmt.Printf(\"%s 3D Enabled\\n\", tv.Name)\n\t\treturn true\n\t}\n\treturn false\n}", "func receiveSomeData(dev *device.SDRDevice) {\n\n\tfmt.Printf(\"-------------------\\n\")\n\tfmt.Printf(\"Data Reception\\n\")\n\tfmt.Printf(\"-------------------\\n\")\n\n\t// Apply settings\n\tif err := dev.SetSampleRate(device.DirectionRX, 0, 1e6); err != nil {\n\t\tlog.Fatal(fmt.Printf(\"setSampleRate fail: error: %v\\n\", err))\n\t}\n\tif err := dev.SetFrequency(device.DirectionRX, 0, 912.3e6, nil); err != nil {\n\t\tlog.Fatal(fmt.Printf(\"setFrequency fail: error: %v\\n\", err))\n\t}\n\n\tstream, err := dev.SetupSDRStreamCS8(device.DirectionRX, []uint{0}, nil)\n\tif err != nil {\n\t\tlog.Fatal(fmt.Printf(\"SetupStream fail: error: %v\\n\", err))\n\t}\n\n\tif err := stream.Activate(0, 0, 0); err != nil {\n\t\tlog.Fatal(fmt.Printf(\"Activate fail: error: %v\\n\", err))\n\t}\n\n\tfmt.Printf(\"Stream MTU: %v\\n\", stream.GetMTU())\n\tfmt.Printf(\"NumDirectAccessBuffers: %v\\n\", stream.GetNumDirectAccessBuffers())\n\n\tbuffers := make([][]int8, 1)\n\tbuffers[0] = make([]int8, 1024)\n\tflags := make([]int, 1)\n\n\tfor i := 0; i < 10; i++ {\n\t\ttimeNs, numElemsRead, err := stream.Read(buffers, 511, flags, 100000)\n\t\tfmt.Printf(\"flags=%v, numElemsRead=%v, timeNs=%v, err=%v\\n\", flags, numElemsRead, timeNs, err)\n\t}\n\n\tif err := stream.Deactivate(0, 0); err != nil {\n\t\tlog.Fatal(fmt.Printf(\"Deactivate fail: error: %v\\n\", err))\n\t}\n\n\tif err := stream.Close(); err != nil {\n\t\tlog.Fatal(fmt.Printf(\"Close fail: error: %v\\n\", err))\n\t}\n}", "func (c *Context) SetDirectSampling(on int) (err int) {\n\treturn int(C.rtlsdr_set_direct_sampling((*C.rtlsdr_dev_t)(c.dev),\n\t\tC.int(on)))\n}", "func (o *Loop) SetAutoclear(ctx context.Context, value bool, options map[string]dbus.Variant) (err error) {\n\terr = o.object.CallWithContext(ctx, InterfaceLoop+\".SetAutoclear\", 0, value, options).Store()\n\treturn\n}", "func flagNotStolen(deviceType string, deviceId string) {\n\n\tdb := connect()\n\tqueryStr := \"UPDATE \" + deviceType + \"Device \" + \"SET isStolen = 0 WHERE deviceId='\" + deviceId + \"'\"\n\tdb.Query(queryStr)\n\tdisconnect(db)\n}", "func (u *LDSUnit) CanAcceptWave() bool {\n\treturn u.toRead == nil\n}", "func (s *Sensor) Direct(flag int) (*os.File, error) {\n\tif s.err != nil {\n\t\treturn nil, s.Err()\n\t}\n\treturn os.OpenFile(filepath.Join(s.Path(), s.String(), direct), flag, 0)\n}", "func (d *Device) EnableBacklight(enable bool) {\n\tif enable {\n\t\td.blPin.High()\n\t} else {\n\t\td.blPin.Low()\n\t}\n}", "func (player *musicPlayer) playSingleFile(filename string, trim float64, ch chan error) error {\n\t// Open the input file (with default parameters)\n\tin := sox.OpenRead(filename)\n\tif in == nil {\n\t\terr := errors.New(no_sox_in_msg)\n\t\tif ch != nil {\n\t\t\tch <- err\n\t\t}\n\t\treturn err\n\t}\n\tdefer in.Release()\n\n\t// Open the output device: Specify the output signal characteristics.\n\t// Since we are using only simple effects, they are the same as the\n\t// input file characteristics.\n\t// Using \"alsa\" or \"pulseaudio\" should work for most files on Linux.\n\t// \"coreaudio\" for OSX\n\t// On other systems, other devices have to be used.\n\tout := sox.OpenWrite(\"default\", in.Signal(), nil, \"alsa\")\n\tif out == nil {\n\t\tout = sox.OpenWrite(\"default\", in.Signal(), nil, \"pulseaudio\")\n\t\tif out == nil {\n\t\t\tout = sox.OpenWrite(\"default\", in.Signal(), nil, \"coreaudio\")\n\t\t\tif out == nil {\n\t\t\t\tout = sox.OpenWrite(\"default\", in.Signal(), nil, \"waveaudio\")\n\t\t\t\tif out == nil {\n\t\t\t\t\terr := errors.New(no_sox_out_msg)\n\t\t\t\t\tif ch != nil {\n\t\t\t\t\t\tch <- err\n\t\t\t\t\t}\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t// It's observed that sox crashes at this step sometimes\n\tdefer out.Release()\n\n\tif ch != nil {\n\t\tch <- nil\n\t}\n\n\t// Create an effects chain: Some effects need to know about the\n\t// input or output encoding so we provide that information here.\n\tchain := sox.CreateEffectsChain(in.Encoding(), out.Encoding())\n\tdefer chain.Release()\n\n\t// The first effect in the effect chain must be something that can\n\t// source samples; in this case, we use the built-in handler that\n\t// inputs data from an audio file.\n\te := sox.CreateEffect(sox.FindEffect(\"input\"))\n\te.Options(in)\n\t// This becomes the first \"effect\" in the chain\n\tchain.Add(e, in.Signal(), in.Signal())\n\te.Release()\n\n\tif trim > 0 {\n\t\tinterm_signal := in.Signal().Copy()\n\n\t\te = sox.CreateEffect(sox.FindEffect(\"trim\"))\n\t\te.Options(strconv.FormatFloat(trim, 'f', 2, 64))\n\t\tchain.Add(e, interm_signal, in.Signal())\n\t\te.Release()\n\t}\n\n\t// The last effect in the effect chain must be something that only consumes\n\t// samples; in this case, we use the built-in handler that outputs data.\n\te = sox.CreateEffect(sox.FindEffect(\"output\"))\n\te.Options(out)\n\tchain.Add(e, in.Signal(), in.Signal())\n\te.Release()\n\n\tplayer.Lock()\n\tplayer.state.chain = chain\n\tplayer.state.status = playing\n\tplayer.state.startTime = time.Now()\n\tif trim > 0 {\n\t\tvar milis int64 = int64(-trim * 1000)\n\t\tplayer.state.startTime = player.state.startTime.Add(time.Duration(milis) * time.Millisecond)\n\t}\n\tplayer.Unlock()\n\n\t// Flow samples through the effects processing chain until EOF is reached.\n\t// Flow process is not locked as it must be possible to delete chain effects\n\t// while Flow is being executed\n\t// note: sox crashes at this step sometimes(rarely)\n\tchain.Flow()\n\n\tplayer.Lock()\n\tif player.state.status == playing {\n\t\tplayer.state.status = waiting\n\t}\n\tplayer.Unlock()\n\n\treturn nil\n}", "func (chanSync *channelRelaySync) AllowSetup() {\n\tchanSync.shared.runLeg.Add(1)\n\tchanSync.shared.runSetup.Done()\n}", "func (p *PWMPin) SetEnabled(e bool) error {\n\tif err := p.writeFile(fmt.Sprintf(\"pwm%s/enable\", p.fn), fmt.Sprintf(\"%v\", bool2int(e))); err != nil {\n\t\treturn err\n\t}\n\tp.enabled = e\n\treturn nil\n}", "func (c *DeviceClient) Use(hooks ...Hook) {\n\tc.hooks.Device = append(c.hooks.Device, hooks...)\n}", "func (mtr *Dprdpr1intflopfifo1Metrics) SetDataMuxForceBypassCsumFlopFfUndflow(val metrics.Counter) error {\n\tmtr.metrics.SetCounter(val, mtr.getOffset(\"DataMuxForceBypassCsumFlopFfUndflow\"))\n\treturn nil\n}", "func (d *DriverDMA) SetClock(freqhz int, pwrsave bool) {\n\tsetClock(d.p, freqhz, pwrsave)\n}", "func (a *Adapter) Enable() error {\n\tif a.poweredChan != nil {\n\t\treturn errors.New(\"already calling Enable function\")\n\t}\n\n\t// wait until powered\n\ta.poweredChan = make(chan error, 1)\n\n\ta.cmd = &centralManagerDelegate{a: a}\n\ta.cm.SetDelegate(a.cmd)\n\n\tif a.cm.State() != cbgo.ManagerStatePoweredOn {\n\t\tselect {\n\t\tcase <-a.poweredChan:\n\t\tcase <-time.NewTimer(10 * time.Second).C:\n\t\t\treturn errors.New(\"timeout enabling CentralManager\")\n\t\t}\n\t}\n\n\t// drain any extra powered-on events from channel\n\tfor len(a.poweredChan) > 0 {\n\t\t<-a.poweredChan\n\t}\n\n\t// wait until powered?\n\ta.pmd = &peripheralManagerDelegate{a: a}\n\ta.pm.SetDelegate(a.pmd)\n\n\treturn nil\n}", "func init() { detrand.Disable() }", "func (pwm *pwmGroup) enable(enable bool) {\n\tpwm.CSR.ReplaceBits(boolToBit(enable)<<rp.PWM_CH0_CSR_EN_Pos, rp.PWM_CH0_CSR_EN_Msk, 0)\n}", "func (spi *SPI) Loop() bool {\n\treturn spi.mode&THREE_WIRE != 0\n}", "func (s *spy) WithoutReading() Gob {\n\treturn &spy{\n\t\tcallThroughCondition: s.callThroughCondition,\n\t\tname: s.name,\n\t\tshouldExport: s.shouldExport,\n\t\tshouldSkipReading: true,\n\t}\n}", "func (mtr *Dprdpr0intflopfifo1Metrics) SetDataMuxForceBypassCsumFlopFfUndflow(val metrics.Counter) error {\n\tmtr.metrics.SetCounter(val, mtr.getOffset(\"DataMuxForceBypassCsumFlopFfUndflow\"))\n\treturn nil\n}", "func (p *Periph) DisableDMA(e Event) {\n\tif e &= realEventMask; e != 0 {\n\t\tp.cr2.ClearBits(uint32(e) >> 1)\n\t}\n}", "func flagStolen(deviceType string, deviceId string) {\n\n\tdb := connect()\n\tqueryStr := \"UPDATE \" + deviceType + \"Device \" + \"SET isStolen = 1 WHERE deviceId='\" + deviceId + \"'\"\n\tdb.Query(queryStr)\n\tdisconnect(db)\n}", "func (dev *Device) read() {\n\tif !dev.Ok {\n\t\t// log.Printf(\"Device is closed === %s\", dev)\n\t\treturn\n\t}\n\tdev.chRecv = make(chan []byte)\n\tgo func() {\n\t\tdefer func() {\n\t\t\tselect {\n\t\t\tcase _, ok := <-dev.chRecv:\n\t\t\t\tif !ok {\n\t\t\t\t\t// log.Println(\"=== chRecv closed ===\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t}\n\t\t\tclose(dev.chRecv)\n\t\t\tlog.Println(\"finish read port\")\n\t\t}()\n\t\tcountError := 0\n\t\t//TODO timeoutRead?\n\t\tfuncerr := func(err error) error {\n\t\t\tif err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tlog.Printf(\"funcread err: %s\", err)\n\t\t\tswitch {\n\t\t\tcase errors.Is(err, os.ErrClosed):\n\t\t\t\tdev.Ok = false\n\t\t\t\treturn err\n\t\t\tcase errors.Is(err, io.ErrClosedPipe):\n\t\t\t\tdev.Ok = false\n\t\t\t\treturn err\n\t\t\tcase errors.Is(err, io.EOF):\n\t\t\t\tif countError > 3 {\n\t\t\t\t\tif !dev.Ok {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tcountError = 0\n\t\t\t\t}\n\t\t\t\tcountError++\n\t\t\t}\n\n\t\t\treturn nil\n\n\t\t\t// if countError > 3 {\n\t\t\t// dev.Ok = false\n\t\t\t// return err\n\t\t\t// }\n\t\t\t// time.Sleep(1 * time.Second)\n\t\t\t// countError++\n\t\t\t// return nil\n\t\t}\n\t\tbf := bufio.NewReader(dev.port)\n\t\ttempb := make([]byte, 1024)\n\t\t// buff := make([]byte, 1)\n\t\tindxb := 0\n\t\tfor {\n\t\t\tif !dev.Ok {\n\t\t\t\t// log.Printf(\"Device is closed === %s ######\", dev)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// log.Println(\"0\")\n\t\t\t// if dev.mode != 0 {\n\t\t\t// \tline, _, err := bf.ReadLine()\n\t\t\t// \tif err != nil {\n\t\t\t// \t\tif err := funcerr(err); err != nil {\n\t\t\t// \t\t\treturn\n\t\t\t// \t\t}\n\t\t\t// \t\tcontinue\n\t\t\t// \t}\n\t\t\t// \tcountError = 0\n\t\t\t// \tselect {\n\t\t\t// \tcase <-dev.chQuit:\n\t\t\t// \t\treturn\n\t\t\t// \tcase dev.chRecv <- line:\n\t\t\t// \tcase <-time.After(1 * time.Second):\n\t\t\t// \t}\n\t\t\t// \tcontinue\n\t\t\t// }\n\t\t\tb, err := bf.ReadByte()\n\t\t\tif err != nil {\n\t\t\t\tif err := funcerr(err); err != nil {\n\t\t\t\t\t// log.Printf(\"0, err: %s\", err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// var b byte\n\t\t\t// if n > 0 {\n\t\t\t// \tb = buff[0]\n\t\t\t// } else {\n\t\t\t// \tcontinue\n\t\t\t// }\n\t\t\t// log.Printf(\"0, err: %s, [% X]\", err, buff[:n])\n\t\t\t// if err != nil {\n\t\t\tif err := funcerr(err); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif indxb <= 0 {\n\t\t\t\tif b == '\\x02' {\n\t\t\t\t\ttempb[0] = b\n\t\t\t\t\tindxb = 1\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ttempb[indxb] = b\n\t\t\tindxb++\n\t\t\t// fmt.Printf(\"len: %v, %v\\n\", indxb, int(tempb[2])+5)\n\t\t\tif indxb < 6 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// log.Println(\"2\")\n\t\t\tif b == '\\x03' && (indxb >= int(tempb[2])+5) {\n\t\t\t\t// fmt.Printf(\"tempb final: [% X]\\n\", tempb[:indxb])\n\t\t\t\tselect {\n\t\t\t\tcase <-dev.chQuit:\n\t\t\t\t\t// log.Println(\"3\")\n\t\t\t\t\treturn\n\t\t\t\tcase dev.chRecv <- tempb[0:indxb]:\n\t\t\t\t\t// fmt.Printf(\"tempb final: [% X]\\n\", tempb[:])\n\t\t\t\tcase <-time.After(1 * time.Second):\n\t\t\t\t}\n\t\t\t\tindxb = 0\n\t\t\t}\n\t\t}\n\t}()\n\tlog.Println(\"reading port\")\n}", "func (buzzer *ActiveBuzzer) ToggleTone() {\n\tif buzzer.pin.Read() == 1 {\n\t\tbuzzer.pin.Low()\n\t} else {\n\t\tbuzzer.pin.High()\n\t}\n}", "func (c *cqut) setCheckDirect(b bool) {\n\tc.client.CheckRedirect = func(req *http.Request, vias []*http.Request) error {\n\t\tif b {\n\t\t\treturn nil\n\t\t}\n\t\treturn http.ErrUseLastResponse\n\t}\n}", "func (hw *I2C) enable() {\n\treg.SetN(hw.ccgr, hw.cg, 0b11, 0b11)\n\n\t// Set SCL frequency\n\t// 66 MHz / 768 = 85 kbps\n\t// TODO: allow Init() to set the baudrate.\n\treg.Write16(hw.ifdr, 0x16)\n\n\treg.Set16(hw.i2cr, I2CR_IEN)\n}", "func (spi *SPI) SetLoop(loop bool) error {\n\treturn spi.setModeFlag(loop, LOOP)\n}", "func SetupLoopback(ctx context.Context, cr *chrome.Chrome) error {\n\ttconn, err := cr.TestAPIConn(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create Test API connection\")\n\t}\n\n\ttimeForCleanUp := 5 * time.Second\n\tctxForCleanUp := ctx\n\tctx, cancel := ctxutil.Shorten(ctx, timeForCleanUp)\n\tdefer cancel()\n\n\tif err := quicksettings.Show(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to show the quicksettings to select playback node\")\n\t}\n\tdefer func() {\n\t\tif err := quicksettings.Hide(ctxForCleanUp, tconn); err != nil {\n\t\t\ttesting.ContextLog(ctx, \"Failed to hide the quicksettings on defer: \", err)\n\t\t}\n\t}()\n\tif err := quicksettings.SelectAudioOption(ctx, tconn, \"Loopback Playback\"); err != nil {\n\t\treturn errors.Wrap(err, \"failed to select ALSA loopback output\")\n\t}\n\n\t// After selecting Loopback Playback, SelectAudioOption() sometimes detected that audio setting\n\t// is still opened while it is actually fading out, and failed to select Loopback Capture.\n\t// Call Hide() and Show() to reset the quicksettings menu first.\n\tif err := quicksettings.Hide(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to hide the quicksettings before show\")\n\t}\n\tif err := quicksettings.Show(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to show the quicksettings to select capture node\")\n\t}\n\tif err := quicksettings.SelectAudioOption(ctx, tconn, \"Loopback Capture\"); err != nil {\n\t\treturn errors.Wrap(err, \"failed to select ALSA loopback input\")\n\t}\n\n\treturn nil\n}", "func (m *RWMutex) RLockBypass() {\n\tm.mu.RLock()\n}", "func (c *DeviceAccess) Enable(ctx context.Context) (*gcdmessage.ChromeResponse, error) {\n\treturn c.target.SendDefaultRequest(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: \"DeviceAccess.enable\"})\n}", "func (d *Device) doConfigure(cfg Configuration) (err error) {\n\n\t// Verify unit communication\n\tif !d.Connected() {\n\t\treturn errNotConnected\n\t}\n\n\t// Multipliers come from \"Table 3. Sensor characteristics\" of the datasheet * 1000\n\tswitch cfg.AccelRange {\n\tcase ACCEL_2G:\n\t\td.accelMultiplier = 61\n\tcase ACCEL_4G:\n\t\td.accelMultiplier = 122\n\tcase ACCEL_8G:\n\t\td.accelMultiplier = 244\n\tcase ACCEL_16G:\n\t\td.accelMultiplier = 732\n\t}\n\tswitch cfg.GyroRange {\n\tcase GYRO_250DPS:\n\t\td.gyroMultiplier = 8750\n\tcase GYRO_500DPS:\n\t\td.gyroMultiplier = 17500\n\tcase GYRO_2000DPS:\n\t\td.gyroMultiplier = 70000\n\t}\n\tswitch cfg.MagRange {\n\tcase MAG_4G:\n\t\td.magMultiplier = 14\n\tcase MAG_8G:\n\t\td.magMultiplier = 29\n\tcase MAG_12G:\n\t\td.magMultiplier = 43\n\tcase MAG_16G:\n\t\td.magMultiplier = 58\n\t}\n\n\tdata := d.buf[:1]\n\n\t// Configure accelerometer\n\t// Sample rate & measurement range\n\tdata[0] = uint8(cfg.AccelSampleRate)<<5 | uint8(cfg.AccelRange)<<3\n\terr = d.bus.WriteRegister(d.AccelAddress, CTRL_REG6_XL, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Configure gyroscope\n\t// Sample rate & measurement range\n\tdata[0] = uint8(cfg.GyroSampleRate)<<5 | uint8(cfg.GyroRange)<<3\n\terr = d.bus.WriteRegister(d.AccelAddress, CTRL_REG1_G, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Configure magnetometer\n\n\t// Temperature compensation enabled\n\t// High-performance mode XY axis\n\t// Sample rate\n\tdata[0] = 0b10000000 | 0b01000000 | uint8(cfg.MagSampleRate)<<2\n\terr = d.bus.WriteRegister(d.MagAddress, CTRL_REG1_M, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Measurement range\n\tdata[0] = uint8(cfg.MagRange) << 5\n\terr = d.bus.WriteRegister(d.MagAddress, CTRL_REG2_M, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Continuous-conversion mode\n\t// https://electronics.stackexchange.com/questions/237397/continuous-conversion-vs-single-conversion-mode\n\tdata[0] = 0b00000000\n\terr = d.bus.WriteRegister(d.MagAddress, CTRL_REG3_M, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// High-performance mode Z axis\n\tdata[0] = 0b00001000\n\terr = d.bus.WriteRegister(d.MagAddress, CTRL_REG4_M, data)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn nil\n}", "func (o DeviceDexTestOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *DeviceDexTest) pulumi.BoolOutput { return v.Enabled }).(pulumi.BoolOutput)\n}", "func (s *Server) CachedTenableCallSkipSave(pp CachedTenableCallParams, skipOnHit bool, writeOnReturn bool) {\n\ts.Metrics.ServerInc(pp.metricType, metrics.Methods.Service.Get)\n\n\tif skipOnHit {\n\t\t// Check for a cache hit! :- )\n\t\tbb, err := s.cacheFetch(pp.r, pp.endPoint, pp.metricType)\n\n\t\tif err == nil && len(bb) > 0 {\n\t\t\t_, _ = pp.w.Write(bb)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Take the AccessKeys and SecretKeys from context\n\tak := middleware.AccessKey(pp.r)\n\tsk := middleware.SecretKey(pp.r)\n\n\tt := tenable.NewService(s.ServiceBaseURL, sk, ak, s.Log)\n\n\tjson, err := pp.f(t)\n\tif err != nil {\n\t\thttp.Error(pp.w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t}\n\n\tif writeOnReturn {\n\t\ts.cacheStore(pp.w, pp.r, json, pp.endPoint, pp.metricType)\n\n\t\t_, _ = pp.w.Write(json)\n\t}\n\n\treturn\n}", "func VolumeControl(ctx context.Context, s *testing.State) {\n\tconst (\n\t\taudioRate = 48000\n\t\taudioChannel = 2\n\t\tduration = 30\n\t)\n\n\tparam := s.Param().(volumeControlParam)\n\tcr := s.PreValue().(*chrome.Chrome)\n\n\tkb, err := input.VirtualKeyboard(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to open the keyboard: \", err)\n\t}\n\tdefer kb.Close()\n\n\tif param.tier == withAudio {\n\t\ts.Log(\"Generate sine raw input file that lasts 30 seconds\")\n\t\trawFileName := \"30SEC.raw\"\n\t\tdownloadsPath, err := cryptohome.DownloadsPath(ctx, cr.NormalizedUser())\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to get user's Download path: \", err)\n\t\t}\n\t\trawFilePath := filepath.Join(downloadsPath, rawFileName)\n\t\trawFile := audio.TestRawData{\n\t\t\tPath: rawFilePath,\n\t\t\tBitsPerSample: 16,\n\t\t\tChannels: audioChannel,\n\t\t\tRate: audioRate,\n\t\t\tFrequencies: []int{440, 440},\n\t\t\tVolume: 100,\n\t\t\tDuration: duration,\n\t\t}\n\t\tif err := audio.GenerateTestRawData(ctx, rawFile); err != nil {\n\t\t\ts.Fatal(\"Failed to generate audio test data: \", err)\n\t\t}\n\t\tdefer os.Remove(rawFile.Path)\n\n\t\twavFileName := \"30SEC.wav\"\n\t\twavFile := filepath.Join(downloadsPath, wavFileName)\n\t\tif err := audio.ConvertRawToWav(ctx, rawFilePath, wavFile, audioRate, audioChannel); err != nil {\n\t\t\ts.Fatal(\"Failed to convert raw to wav: \", err)\n\t\t}\n\t\tdefer os.Remove(wavFile)\n\n\t\t// Open the test API.\n\t\ttconn, err := cr.TestAPIConn(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to create test API connection: \", err)\n\t\t}\n\t\tdefer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)\n\t\tfiles, err := filesapp.Launch(ctx, tconn)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to launch the Files App: \", err)\n\t\t}\n\t\tdefer files.Close(ctx)\n\t\tif err := files.OpenDownloads()(ctx); err != nil {\n\t\t\ts.Fatal(\"Failed to open Downloads folder in files app: \", err)\n\t\t}\n\t\tif err := files.OpenFile(wavFileName)(ctx); err != nil {\n\t\t\ts.Fatalf(\"Failed to open the audio file %q: %v\", wavFileName, err)\n\t\t}\n\t\t// Closing the audio player.\n\t\tdefer func() {\n\t\t\tif kb.Accel(ctx, \"Ctrl+W\"); err != nil {\n\t\t\t\ts.Error(\"Failed to close Audio player: \", err)\n\t\t\t}\n\t\t}()\n\n\t\ts.Log(\"Play the audio file for 5 seconds\")\n\t\t// Sample time for the audio to play for 5 seconds.\n\t\tif err := testing.Sleep(ctx, 5*time.Second); err != nil {\n\t\t\ts.Fatal(\"Error while waiting during sample time: \", err)\n\t\t}\n\n\t\taudioDeviceName, err := audionode.SetAudioNode(ctx, param.expectedAudioNode)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to set the Audio node: \", err)\n\t\t}\n\t\ts.Logf(\"Selected audio device name: %q\", audioDeviceName)\n\n\t\tdevName, err := crastestclient.FirstRunningDevice(ctx, audio.OutputStream)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to detect running output device: \", err)\n\t\t}\n\n\t\tif audioDeviceName != devName {\n\t\t\ts.Fatalf(\"Failed to route the audio through expected audio node: got %q; want %q\", devName, audioDeviceName)\n\t\t}\n\t}\n\n\tvh, err := audionode.NewVolumeHelper(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to create the volumeHelper: \", err)\n\t}\n\toriginalVolume, err := vh.ActiveNodeVolume(ctx)\n\tdefer vh.SetVolume(ctx, originalVolume)\n\n\ttopRow, err := input.KeyboardTopRowLayout(ctx, kb)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to obtain the top-row layout: \", err)\n\t}\n\n\tisMuted := func() bool {\n\t\tdump, err := testexec.CommandContext(ctx, \"sh\", \"-c\", \"cras_test_client --dump_server_info | grep muted\").Output()\n\t\tif err != nil {\n\t\t\ts.Errorf(\"Failed to dump server info: %s\", err)\n\t\t}\n\t\tmuted := strings.TrimSpace(string(dump[strings.LastIndex(string(dump), \":\")+1:]))\n\t\treturn muted == \"Muted\"\n\t}\n\n\ts.Log(\"Press mute key and unmute by pressing Volume up key\")\n\tif err = kb.Accel(ctx, topRow.VolumeMute); err != nil {\n\t\ts.Fatal(`Failed to press \"Mute\": `, err)\n\t}\n\tif !isMuted() {\n\t\ts.Fatal(\"Failed to mute the audio\")\n\t}\n\n\tif err = kb.Accel(ctx, topRow.VolumeUp); err != nil {\n\t\ts.Fatal(`Failed to press \"VolumeUp\": `, err)\n\t}\n\n\tif isMuted() {\n\t\ts.Fatal(\"Failed to unmute the audio\")\n\t}\n\n\ts.Log(\"Decrease volume to 0 and verify for every key press\")\n\tfor {\n\t\tvolume, err := vh.ActiveNodeVolume(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to get volume: \", err)\n\t\t}\n\t\tif volume == 0 {\n\t\t\tbreak\n\t\t}\n\t\tif err := vh.VerifyVolumeChanged(ctx, func() error {\n\t\t\treturn kb.Accel(ctx, topRow.VolumeDown)\n\t\t}); err != nil {\n\t\t\ts.Fatal(`Failed to change volume after pressing \"VolumeDown\": `, err)\n\t\t}\n\t}\n\n\ts.Log(\"Increase volume to 100 and verify for every key press\")\n\tfor {\n\t\tvolume, err := vh.ActiveNodeVolume(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to get volume: \", err)\n\t\t}\n\t\tif volume == 100 {\n\t\t\tbreak\n\t\t}\n\t\tif err := vh.VerifyVolumeChanged(ctx, func() error {\n\t\t\treturn kb.Accel(ctx, topRow.VolumeUp)\n\t\t}); err != nil {\n\t\t\ts.Fatal(`Failed to change volume after pressing \"VolumeUp\": `, err)\n\t\t}\n\t}\n}", "func (c *Mock) ReadPump(channel chan *interfaces.IncomingMessage, unregister chan interfaces.Client) {\n\tc.FakeReadPump(channel, unregister)\n}", "func (d *Dev) ReadContinuous() <-chan analog.Sample {\n\td.mu.Lock()\n\tdefer d.mu.Unlock()\n\tif d.done != nil {\n\t\treturn nil\n\t}\n\tdone := make(chan struct{})\n\tret := make(chan analog.Sample)\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\tclose(ret)\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tvalue, err := d.ReadTimeout(time.Second)\n\t\t\t\tif err == nil {\n\t\t\t\t\tret <- analog.Sample{Raw: value}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\td.done = done\n\treturn ret\n}", "func (l *RelayDriver) Off() (err error) {\n\tif err = l.connection.DigitalWrite(l.Pin(), 0); err != nil {\n\t\treturn\n\t}\n\tl.high = false\n\treturn\n}", "func (handler *ConsoleLogHandler) Enable() {\r\n atomic.StoreUint32(&handler.disabled, falseUint32)\r\n}", "func (p *Port) DisableClock() {\n\tdisableClock(p)\n}", "func (p PowerControl) SetIn(in chan interface{}) {\n\tp.in = in\n}", "func processSensorData() (sensorRead sensorReadType, pos int, hint int, cross bool, out bool) {\n\tread()\n\tf, l, r, b := trimSensor(cB), trimSensor(cL), trimSensor(cR), trimSensor(cB)\n\n\tsensorRead = sensorReadZero\n\tif isOnTrack(b) {\n\t\tsensorRead |= bitB\n\t}\n\tif isOnTrack(r) {\n\t\tsensorRead |= bitR\n\t}\n\tif isOnTrack(l) {\n\t\tsensorRead |= bitL\n\t}\n\tif isOnTrack(f) {\n\t\tsensorRead |= bitF\n\t}\n\n\tswitch sensorRead {\n\tcase sensorReadZero:\n\tcase sensorReadB:\n\tcase sensorReadF:\n\t\t// Out\n\t\tout = true\n\t\tpos, hint, cross = 0, 0, false\n\tcase sensorReadR:\n\t\tpos = conf.SensorRadius*2 + distanceFromSensor(r)\n\t\thint = 0\n\t\tcross, out = false, false\n\tcase sensorReadRB:\n\t\tpos = conf.SensorRadius + positionBetweenSensors(b, r)\n\t\thint = 1\n\t\tcross, out = false, false\n\tcase sensorReadL:\n\t\tpos = -conf.SensorRadius*2 - distanceFromSensor(l)\n\t\thint = 0\n\t\tcross, out = false, false\n\tcase sensorReadLB:\n\t\tpos = -conf.SensorRadius + positionBetweenSensors(l, b)\n\t\thint = 1\n\t\tcross, out = false, false\n\tcase sensorReadLR:\n\tcase sensorReadLRB:\n\tcase sensorReadFLRB:\n\tcase sensorReadFLR:\n\t\t// Cross\n\t\tcross = true\n\t\tpos, hint, out = 0, 0, false\n\tcase sensorReadFB:\n\t\tpos = 0\n\t\thint = 0\n\t\tcross, out = false, false\n\tcase sensorReadFR:\n\t\tpos = conf.SensorRadius + positionBetweenSensors(f, r)\n\t\thint = -1\n\t\tcross, out = false, false\n\tcase sensorReadFRB:\n\t\tpos = conf.SensorRadius + positionBetweenSensors((f+b)/2, r)\n\t\thint = 0\n\t\tcross, out = false, false\n\tcase sensorReadFL:\n\t\tpos = -conf.SensorRadius + positionBetweenSensors(l, f)\n\t\thint = 0\n\t\tcross, out = false, false\n\tcase sensorReadFLB:\n\t\tpos = -conf.SensorRadius + positionBetweenSensors(l, (f+b)/2)\n\t\thint = 0\n\t\tcross, out = false, false\n\tdefault:\n\t\tprint(\"Error: reading\", sensorRead)\n\t}\n\n\treturn\n}", "func (bo *BoolOptions) enable(name string) {\n\tif bo.Library != nil {\n\t\tif _, opt := bo.Library.Lookup(name); opt != nil {\n\t\t\tfor _, dependency := range opt.Requires {\n\t\t\t\tbo.enable(dependency)\n\t\t\t}\n\t\t}\n\t}\n\n\tbo.Opts[name] = true\n}", "func (m *Manager) readDevice(dev *udev.Device) {\n\taction := dev.Action()\n\t\n\t// Handle Remove action\n\tif action == \"remove\" {\n\t\tmodem, ok := m.devices[dev.DevNode()]\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tm.handleRemove(modem)\n\t\tdelete(m.devices, dev.DevNode())\n\t\treturn\n\t}\n\n\tfileDescriptor := dev.SysName()\n\toriginalDevNode := dev.DevNode()\n\toriginalSubSys := dev.Subsystem()\n\toriginalEPnum := dev.Parent().Parent().SysAttrValue(\"bNumEndpoints\")\n\n\t// Filter unrelated devices\n\tif originalSubSys != \"tty\" && originalSubSys != \"net\" {\n\t\treturn\n\t}\n\n\tdev = dev.ParentWithSubsystemDevType(\"usb\", \"usb_device\")\n\tif dev.IsNil() {\n\t\treturn\n\t}\n\n\tvid := dev.SysAttrValue(\"idVendor\")\n\tpid := dev.SysAttrValue(\"idProduct\")\n\tfor _, f := range m.filters {\n\t\tif vid == f.vid && pid == f.pid {\n\t\t\td := m.devices[dev.DevNode()]\n\t\t\tif originalSubSys == \"net\" {\n\t\t\t\td.Net = fileDescriptor\n\t\t\t}\n\t\t\tif originalSubSys == \"tty\" && originalEPnum == \"03\" {\n\t\t\t\t// Delay if add action\n\t\t\t\tif action == \"add\" {\n\t\t\t\t\ttime.Sleep(time.Second * 5)\n\t\t\t\t}\n\t\t\t\timei, err := getImei(originalDevNode)\n\t\t\t\tif err == nil {\n\t\t\t\t\td.Tty = originalDevNode\n\t\t\t\t\td.Imei = imei\n\t\t\t\t\td.ready = 1\n\t\t\t\t}\n\t\t\t\tif (action != \"update\"){\n\t\t\t\t\tm.handleAdd(d)\n\t\t\t\t} else {\n\t\t\t\t\tm.handleUpdate(d)\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tm.devices[dev.DevNode()] = d\n\t\t}\n\t}\n}", "func FsBaseDaisy(inp <-chan *fs.FsBase, tube FsBaseTube) (out <-chan *fs.FsBase) {\n\tcha := make(chan *fs.FsBase)\n\tgo tube(inp, cha)\n\treturn cha\n}", "func ShallowSpyAndConditionallyCallThrough(name string, callThroughCondition string) Gob {\n\treturn &spy{name: name, callThroughCondition: callThroughCondition, shouldExport: false}\n}", "func (filter *DotfileFilter) toggle() {\n\tfilter.enable = !filter.enable\n}", "func DisableCopyOnRead(scope *Scope, resource tf.Output) (o *tf.Operation) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"DisableCopyOnRead\",\n\t\tInput: []tf.Input{\n\t\t\tresource,\n\t\t},\n\t}\n\treturn scope.AddOperation(opspec)\n}", "func (joint B2WheelJoint) EnableLimit(flag bool) {\n\tif flag != joint.M_enableLimit {\n\t\tjoint.M_bodyA.SetAwake(true)\n\t\tjoint.M_bodyB.SetAwake(true)\n\t\tjoint.M_enableLimit = flag\n\t\tjoint.M_lowerImpulse = 0.0\n\t\tjoint.M_upperImpulse = 0.0\n\t}\n}", "func (bo *BoolOptions) disable(name string) {\n\tbo.Opts[name] = false\n\n\tif bo.Library != nil {\n\t\t// Disable all options which have a dependency on the option\n\t\t// that was just disabled\n\t\tfor key, opt := range *bo.Library {\n\t\t\tif opt.RequiresOption(name) && bo.Opts[key] {\n\t\t\t\tbo.disable(key)\n\t\t\t}\n\t\t}\n\t}\n}", "func (o UsageRuleOutput) SkipServiceControl() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v UsageRule) *bool { return v.SkipServiceControl }).(pulumi.BoolPtrOutput)\n}", "func (s *Component) WriteDigital(v bool) {\n\tif v {\n\t\ts.device.On()\n\t} else {\n\t\ts.device.Off()\n\t}\n}" ]
[ "0.6178922", "0.46326694", "0.45607126", "0.45432112", "0.45374885", "0.44673994", "0.4408282", "0.4354577", "0.4323177", "0.43193677", "0.43165877", "0.43164214", "0.42729017", "0.4270603", "0.4266582", "0.42603517", "0.4227956", "0.4212063", "0.4193692", "0.41775048", "0.41424692", "0.41368407", "0.41356575", "0.41281587", "0.4125328", "0.41080526", "0.4106311", "0.40962923", "0.409284", "0.40868944", "0.40724623", "0.4066766", "0.40526468", "0.40438676", "0.40401125", "0.4040093", "0.40062255", "0.40034115", "0.39985052", "0.3991751", "0.3988603", "0.39826345", "0.3979267", "0.397766", "0.39761335", "0.39741498", "0.3969392", "0.3964207", "0.39603907", "0.39600906", "0.39461404", "0.3943889", "0.3943676", "0.39356965", "0.39344424", "0.3934175", "0.39335614", "0.39310375", "0.39241746", "0.39146945", "0.39123034", "0.39047796", "0.39043805", "0.3901519", "0.39013842", "0.3897814", "0.38973954", "0.38802108", "0.38788655", "0.3874624", "0.38681844", "0.38648683", "0.3855762", "0.38502535", "0.38416612", "0.38334593", "0.38314465", "0.38262132", "0.38261998", "0.38239592", "0.38202876", "0.38179386", "0.3806919", "0.38050997", "0.38003904", "0.3799426", "0.37918293", "0.3777319", "0.37760764", "0.37750572", "0.37699586", "0.37697396", "0.37670487", "0.37627035", "0.37621292", "0.37593007", "0.3752347", "0.37523317", "0.37496868", "0.37444523" ]
0.63306314
0
Retrieves the bypass state of the DSP unit. If a unit is bypassed, it will still process its inputs, unlike "DSP.SetActive" (when set to false) which causes inputs to stop processing as well.
func (d *DSP) Bypass() (bool, error) { var bypass C.FMOD_BOOL res := C.FMOD_DSP_GetBypass(d.cptr, &bypass) return setBool(bypass), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) SetBypass(bypass bool) error {\n\tres := C.FMOD_DSP_SetBypass(d.cptr, getBool(bypass))\n\treturn errs[res]\n}", "func (o NetworkRuleSetResponseOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v NetworkRuleSetResponse) *string { return v.Bypass }).(pulumi.StringPtrOutput)\n}", "func GetBypass(conn io.ReadWriter) (bypass Bypass, err error) {\n\n\tresp, err := getQuery(getBypass, conn)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn *resp.(*Bypass), err\n}", "func (o NetworkRuleSetResponsePtrOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *NetworkRuleSetResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Bypass\n\t}).(pulumi.StringPtrOutput)\n}", "func (o NetworkRuleSetOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v NetworkRuleSet) *string { return v.Bypass }).(pulumi.StringPtrOutput)\n}", "func (o NetworkRuleSetPtrOutput) Bypass() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *NetworkRuleSet) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Bypass\n\t}).(pulumi.StringPtrOutput)\n}", "func (f *FastURL) GetPass() []byte {\n\treturn f.pass\n}", "func (d *Device) Off() {\n\turl := fmt.Sprintf(\"%s?token=%s\", d.AppServerURL, token)\n\n\tpassThroughRequest := PassThroughRequest{\n\t\tMethod: \"passthrough\",\n\t\tParams: PassThroughRequestParams{\n\t\t\tDeviceID: d.DeviceID,\n\t\t\tRequestData: `{\"system\":{\"set_relay_state\":{\"state\":0}}}`,\n\t\t},\n\t}\n\n\tpayload, _ := json.Marshal(passThroughRequest)\n\n\treq, _ := http.NewRequest(\"POST\", url, bytes.NewReader(payload))\n\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n}", "func (r *DeviceManagementScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceManagementScriptDeviceState, 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 (d *DSP) Idle() (bool, error) {\n\tvar idle C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetIdle(d.cptr, &idle)\n\treturn setBool(idle), errs[res]\n}", "func (s *Flee) Get() *SteeringOutput {\n\tsteering := NewSteeringOutput()\n\t// Get the direction to the target\n\tsteering.Linear = s.entity.Data.Position.Clone().Sub(s.target.Data.Position)\n\t// Go full speed ahead\n\tsteering.Linear.Normalize().Scale(s.entity.Data.MaxAcceleration)\n\treturn steering\n}", "func (m *DeviceComplianceScriptDeviceState) GetDetectionState()(*RunState) {\n val, err := m.GetBackingStore().Get(\"detectionState\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*RunState)\n }\n return nil\n}", "func GetDevicePowerState(hDevice HANDLE, pfOn *BOOL) bool {\n\tret1 := syscall3(getDevicePowerState, 2,\n\t\tuintptr(hDevice),\n\t\tuintptr(unsafe.Pointer(pfOn)),\n\t\t0)\n\treturn ret1 != 0\n}", "func (cpu *Mos6502) ldx() uint8 {\n\tcpu.fetch()\n\tcpu.x = cpu.fetchedData\n\tcpu.setStatusFlag(Z, cpu.x == 0x00)\n\tcpu.setStatusFlag(N, (cpu.x&0x80) > 0)\n\treturn 1\n}", "func (o *SyntheticsAPITestResultShortResult) GetPassed() bool {\n\tif o == nil || o.Passed == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Passed\n}", "func (unitImpl *UnitImpl) Shield() int64 {\n\treturn unitImpl.shieldImpl\n}", "func (r *DeviceHealthScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceHealthScriptDeviceState, 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 (r *DeviceHealthScriptDeviceStateRequest) Get(ctx context.Context) (resObj *DeviceHealthScriptDeviceState, 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 DUTActive(ctx context.Context, servoInst *servo.Servo) (bool, error) {\n\tstate, err := servoInst.GetECSystemPowerState(ctx)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"failed to get ec_system_power_state\")\n\t}\n\ttesting.ContextLog(ctx, \"state: \", state)\n\tif state == \"S0\" {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (this *TEncCfg) GetLoopFilterDisable() bool { return this.m_bLoopFilterDisable }", "func (state *RawTiltState) GetTiltDegs() float64 {\n\treturn float64(C.freenect_get_tilt_degs(state.ptr()))\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) GetPasswordBlockFingerprintUnlock()(*bool) {\n return m.passwordBlockFingerprintUnlock\n}", "func (p *Player) Pass() {\n\tp.Passed = true\n}", "func (o DeviceDexTestOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *DeviceDexTest) pulumi.BoolOutput { return v.Enabled }).(pulumi.BoolOutput)\n}", "func (r *DeviceManagementScriptUserStateRequest) Get(ctx context.Context) (resObj *DeviceManagementScriptUserState, 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 (c *CPU6502) ldx() uint8 {\n\tc.fetch()\n\tc.x = c.fetched\n\tc.setFlagZ(c.x)\n\tc.setFlagN(c.x)\n\treturn 1\n}", "func (self *TileSprite) InputEnabled() bool{\n return self.Object.Get(\"inputEnabled\").Bool()\n}", "func (o *EnvironmentUsageDto) GetTrial() bool {\n\tif o == nil || o.Trial == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Trial\n}", "func Slow(input SlowServiceInput) (SlowServiceOutput, *Status) {\n\tlog.Println(\"input\", input)\n\tstart := time.Now()\n\tif input.Delay != 0 {\n\t\ttime.Sleep(input.Delay * time.Millisecond)\n\t} else {\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n\tend := time.Now()\n\treturn SlowServiceOutput{end.Sub(start) / time.Millisecond}, nil\n}", "func (m *UpdateMegaParProfileRequest) GetPower() (val bool, set bool) {\n\tif m.Power == nil {\n\t\treturn\n\t}\n\n\treturn *m.Power, true\n}", "func (d *DSP) MeteringEnabled() (bool, bool, error) {\n\tvar inputEnabled, outputEnabled C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetMeteringEnabled(d.cptr, &inputEnabled, &outputEnabled)\n\treturn setBool(inputEnabled), setBool(outputEnabled), errs[res]\n}", "func (t MagneticFieldStrength) Unit() *Unit {\n\treturn New(float64(t), Dimensions{\n\t\tCurrentDim: -1,\n\t\tMassDim: 1,\n\t\tTimeDim: -2,\n\t})\n}", "func (device *SilentStepperBrick) Disable() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionDisable), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (d *DynamicRecord) GetForceDown() (bool) {\n\tmutableMutex.Lock()\n\tdefer mutableMutex.Unlock()\n\treturn d.ForceDown\n}", "func (d *ClampedRandomWalkDistribution) Get() float64 {\n\treturn d.State\n}", "func (m *DeviceEnrollmentWindowsHelloForBusinessConfiguration) GetState()(*Enablement) {\n val, err := m.GetBackingStore().Get(\"state\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*Enablement)\n }\n return nil\n}", "func (_class PIFClass) GetDisallowUnplug(sessionID SessionRef, self PIFRef) (_retval bool, _err error) {\n\t_method := \"PIF.get_disallow_unplug\"\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 = convertBoolToGo(_method + \" -> \", _result.Value)\n\treturn\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) GetWorkProfilePasswordBlockFingerprintUnlock()(*bool) {\n return m.workProfilePasswordBlockFingerprintUnlock\n}", "func (m *TelecomExpenseManagementPartner) GetEnabled()(*bool) {\n val, err := m.GetBackingStore().Get(\"enabled\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (p *PromptSet) GetPass() ([]byte, error) {\n\treturn withSession(func(s *session) ([]byte, error) {\n\t\treturn s.getPass(p.Get)\n\t})\n}", "func (ps *PassState) Name() string {\n\treturn ps.name\n}", "func (dev *Device) GetTiltState() *RawTiltState {\n\treturn (*RawTiltState)(unsafe.Pointer(C.freenect_get_tilt_state(dev.ptr())))\n}", "func (m *AndroidCompliancePolicy) GetDeviceThreatProtectionEnabled()(*bool) {\n val, err := m.GetBackingStore().Get(\"deviceThreatProtectionEnabled\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (this *meterStruct) Enabled() bool {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\treturn enabled\n}", "func (o FirewallPolicyRuleOutput) Disabled() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v FirewallPolicyRule) *bool { return v.Disabled }).(pulumi.BoolPtrOutput)\n}", "func (r *DeviceInstallStateRequest) Get(ctx context.Context) (resObj *DeviceInstallState, 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 DisableEffects() {\n\n\tgl.UseProgram(0)\n\tpaunchEffect = nil\n}", "func (o *PhysicsDirectBodyState) GetStep() gdnative.Real {\n\t//log.Println(\"Calling PhysicsDirectBodyState.GetStep()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"PhysicsDirectBodyState\", \"get_step\")\n\n\t// Call the parent method.\n\t// float\n\tretPtr := gdnative.NewEmptyReal()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewRealFromPointer(retPtr)\n\treturn ret\n}", "func (h *DFPStateHandler) Get(c echo.Context) error {\n\tctx := c.Request().Context()\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tc.Response().Header().Set(echo.HeaderContentType, jsonapi.MediaType)\n\n\tstate := &models.DFPState{}\n\tif err := h.us.Get(ctx, dfpstate.ID, state); err != nil {\n\t\tlog.Errorf(\"Error when get dfp_state: %s\", err.Error())\n\t\tc.Response().WriteHeader(http.StatusInternalServerError)\n\t\treturn jsonapi.MarshalErrors(c.Response(), []*jsonapi.ErrorObject{\n\t\t\t{\n\t\t\t\tStatus: fmt.Sprintf(\"%d\", http.StatusInternalServerError),\n\t\t\t\tTitle: \"Error when get dfp_state\",\n\t\t\t\tDetail: err.Error(),\n\t\t\t},\n\t\t})\n\t}\n\n\tc.Response().WriteHeader(http.StatusOK)\n\treturn jsonapi.MarshalOnePayloadEmbedded(c.Response(), state)\n}", "func (s *Seek) Get() *SteeringOutput {\n\tsteering := NewSteeringOutput()\n\t// Get the direction to the target\n\tsteering.Linear = s.target.Data.Position.Clone().Sub(s.entity.Data.Position)\n\t// Go full speed ahead\n\tsteering.Linear.Normalize().Scale(s.entity.Data.MaxAcceleration)\n\treturn steering\n}", "func (device *SilentStepperBrick) Stop() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionStop), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (m *SecureScoreControlProfile) GetDeprecated()(*bool) {\n return m.deprecated\n}", "func (s *MpuSensor) Read() (float64, error) {\n\n\terr := s.Enable()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\toptions := make(map[string]interface{})\n\tb, err := s.data.ReadValue(options)\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tamb := binary.LittleEndian.Uint16(b[2:])\n\n\tambientValue := calcTmpLocal(uint16(amb))\n\n\treturn ambientValue, err\n}", "func (obj *Device) GetDepthStencilSurface() (*Surface, Error) {\n\tvar surface *Surface\n\tret, _, _ := syscall.Syscall(\n\t\tobj.vtbl.GetDepthStencilSurface,\n\t\t2,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(unsafe.Pointer(&surface)),\n\t\t0,\n\t)\n\treturn surface, toErr(ret)\n}", "func (r *DeviceCompliancePolicyStateRequest) Get(ctx context.Context) (resObj *DeviceCompliancePolicyState, 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 (r *Router) UseBypass(mwf ...gorillamux.MiddlewareFunc) {\n\tr.mux.Use(mwf...)\n}", "func (p *PWMPin) Enabled() (bool, error) {\n\treturn p.enabled, nil\n}", "func (pw *PixelWand) GetFuzz() float64 {\n\tret := float64(C.PixelGetFuzz(pw.pw))\n\truntime.KeepAlive(pw)\n\treturn ret\n}", "func (m *AndroidCompliancePolicy) GetSecurityDisableUsbDebugging()(*bool) {\n val, err := m.GetBackingStore().Get(\"securityDisableUsbDebugging\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (device *SilentStepperBrick) IsEnabled() (enabled bool, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionIsEnabled), buf.Bytes())\n\tif err != nil {\n\t\treturn enabled, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 9 {\n\t\t\treturn enabled, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 9)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn enabled, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &enabled)\n\n\t}\n\n\treturn enabled, nil\n}", "func (m *SecureScoreControlProfile) GetDeprecated()(*bool) {\n val, err := m.GetBackingStore().Get(\"deprecated\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (d *DSP) Type() (DSPType, error) {\n\tvar typ C.FMOD_DSP_TYPE\n\tres := C.FMOD_DSP_GetType(d.cptr, &typ)\n\treturn DSPType(typ), errs[res]\n}", "func (device *SilentStepperBrick) GetSpeedRamping() (acceleration uint16, deacceleration uint16, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetSpeedRamping), buf.Bytes())\n\tif err != nil {\n\t\treturn acceleration, deacceleration, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 12 {\n\t\t\treturn acceleration, deacceleration, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 12)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn acceleration, deacceleration, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &acceleration)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &deacceleration)\n\n\t}\n\n\treturn acceleration, deacceleration, nil\n}", "func (m *DeviceHealthAttestationState) GetEarlyLaunchAntiMalwareDriverProtection()(*string) {\n val, err := m.GetBackingStore().Get(\"earlyLaunchAntiMalwareDriverProtection\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (d *Device) GetPowerState() (string, error) {\n\tres, err := d.send(\"Main.Power?\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"get power state: %v\", err)\n\t}\n\tval, err := extractValue(res)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"get power state: %v\", err)\n\t}\n\treturn val, nil\n}", "func (c *Context) GetDirectSampling() (err int) {\n\treturn int(C.rtlsdr_get_direct_sampling((*C.rtlsdr_dev_t)(c.dev)))\n}", "func (m *AospDeviceOwnerDeviceConfiguration) GetFactoryResetBlocked()(*bool) {\n val, err := m.GetBackingStore().Get(\"factoryResetBlocked\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (m *OrgUnitMutation) Duty() (r string, exists bool) {\n\tv := m.duty\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (m *moduleService) Input() *dpdk.Ring {\n\treturn m.input\n}", "func (a *BackoffTimerValue) GetUnitTimerValue() (unitTimerValue uint8) {}", "func PassThrough(token float32) {\n\tC.glowPassThrough(gpPassThrough, (C.GLfloat)(token))\n}", "func (t *CircularTimes) IsPass() bool {\n return t.Wtp != nil\n}", "func (m *DeviceEnrollmentWindowsHelloForBusinessConfiguration) GetRemotePassportEnabled()(*bool) {\n val, err := m.GetBackingStore().Get(\"remotePassportEnabled\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func Ldx(c *CPU) {\n\tc.ApplyNZ(c.EffVal)\n\tc.X = c.EffVal\n}", "func (t *Uint64Tracker) Get() uint64 {\n\tresultChan := make(chan uint64)\n\tt.input <- inquiry{\n\t\tHasPreviousValue: false,\n\t\tReturn: resultChan,\n\t}\n\treturn <-resultChan\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (m *DeviceManagementSettings) GetSecureByDefault()(*bool) {\n val, err := m.GetBackingStore().Get(\"secureByDefault\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (p Position) Pass() bool {\n\treturn !p.Valid()\n}", "func (m *IosStoreAppAssignmentSettings) GetUninstallOnDeviceRemoval()(*bool) {\n val, err := m.GetBackingStore().Get(\"uninstallOnDeviceRemoval\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (up UnlockConditionProxy) Fulfill(fulfillment UnlockFulfillment, ctx FulfillContext) error {\n\tcondition := up.Condition\n\tif condition == nil {\n\t\tcondition = &NilCondition{}\n\t}\n\tif p, ok := fulfillment.(UnlockFulfillmentProxy); ok {\n\t\tfulfillment = p.Fulfillment\n\t\tif fulfillment == nil {\n\t\t\tfulfillment = &NilFulfillment{}\n\t\t}\n\t}\n\treturn condition.Fulfill(fulfillment, ctx)\n}", "func (r *ReceiveFuncState) Stop() {\n\tmu.Lock()\n\tdefer mu.Unlock()\n\tr.running = false\n\tselfCheckLocked()\n}", "func (w *Writer) Bypass() io.Writer {\n\treturn &bypass{writer: w}\n}", "func (m *DeviceStateChangedEvent) GetDevice() (val Device, set bool) {\n\tif m.Device == nil {\n\t\treturn\n\t}\n\n\treturn *m.Device, true\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) GetWorkProfileBlockScreenCapture()(*bool) {\n return m.workProfileBlockScreenCapture\n}", "func (s *Streaming) UncorrectedValue() float64 {\n\treturn s.c * s.normx * s.normy / s.n\n}", "func (o *PhysicsDirectBodyState) GetTotalLinearDamp() gdnative.Real {\n\t//log.Println(\"Calling PhysicsDirectBodyState.GetTotalLinearDamp()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"PhysicsDirectBodyState\", \"get_total_linear_damp\")\n\n\t// Call the parent method.\n\t// float\n\tretPtr := gdnative.NewEmptyReal()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewRealFromPointer(retPtr)\n\treturn ret\n}", "func (r *DeviceComplianceSettingStateRequest) Get(ctx context.Context) (resObj *DeviceComplianceSettingState, 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 (o Iperf3SpecOutput) Udp() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v Iperf3Spec) *bool { return v.Udp }).(pulumi.BoolPtrOutput)\n}", "func (b BaseDefender) GetShieldPower(researches Researches) int64 {\n\treturn int64(float64(b.ShieldPower) * (1 + float64(researches.ShieldingTechnology)*0.1))\n}", "func New(uid string, ipcon *ipconnection.IPConnection) (SilentStepperBrick, error) {\n\tinternalIPCon := ipcon.GetInternalHandle().(IPConnection)\n\tdev, err := NewDevice([3]uint8{2, 0, 1}, uid, &internalIPCon, 0, DeviceIdentifier, DeviceDisplayName)\n\tif err != nil {\n\t\treturn SilentStepperBrick{}, err\n\t}\n\tdev.ResponseExpected[FunctionSetMaxVelocity] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetMaxVelocity] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetCurrentVelocity] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetSpeedRamping] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetSpeedRamping] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionFullBrake] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionSetCurrentPosition] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetCurrentPosition] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetTargetPosition] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetTargetPosition] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetSteps] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetSteps] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetRemainingSteps] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetStepConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetStepConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionDriveForward] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionDriveBackward] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionStop] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetStackInputVoltage] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetExternalInputVoltage] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetMotorCurrent] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetMotorCurrent] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionEnable] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionDisable] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionIsEnabled] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetBasicConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetBasicConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetSpreadcycleConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetSpreadcycleConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetStealthConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetStealthConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetCoolstepConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetCoolstepConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetMiscConfiguration] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetMiscConfiguration] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetDriverStatus] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetMinimumVoltage] = ResponseExpectedFlagTrue\n\tdev.ResponseExpected[FunctionGetMinimumVoltage] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetTimeBase] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetTimeBase] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetAllData] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetAllDataPeriod] = ResponseExpectedFlagTrue\n\tdev.ResponseExpected[FunctionGetAllDataPeriod] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetSPITFPBaudrateConfig] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetSPITFPBaudrateConfig] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetSendTimeoutCount] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionSetSPITFPBaudrate] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionGetSPITFPBaudrate] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetSPITFPErrorCount] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionEnableStatusLED] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionDisableStatusLED] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionIsStatusLEDEnabled] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetProtocol1BrickletName] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetChipTemperature] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionReset] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionWriteBrickletPlugin] = ResponseExpectedFlagFalse\n\tdev.ResponseExpected[FunctionReadBrickletPlugin] = ResponseExpectedFlagAlwaysTrue\n\tdev.ResponseExpected[FunctionGetIdentity] = ResponseExpectedFlagAlwaysTrue\n\treturn SilentStepperBrick{dev}, nil\n}", "func (c Timer) Passed() time.Duration {\n\treturn c.passed\n}", "func (d *Demodulator) Process(input []byte) (power, ddm, sdm, ident float64) {\n\tiqToComplex128(input, d.iqData)\n\tmult(d.iqData, d.nco, d.lpfIn[history:history+d.n])\n\t//lowpass(d.lpfIn, d.lpfOut)\n\tmult(d.iqData, d.nco, d.lpfOut[history:history+d.n])\n\t// TODO: subsample lpfOut here?\n\tabs(d.lpfOut[history:history+d.n], d.fftData) // Demodulate the AM signal\n\ts := d.fft.Transform(d.fftData)\n\tcarrier := cmplx.Abs(s[0])\n\tmod150 := (cmplx.Abs(s[15]) + cmplx.Abs(s[len(s)-15])) / carrier * 100\n\tmod90 := (cmplx.Abs(s[9]) + cmplx.Abs(s[len(s)-9])) / carrier * 100\n\tddm = (mod150 - mod90) // 150 Hz dominance (DDM > 0): Fly UP/LEFT\n\tsdm = (mod150 + mod90)\n\tident = (cmplx.Abs(s[102]) + cmplx.Abs(s[len(s)-102])) / carrier * 100\n\tcarrier = carrier / float64(len(s))\n\tpower = 20 * math.Log10(carrier) // Carrier power in dBFS\n\treturn\n}", "func (o *Drive) GetCanPowerOff(ctx context.Context) (canPowerOff bool, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceDrive, \"CanPowerOff\").Store(&canPowerOff)\n\treturn\n}", "func (b *OGame) FleetDeutSaveFactor() float64 {\n\treturn b.serverData.GlobalDeuteriumSaveFactor\n}", "func (u *UpdateShortMessage) GetOut() (value bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\treturn u.Flags.Has(1)\n}", "func (obj *Device) GetSamplerState(\n\tsampler uint32,\n\ttyp SAMPLERSTATETYPE,\n) (value uint32, err Error) {\n\tret, _, _ := syscall.Syscall6(\n\t\tobj.vtbl.GetSamplerState,\n\t\t4,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(sampler),\n\t\tuintptr(typ),\n\t\tuintptr(unsafe.Pointer(&value)),\n\t\t0,\n\t\t0,\n\t)\n\terr = toErr(ret)\n\treturn\n}", "func (se *StateEngine) ShallowState() States {\n\tif se.curr == nil {\n\t\treturn nil\n\t}\n\n\treturn se.curr\n}", "func (s *State) Depth() Target {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn s.depth()\n}" ]
[ "0.5498904", "0.5114599", "0.511114", "0.5076523", "0.5017003", "0.49804524", "0.4573164", "0.44703326", "0.4407118", "0.4379531", "0.43793228", "0.43538514", "0.43259448", "0.42959827", "0.42699644", "0.42666838", "0.42413324", "0.42413324", "0.42408648", "0.42398065", "0.422722", "0.42156073", "0.41638404", "0.41596922", "0.4118252", "0.4114577", "0.4110464", "0.41022223", "0.40984958", "0.4095035", "0.40929976", "0.4087843", "0.40824708", "0.4082077", "0.4076224", "0.40669158", "0.40618825", "0.40527725", "0.40478024", "0.40437266", "0.40331388", "0.40235904", "0.40205026", "0.40104252", "0.40058252", "0.39796358", "0.39756322", "0.3972405", "0.39691252", "0.39685526", "0.39676055", "0.39626026", "0.39400172", "0.39343783", "0.39257783", "0.3922174", "0.3914633", "0.39145562", "0.39143702", "0.39108744", "0.39020565", "0.38908914", "0.38891393", "0.38839105", "0.3875789", "0.3863574", "0.38598728", "0.3834836", "0.38315672", "0.38302454", "0.38270155", "0.3819698", "0.3817072", "0.38162446", "0.38143584", "0.38142473", "0.38142473", "0.38142473", "0.38121617", "0.38116482", "0.3808819", "0.3806611", "0.38012013", "0.3800959", "0.38009208", "0.38002032", "0.38001192", "0.3799726", "0.37994722", "0.3799054", "0.37984815", "0.3797182", "0.37957868", "0.37955368", "0.37898746", "0.37879023", "0.37868792", "0.37863013", "0.3784724", "0.377792" ]
0.69877833
0
Allows the user to scale the affect of a DSP effect, through control of the 'wet' mix, which is the postprocessed signal and the 'dry' which is the preprocessed signal. prewet: Floating point value from 0 to 1, describing a linear scale of the 'wet' (preprocessed signal) mix of the effect. Default = 1.0. Scale can be lower than 0 (negating) and higher than 1 (amplifying). postwet: Floating point value from 0 to 1, describing a linear scale of the 'wet' (postprocessed signal) mix of the effect. Default = 1.0. Scale can be lower than 0 (negating) and higher than 1 (amplifying). dry: Floating point value from 0 to 1, describing a linear scale of the 'dry' (preprocessed signal) mix of the effect. Default = 0.0. Scale can be lower than 0 and higher than 1 (amplifying). The dry signal path is silent by default, because dsp effects transform the input and pass the newly processed result to the output. It does not add to the input.
func (d *DSP) SetWetDryMix(prewet, postwet, dry float64) error { res := C.FMOD_DSP_SetWetDryMix(d.cptr, C.float(prewet), C.float(postwet), C.float(dry)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *Base) Scale(w http.ResponseWriter, r *http.Request) {\n\tb.log.Printf(\"%s %s -> %s\", r.Method, r.URL.Path, r.RemoteAddr)\n\n\tsOptions, pOptions, kOptions, oOptions := render.SetDefaultScaleOptions()\n\n\tpv := render.PageVars{\n\t\tTitle: \"Practice Scales and Arpeggios\", // default scale initially displayed is A Major\n\t\tScalearp: \"Scale\",\n\t\tPitch: \"Major\",\n\t\tKey: \"A\",\n\t\tScaleImgPath: \"img/scale/major/a1.png\",\n\t\tGifPath: \"\",\n\t\tAudioPath: \"mp3/scale/major/a1.mp3\",\n\t\tAudioPath2: \"mp3/drone/a1.mp3\",\n\t\tLeftLabel: \"Listen to Major scale\",\n\t\tRightLabel: \"Listen to Drone\",\n\t\tScaleOptions: sOptions,\n\t\tPitchOptions: pOptions,\n\t\tKeyOptions: kOptions,\n\t\tOctaveOptions: oOptions,\n\t}\n\n\tif err := render.Render(w, \"scale.html\", pv); err != nil {\n\t\tb.log.Printf(\"%s %s -> %s : ERROR : %v\", r.Method, r.URL.Path, r.RemoteAddr, err)\n\t\treturn\n\t}\n}", "func (dw *DrawingWand) Scale(x, y float64) {\n\tC.MagickDrawScale(dw.dw, C.double(x), C.double(y))\n}", "func (wv *Spectrum) Scale(s float32) {\n\twv.C[0] *= s\n\twv.C[1] *= s\n\twv.C[2] *= s\n\twv.C[3] *= s\n}", "func (tfs *tiflashScaler) Scale(tc *v1alpha1.TidbCluster, oldSet *apps.StatefulSet, newSet *apps.StatefulSet) error {\n\tscaling, _, _, _ := scaleOne(oldSet, newSet)\n\tif scaling > 0 {\n\t\treturn tfs.ScaleOut(tc, oldSet, newSet)\n\t} else if scaling < 0 {\n\t\treturn tfs.ScaleIn(tc, oldSet, newSet)\n\t}\n\t// we only sync auto scaler annotations when we are finishing syncing scaling\n\treturn tfs.SyncAutoScalerAnn(tc, oldSet)\n}", "func (q1 Quat) Scale(c float32) Quat {\n\treturn Quat{q1.W * c, Vec3{q1.V[0] * c, q1.V[1] * c, q1.V[2] * c}}\n}", "func Scale(appName string, webCount int, workerCount int) error {\n\targs := []string{\"dokku\", \"ps:scale\", appName}\n\n\tif webCount > 0 {\n\t\twebPart := fmt.Sprintf(\"web=%v\", webCount)\n\t\targs = append(args, webPart)\n\t}\n\n\tif workerCount > 0 {\n\t\tworkerPart := fmt.Sprintf(\"worker=%v\", workerCount)\n\t\targs = append(args, workerPart)\n\t}\n\n\tlog.GeneralLogger.Println(args)\n\tcmd := common.NewShellCmd(strings.Join(args, \" \"))\n\tcmd.ShowOutput = false\n\tout, err := cmd.Output()\n\n\tif err != nil {\n\t\tlog.ErrorLogger.Println(\"Dokku ps:scale error:\", err.Error())\n\t\tlog.ErrorLogger.Println(\"Dokku ps:scale output:\", string(out))\n\t\treturn err\n\t}\n\tlog.GeneralLogger.Println(\"Dokku ps:scale output:\", string(out))\n\treturn nil\n}", "func (q Quat) Scale(scalar float64) Quat {\n\n\treturn Quat{q.W * scalar,\n\t\tq.X * scalar,\n\t\tq.Y * scalar,\n\t\tq.Z * scalar}\n}", "func (b *Base) ScaleShow(w http.ResponseWriter, r *http.Request) {\n\tb.log.Printf(\"%s %s -> %s\", r.Method, r.URL.Path, r.RemoteAddr)\n\n\t//populate the default ScaleOptions, PitchOptions, KeyOptions, OctaveOptions for scales and arpeggios\n\tsOptions, pOptions, kOptions, oOptions := render.SetDefaultScaleOptions()\n\n\tr.ParseForm() //r is url.Values which is a map[string][]string\n\n\tvar svalues []string\n\tfor _, values := range r.Form { // range over map\n\t\tfor _, value := range values { // range over []string\n\t\t\tsvalues = append(svalues, value) // stick each value in a slice I know the name of\n\t\t}\n\t}\n\n\tscalearp, key, pitch, octave, leftlabel, rightlabel := \"\", \"\", \"\", \"\", \"\", \"\"\n\n\t// the slice of values return by the request can be arranged in any order\n\t// so identify selected scale / arpeggio, pitch, key and octave and store values in variables for later use.\n\tfor i := 0; i < 4; i++ {\n\t\tswitch svalues[i] {\n\t\tcase \"Major\":\n\t\t\tpitch = svalues[i]\n\t\tcase \"Minor\":\n\t\t\tpitch = svalues[i]\n\t\tcase \"1\":\n\t\t\toctave = svalues[i]\n\t\tcase \"2\":\n\t\t\toctave = svalues[i]\n\t\tcase \"Scale\":\n\t\t\tscalearp = svalues[i]\n\t\tcase \"Arpeggio\":\n\t\t\tscalearp = svalues[i]\n\t\tdefault:\n\t\t\tkey = svalues[i]\n\t\t}\n\t}\n\n\t// Update options based on the user's selection\n\n\t// Set key options - set isChecked true for selected key and false for all other keys\n\tkOptions = render.SetKeyOptions(key)\n\n\t// Set scale options\n\tif scalearp == \"Scale\" {\n\t\t// if scale is selected set scale isChecked to true and arpeggio isChecked to false\n\t\tsOptions = []render.ScaleOptions{\n\t\t\trender.ScaleOptions{\"Scalearp\", \"Scale\", false, true, \"Scales\"},\n\t\t\trender.ScaleOptions{\"Scalearp\", \"Arpeggio\", false, false, \"Arpeggios\"},\n\t\t}\n\t} else {\n\t\t// if arpeggio is selected set arpeggio isChecked to true and scale isChecked to false\n\t\tsOptions = []render.ScaleOptions{\n\t\t\trender.ScaleOptions{\"Scalearp\", \"Scale\", false, false, \"Scales\"},\n\t\t\trender.ScaleOptions{\"Scalearp\", \"Arpeggio\", false, true, \"Arpeggios\"},\n\t\t}\n\t}\n\n\t// Set pitch options\n\tif pitch == \"Major\" {\n\t\tpOptions = []render.ScaleOptions{ // if major was selected, set major isChecked to true and minor isChecked to false\n\t\t\trender.ScaleOptions{\"Pitch\", \"Major\", false, true, \"Major\"},\n\t\t\trender.ScaleOptions{\"Pitch\", \"Minor\", false, false, \"Minor\"},\n\t\t}\n\t} else {\n\t\tpOptions = []render.ScaleOptions{ // if minor was selected, set minor isChecked to true and major isChecked to false\n\t\t\trender.ScaleOptions{\"Pitch\", \"Major\", false, false, \"Major\"},\n\t\t\trender.ScaleOptions{\"Pitch\", \"Minor\", false, true, \"Minor\"},\n\t\t}\n\t}\n\n\t// Set octave options\n\tif octave == \"1\" {\n\t\toOptions = []render.ScaleOptions{\n\t\t\trender.ScaleOptions{\"Octave\", \"1\", false, true, \"1 Octave\"},\n\t\t\trender.ScaleOptions{\"Octave\", \"2\", false, false, \"2 Octave\"},\n\t\t}\n\t} else {\n\t\toOptions = []render.ScaleOptions{\n\t\t\trender.ScaleOptions{\"Octave\", \"1\", false, false, \"1 Octave\"},\n\t\t\trender.ScaleOptions{\"Octave\", \"2\", false, true, \"2 Octave\"},\n\t\t}\n\t}\n\n\t// work out what the actual key is and set its value\n\tif pitch == \"Major\" {\n\t\t// for major scales if the key is longer than 2 characters, we only care about the last 2 characters\n\t\tif len(key) > 2 { // only select last two characters for keys which contain two possible names e.g. C#/Db\n\t\t\tkey = key[3:]\n\t\t}\n\t} else { // pitch is minor\n\t\t// for minor scales if the key is longer than 2 characters, we only care about the first 2 characters\n\t\tif len(key) > 2 { // only select first two characters for keys which contain two possible names e.g. C#/Db\n\t\t\tkey = key[:2]\n\t\t}\n\t}\n\n\t// Set the labels, Major have a scale and a drone, while minor have melodic and harmonic minor scales\n\tif pitch == \"Major\" {\n\t\tleftlabel = \"Listen to Major \"\n\t\trightlabel = \"Listen to Drone\"\n\t\tif scalearp == \"Scale\" {\n\t\t\tleftlabel += \"Scale\"\n\t\t} else {\n\t\t\tleftlabel += \"Arpeggio\"\n\t\t}\n\t} else {\n\t\tif scalearp == \"Arpeggio\" {\n\t\t\tleftlabel += \"Listen to Minor Arpeggio\"\n\t\t\trightlabel = \"Listen to Drone\"\n\t\t} else {\n\t\t\tleftlabel += \"Listen to Harmonic Minor Scale\"\n\t\t\trightlabel += \"Listen to Melodic Minor Scale\"\n\t\t}\n\t}\n\n\t// Intialise paths to the associated images and mp3s\n\timgPath, audioPath, audioPath2 := \"img/\", \"mp3/\", \"mp3/\"\n\n\t// Build paths to img and mp3 files that correspond to user selection\n\tif scalearp == \"Scale\" {\n\t\timgPath += \"scale/\"\n\t\taudioPath += \"scale/\"\n\n\t} else {\n\t\t// if arpeggio is selected, add \"arps/\" to the img and mp3 paths\n\t\timgPath += \"arps/\"\n\t\taudioPath += \"arps/\"\n\t}\n\n\tif pitch == \"Major\" {\n\t\timgPath += \"major/\"\n\t\taudioPath += \"major/\"\n\t} else {\n\t\timgPath += \"minor/\"\n\t\taudioPath += \"minor/\"\n\t}\n\n\taudioPath += strings.ToLower(key)\n\timgPath += strings.ToLower(key)\n\t// if the img or audio path contain #, delete last character and replace it with s\n\timgPath = render.ChangeSharpToS(imgPath)\n\taudioPath = render.ChangeSharpToS(audioPath)\n\n\tswitch octave {\n\tcase \"1\":\n\t\timgPath += \"1\"\n\t\taudioPath += \"1\"\n\tcase \"2\":\n\t\timgPath += \"2\"\n\t\taudioPath += \"2\"\n\t}\n\n\taudioPath += \".mp3\"\n\timgPath += \".png\"\n\n\t//generate audioPath2\n\t// audio path2 can either be a melodic minor scale or a drone note.\n\t// Set to melodic minor scale - if the first 16 characters of audio path are:\n\tif audioPath[:16] == \"mp3/scale/minor/\" {\n\t\taudioPath2 = audioPath // set audioPath2 to the original audioPath\n\t\taudioPath2 = audioPath2[:len(audioPath2)-4] // chop off the last 4 characters, this removes .mp3\n\t\taudioPath2 += \"m.mp3\" // then add m for melodic and the .mp3 suffix\n\t} else { // audioPath2 needs to be a drone note.\n\t\taudioPath2 += \"drone/\"\n\t\taudioPath2 += strings.ToLower(key)\n\t\t// may have just added a # to the path, so use the function to change # to s\n\t\taudioPath2 = render.ChangeSharpToS(audioPath2)\n\t\tswitch octave {\n\t\tcase \"1\":\n\t\t\taudioPath2 += \"1.mp3\"\n\t\tcase \"2\":\n\t\t\taudioPath2 += \"2.mp3\"\n\t\t}\n\t}\n\n\tpageVars := render.PageVars{\n\t\tTitle: \"Practice Scales and Arpeggios\",\n\t\tScalearp: scalearp,\n\t\tKey: key,\n\t\tPitch: pitch,\n\t\tScaleImgPath: imgPath,\n\t\tGifPath: \"img/major/gif/a1.gif\",\n\t\tAudioPath: audioPath,\n\t\tAudioPath2: audioPath2,\n\t\tLeftLabel: leftlabel,\n\t\tRightLabel: rightlabel,\n\t\tScaleOptions: sOptions,\n\t\tPitchOptions: pOptions,\n\t\tKeyOptions: kOptions,\n\t\tOctaveOptions: oOptions,\n\t}\n\n\trender.Render(w, \"scale.html\", pageVars)\n}", "func (p *P1D) Scale(factor float64) {\n\tp.bng.scaleW(factor)\n}", "func (o ContainerOutput) Scale() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *Container) pulumi.IntOutput { return v.Scale }).(pulumi.IntOutput)\n}", "func (o ContainerServiceOutput) Scale() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *ContainerService) pulumi.IntOutput { return v.Scale }).(pulumi.IntOutput)\n}", "func Scale(value float64) *SimpleElement { return newSEFloat(\"scale\", value) }", "func (mw *MagickWand) Scale(cols, rows uint) error {\n\treturn mw.ScaleImage(cols, rows)\n}", "func (p *Proc) Scale(x, y float64) {\n\tp.stk.scale(x, y)\n}", "func (dev *pwm_context) Scale(value int) error {\n\tif dev.period == -1 {\n\t\tif err := dev.ReadPeriod(); err != nil {\n\t\t\treturn fmt.Errorf(\"pwm: error running Scale: %s\", err)\n\t\t}\n\t}\n\n\tduty := (float64(value) - dev.min) / dev.span\n\tfmt.Printf(\"pwm: Scaling pin[%d] from value: %d to duty: %f\\n\", dev.pin, value, duty)\n\treturn dev.WriteDuty(int(float64(dev.period) * duty))\n}", "func (tr *trooper) setScale(scale float64) { tr.part.SetScale(scale, scale, scale) }", "func (this *Decider) OnScale(command common.Command) error {\n\tappMetrical := AppMetrical{}\n\terr := json.Unmarshal([]byte(command.Body), &appMetrical)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tappInfo, strategyName := this.getAppInfo(appMetrical.App)\n\tif appInfo == nil {\n\t\tlog.Printf(\"can not get app info, may be the strategy is disabled.\")\n\t\treturn nil\n\t}\n\n\tscaleNumber, err := getScaleNumber(appMetrical.Metrical, appInfo.AppConf)\n\tif err != nil {\n\t\tlog.Printf(\"get scale number error [%s] : %s\", appMetrical.App, err)\n\t\treturn err\n\t}\n\n\tlog.Printf(\"get scale number: %d\", scaleNumber)\n\n\tif scaleNumber <= 0 {\n\t\t// Do nothing except set the new metrical\n\t\treturn nil\n\t} else if scaleNumber > 0 {\n\t\tappScales := this.getAppScales(strategyName, appInfo, scaleNumber)\n\t\tfmt.Println(\"===need scale=====\", appScales)\n\n\t\tmetricalAppScales := []common.MetricalAppScale{}\n\n\t\tfor _, app := range appScales {\n\t\t\taInfo, _ := this.getAppInfo(app.App)\n\t\t\tmetricalAppScales = append(metricalAppScales,\n\t\t\t\tcommon.MetricalAppScale{app.App, app.Number, aInfo.AppConf.MinNum})\n\t\t}\n\n\t\tmetricalAppScales = append(metricalAppScales,\n\t\t\tcommon.MetricalAppScale{appInfo.AppConf.App,\n\t\t\t\tscaleNumber, appInfo.AppConf.MinNum})\n\n\t\tmetricalAppScaleHosts, e := this.Client.MetricalScaleApps(metricalAppScales)\n\n\t\tif e != nil {\n\t\t\tlog.Printf(\"get metrical app scale hosts failed [%s]\", e)\n\t\t\treturn e\n\t\t}\n\t\tfmt.Println(\"get metrical app scale hosts\", metricalAppScaleHosts)\n\t\t// publish messages to apps\n\t\tpublishMessagesToApps(metricalAppScaleHosts, appInfo.AppConf.App)\n\t}\n\n\tdefer func() {\n\t\t// update current metrical\n\t\t(*appInfo).CurrentMetrical = appMetrical.Metrical\n\t}()\n\n\treturn nil\n}", "func (sc *ServiceController) Scale(role string, cardinal int) (bool, string) {\n\n\troleBody := make(map[string]interface{})\n\n\troleBody[\"cardinality\"] = 2\n\troleBody[\"force\"] = true\n\n\treturn sc.UpdateRole(role, roleBody)\n}", "func (w *windowImpl) Scale(dr image.Rectangle, src screen.Texture, sr image.Rectangle, op draw.Op, opts *screen.DrawOptions) {\n\tpanic(\"not implemented\") // TODO: Implement\n}", "func (filter *Saturation) IsScalable() {\n}", "func (c *CanaryDeployer) Scale(cd *flaggerv1.Canary, replicas int32) error {\n\ttargetName := cd.Spec.TargetRef.Name\n\tdep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{})\n\tif err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\treturn fmt.Errorf(\"deployment %s.%s not found\", targetName, cd.Namespace)\n\t\t}\n\t\treturn fmt.Errorf(\"deployment %s.%s query error %v\", targetName, cd.Namespace, err)\n\t}\n\n\tdepCopy := dep.DeepCopy()\n\tdepCopy.Spec.Replicas = int32p(replicas)\n\n\t_, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(depCopy)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"scaling %s.%s to %v failed: %v\", depCopy.GetName(), depCopy.Namespace, replicas, err)\n\t}\n\treturn nil\n}", "func Scale(f float64, d Number) Number {\n\treturn Number{Real: f * d.Real, E1mag: f * d.E1mag, E2mag: f * d.E2mag, E1E2mag: f * d.E1E2mag}\n}", "func (d *DSP) WetDryMix() (float64, float64, float64, error) {\n\tvar prewet, postwet, dry C.float\n\tres := C.FMOD_DSP_GetWetDryMix(d.cptr, &prewet, &postwet, &dry)\n\treturn float64(prewet), float64(postwet), float64(dry), errs[res]\n}", "func Scale(tonic string, gap string) []string {\n\tretScale := []string{}\n\tscl := notes(tonic)\n\ttonic = strings.Title(tonic)\n\n\tfor i, s := range scl {\n\t\tif s == tonic {\n\t\t\tscl = append(scl[i:], scl[:i]...)\n\t\t}\n\t}\n\n\tif gap == \"\" {\n\t\tgap = \"mmmmmmmmmmmm\"\n\t}\n\n\tfor _, s := range strings.Split(gap, \"\") {\n\t\tretScale = append(retScale, scl[0])\n\n\t\tswitch s {\n\t\tcase \"m\":\n\t\t\tscl = scl[1:]\n\t\tcase \"M\":\n\t\t\tscl = scl[2:]\n\t\tcase \"A\":\n\t\t\tscl = scl[3:]\n\t\t}\n\t}\n\n\treturn retScale\n}", "func ScaleStatefulSet(ctx context.Context, sts *appsv1.StatefulSet, amount int32, kubeClient kubernetes.Interface) error {\n\tupdatedSts := sts.DeepCopy()\n\tupdatedReplicas := *updatedSts.Spec.Replicas + amount\n\tif updatedReplicas < 0 {\n\t\treturn errors.New(\"error, can't scale statefulset below 0 replicas\")\n\t}\n\tupdatedSts.Spec.Replicas = &updatedReplicas\n\terr := PatchStatefulSet(ctx, sts, updatedSts, kubeClient)\n\treturn err\n}", "func (c *ProcessClient) Scale(ctx context.Context, guid string, scale *resource.ProcessScale) (*resource.Process, error) {\n\tvar process resource.Process\n\t_, err := c.client.post(ctx, path.Format(\"/v3/processes/%s/actions/scale\", guid), scale, &process)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &process, nil\n}", "func (canvas *Canvas) Scale(x, y float32) {\n\twriteCommand(canvas.contents, \"cm\", x, 0, 0, y, 0, 0)\n}", "func (a *Workload) Scale(ctx context.Context, instances int32) error {\n\treturn retry.RetryOnConflict(retry.DefaultRetry, func() error {\n\t\t// Retrieve the latest version of Deployment before attempting update\n\t\t// RetryOnConflict uses exponential backoff to avoid exhausting the apiserver\n\t\tdeployment, err := a.Deployment(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdeployment.Spec.Replicas = &instances\n\n\t\t_, err = a.cluster.Kubectl.AppsV1().Deployments(a.app.Org).Update(\n\t\t\tctx, deployment, metav1.UpdateOptions{})\n\n\t\treturn err\n\t})\n}", "func (s *Surface) Scale(x, y float64) {\n\ts.Ctx.Call(\"scale\", x, y)\n}", "func (k *kubectlContext) Scale(resource string, scale uint) error {\n\tout, err := k.do(\"scale\", fmt.Sprintf(\"--replicas=%d\", scale), resource)\n\tk.t.Log(string(out))\n\treturn err\n}", "func (this *Decider) ScaleAction(command common.Command) error {\n\tmessage := common.InformScaleDownAppMessage{}\n\terr := json.Unmarshal([]byte(command.Body), &message)\n\tif err != nil {\n\t}\n\n\tthis.Client.MetricalScaleAppsAction(message)\n\treturn err\n}", "func (dc *DeploymentController) scale(ctx context.Context, deployment *apps.Deployment, newRS *apps.ReplicaSet, oldRSs []*apps.ReplicaSet) error {\n\t// If there is only one active replica set then we should scale that up to the full count of the\n\t// deployment. If there is no active replica set, then we should scale up the newest replica set.\n\tif activeOrLatest := deploymentutil.FindActiveOrLatest(newRS, oldRSs); activeOrLatest != nil {\n\t\tif *(activeOrLatest.Spec.Replicas) == *(deployment.Spec.Replicas) {\n\t\t\treturn nil\n\t\t}\n\t\t_, _, err := dc.scaleReplicaSetAndRecordEvent(ctx, activeOrLatest, *(deployment.Spec.Replicas), deployment)\n\t\treturn err\n\t}\n\n\t// If the new replica set is saturated, old replica sets should be fully scaled down.\n\t// This case handles replica set adoption during a saturated new replica set.\n\tif deploymentutil.IsSaturated(deployment, newRS) {\n\t\tfor _, old := range controller.FilterActiveReplicaSets(oldRSs) {\n\t\t\tif _, _, err := dc.scaleReplicaSetAndRecordEvent(ctx, old, 0, deployment); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\t// There are old replica sets with pods and the new replica set is not saturated.\n\t// We need to proportionally scale all replica sets (new and old) in case of a\n\t// rolling deployment.\n\tif deploymentutil.IsRollingUpdate(deployment) {\n\t\tallRSs := controller.FilterActiveReplicaSets(append(oldRSs, newRS))\n\t\tallRSsReplicas := deploymentutil.GetReplicaCountForReplicaSets(allRSs)\n\n\t\tallowedSize := int32(0)\n\t\tif *(deployment.Spec.Replicas) > 0 {\n\t\t\tallowedSize = *(deployment.Spec.Replicas) + deploymentutil.MaxSurge(*deployment)\n\t\t}\n\n\t\t// Number of additional replicas that can be either added or removed from the total\n\t\t// replicas count. These replicas should be distributed proportionally to the active\n\t\t// replica sets.\n\t\tdeploymentReplicasToAdd := allowedSize - allRSsReplicas\n\n\t\t// The additional replicas should be distributed proportionally amongst the active\n\t\t// replica sets from the larger to the smaller in size replica set. Scaling direction\n\t\t// drives what happens in case we are trying to scale replica sets of the same size.\n\t\t// In such a case when scaling up, we should scale up newer replica sets first, and\n\t\t// when scaling down, we should scale down older replica sets first.\n\t\tvar scalingOperation string\n\t\tswitch {\n\t\tcase deploymentReplicasToAdd > 0:\n\t\t\tsort.Sort(controller.ReplicaSetsBySizeNewer(allRSs))\n\t\t\tscalingOperation = \"up\"\n\n\t\tcase deploymentReplicasToAdd < 0:\n\t\t\tsort.Sort(controller.ReplicaSetsBySizeOlder(allRSs))\n\t\t\tscalingOperation = \"down\"\n\t\t}\n\n\t\t// Iterate over all active replica sets and estimate proportions for each of them.\n\t\t// The absolute value of deploymentReplicasAdded should never exceed the absolute\n\t\t// value of deploymentReplicasToAdd.\n\t\tdeploymentReplicasAdded := int32(0)\n\t\tnameToSize := make(map[string]int32)\n\t\tlogger := klog.FromContext(ctx)\n\t\tfor i := range allRSs {\n\t\t\trs := allRSs[i]\n\n\t\t\t// Estimate proportions if we have replicas to add, otherwise simply populate\n\t\t\t// nameToSize with the current sizes for each replica set.\n\t\t\tif deploymentReplicasToAdd != 0 {\n\t\t\t\tproportion := deploymentutil.GetProportion(logger, rs, *deployment, deploymentReplicasToAdd, deploymentReplicasAdded)\n\n\t\t\t\tnameToSize[rs.Name] = *(rs.Spec.Replicas) + proportion\n\t\t\t\tdeploymentReplicasAdded += proportion\n\t\t\t} else {\n\t\t\t\tnameToSize[rs.Name] = *(rs.Spec.Replicas)\n\t\t\t}\n\t\t}\n\n\t\t// Update all replica sets\n\t\tfor i := range allRSs {\n\t\t\trs := allRSs[i]\n\n\t\t\t// Add/remove any leftovers to the largest replica set.\n\t\t\tif i == 0 && deploymentReplicasToAdd != 0 {\n\t\t\t\tleftover := deploymentReplicasToAdd - deploymentReplicasAdded\n\t\t\t\tnameToSize[rs.Name] = nameToSize[rs.Name] + leftover\n\t\t\t\tif nameToSize[rs.Name] < 0 {\n\t\t\t\t\tnameToSize[rs.Name] = 0\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// TODO: Use transactions when we have them.\n\t\t\tif _, _, err := dc.scaleReplicaSet(ctx, rs, nameToSize[rs.Name], deployment, scalingOperation); err != nil {\n\t\t\t\t// Return as soon as we fail, the deployment is requeued\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (q *Quaternion) Scale(factor float64) {\n\tq.Q0 = factor * q.Q0\n\tq.Q1 = factor * q.Q1\n\tq.Q2 = factor * q.Q2\n\tq.Q3 = factor * q.Q3\n}", "func scaling() gs.CSSRule {\n\treturn gs.S(\"code\",\n\t\tgs.S(\"&,kbd\",\n\t\t\tgs.S(\"&,samp\",\n\t\t\t\tgs.P(\"font-family\", \"monospace, monospace;\"),\n\t\t\t\tgs.P(\"font-size\", \"1em\"),\n\t\t\t),\n\t\t),\n\t)\n}", "func (t *Transform) Scale(sx, sy float64) {\n\tout := fmt.Sprintf(\"scale(%g,%g)\", sx, sy)\n\n\tt.transforms = append(t.transforms, out)\n}", "func (s *Service) scale(replicas int) {\n\tlog.WithField(\"replicas\", replicas).Debug(\"Service scaling\")\n\ts.state = StateScaling\n\tif s.CurrentReplicas != replicas {\n\t\ts.auklet.scaleService(s.ServiceID, replicas)\n\t\ts.auklet.Lock()\n\t\ts.auklet.metrics[MetricServiceScaleEventsTotal].(prometheus.Counter).Inc()\n\t\tif replicas > s.CurrentReplicas {\n\t\t\ts.auklet.serviceMetrics[s.ServiceID][MetricScaleUpEventsCount].(prometheus.Counter).Inc()\n\t\t} else {\n\t\t\ts.auklet.serviceMetrics[s.ServiceID][MetricScaleDownEventsCount].(prometheus.Counter).Inc()\n\t\t}\n\t\ts.auklet.Unlock()\n\t}\n\n\t// after scaling return to stable state\n\ts.stable()\n}", "func main() {\n\tv := Vertex{1, 2}\n\tc := float64(rand.Intn(1337))\n\n\tfmt.Println(\"original\", v.Abs())\n\n\tv.Scale(c)\n\tfmt.Println(v.Abs())\n\n\tScale(&v, 1/c)\n\tfmt.Println(\"rescaled\", Abs(v))\n\n\tp := &Vertex{3,4}\n\tp.Scale(3)\n\tScale(p,8)\n\n\tfmt.Println(v,p)\n}", "func (v *Vec4) Scale(s float32) {\n\tv.X *= s\n\tv.Y *= s\n\tv.Z *= s\n\tv.W *= s\n}", "func (c *LinehaulCostComputation) Scale(factor float64) {\n\tc.BaseLinehaul = c.BaseLinehaul.MultiplyFloat64(factor)\n\tc.OriginLinehaulFactor = c.OriginLinehaulFactor.MultiplyFloat64(factor)\n\tc.DestinationLinehaulFactor = c.DestinationLinehaulFactor.MultiplyFloat64(factor)\n\tc.ShorthaulCharge = c.ShorthaulCharge.MultiplyFloat64(factor)\n\tc.LinehaulChargeTotal = c.LinehaulChargeTotal.MultiplyFloat64(factor)\n}", "func (o BackendResponseOutput) CapacityScaler() pulumi.Float64Output {\n\treturn o.ApplyT(func(v BackendResponse) float64 { return v.CapacityScaler }).(pulumi.Float64Output)\n}", "func (encoder *encoder) ScaleDown(pt *Plaintext, ptRt *PlaintextRingT) {\n\tencoder.scaler.DivByQOverTRounded(pt.value, ptRt.value)\n}", "func (self *T) Scale(f float64) *T {\n\tself[0] *= f\n\tself[1] *= f\n\treturn self\n}", "func (t *Tree) Scale(s float32) {\n\tif t.Leaf != nil {\n\t\tfor i, x := range t.Leaf.OutputDelta {\n\t\t\tt.Leaf.OutputDelta[i] = x * s\n\t\t}\n\t} else {\n\t\tt.Branch.FalseBranch.Scale(s)\n\t\tt.Branch.TrueBranch.Scale(s)\n\t}\n}", "func Scale(s Frac, m M) M {\n\tm = CopyMatrix(m)\n\n\tfor r := 1; r <= m.Rows(); r++ {\n\t\tm.MultiplyRow(r, s)\n\t}\n\n\treturn m\n}", "func (me TxsdAnimateTransformTypeType) IsScale() bool { return me.String() == \"scale\" }", "func ScaleStatefulSet(ctx context.Context, t ginkgo.GinkgoTInterface, options *k8s.KubectlOptions,\n\tcl kubernetes.Interface, namespace string, replicas int32) error {\n\tstatefulSet, err := cl.AppsV1().StatefulSets(namespace).Get(ctx, StatefulSetName, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstatefulSet.Spec.Replicas = &replicas\n\t_, err = cl.AppsV1().StatefulSets(namespace).Update(ctx, statefulSet, metav1.UpdateOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tWaitDemoApp(t, options, int(replicas))\n\treturn nil\n}", "func Scale(v *Vertex, f float64) {\n\tv.x *= f\n\tv.y *= f\n}", "func (p *Part) SetScale(scale vector.Vector) {\n\tif scale.Len() != 3 && scale.Kind() != reflect.Float32 {\n\t\tlog.Fatalf(\"Part.SetScale: expects 3D-Float32 vector, got %dD-%v\", scale.Len(), scale.Kind())\n\t}\n\t// Create scaling matrix\n\tp.scaling = matrix.NewMatrix([][]float32{\n\t\t{scale.Get(0).(float32), 0.0, 0.0},\n\t\t{0.0, scale.Get(1).(float32), 0.0},\n\t\t{0.0, 0.0, scale.Get(2).(float32)},\n\t})\n}", "func (v Vertex) Scale(f int) {\n\tv.x = v.x * f\n\tv.y = v.y * f\n}", "func scale(n int) string {\n\tswitch n {\n\tcase 1:\n\t\treturn \"Celcius\"\n\tcase 2:\n\t\treturn \"Fahrenheit\"\n\tdefault:\n\t\treturn \"\"\n\t}\n}", "func KubeScale(count string, deployment string) string {\n\tvar outputstring string\n\tif count == \"\" || deployment == \"\" {\n\t\toutputstring = \"\"\n\t} else if strings.HasSuffix(deployment, \".yaml\") {\n\t\toutputstring = fmt.Sprintf(\"scale --replicas=%s -f %s\", count, deployment)\n\t} else {\n\t\toutputstring = fmt.Sprintf(\"scale --replicas=%s %s\", count, deployment)\n\t}\n\treturn KubeCommand(outputstring)\n}", "func Scale(v *Vertex, f float64) {\n\tv.X *= f\n\tv.Y *= f\n}", "func (p Point) Scale(s Length) Point {\n\treturn Point{p.X * s, p.Y * s}\n}", "func SrampD1(x, β float64) float64 {\n\tif -β*x > 500.0 {\n\t\treturn 0.0\n\t}\n\treturn 1.0 / (1.0 + math.Exp(-β*x))\n}", "func ScaleStatefulSet(ctx context.Context, c client.Client, key client.ObjectKey, replicas int32) error {\n\tstatefulset := &appsv1.StatefulSet{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: key.Name,\n\t\t\tNamespace: key.Namespace,\n\t\t},\n\t}\n\n\treturn scaleResource(ctx, c, statefulset, replicas)\n}", "func (ki *KernelInfo) Scale(scale float64, normalizeType KernelNormalizeType) {\n\tC.ScaleKernelInfo(ki.info, C.double(scale), C.GeometryFlags(normalizeType))\n\truntime.KeepAlive(ki)\n}", "func (t *TextureTranform) ScaleOrDefault() [2]float32 {\n\tif t.Scale == emptyScale {\n\t\treturn DefaultScale\n\t}\n\treturn t.Scale\n}", "func (p *Point) Scale(v float64) {\n\tp.x *= v\n\tp.y *= v\n}", "func (v *Vertex) Scale(f float64) {\n v.X = v.X * f\n v.Y = v.Y * f\n}", "func (v Vec3) Scale(s float64) Vec3 {\n\treturn Vec3{v[0] * s, v[1] * s, v[2] * s}\n}", "func (v *Vertex) Scale(f float64) {\n v.X = v.X * f\n v.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * 1\n\tv.Y = v.Y * 1\n}", "func Scale(p point, factor int) point {\n\treturn point{p.x * factor, p.y * factor, p.z * factor}\n}", "func (z *Big) SetMantScale(value int64, scale int) *Big {\n\tz.SetUint64(arith.Abs(value))\n\tz.exp = -scale // compiler should optimize out z.exp = 0 in SetUint64\n\tif value < 0 {\n\t\tz.form |= signbit\n\t}\n\treturn z\n}", "func (m *Matrix3) Scale(s float64) {\n\tfor i, x := range m {\n\t\tm[i] = x * s\n\t}\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X *= f\n\tv.Y *= f\n}", "func stress1(verbose bool) {\n\tfor i:=0; i<20; i++ {\n\t\tif verbose {\n\t\t\tputs(\"Setting scale to 1\\n\")\n\t\t}\n\t\tscale(1)\n\t\twait(10)\n\n\t\tif verbose {\n\t\t\tputs(\"Setting scale to 2\\n\")\n\t\t}\n\t\tscale(2)\n\t\twait(10)\n\t}\n}", "func (t *Transform) SetScale(sx, sy float64) *Transform {\n\tt.Scale1.X = sx - 1\n\tt.Scale1.Y = sy - 1\n\treturn t\n}", "func scaleResource(ctx context.Context, c client.Client, obj client.Object, replicas int32) error {\n\tpatch := []byte(fmt.Sprintf(`{\"spec\":{\"replicas\":%d}}`, replicas))\n\n\t// TODO: replace this with call to scale subresource once controller-runtime supports it\n\t// see: https://github.com/kubernetes-sigs/controller-runtime/issues/172\n\treturn c.Patch(ctx, obj, client.RawPatch(types.MergePatchType, patch))\n}", "func Scale(X *mat.Dense) *mat.Dense {\n\tXout, _ := NewStandardScaler().FitTransform(X, nil)\n\treturn Xout\n}", "func (encoder *encoder) ScaleUp(ptRt *PlaintextRingT, pt *Plaintext) {\n\tscaleUp(encoder.ringQ, encoder.deltaMont, ptRt.value, pt.value)\n}", "func (tt *telloTrackT) deriveScale() (scale float32) {\n\tscale = 1.0 // minimum scale value\n\tif tt.maxX > scale {\n\t\tscale = tt.maxX\n\t}\n\tif -tt.minX > scale {\n\t\tscale = -tt.minX\n\t}\n\tif tt.maxY > scale {\n\t\tscale = tt.maxY\n\t}\n\tif -tt.minY > scale {\n\t\tscale = -tt.minY\n\t}\n\tscale = float32(math.Ceil(float64(scale)))\n\treturn scale\n}", "func scale(up bool) {\n\tif Font.TTF == nil {\n\t\treturn\n\t}\n\tif up {\n\t\tFont.size++\n\t} else if Font.size < 5 {\n\t\treturn\n\t} else {\n\t\tFont.size--\n\t}\n\tSetFont(Font.TTF, Font.size)\n}", "func (c *canvasRenderer) Scale(amount sprec.Vec2) {\n\tc.currentLayer.Transform = sprec.Mat4Prod(\n\t\tc.currentLayer.Transform,\n\t\tsprec.ScaleMat4(amount.X, amount.Y, 1.0),\n\t)\n}", "func (self *T) Scale(f float32) *T {\n\tself[0][0] *= f\n\tself[1][1] *= f\n\treturn self\n}", "func (v *Vertex) Scale(f float64) {\r\n\tv.X = v.X * f\r\n\tv.Y = v.Y * f\r\n}", "func (v *Vertex) Scale(f float64) {\n\tv.x = v.x * f\n\tv.y = v.y * f\n}", "func Scale(namespace string, app string, n *int32) error {\n\tc, err := k8s.NewInClusterClient()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get k8s client\")\n\t}\n\n\td, err := c.ExtensionsV1Beta1().GetDeployment(ctx, app, namespace)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get deployment\")\n\t}\n\n\td.Spec.Replicas = n\n\n\t_, err = c.ExtensionsV1Beta1().UpdateDeployment(ctx, d)\n\treturn errors.Wrap(err, \"failed to scale deployment\")\n}", "func (v Vec3) Scale(t float64) Vec3 {\n\treturn Vec3{X: v.X * t, Y: v.Y * t, Z: v.Z * t}\n}", "func (c mockK8sClient) Scale(resource *kubernetes.Workload, replicas int32) error {\n\tc.Counts.NumPods = replicas\n\treturn nil\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func (v *Vertex) Scale(f float64) {\n\tv.X = v.X * f\n\tv.Y = v.Y * f\n}", "func ScaleData(metricID string, unit string, value float64) float64 {\n\tif (strings.Compare(unit, \"MicroSecond\") == 0) || strings.Contains(metricID, \"builtin:service.response.time\") {\n\t\t// scale from microseconds to milliseconds\n\t\treturn value / 1000.0\n\t}\n\n\t// convert Bytes to Kilobyte\n\tif strings.Compare(unit, \"Byte\") == 0 {\n\t\treturn value / 1024\n\t}\n\n\treturn value\n}", "func (v *vertex) Scale(f float64) {\n\tv.x = v.x * f\n\tv.y = v.y * f\n}", "func (me XsdGoPkgHasElem_Scale) ScaleDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func Samplerate(s float64) Option {\n\treturn func(args *Options) {\n\t\targs.Samplerate = s\n\t}\n}", "func (a *Audio) SetSfxVolume(vol float32) {\n\tlog.Debug(\"Set Sfx Volume %v\", vol)\n\n\t// Gameplay sound effects\n\ta.levelDone.SetGain(vol)\n\ta.levelRestart.SetGain(vol)\n\ta.levelFail.SetGain(vol)\n\ta.gameComplete.SetGain(vol)\n\n\t// User interface sound effects\n\ta.click.SetGain(vol)\n\ta.hover.SetGain(vol)\n\n\t// Gopher sound effects\n\ta.gopherWalk.SetGain(vol)\n\ta.gopherBump.SetGain(vol)\n\ta.gopherHurt.SetGain(vol)\n\ta.gopherFallStart.SetGain(vol)\n\ta.gopherFallEnd.SetGain(vol)\n\n\t// Box sound effects\n\ta.boxPush.SetGain(vol)\n\ta.boxOnPad.SetGain(vol)\n\ta.boxOffPad.SetGain(vol)\n\ta.boxFallStart.SetGain(vol)\n\ta.boxFallEnd.SetGain(vol)\n\n\t// Elevator sound effects\n\ta.elevatorUp.SetGain(vol)\n\ta.elevatorDown.SetGain(vol)\n}", "func (self *T) Scaled(f float32) T {\n\tr := *self\n\treturn *r.Scale(f)\n}", "func (me XsdGoPkgHasElems_Scale) ScaleDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func (m Matrix) Scale(scale vec32.Vector) Matrix {\n\treturn Mul(m, Matrix{\n\t\t{scale[0], 0, 0, 0},\n\t\t{0, scale[1], 0, 0},\n\t\t{0, 0, scale[2], 0},\n\t\t{0, 0, 0, 1},\n\t})\n}", "func (z *InfraHamilton) Scal(y *InfraHamilton, a *big.Rat) *InfraHamilton {\n\tz.l.Scal(&y.l, a)\n\tz.r.Scal(&y.r, a)\n\treturn z\n}", "func ( v Vertex ) Scale1( f float64 ) {\n\t// Value receiver, no change to the struct\n\tv.x = v.x * f\n\tv.y = v.y * f\n}", "func Sramp(x, β float64) float64 {\n\tif -β*x > 500.0 {\n\t\treturn 0.0\n\t}\n\treturn x + math.Log(1.0+math.Exp(-β*x))/β\n}", "func (self Transform) Scale(scaleX, scaleY float32) {\n\tC.sfTransform_scale(self.Cref, C.float(scaleX), C.float(scaleY))\n}", "func (m *PrinterDefaults) SetScaling(value *PrintScaling)() {\n err := m.GetBackingStore().Set(\"scaling\", value)\n if err != nil {\n panic(err)\n }\n}" ]
[ "0.58391404", "0.5583572", "0.5322332", "0.5293805", "0.52633417", "0.5142366", "0.5142163", "0.5118127", "0.50875956", "0.50541645", "0.5047431", "0.4986008", "0.49298394", "0.49247116", "0.4922239", "0.48938483", "0.48694026", "0.48514295", "0.48286203", "0.4815054", "0.47623754", "0.47390583", "0.46795666", "0.4673818", "0.46529794", "0.46383223", "0.46284568", "0.46155998", "0.45935893", "0.4593012", "0.45802334", "0.45771405", "0.45627016", "0.45444956", "0.4543515", "0.4542628", "0.45136136", "0.45125568", "0.4509166", "0.45072716", "0.44995314", "0.4486292", "0.4464864", "0.4463617", "0.44470677", "0.44386032", "0.44269985", "0.44264555", "0.44178128", "0.4414526", "0.44121763", "0.43695092", "0.43690354", "0.436105", "0.43514773", "0.43494722", "0.43304747", "0.43272537", "0.43156162", "0.4313411", "0.430431", "0.42983", "0.42852804", "0.42818606", "0.42815048", "0.42805025", "0.42729717", "0.42687583", "0.4248137", "0.42454475", "0.4244247", "0.42374784", "0.42362234", "0.42275083", "0.42121804", "0.4201942", "0.4194171", "0.4183484", "0.41829586", "0.41819236", "0.41703358", "0.41703358", "0.41703358", "0.41703358", "0.41703358", "0.41703358", "0.41703358", "0.4169984", "0.41557273", "0.41532516", "0.41523176", "0.4146893", "0.41313913", "0.41254535", "0.41237244", "0.4123291", "0.4116889", "0.4114849", "0.4113736", "0.41098705" ]
0.5086322
9
Retrieves the wet/dry scale of a DSP effect, through the 'wet' mix, which is the postprocessed signal and the 'dry' mix which is the preprocessed signal. The dry signal path is silent by default, because dsp effects transform the input and pass the newly processed result to the output. It does not add to the input.
func (d *DSP) WetDryMix() (float64, float64, float64, error) { var prewet, postwet, dry C.float res := C.FMOD_DSP_GetWetDryMix(d.cptr, &prewet, &postwet, &dry) return float64(prewet), float64(postwet), float64(dry), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) SetWetDryMix(prewet, postwet, dry float64) error {\n\tres := C.FMOD_DSP_SetWetDryMix(d.cptr, C.float(prewet), C.float(postwet), C.float(dry))\n\treturn errs[res]\n}", "func wate(freq float64, fx, wtx []float64, lband int, filterType FilterType) float64 {\n\tif filterType != Differentiator {\n\t\treturn wtx[lband]\n\t}\n\tif fx[lband] >= 0.0001 {\n\t\treturn wtx[lband] / freq\n\t}\n\treturn wtx[lband]\n}", "func NewDry(screen *ui.Screen, env *drydocker.DockerEnv) (*Dry, error) {\n\td, err := drydocker.ConnectToDaemon(env)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn newDry(screen, d)\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func NewDry(screen *ui.Screen, cfg Config) (*Dry, error) {\n\n\td, err := docker.ConnectToDaemon(cfg.dockerEnv())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdry, err := newDry(screen, d)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif cfg.MonitorMode {\n\t\tdry.changeView(Monitor)\n\t\twidgets.Monitor.RefreshRate(cfg.MonitorRefreshRate)\n\t}\n\treturn dry, nil\n}", "func (b BaseDefender) GetShieldPower(researches Researches) int64 {\n\treturn int64(float64(b.ShieldPower) * (1 + float64(researches.ShieldingTechnology)*0.1))\n}", "func (_CraftingI *CraftingICaller) GetWeaponDc(opts *bind.CallOpts, _item_id *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _CraftingI.contract.Call(opts, &out, \"get_weapon_dc\", _item_id)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (p *Pump) WavBitDepth() int {\n\treturn p.wavBitDepth\n}", "func (d *DSP) Bypass() (bool, error) {\n\tvar bypass C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetBypass(d.cptr, &bypass)\n\treturn setBool(bypass), errs[res]\n}", "func (m *WTWWSWMediator) TransferWater(amount float64) {\n\tamount = m.WTW.OutputToStorage(amount)\n\tm.WSW.InputFromWTW(amount)\n}", "func (o GetSrvRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetSrvRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (o GetSrvRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetSrvRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (p *Pump) WavSampleRate() phono.SampleRate {\n\treturn p.wavSampleRate\n}", "func (s *Service) GetSignalStrength(ctx context.Context) (uint8, error) {\n\tprops, err := s.GetProperties(ctx)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"unable to get properties\")\n\t}\n\tstrength, err := props.GetUint8(shillconst.ServicePropertyStrength)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"unable to get strength from properties\")\n\t}\n\treturn strength, nil\n}", "func (ind *Indicator) Soft(val VarSet, key string) float64 {\n\tif _lv, ok := ind.Stored(key); ok && ind.stores {\n\t\treturn _lv\n\t}\n\n\tv, ok := val[ind.varid]\n\tvar l float64\n\tif !ok || v == ind.setting {\n\t\tl = 1.0\n\t}\n\n\tind.Store(key, l)\n\treturn l\n}", "func (toneAnalyzer *ToneAnalyzerV3) ToneWithContext(ctx context.Context, toneOptions *ToneOptions) (result *ToneAnalysis, response *core.DetailedResponse, err error) {\n\terr = core.ValidateNotNil(toneOptions, \"toneOptions cannot be nil\")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.ValidateStruct(toneOptions, \"toneOptions\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif toneOptions.ToneInput != nil && toneOptions.ContentType == nil {\n\t\ttoneOptions.SetContentType(\"application/json\")\n\t}\n\n\tbuilder := core.NewRequestBuilder(core.POST)\n\tbuilder = builder.WithContext(ctx)\n\tbuilder.EnableGzipCompression = toneAnalyzer.GetEnableGzipCompression()\n\t_, err = builder.ResolveRequestURL(toneAnalyzer.Service.Options.URL, `/v3/tone`, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfor headerName, headerValue := range toneOptions.Headers {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\n\tsdkHeaders := common.GetSdkHeaders(\"tone_analyzer\", \"V3\", \"Tone\")\n\tfor headerName, headerValue := range sdkHeaders {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\tbuilder.AddHeader(\"Accept\", \"application/json\")\n\tif toneOptions.ContentType != nil {\n\t\tbuilder.AddHeader(\"Content-Type\", fmt.Sprint(*toneOptions.ContentType))\n\t}\n\tif toneOptions.ContentLanguage != nil {\n\t\tbuilder.AddHeader(\"Content-Language\", fmt.Sprint(*toneOptions.ContentLanguage))\n\t}\n\tif toneOptions.AcceptLanguage != nil {\n\t\tbuilder.AddHeader(\"Accept-Language\", fmt.Sprint(*toneOptions.AcceptLanguage))\n\t}\n\n\tbuilder.AddQuery(\"version\", fmt.Sprint(*toneAnalyzer.Version))\n\tif toneOptions.Sentences != nil {\n\t\tbuilder.AddQuery(\"sentences\", fmt.Sprint(*toneOptions.Sentences))\n\t}\n\tif toneOptions.Tones != nil {\n\t\tbuilder.AddQuery(\"tones\", strings.Join(toneOptions.Tones, \",\"))\n\t}\n\n\t_, err = builder.SetBodyContent(core.StringNilMapper(toneOptions.ContentType), toneOptions.ToneInput, nil, toneOptions.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\trequest, err := builder.Build()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar rawResponse map[string]json.RawMessage\n\tresponse, err = toneAnalyzer.Service.Request(request, &rawResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\tif rawResponse != nil {\n\t\terr = core.UnmarshalModel(rawResponse, \"\", &result, UnmarshalToneAnalysis)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tresponse.Result = result\n\t}\n\n\treturn\n}", "func (m *Message) AllDSP() ([]*DSP, error) {\n\tpss, err := m.ParseAll(\"DSP\")\n\treturn pss.([]*DSP), err\n}", "func SrampD1(x, β float64) float64 {\n\tif -β*x > 500.0 {\n\t\treturn 0.0\n\t}\n\treturn 1.0 / (1.0 + math.Exp(-β*x))\n}", "func (pj *EcCa1Prjn) DWt() {\n\tif !pj.Learn.Learn {\n\t\treturn\n\t}\n\tslay := pj.Send.(leabra.LeabraLayer).AsLeabra()\n\trlay := pj.Recv.(leabra.LeabraLayer).AsLeabra()\n\tfor si := range slay.Neurons {\n\t\tsn := &slay.Neurons[si]\n\t\tnc := int(pj.SConN[si])\n\t\tst := int(pj.SConIdxSt[si])\n\t\tsyns := pj.Syns[st : st+nc]\n\t\tscons := pj.SConIdx[st : st+nc]\n\n\t\tfor ci := range syns {\n\t\t\tsy := &syns[ci]\n\t\t\tri := scons[ci]\n\t\t\trn := &rlay.Neurons[ri]\n\n\t\t\terr := (sn.ActP * rn.ActP) - (sn.ActQ1 * rn.ActQ1)\n\t\t\tbcm := pj.Learn.BCMdWt(sn.AvgSLrn, rn.AvgSLrn, rn.AvgL)\n\t\t\tbcm *= pj.Learn.XCal.LongLrate(rn.AvgLLrn)\n\t\t\terr *= pj.Learn.XCal.MLrn\n\t\t\tdwt := bcm + err\n\n\t\t\tnorm := float32(1)\n\t\t\tif pj.Learn.Norm.On {\n\t\t\t\tnorm = pj.Learn.Norm.NormFmAbsDWt(&sy.Norm, mat32.Abs(dwt))\n\t\t\t}\n\t\t\tif pj.Learn.Momentum.On {\n\t\t\t\tdwt = norm * pj.Learn.Momentum.MomentFmDWt(&sy.Moment, dwt)\n\t\t\t} else {\n\t\t\t\tdwt *= norm\n\t\t\t}\n\t\t\tsy.DWt += pj.Learn.Lrate * dwt\n\t\t}\n\t\t// aggregate max DWtNorm over sending synapses\n\t\tif pj.Learn.Norm.On {\n\t\t\tmaxNorm := float32(0)\n\t\t\tfor ci := range syns {\n\t\t\t\tsy := &syns[ci]\n\t\t\t\tif sy.Norm > maxNorm {\n\t\t\t\t\tmaxNorm = sy.Norm\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor ci := range syns {\n\t\t\t\tsy := &syns[ci]\n\t\t\t\tsy.Norm = maxNorm\n\t\t\t}\n\t\t}\n\t}\n}", "func (f *File) TrimSilence() {\n\t// TODO: calibrate constants\n\tf.AudioData.TrimSilent(0.03, 0.25)\n}", "func (o *UpdateVpnConnectionRequest) SetDryRun(v bool) {\n\to.DryRun = &v\n}", "func (p *DefaultPolicy) GetEffect() string {\n\treturn p.Effect\n}", "func handler(w http.ResponseWriter, _ *http.Request) {\n\tsignal, _ := dsp.ReadSignalFile(\"examples/signals/example-noisy-signal_31_hz.txt\", 31)\n\n\tplot1 := plotSignal(signal, opts.Title{\n\t\tTitle: \"Original signal\",\n\t\tSubtitle: signal.String(),\n\t})\n\n\tpage := components.NewPage()\n\tpage.AddCharts(plot1)\n\n\tsplit := 10\n\tparts := signal.Split(time.Duration(split) * time.Second)\n\n\tduration := 0.0\n\n\tfor i := 0; i < len(parts); i++ {\n\t\tpart := parts[i]\n\n\t\tfrom := i * split\n\t\tto := from + int(part.Duration())\n\n\t\tpage.AddCharts(plotSignal(part, opts.Title{\n\t\t\tTitle: fmt.Sprintf(\"Signal %vs to %vs\", i*split, (i+1)*split),\n\t\t\tSubtitle: part.String(),\n\t\t}))\n\n\t\t// Normalize the signal around -1 and 1\n\t\tsignalNormalized, err := part.Normalize()\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tpage.AddCharts(plotSignal(signalNormalized, opts.Title{\n\t\t\tTitle: fmt.Sprintf(\"Normalized signal %vs to %vs\", from, to),\n\t\t\tSubtitle: signalNormalized.String(),\n\t\t}))\n\n\t\t// 4. Frequency spectrum of the signal\n\t\tfrequencySpectrum, err := signalNormalized.FrequencySpectrum()\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tpage.AddCharts(plotSpectrum(frequencySpectrum, opts.Title{\n\t\t\tTitle: fmt.Sprintf(\"Frequency spectrum %vs to %vs\", from, to),\n\t\t\tSubtitle: frequencySpectrum.String(),\n\t\t}))\n\n\t\t// Some example calculations\n\t\tfor j, frequency := range frequencySpectrum.Frequencies {\n\t\t\t// Only care frequencies above 2hz\n\t\t\tif frequency > 2 {\n\t\t\t\tif frequencySpectrum.Spectrum[j] > 0.3 {\n\t\t\t\t\t// More than 30%, it's considered noisy\n\t\t\t\t\tduration += part.Duration()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Printf(\"noisy %vs, percentage %.1f%%\\n\", duration, 100*duration/signal.Duration())\n\n\tpage.Render(w)\n}", "func (module *OscModule) DSP(timestamp int64) {\n\tbuflen := module.GetBufferLength()\n\tsr := module.GetSampleRate()\n\n\tvar pmodInput []float64\n\tvar fmodInput []float64\n\tvar ampInput []float64\n\n\toutput := module.Outlets[0].Buffer\n\n\t// Check if inlet is connected for phase modulation\n\tif module.Inlets[0].Connections.Len() > 0 {\n\t\tpmodInput = module.Inlets[0].Buffer\n\t}\n\n\tif module.Inlets[1].Connections.Len() > 0 {\n\t\tfmodInput = module.Inlets[1].Buffer\n\t}\n\n\tif module.Inlets[2].Connections.Len() > 0 {\n\t\tampInput = module.Inlets[2].Buffer\n\t}\n\n\tfor i := int32(0); i < buflen; i++ {\n\t\tpmod := 0.0\n\n\t\tif pmodInput != nil {\n\t\t\tpmod = pmodInput[i]\n\t\t}\n\n\t\tif fmodInput != nil {\n\t\t\tinc := fmodInput[i] / sr\n\t\t\tmodule.Inc = inc\n\t\t}\n\n\t\tif ampInput != nil {\n\t\t\tamp := ampInput[i]\n\t\t\tmodule.Amplitude = amp\n\t\t}\n\n\t\toutput[i] = module.Process(pmod)\n\t}\n}", "func (o *UpdateVpnConnectionRequest) GetDryRun() bool {\n\tif o == nil || o.DryRun == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.DryRun\n}", "func (o SRVRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v SRVRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (ws *WhanauServer) PerformSystolicMixing(numWalks int) {\n\tfmt.Printf(\"\")\n\tws.doneMixing = false\n\tgo ws.ServerHandler()\n\n\tserver_pool := make([]string, numWalks)\n\tfor i := 0; i < len(server_pool); i++ {\n\t\t// populate with own address\n\t\tserver_pool[i] = ws.myaddr\n\t}\n\n\tif len(ws.neighbors) == 0 {\n\t\tws.rw_mu.Lock()\n\n\t\tws.rw_servers = make([]string, len(server_pool))\n\t\tcopy(ws.rw_servers, server_pool)\n\t\tws.rw_idx = 0\n\n\t\tws.rw_mu.Unlock()\n\t\treturn\n\t}\n\n\t// perform w iterations to get sufficient mixing\n\tfor iter := 0; iter < ws.w; iter++ {\n\t\tnaddresses := int(float64(len(server_pool)) /\n\t\t\tfloat64(len(ws.neighbors)))\n\t\tDPrintf(\"server %v in performsystolic at ts %d\\n\", ws.me, iter)\n\t\tfor idx, srv := range ws.neighbors {\n\t\t\tstart := idx * naddresses\n\t\t\tend := start + naddresses\n\t\t\tif idx == len(ws.neighbors)-1 {\n\t\t\t\tend = len(server_pool)\n\t\t\t}\n\t\t\tDPrintf(\"server %v using bounds %d %d with len %d neighbors %v addresses %d\\n\", ws.me, start, end, len(server_pool), len(ws.neighbors), naddresses)\n\t\t\tsrv_args := &SystolicMixingArgs{server_pool[start:end], iter + 1,\n\t\t\t\tws.myaddr}\n\t\t\tvar srv_reply SystolicMixingReply\n\n\t\t\tok := call(srv, \"WhanauServer.GetRandomServers\",\n\t\t\t\tsrv_args, &srv_reply)\n\t\t\tif !ok || srv_reply.Err != OK {\n\t\t\t\tlog.Fatalf(\"call to server %s failed\\n\", srv)\n\t\t\t\t// TODO handle error :(\n\t\t\t}\n\t\t}\n\n\t\t// when can we move on? need replies from all neighbors\n\t\tval := ws.received_servers[iter+1]\n\n\t\t// val is a list of lists of servers. how long is it?\n\t\t// should be as long as the neighbors set.\n\t\tfor val == nil || len(val) < len(ws.neighbors) {\n\t\t\ttime.Sleep(time.Millisecond * 100)\n\t\t\tval = ws.received_servers[iter+1]\n\t\t}\n\n\t\tif iter+1 == ws.w {\n\t\t\t// we're done\n\t\t\t// TODO not sure if off by one here\n\t\t\tbreak\n\t\t}\n\n\t\t// free up memory!!\n\t\tdelete(ws.received_servers, iter)\n\n\t\t// create server pool by concatenating new vals\n\t\tserver_pool = make([]string, 0)\n\t\tfor _, v := range val {\n\t\t\tserver_pool = append(server_pool, v...)\n\t\t}\n\t\tserver_pool = Shuffle(server_pool)\n\n\t}\n\n\t// done. After w iterations, we should have a sufficiently randomized\n\t// list of servers. Save the servers.\n\tws.rw_mu.Lock()\n\n\tws.rw_servers = make([]string, len(server_pool))\n\tcopy(ws.rw_servers, server_pool)\n\tws.rw_idx = 0\n\n\tws.rw_mu.Unlock()\n}", "func (b Boat) medium() string {\n\treturn \"water\"\n}", "func (mr *MockLogicMockRecorder) DrySend(sender, value, fee, nonce, allowNonceGap, chainHeight interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DrySend\", reflect.TypeOf((*MockLogic)(nil).DrySend), sender, value, fee, nonce, allowNonceGap, chainHeight)\n}", "func (s *Solution) Decide(scale Scale) (int, Weight) {\n\tif s.flags&REVERSED == 0 {\n\t\tpanic(fmt.Errorf(\"This solution must be reversed first.\"))\n\t}\n\tf, w, _ := s.decide(scale)\n\treturn f, w\n}", "func (d *DSP) Type() (DSPType, error) {\n\tvar typ C.FMOD_DSP_TYPE\n\tres := C.FMOD_DSP_GetType(d.cptr, &typ)\n\treturn DSPType(typ), errs[res]\n}", "func (s *Sink) Samplerate() uint {\n\treturn s.samplerate\n}", "func (o *UpdateServerCertificateRequest) GetDryRun() bool {\n\tif o == nil || o.DryRun == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.DryRun\n}", "func GET_MED(wps *WavpackStream, med int, channel int) int {\n\treturn (((wps.w.median[med][channel]) >> 4) + 1)\n}", "func (o *ReadConsumptionAccountRequest) GetDryRun() bool {\n\tif o == nil || o.DryRun == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.DryRun\n}", "func (a Animal) Speak() {\n\tfmt.Println(a.noise)\n}", "func (o WeightedBackendServiceResponseOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v WeightedBackendServiceResponse) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (pj *MatrixPrjn) DWt() {\n\tif !pj.Learn.Learn {\n\t\treturn\n\t}\n\tslay := pj.Send.(leabra.LeabraLayer).AsLeabra()\n\trlay := pj.Recv.(*MatrixLayer)\n\n\tda := rlay.DA\n\tdaLrn := rlay.DALrn // includes d2 reversal etc\n\n\tach := rlay.ACh\n\tachDk := mat32.Min(1, ach*pj.Trace.Decay)\n\n\tfor si := range slay.Neurons {\n\t\tsn := &slay.Neurons[si]\n\t\tnc := int(pj.SConN[si])\n\t\tst := int(pj.SConIdxSt[si])\n\t\tsyns := pj.Syns[st : st+nc]\n\t\ttrsyns := pj.TrSyns[st : st+nc]\n\t\tscons := pj.SConIdx[st : st+nc]\n\n\t\tfor ci := range syns {\n\t\t\tsy := &syns[ci]\n\t\t\ttrsy := &trsyns[ci]\n\t\t\tri := scons[ci]\n\t\t\trn := &rlay.Neurons[ri]\n\n\t\t\ttr := trsy.Tr\n\n\t\t\tntr := rn.ActLrn * sn.ActLrn\n\t\t\tdwt := float32(0)\n\n\t\t\tif pj.Trace.CurTrlDA {\n\t\t\t\ttr += ntr\n\t\t\t}\n\n\t\t\tif da != 0 {\n\t\t\t\tdwt = daLrn * tr\n\t\t\t}\n\t\t\ttr -= achDk * tr // decay trace that drove dwt\n\n\t\t\tif !pj.Trace.CurTrlDA {\n\t\t\t\ttr += ntr\n\t\t\t}\n\t\t\ttrsy.Tr = tr\n\t\t\ttrsy.NTr = ntr\n\n\t\t\tnorm := float32(1)\n\t\t\tif pj.Learn.Norm.On {\n\t\t\t\tnorm = pj.Learn.Norm.NormFmAbsDWt(&sy.Norm, mat32.Abs(dwt))\n\t\t\t} else {\n\t\t\t\tsy.Norm = trsy.NTr // store in norm, moment!\n\t\t\t\tsy.Moment = trsy.Tr\n\t\t\t}\n\t\t\tif pj.Learn.Momentum.On {\n\t\t\t\tdwt = norm * pj.Learn.Momentum.MomentFmDWt(&sy.Moment, dwt)\n\t\t\t} else {\n\t\t\t\tdwt *= norm\n\t\t\t}\n\t\t\tsy.DWt += pj.Learn.Lrate * dwt\n\t\t}\n\t\t// aggregate max DWtNorm over sending synapses\n\t\tif pj.Learn.Norm.On {\n\t\t\tmaxNorm := float32(0)\n\t\t\tfor ci := range syns {\n\t\t\t\tsy := &syns[ci]\n\t\t\t\tif sy.Norm > maxNorm {\n\t\t\t\t\tmaxNorm = sy.Norm\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor ci := range syns {\n\t\t\t\tsy := &syns[ci]\n\t\t\t\tsy.Norm = maxNorm\n\t\t\t}\n\t\t}\n\t}\n}", "func (filter *Saturation) IsScalable() {\n}", "func Silence(data <-chan models.AmJSON) <-chan models.AmJSON {\n\n\tsilencedData := make(chan models.AmJSON)\n\tgo func() {\n\t\tdefer close(silencedData)\n\t\tfor each := range data {\n\t\t\tif utils.ConfigJSON.Server.DryRun == false {\n\t\t\t\terr := silenceAlert(each)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"Could not silence alert, error:%v\\n\", err)\n\t\t\t\t\tif utils.ConfigJSON.Server.Verbose > 1 {\n\t\t\t\t\t\tlog.Printf(\"Silence Data: %s\\n \", each)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tutils.ChangeCounters.NoOfSilencesCreated++\n\t\t\tsilencedData <- each\n\t\t}\n\t}()\n\treturn silencedData\n}", "func (o DrillSpecPodConfigPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v DrillSpecPodConfigPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecution) int {\n\t\treturn v.Weight\n\t}).(pulumi.IntOutput)\n}", "func (_CraftingI *CraftingICallerSession) GetWeaponDc(_item_id *big.Int) (*big.Int, error) {\n\treturn _CraftingI.Contract.GetWeaponDc(&_CraftingI.CallOpts, _item_id)\n}", "func (mr *MockAtomicLogicMockRecorder) DrySend(sender, value, fee, nonce, allowNonceGap, chainHeight interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DrySend\", reflect.TypeOf((*MockAtomicLogic)(nil).DrySend), sender, value, fee, nonce, allowNonceGap, chainHeight)\n}", "func downmixSingleSampleToMono(values ...int16) int16 {\n\tvar sum int = 0\n\tfor _, v := range values {\n\t\tsum += int(v)\n\t}\n\treturn int16(sum / len(values))\n}", "func (o *ReadConsumptionAccountRequest) SetDryRun(v bool) {\n\to.DryRun = &v\n}", "func (toneAnalyzer *ToneAnalyzerV3) Tone(toneOptions *ToneOptions) (result *ToneAnalysis, response *core.DetailedResponse, err error) {\n\treturn toneAnalyzer.ToneWithContext(context.Background(), toneOptions)\n}", "func (_CraftingI *CraftingISession) GetWeaponDc(_item_id *big.Int) (*big.Int, error) {\n\treturn _CraftingI.Contract.GetWeaponDc(&_CraftingI.CallOpts, _item_id)\n}", "func (s Wave) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (o *UpdateServerCertificateRequest) SetDryRun(v bool) {\n\to.DryRun = &v\n}", "func (o QperfSpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecution) int {\n\t\treturn v.Weight\n\t}).(pulumi.IntOutput)\n}", "func (img *Pgm) CorrectTone() {\n\tmax := 0\n\tmin := img.tone\n\n\t// check max/min tone in image\n\tfor i := 0; i < img.height; i++ {\n\t\tfor j := 0; j < img.width; j++ {\n\t\t\tmax = util.Max(int(img.data[i][j]), max)\n\t\t\tmin = util.Min(int(img.data[i][j]), min)\n\t\t}\n\t}\n\n\tfor i := 0; i < img.height; i++ {\n\t\tfor j := 0; j < img.width; j++ {\n\t\t\timg.data[i][j] = byte(\n\t\t\t\tnormalize(\n\t\t\t\t\tint(img.data[i][j]), min, max, img.tone))\n\t\t}\n\t}\n}", "func (o *AudioStreamSample) GetMixRate() gdnative.Int {\n\t//log.Println(\"Calling AudioStreamSample.GetMixRate()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"AudioStreamSample\", \"get_mix_rate\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func getDataWaterQuality(inputData *WaterQualityGraphWaterlevelAnalystInput, q string, wqType string) (*WaterQualityWaterlevelOutput, error) {\n\n\tdb, err := pqx.Open()\n\tif err != nil {\n\t\treturn nil, errors.NewEvent(eventcode.EventNetworkCriticalUnableConDB, err)\n\t}\n\n\tp := []interface{}{inputData.DatetimeStart, inputData.DatetimeEnd}\n\tif wqType != \"\" {\n\t\tp = append(p, inputData.WaterlevelStation)\n\t} else {\n\t\tp = append(p, inputData.WaterQualityStation)\n\t}\n\tfmt.Println(q)\n\trows, err := db.Query(q, p...)\n\tif err != nil {\n\t\treturn nil, pqx.GetRESTError(err)\n\t}\n\tdefer rows.Close()\n\n\tdataRow := &WaterQualityWaterlevelOutput{}\n\tdateOutput := make([]*WaterQualityGraphOutputData, 0)\n\tfor rows.Next() {\n\t\tvar (\n\t\t\tstationName pqx.JSONRaw\n\t\t\tdatetime time.Time\n\t\t\tvalue sql.NullFloat64\n\t\t)\n\t\trows.Scan(&stationName, &datetime, &value)\n\n\t\tdd := &WaterQualityGraphOutputData{}\n\t\tdataRow.SeriesName = stationName.JSON()\n\t\tdd.Name = udt.DatetimeFormat(datetime, \"datetime\")\n\t\tdd.Value = ValidData(value.Valid, value.Float64)\n\t\tdateOutput = append(dateOutput, dd)\n\t}\n\tdataRow.Data = dateOutput\n\treturn dataRow, nil\n}", "func (o *UpdateNetRequest) GetDryRun() bool {\n\tif o == nil || o.DryRun == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.DryRun\n}", "func (o GetServerGroupServerAttachmentsAttachmentOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetServerGroupServerAttachmentsAttachment) int { return v.Weight }).(pulumi.IntOutput)\n}", "func trimWave(buf []int16) {\n\tif len(buf) == 0 {\n\t\treturn\n\t}\n\tbufsize := len(buf)\n\tcut := bufsize - 1\n\tvar last int16\n\tfor i := range buf {\n\t\tif i == 0 {\n\t\t\tlast = buf[cut]\n\t\t}\n\t\tif buf[cut] < last {\n\t\t\t// falling\n\t\t\tif buf[cut] < 0 && buf[cut] < 32 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tlast = buf[cut]\n\t\tif i > 1024 {\n\t\t\t// too long\n\t\t\tcut = len(buf) - 1\n\t\t\tbreak\n\t\t}\n\t\tcut--\n\t\tif cut == 0 {\n\t\t\t// volume must be low\n\t\t\tcut = len(buf) - 1\n\t\t\tbreak\n\t\t}\n\t}\n\tfor i := cut; i < bufsize; i++ {\n\t\tbuf[i] = 0\n\t}\n}", "func DryRun(dryRun bool) meterOption {\n\treturn func(m *ProgressMeter) {\n\t\tm.dryRun = dryRun\n\t}\n}", "func (o *UpdateNetRequest) SetDryRun(v bool) {\n\to.DryRun = &v\n}", "func (o SrvRecordRecordOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v SrvRecordRecord) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (k *kubectlContext) DryRun(filename string) (string, error) {\n\tout, err := k.do(\"apply\", \"--server-dry-run\", \"--output\", \"yaml\", \"--filename\", filename)\n\treturn string(out), err\n}", "func (filter *Saturation) Process(img *FilterImage) error {\n\tout := img.Image\n\tbounds := out.Bounds()\n\tfor x := bounds.Min.X; x < bounds.Max.X; x++ {\n\t\tfor y := bounds.Min.Y; y < bounds.Max.Y; y++ {\n\t\t\tr, g, b, a := out.At(x, y).RGBA()\n\n\t\t\tgrey := (r + g + b) / 3\n\n\t\t\tnr := Trunc(r + ((Abs(int32(r-grey)) * filter.Strength) / 100))\n\t\t\tng := Trunc(g + ((Abs(int32(g-grey)) * filter.Strength) / 100))\n\t\t\tnb := Trunc(b + ((Abs(int32(b-grey)) * filter.Strength) / 100))\n\n\t\t\tnc := color.NRGBA64{nr, ng, nb, uint16(a)}\n\t\t\tout.Set(x, y, nc)\n\t\t}\n\t}\n\treturn nil\n}", "func (c *SetRawCommand) WithDw(val uint32) *SetRawCommand {\n\tc.storeValueCommandBuilder.WithDw(val)\n\treturn c\n}", "func (o EipAddressOutput) Bandwidth() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *EipAddress) pulumi.StringOutput { return v.Bandwidth }).(pulumi.StringOutput)\n}", "func (a *Animal) Speak() {\r\n\tfmt.Println(a.noise)\r\n}", "func (mw *MagickWand) Strip() error {\n\treturn mw.StripImage()\n}", "func eff(freq float64, fx []float64, lband int, filterType FilterType) float64 {\n\tif filterType != Differentiator {\n\t\treturn fx[lband]\n\t}\n\treturn fx[lband] * freq\n}", "func (snd *HwSound) step() (uint16, uint16) {\n\tvar lmix, rmix int64\n\tvar chbuf [4]int64\n\n\t// Master enable\n\tif snd.SndGCnt.Value&(1<<15) == 0 {\n\t\treturn uint16(snd.SndBias.Value), uint16(snd.SndBias.Value)\n\t}\n\n\tscans := []int{\n\t\thw.SCANCODE_0,\n\t\thw.SCANCODE_1,\n\t\thw.SCANCODE_2,\n\t\thw.SCANCODE_3,\n\t\thw.SCANCODE_4,\n\t\thw.SCANCODE_5,\n\t\thw.SCANCODE_6,\n\t\thw.SCANCODE_7,\n\t\thw.SCANCODE_8,\n\t\thw.SCANCODE_9,\n\t}\n\n\tkeys := hw.GetKeyboardState()\n\tmask := 0xFFFF\n\tpressed := 0\n\tfor i := 0; i < len(scans); i++ {\n\t\tif keys[scans[i]] != 0 {\n\t\t\tpressed |= 1 << uint(i)\n\t\t}\n\t}\n\tif pressed != 0 {\n\t\tmask = pressed\n\t}\n\n\tfor i := 0; i < 16; i++ {\n\t\tvar sample int64\n\n\t\tcntrl := snd.Ch[i].SndCnt.Value\n\t\tvoice := &snd.voice[i]\n\n\t\tif !voice.on {\n\t\t\tcontinue\n\t\t}\n\t\tif mask&(1<<uint(i)) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tvoice.tmr += cTimerStepPerSample\n\t\tfor voice.tmr >= 0x10000 {\n\t\t\tif voice.delay >= 0 {\n\t\t\t\tvoice.delay--\n\t\t\t} else {\n\t\t\t\tvoice.pos++\n\t\t\t}\n\t\t\tvoice.tmr = uint32(snd.Ch[i].SndTmr.Value) + (voice.tmr - 0x10000)\n\t\t}\n\t\tif voice.delay >= 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch voice.mode {\n\t\tcase kMode8bit:\n\t\t\tif int(voice.pos) >= len(voice.mem) {\n\t\t\t\tvoice.pos = voice.pos + snd.loopChannel(i) - uint(len(voice.mem))\n\t\t\t\tif voice.pos == kPosNoLoop {\n\t\t\t\t\tsnd.stopChannel(i)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tsample = int64(int8(voice.mem[voice.pos])) << 8\n\t\tcase kMode16bit, kModeAdpcm:\n\t\t\tif int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\tvoice.pos = voice.pos + snd.loopChannel(i) - uint(len(voice.mem)/2)\n\t\t\t\tif voice.pos == kPosNoLoop || int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\t\tsnd.stopChannel(i)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tsample = int64(int16(binary.LittleEndian.Uint16(voice.mem[voice.pos*2:])))\n\t\tcase kModePsgNoise:\n\t\t\tfor int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\tvoice.pos -= uint(len(voice.mem)) / 2\n\t\t\t}\n\t\t\tsample = int64(int16(binary.LittleEndian.Uint16(voice.mem[voice.pos*2:])))\n\t\t}\n\n\t\t// Convert into fixed point to keep some precision\n\t\tsample <<= 8\n\n\t\t// Apply volume divider\n\t\tsample >>= voldiv[(cntrl>>8)&3]\n\n\t\t// Apply channel volume\n\t\tsample = mulvol64(sample, int64(cntrl&127))\n\n\t\tif i < 4 {\n\t\t\t// Save copy of channels used in capture\n\t\t\tchbuf[i] = sample\n\n\t\t\t// Check specific \"Channel 1/3 disable\" bit\n\t\t\tif i == 1 && snd.SndGCnt.Value&(1<<12) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i == 3 && snd.SndGCnt.Value&(1<<13) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Apply panning\n\t\tpan := int64((cntrl >> 16) & 127)\n\t\tlsample := mulvol64(sample, 127-pan)\n\t\trsample := mulvol64(sample, pan)\n\n\t\t// Mix\n\t\tlmix += int64(lsample)\n\t\trmix += int64(rsample)\n\t}\n\n\t// Handle capture\n\tfor i := 0; i < 2; i++ {\n\t\tcap := &snd.capture[i]\n\t\tif cap.on {\n\t\t\tvar sample int64\n\t\t\tif !cap.single {\n\t\t\t\tif i == 0 {\n\t\t\t\t\tsample = lmix\n\t\t\t\t} else {\n\t\t\t\t\tsample = rmix\n\t\t\t\t}\n\t\t\t\tif sample > 0x7FFF00 {\n\t\t\t\t\tsample = 0x7FFF00\n\t\t\t\t}\n\t\t\t\tif sample < -0x800000 {\n\t\t\t\t\tsample = -0x800000\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsample = chbuf[i*2]\n\t\t\t}\n\t\t\tif cap.add {\n\t\t\t\tpanic(\"capture with addition\")\n\t\t\t}\n\n\t\t\tcap.tmr += cTimerStepPerSample\n\t\t\tfor cap.tmr >= 0x10000 {\n\t\t\t\tif cap.bit8 {\n\t\t\t\t\tsnd.Bus.Write8(cap.wpos, uint8(sample>>16))\n\t\t\t\t\tcap.wpos++\n\t\t\t\t} else {\n\t\t\t\t\tsnd.Bus.Write16(cap.wpos, uint16(sample>>8))\n\t\t\t\t\tcap.wpos += 2\n\t\t\t\t}\n\n\t\t\t\tcap.tmr = uint32(cap.reset) + (cap.tmr - 0x10000)\n\t\t\t\tif cap.wpos >= *cap.regdad+*cap.reglen*4 {\n\t\t\t\t\tif cap.loop {\n\t\t\t\t\t\tcap.wpos = *cap.regdad\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcap.on = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch (snd.SndGCnt.Value >> 8) & 3 {\n\tcase 1:\n\t\tlmix = chbuf[1]\n\tcase 2:\n\t\tlmix = chbuf[3]\n\tcase 3:\n\t\tlmix = chbuf[1] + chbuf[3]\n\t}\n\tswitch (snd.SndGCnt.Value >> 10) & 3 {\n\tcase 1:\n\t\trmix = chbuf[1]\n\tcase 2:\n\t\trmix = chbuf[3]\n\tcase 3:\n\t\trmix = chbuf[1] + chbuf[3]\n\t}\n\n\t// Apply master volume\n\tgvol := int64(snd.SndGCnt.Value & 127)\n\tlmix = mulvol64(lmix, gvol)\n\trmix = mulvol64(rmix, gvol)\n\n\t// Adjust volume after mixing\n\tlmix >>= 6\n\trmix >>= 6\n\n\t// Convert from fixed into integer (strip fraction)\n\tlmix >>= 8\n\trmix >>= 8\n\n\t// Bias\n\tlmix += int64(snd.SndBias.Value)\n\trmix += int64(snd.SndBias.Value)\n\n\t// Clamp\n\tif lmix < 0 {\n\t\tlmix = 0\n\t} else if lmix > 0x3FF {\n\t\tlmix = 0x3FF\n\t}\n\tif rmix < 0 {\n\t\trmix = 0\n\t} else if rmix > 0x3FF {\n\t\trmix = 0x3FF\n\t}\n\n\treturn uint16(lmix), uint16(rmix)\n}", "func (o GetRecordResultOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetRecordResult) int { return v.Weight }).(pulumi.IntOutput)\n}", "func (_TrialRulesAbstract *TrialRulesAbstractTransactor) GetWitness(opts *bind.TransactOpts, trialStatus uint8) (*types.Transaction, error) {\n\treturn _TrialRulesAbstract.contract.Transact(opts, \"getWitness\", trialStatus)\n}", "func (g *Game) GetWorth(h Hotel) HotelWorth {\n\treturn GetWorth(h, g.CurrentChainSizes[h])\n}", "func Example_4() {\n\t// open input file.\n\tinputFile, err := os.Open(\"_testdata/sample1.wav\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to open input file: %v\", err)\n\t}\n\tdefer inputFile.Close()\n\n\t// asset sink.\n\tasset := &audio.Asset{}\n\n\t// read wav pipeline.\n\twavFile, err := pipe.New(\n\t\t&pipe.Line{\n\t\t\t// wav pump.\n\t\t\tPump: &wav.Pump{ReadSeeker: inputFile},\n\t\t\t// in-memory asset.\n\t\t\tSinks: pipe.Sinks(asset),\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to bind import pipeline: %v\", err)\n\t}\n\tdefer wavFile.Close()\n\n\terr = pipe.Wait(wavFile.Run(context.Background(), 512))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to execute import pipeline: %v\", err)\n\t}\n\n\t// track pump.\n\ttrack := audio.NewTrack(asset.SampleRate(), asset.NumChannels())\n\n\t// add samples.\n\ttrack.AddClip(198450, asset.Clip(0, 44100))\n\ttrack.AddClip(66150, asset.Clip(44100, 44100))\n\ttrack.AddClip(132300, asset.Clip(0, 44100))\n\n\t// create output file.\n\toutputFile, err := os.Create(\"_testdata/out4.wav\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create output file: %v\", err)\n\t}\n\tdefer outputFile.Close()\n\n\t// pipeline to process clips.\n\tp, err := pipe.New(\n\t\t&pipe.Line{\n\t\t\t// track with clips.\n\t\t\tPump: track,\n\t\t\tSinks: pipe.Sinks(\n\t\t\t\t// wav sink.\n\t\t\t\t&wav.Sink{\n\t\t\t\t\tWriteSeeker: outputFile,\n\t\t\t\t\tBitDepth: signal.BitDepth16,\n\t\t\t\t},\n\t\t\t\t// portaudio sink.\n\t\t\t\t&portaudio.Sink{},\n\t\t\t),\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to bind playback and save pipeline: %v\", err)\n\t}\n\tdefer p.Close()\n\n\t// run the pipeline.\n\terr = pipe.Wait(p.Run(context.Background(), 512))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to execute playback and save pipeline: %v\", err)\n\t}\n}", "func (s Sampling) Sampler() trace.Sampler {\n\tif s == Disabled {\n\t\treturn trace.NeverSample()\n\t}\n\treturn trace.ProbabilitySampler(float64(s))\n}", "func (device *SilentStepperBrick) GetStealthConfiguration() (enableStealth bool, amplitude uint8, gradient uint8, enableAutoscale bool, forceSymmetric bool, freewheelMode FreewheelMode, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetStealthConfiguration), buf.Bytes())\n\tif err != nil {\n\t\treturn enableStealth, amplitude, gradient, enableAutoscale, forceSymmetric, freewheelMode, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 14 {\n\t\t\treturn enableStealth, amplitude, gradient, enableAutoscale, forceSymmetric, freewheelMode, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 14)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn enableStealth, amplitude, gradient, enableAutoscale, forceSymmetric, freewheelMode, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &enableStealth)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &amplitude)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &gradient)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &enableAutoscale)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &forceSymmetric)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &freewheelMode)\n\n\t}\n\n\treturn enableStealth, amplitude, gradient, enableAutoscale, forceSymmetric, freewheelMode, nil\n}", "func (o WeightedBackendServiceOutput) Weight() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v WeightedBackendService) *int { return v.Weight }).(pulumi.IntPtrOutput)\n}", "func (cow Cow) Speak() {\n\tfmt.Println(cow.sound)\n}", "func (o *PostApplyManifestParams) SetDryRun(dryRun *bool) {\n\to.DryRun = dryRun\n}", "func (o *UpdateLoadBalancerRequest) SetDryRun(v bool) {\n\to.DryRun = &v\n}", "func (o AttachmentOutput) Weight() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *Attachment) pulumi.IntPtrOutput { return v.Weight }).(pulumi.IntPtrOutput)\n}", "func (s *Scene) WindDensity() float64 {\n\treturn s.windDensity\n}", "func (s Shark) Power() int {\n\treturn s.BitingPower\n}", "func speechHandler(w http.ResponseWriter, r *http.Request) {\n\tfw := flushWriter{w: w}\n\tif f, ok := w.(http.Flusher); ok {\n\t\tfw.f = f\n\t}\n\n\t// build speech and encoding commands\n\tvalues := r.URL.Query()\n\tspeak, err := buildSpeechCmd(&values, &w)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tencode, err := buildEncodeCmd(&values, &w)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// pipe synthesizer to encoder\n\tencode.Stdin, _ = speak.StdoutPipe()\n\tencode.Stdout = &fw\n\n\tif err := encode.Start(); err != nil {\n\t\thttp.Error(w, \"Failed to start encoder\", 500)\n\t\treturn\n\t}\n\n\tif err := speak.Run(); err != nil {\n\t\thttp.Error(w, \"Failed to run synthesizer\", 500)\n\t\treturn\n\t}\n\n\tif err := encode.Wait(); err != nil {\n\t\thttp.Error(w, \"Failed to finish encoding: \"+err.Error(), 500)\n\t\treturn\n\t}\n}", "func (o ContainerServiceOutput) Power() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ContainerService) pulumi.StringOutput { return v.Power }).(pulumi.StringOutput)\n}", "func (o DrillSpecPodConfigPodSchedulingTolerationsOutput) Effect() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v DrillSpecPodConfigPodSchedulingTolerations) *string { return v.Effect }).(pulumi.StringPtrOutput)\n}", "func (rsi RSI) Warmed() bool {\n\treturn rsi.emaUp.Warmed()\n}", "func (o Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecution) int {\n\t\treturn v.Weight\n\t}).(pulumi.IntOutput)\n}", "func (t *ToneGenerator) Tone(freq, seconds float64, vol int32) []int32 {\n\tvar synthArray = make([]int32, int(seconds*t.sampleRate))\n\tdelta := freq * t.step\n\n\tfor i := 0; i < len(synthArray); i++ {\n\t\tsynthArray[i] = int32(t.wave(float64(i)*delta) * float64(vol))\n\n\t}\n\treturn synthArray\n}", "func Shield(c *gin.Context) {\n\tstandings, err := GetShield()\n\tif err != nil {\n\t\tc.AbortWithError(http.StatusInternalServerError, err)\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"standings\": standings,\n\t})\n}", "func DecisionStump(param *DecisionStumpOptionalParam) (dsModel, *mat.Dense) {\n resetTimers()\n enableTimers()\n disableBacktrace()\n disableVerbose()\n restoreSettings(\"Decision Stump\")\n\n // Detect if the parameter was passed; set if so.\n if param.BucketSize != 6 {\n setParamInt(\"bucket_size\", param.BucketSize)\n setPassed(\"bucket_size\")\n }\n\n // Detect if the parameter was passed; set if so.\n if param.InputModel != nil {\n setDSModel(\"input_model\", param.InputModel)\n setPassed(\"input_model\")\n }\n\n // Detect if the parameter was passed; set if so.\n if param.Labels != nil {\n gonumToArmaUrow(\"labels\", param.Labels)\n setPassed(\"labels\")\n }\n\n // Detect if the parameter was passed; set if so.\n if param.Test != nil {\n gonumToArmaMat(\"test\", param.Test)\n setPassed(\"test\")\n }\n\n // Detect if the parameter was passed; set if so.\n if param.Training != nil {\n gonumToArmaMat(\"training\", param.Training)\n setPassed(\"training\")\n }\n\n // Detect if the parameter was passed; set if so.\n if param.Verbose != false {\n setParamBool(\"verbose\", param.Verbose)\n setPassed(\"verbose\")\n enableVerbose()\n }\n\n // Mark all output options as passed.\n setPassed(\"output_model\")\n setPassed(\"predictions\")\n\n // Call the mlpack program.\n C.mlpackDecisionStump()\n\n // Initialize result variable and get output.\n var outputModel dsModel\n outputModel.getDSModel(\"output_model\")\n var predictionsPtr mlpackArma\n predictions := predictionsPtr.armaToGonumUrow(\"predictions\")\n\n // Clear settings.\n clearSettings()\n\n // Return output(s).\n return outputModel, predictions\n}", "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func (w *Wav) GetData() (interface{}, error) {\n\tbytePerSample := int(w.BitsPerSample / 8)\n\tsampleParser, err := GetSampleParser(w.BitsPerSample, w.WaveFormat)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif w.NumChannels == 1 {\n\t\tsample := parseMonoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\tif w.NumChannels == 2 {\n\t\tsample := parseStereoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\treturn nil, errors.New(\"failed to sampled data from wav file\")\n}", "func (o DiskReplicaPairOutput) Bandwidth() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *DiskReplicaPair) pulumi.StringOutput { return v.Bandwidth }).(pulumi.StringOutput)\n}", "func (w *Width) Blend(delta float64) {\n\tif !w.ended {\n\t\tw.current += delta\n\t}\n}", "func send_word_lossless(wps *WavpackStream, value int, channel int) {\n\tvar sign int\n\tif value < 0 {\n\t\tsign = 1\n\t} else {\n\t\tsign = 0\n\t}\n\n\tvar ones_count uint\n\tvar low uint\n\tvar high uint\n\n\tif ((wps.w.median[0][0] & ^1) == 0) && (wps.w.holding_zero == 0) &&\n\t\t((wps.w.median[0][1] & ^1) == 0) {\n\t\tif wps.w.zeros_acc != 0 {\n\t\t\tif value != 0 {\n\t\t\t\tflush_word(wps)\n\t\t\t} else {\n\t\t\t\twps.w.zeros_acc++\n\n\t\t\t\treturn\n\t\t\t}\n\t\t} else if value != 0 {\n\t\t\tputbit_0(wps)\n\t\t} else {\n\t\t\twps.w.median[0][0] = 0\n\t\t\twps.w.median[1][0] = 0\n\t\t\twps.w.median[2][0] = 0\n\t\t\twps.w.median[0][1] = 0\n\t\t\twps.w.median[1][1] = 0\n\t\t\twps.w.median[2][1] = 0\n\t\t\twps.w.zeros_acc = 1\n\n\t\t\treturn\n\t\t}\n\t}\n\n\tif sign != 0 {\n\t\tvalue = ^value\n\t}\n\n\tif value < GET_MED(wps, 0, channel) {\n\t\tlow = 0\n\t\tones_count = 0\n\t\thigh = uint(GET_MED(wps, 0, channel) - 1)\n\t\tDEC_MED0(wps, channel)\n\t} else {\n\t\tlow = uint(GET_MED(wps, 0, channel))\n\t\tINC_MED0(wps, channel)\n\n\t\tif (value - int(low)) < GET_MED(wps, 1, channel) {\n\t\t\tones_count = 1\n\t\t\thigh = uint((int(low) + GET_MED(wps, 1, channel)) - 1)\n\t\t\tDEC_MED1(wps, channel)\n\t\t} else {\n\t\t\tlow += uint(GET_MED(wps, 1, channel))\n\t\t\tINC_MED1(wps, channel)\n\n\t\t\tif (value - int(low)) < GET_MED(wps, 2, channel) {\n\t\t\t\tones_count = 2\n\t\t\t\thigh = uint((int(low) + GET_MED(wps, 2, channel)) - 1)\n\t\t\t\tDEC_MED2(wps, channel)\n\t\t\t} else {\n\t\t\t\tones_count = uint(2 + ((value - int(low)) / GET_MED(wps, 2, channel)))\n\t\t\t\tlow += uint(int(ones_count-2) * GET_MED(wps, 2, channel))\n\t\t\t\thigh = uint((int(low) + GET_MED(wps, 2, channel)) - 1)\n\t\t\t\tINC_MED2(wps, channel)\n\t\t\t}\n\t\t}\n\t}\n\n\tif wps.w.holding_zero != 0 {\n\t\tif ones_count != 0 {\n\t\t\twps.w.holding_one++\n\t\t}\n\n\t\tflush_word(wps)\n\n\t\tif ones_count != 0 {\n\t\t\twps.w.holding_zero = 1\n\t\t\tones_count--\n\t\t} else {\n\t\t\twps.w.holding_zero = 0\n\t\t}\n\t} else {\n\t\twps.w.holding_zero = 1\n\t}\n\n\twps.w.holding_one = ones_count * 2\n\n\tif high != low {\n\t\tvar maxcode uint = high - low\n\t\tvar code uint = uint(value - int(low))\n\t\tvar bitcount int = count_bits(maxcode)\n\t\tvar extras uint = bitset[bitcount] - maxcode - 1\n\n\t\tif code < extras {\n\t\t\twps.w.pend_data |= (code << wps.w.pend_count)\n\t\t\twps.w.pend_count += uint(bitcount - 1)\n\t\t} else {\n\t\t\twps.w.pend_data |= (((code + extras) >> 1) << wps.w.pend_count)\n\t\t\twps.w.pend_count += uint(bitcount - 1)\n\t\t\twps.w.pend_data |= (((code + extras) & 1) << wps.w.pend_count)\n\t\t\twps.w.pend_count++\n\t\t}\n\t}\n\n\twps.w.pend_data |= uint(sign << wps.w.pend_count)\n\twps.w.pend_count++\n\n\tif wps.w.holding_zero == 0 {\n\t\tflush_word(wps)\n\t}\n}", "func (o DrillSpecPodConfigPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v DrillSpecPodConfigPodSchedulingAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecution) int {\n\t\treturn v.Weight\n\t}).(pulumi.IntOutput)\n}", "func (p *Pump) WavAudioFormat() int {\n\treturn p.wavAudioFormat\n}", "func (o QperfSpecClientConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionOutput) Weight() pulumi.IntOutput {\n\treturn o.ApplyT(func(v QperfSpecClientConfigurationPodSchedulingAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecution) int {\n\t\treturn v.Weight\n\t}).(pulumi.IntOutput)\n}", "func (o AnycastEipAddressOutput) Bandwidth() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *AnycastEipAddress) pulumi.IntOutput { return v.Bandwidth }).(pulumi.IntOutput)\n}", "func genWavs(dir string) error {\n\twaveData := []struct {\n\t\tfName string\n\t\twave gotes.WaveFn\n\t\tdur time.Duration\n\t}{\n\t\t{\n\t\t\tfName: \"sin-a3.wav\",\n\t\t\twave: gotes.SinWave(gotes.NoteA3),\n\t\t},\n\t\t{\n\t\t\tfName: \"square-a3.wav\",\n\t\t\twave: gotes.AmplifyWave(\n\t\t\t\tgotes.FixedAmplify(0.3),\n\t\t\t\tgotes.SquareWave(gotes.NoteA3),\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tfName: \"tri-a3.wav\",\n\t\t\twave: gotes.TriangleWave(gotes.NoteA3),\n\t\t},\n\t\t{\n\t\t\tfName: \"saw-a3.wav\",\n\t\t\twave: gotes.AmplifyWave(\n\t\t\t\tgotes.FixedAmplify(0.4),\n\t\t\t\tgotes.SawWave(gotes.NoteA3),\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tfName: \"good-osc-1.wav\",\n\t\t\twave: gotes.AmplifyWave(\n\t\t\t\tgotes.Gain(0.5),\n\t\t\t\tgotes.IntegrateWave(\n\t\t\t\t\tgotes.OscillateTime(2.0, 0.2),\n\t\t\t\t\tgotes.SinWave(gotes.NoteA3),\n\t\t\t\t),\n\t\t\t),\n\t\t\tdur: 10 * time.Second,\n\t\t},\n\t\t{\n\t\t\tfName: \"bad-osc-1.wav\",\n\t\t\twave: gotes.AmplifyWave(\n\t\t\t\tgotes.Gain(0.5),\n\t\t\t\tgotes.IntegrateWave(\n\t\t\t\t\tgotes.BadOscillateTime(2.0, 0.2),\n\t\t\t\t\tgotes.SinWave(gotes.NoteA3),\n\t\t\t\t),\n\t\t\t),\n\t\t\tdur: 10 * time.Second,\n\t\t},\n\t\t{\n\t\t\tfName: \"bad-osc-2.wav\",\n\t\t\twave: gotes.AmplifyWave(\n\t\t\t\tgotes.Gain(0.5),\n\t\t\t\tgotes.IntegrateWave(\n\t\t\t\t\tgotes.BadOscillateTime2(1.0, 0.2),\n\t\t\t\t\tgotes.SinWave(gotes.NoteA3),\n\t\t\t\t),\n\t\t\t),\n\t\t\tdur: 10 * time.Second,\n\t\t},\n\t}\n\n\tfor _, w := range waveData {\n\t\tdur := w.dur\n\t\tif dur == 0 {\n\t\t\tdur = defaultDur\n\t\t}\n\t\tstreamer := gotes.StreamerFromWave(w.wave, sampleRate)\n\t\tbuf := gotes.WriteWav(\n\t\t\tgotes.SampleStreamer(streamer, sampleRate, dur),\n\t\t\tgotes.WavConfig{\n\t\t\t\tSampleRate: sampleRate,\n\t\t\t\tChannels: channels,\n\t\t\t\tBitDepth: bitDepth,\n\t\t\t},\n\t\t)\n\t\tif err := writeBuf(buf, dir, w.fName); err != nil {\n\t\t\treturn fmt.Errorf(\"Error writing '%s': %w\", w.fName, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (dw *DrawingWand) GetFontStretch() StretchType {\n\treturn StretchType(C.MagickDrawGetFontStretch(dw.dw))\n}", "func (i *Item) weigh(cmd *command.Command) (handled bool) {\n\tcmd.Respond(\"You estimate %s to weigh about %s.\", i.Name(), i.weight)\n\tcmd.Broadcast([]thing.Interface{cmd.Issuer}, \"You see %s estimate the weight of %s.\", cmd.Issuer.Name(), i.Name())\n\treturn true\n}" ]
[ "0.6021038", "0.50523424", "0.44711807", "0.42859626", "0.42424402", "0.42091733", "0.4189023", "0.41564986", "0.41545135", "0.41147637", "0.4106844", "0.4106844", "0.40757304", "0.4045652", "0.40456426", "0.4031883", "0.4024371", "0.4006875", "0.40053827", "0.39639735", "0.39481232", "0.39051655", "0.3897723", "0.3897685", "0.38953748", "0.3890035", "0.3887897", "0.38872287", "0.38861865", "0.38757396", "0.38499808", "0.38298398", "0.38274556", "0.3818977", "0.38129076", "0.3806055", "0.3804865", "0.38029477", "0.38027182", "0.37975955", "0.3795499", "0.37895465", "0.37807938", "0.37702048", "0.37684187", "0.37672785", "0.3760484", "0.37575808", "0.37301666", "0.37294203", "0.37282813", "0.372405", "0.37233132", "0.3713952", "0.37097064", "0.37065217", "0.37065017", "0.37017295", "0.36999378", "0.36882633", "0.36863992", "0.36809427", "0.36792502", "0.3677899", "0.36607578", "0.3658687", "0.36575928", "0.36568844", "0.3655049", "0.3654404", "0.36536413", "0.3647502", "0.36405107", "0.36305854", "0.36284786", "0.36220136", "0.3621519", "0.3618405", "0.36102667", "0.35968444", "0.35929435", "0.35905328", "0.35892096", "0.358907", "0.35860687", "0.35838327", "0.35776702", "0.35772514", "0.35746107", "0.3573032", "0.35693607", "0.3566515", "0.35629866", "0.35619044", "0.3557873", "0.3557729", "0.35574162", "0.35561684", "0.3550711", "0.3548962" ]
0.7108342
0
Sets the signal format of a dsp unit so that the signal is processed on the speakers specified. Also defines the number of channels in the unit that a read callback will process, and the output signal of the unit. channelmask: A series of bits specified by "ChannelMask" to determine which speakers are represented by the channels in the signal. numchannels: The number of channels to be processed on this unit and sent to the outputs connected to it. Maximum of FMOD_MAX_CHANNEL_WIDTH. source_speakermode: The source speaker mode where the signal came from. Setting the number of channels on a unit will force a down or up mix to that channel count before processing the DSP read callback. This channelcount is then sent to the outputs of the unit. source_speakermode is informational, when channelmask describes what bits are active, and numchannels describes how many channels are in a buffer, source_speakermode describes where the channels originated from. For example if numchannels = 2 then this could describe for the DSP if the original signal started from a stereo signal or a 5.1 signal. It could also describe the signal as all monaural, for example if numchannels was 16 and the speakermode was FMOD_SPEAKERMODE_MONO.
func (d *DSP) SetChannelFormat(channelmask ChannelMask, numchannels int, source_speakermode SpeakerMode) error { res := C.FMOD_DSP_SetChannelFormat(d.cptr, C.FMOD_CHANNELMASK(channelmask), C.int(numchannels), C.FMOD_SPEAKERMODE(source_speakermode)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ChannelFormat() (ChannelMask, int, SpeakerMode, error) {\n\tvar channelmask C.FMOD_CHANNELMASK\n\tvar numchannels C.int\n\tvar source_speakermode C.FMOD_SPEAKERMODE\n\tres := C.FMOD_DSP_GetChannelFormat(d.cptr, &channelmask, &numchannels, &source_speakermode)\n\treturn ChannelMask(channelmask), int(numchannels), SpeakerMode(source_speakermode), errs[res]\n}", "func (d *DSP) OutputChannelFormat(inmask ChannelMask, inchannels int, inspeakermode SpeakerMode) (ChannelMask, int, SpeakerMode, error) {\n\tvar outmask C.FMOD_CHANNELMASK\n\tvar outchannels C.int\n\tvar outspeakermode C.FMOD_SPEAKERMODE\n\tres := C.FMOD_DSP_GetOutputChannelFormat(d.cptr, C.FMOD_CHANNELMASK(inmask), C.int(inchannels), C.FMOD_SPEAKERMODE(inspeakermode), &outmask, &outchannels, &outspeakermode)\n\treturn ChannelMask(outmask), int(outchannels), SpeakerMode(outspeakermode), errs[res]\n}", "func (e *Engine) SetInputChannels(numberOfChannels int) error {\n\tif !e.initialized {\n\t\treturn errorEngineNotInitialized\n\t}\n\t// return error if the input device does not exist\n\tif e.streamParameters.Input.Device == nil {\n\t\treturn errorDeviceDoesNotExist\n\t}\n\t// error if numberOfChannels is not mono or stereo\n\t// or if we are assigning stereo to a mono only device\n\tunsupportedNumberOfChannels := (numberOfChannels < 1) || (numberOfChannels > 2) ||\n\t\t(numberOfChannels == 2 && e.streamParameters.Input.Device.MaxInputChannels == 1)\n\tif unsupportedNumberOfChannels {\n\t\treturn errorUnsupportedNumberOfChannels\n\t}\n\t// successfully assign (a correct) number of channels\n\te.streamParameters.Input.Channels = numberOfChannels\n\treturn nil\n}", "func (e *encoder) writeFmtChunk() error {\n\t// Chunk header\n\theader := fmtChunkHeader\n\tcopy(e.fmt.Header[:], header)\n\n\t// Size of this chunk\n\tsize := uint64(fmtChunkSize)\n\tbinary.LittleEndian.PutUint64(e.fmt.Size[:], size)\n\n\t// Format version\n\tformatVersion := uint32(fmtVersion)\n\tbinary.LittleEndian.PutUint32(e.fmt.Version[:], formatVersion)\n\n\t// Format id\n\tformatId := uint32(fmtIdentifier)\n\tbinary.LittleEndian.PutUint32(e.fmt.Identifier[:], formatId)\n\n\t// Channel type\n\tvar channelType uint32\n\tfor key, order := range fmtChannelOrder {\n\t\tif reflect.DeepEqual(e.audio.ChannelOrder, order) {\n\t\t\tchannelType = key\n\t\t}\n\t}\n\tif channelType == 0 {\n\t\tvar s string\n\t\tfor i, channel := range e.audio.ChannelOrder {\n\t\t\tif i < len(e.audio.ChannelOrder)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"fmt: unsupported channel ordering: %v\", s)\n\t}\n\tchannelTypeString, _ := fmtChannelType[channelType]\n\tbinary.LittleEndian.PutUint32(e.fmt.ChannelType[:], channelType)\n\n\t// Channel num\n\tchannelNum := uint32(e.audio.NumChannels)\n\tif channelNum > 1 && (channelNum != uint32(len(e.audio.ChannelOrder))) {\n\t\treturn fmt.Errorf(\"fmt: mismatch between num channels and channel order: %v, %v\", channelNum, e.audio.ChannelOrder)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.ChannelNum[:], channelNum)\n\n\t// SamplingFrequency\n\tsamplingFrequency := uint32(e.audio.SamplingFrequency)\n\tsamplingFrequencyString, ok := fmtSamplingFrequency[samplingFrequency]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: unsupported sampling frequency: %v\", samplingFrequency)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.SamplingFrequency[:], samplingFrequency)\n\n\t// Bits per sample\n\tbitsPerSample := uint32(e.audio.BitsPerSample)\n\t_, ok = fmtBitsPerSample[bitsPerSample]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: unsupported bits per sample: %v\", bitsPerSample)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.BitsPerSample[:], bitsPerSample)\n\n\t// SampleCount\n\n\t// Log the fields of the chunk (only active if a log output has been set)\n\te.logger.Print(\"\\nFmt Chunk\\n=========\\n\")\n\te.logger.Printf(\"Chunk header: %q\\n\", header)\n\te.logger.Printf(\"Size of this chunk: %v\\n\", size)\n\te.logger.Printf(\"Format version: %v\\n\", formatVersion)\n\te.logger.Printf(\"Format id: %v\\n\", formatId)\n\te.logger.Printf(\"Channel type: %v (%s)\\n\", channelType, channelTypeString)\n\te.logger.Printf(\"Channel num: %v\\n\", channelNum)\n\tif len(e.audio.ChannelOrder) > 1 {\n\t\tvar s string\n\t\tfor i, channel := range e.audio.ChannelOrder {\n\t\t\tif i < len(e.audio.ChannelOrder)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\te.logger.Printf(\"Channel order: %v\\n\", s)\n\t}\n\te.logger.Printf(\"Sampling frequency: %vHz (%s)\\n\", samplingFrequency, samplingFrequencyString)\n\te.logger.Printf(\"Bits per sample: %v\\n\", bitsPerSample)\n\n\t// Write the entire chunk in one go\n\terr := binary.Write(e.writer, binary.LittleEndian, &e.fmt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func RecordChannels(m proto.ChannelMap) RecordOption {\n\tif len(m) == 0 {\n\t\tpanic(\"pulse: invalid channel map\")\n\t}\n\treturn func(r *RecordStream) {\n\t\tr.createRequest.ChannelMap = m\n\t\tr.createRequest.Channels = byte(len(m))\n\t}\n}", "func (j *JustAddPowerReciever) SetAudioVideoInput(ctx context.Context, output, input string) error {\n\tj.Log.Debug(\"Setting receiver to transmitter\")\n\n\tgo j.checkTransmitterChannel(input)\n\n\tj.Log.Debug(\"Routing from, to\", zap.String(\"from\", j.Address), zap.String(\"to\", input))\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", input)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", input, err)\n\t}\n\n\tchannel := fmt.Sprintf(\"%v\", ipAddress.IP[3])\n\n\tj.Log.Debug(\"channel\", zap.String(\"channel\", channel))\n\n\tresult, errrr := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/command/channel\", j.Address), channel, \"POST\")\n\n\tif errrr != nil {\n\t\treturn fmt.Errorf(\"Error when making request: %w\", errrr)\n\t}\n\n\tvar jsonResult JustAddPowerChannelResult\n\terr = json.Unmarshal(result, &jsonResult)\n\n\tj.Log.Debug(\"Result\", zap.Any(\"jsonResult\", jsonResult))\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when unpacking json\")\n\t}\n\treturn nil\n}", "func Write(fname string, format Format, rate uint32, slice interface{}) error {\n\tvar wf *File\n\tbuf := new(bytes.Buffer)\n\tswitch x := slice.(type) {\n\tcase []float64:\n\t\tif format == Float {\n\t\t\terr := binary.Write(buf, binary.LittleEndian, x)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\twf = NewFile(format, 1, rate, 64, len(x))\n\t\t} else if format == PCM {\n\t\t\tfor _, xn := range x {\n\t\t\t\txn16 := float64toInt16(xn)\n\t\t\t\terr := binary.Write(buf, binary.LittleEndian, xn16)\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\twf = NewFile(format, 1, rate, 16, len(x))\n\t\t}\n\tcase []float32:\n\t\tif format == Float {\n\t\t\terr := binary.Write(buf, binary.LittleEndian, x)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\twf = NewFile(format, 1, rate, 32, len(x))\n\t\t} else if format == PCM {\n\t\t\tfor _, xn := range x {\n\t\t\t\txn16 := float64toInt16(float64(xn))\n\t\t\t\terr := binary.Write(buf, binary.LittleEndian, xn16)\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\twf = NewFile(format, 1, rate, 16, len(x))\n\t\t}\n\tcase []int16:\n\t\tif format == PCM {\n\t\t\terr := binary.Write(buf, binary.LittleEndian, x)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\twf = NewFile(format, 1, rate, 16, len(x))\n\t\t}\n\t}\n\tif wf == nil {\n\t\treturn fmt.Errorf(\"Write %s: conversion from %T to %s not supported\",\n\t\t\tfname, slice, format)\n\t}\n\tcopy(wf.Data, buf.Bytes())\n\treturn wf.Write(fname)\n}", "func (d *Detector) SetSampleRate(x int) error {\n\terrno := C.fvad_set_sample_rate(d.fvad, C.int(x))\n\tif errno != 0 {\n\t\treturn fmt.Errorf(\"invalid sample rate: %v\", x)\n\t}\n\treturn nil\n}", "func NewFormat(chans int, freq freq.T, sc sample.Codec) *Format {\n\treturn &Format{\n\t\tchannels: chans,\n\t\tfreq: freq,\n\t\tCodec: sc}\n}", "func (d *Decoder) SetRawDataSize(frames int32) {\n\td.maxRawdataSize = frames\n\td.rawdataBuf = [][]int16{\n\t\tmake([]int16, frames),\n\t}\n\tpocketsphinx.SetRawdataSize(d.dec, frames*2)\n}", "func (f *Format) Channels() int {\n\treturn f.channels\n}", "func (d *Dev) SetPwmFreq(freqHz float32) error {\n\tprescaleval := float32(25 * physic.MegaHertz)\n\tprescaleval /= 4096.0 //# 12-bit\n\tprescaleval /= (freqHz * float32(physic.Hertz))\n\tprescaleval -= 1.0\n\n\tprescale := int(math.Floor(float64(prescaleval + 0.5)))\n\n\tvar oldmode byte\n\terr := d.dev.Tx([]byte{Mode1}, []byte{oldmode})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tnewmode := (byte)((oldmode & 0x7F) | 0x10) // sleep\n\td.dev.Write([]byte{Mode1, newmode}) // go to sleep\n\td.dev.Write([]byte{Prescale, byte(prescale)})\n\td.dev.Write([]byte{Mode1, oldmode})\n\n\ttime.Sleep(100 * time.Millisecond)\n\n\td.dev.Write([]byte{Mode1, (byte)(oldmode | 0x80)})\n\treturn nil\n}", "func (e *Engine) SetDevices(inputDeviceInfo, outputDeviceInfo *portaudio.DeviceInfo) error {\n\tif !e.initialized {\n\t\treturn errorEngineNotInitialized\n\t}\n\t// create a new (low latency) stream parameter configuration.\n\t// Hopefully you (at least) passed in an output device, otherwise\n\t// Start() will blow up later)\n\tstreamParameters := portaudio.LowLatencyParameters(inputDeviceInfo, outputDeviceInfo)\n\t// copy the relevant old stream parameter values into the new stream\n\t// parameter values\n\tstreamParameters.SampleRate = e.streamParameters.SampleRate\n\tstreamParameters.FramesPerBuffer = e.streamParameters.FramesPerBuffer\n\t// force stereo output. NB, the output device *must* support stereo\n\t// (otherwise this entire library will not work) if it doesn't support\n\t// stereo, well, you'll find out when Start() is called won't you\n\tstreamParameters.Output.Channels = 2\n\t// if we acquired an input device\n\tif streamParameters.Input.Device != nil {\n\t\t// prefer stereo input (if it has >2 possible channels)\n\t\tif streamParameters.Input.Device.MaxInputChannels >= 2 {\n\t\t\tstreamParameters.Input.Channels = 2\n\t\t}\n\t\t// else there's only mono input, and it's set already (I think)\n\t}\n\t// update the stream parameters\n\te.streamParameters = streamParameters\n\treturn nil\n}", "func (e *Engine) SetSampleRate(sr float64) error {\n\tif !e.initialized {\n\t\treturn errorEngineNotInitialized\n\t}\n\t// update the stream parameters\n\te.streamParameters.SampleRate = sr\n\treturn nil\n}", "func set_channel(c spi.Conn, channel uint8) {\n\tif (channel > 125) {\n\t\tchannel = 125\n\t}\n\twrite_register(c, RfCh, channel)\n}", "func ParseFormat(r io.Reader, N int) (*Format, error) {\n\tif N < fmtStartChunkSize {\n\t\treturn nil, fmt.Errorf(\"format chunk too small: %d\", N)\n\t}\n\tbuf := make([]byte, N)\n\tn, e := r.Read(buf)\n\tif e != nil && e != io.EOF {\n\t\treturn nil, e\n\t}\n\tif n != N {\n\t\treturn nil, fmt.Errorf(\"only read %d/%d bytes of format\", n, N)\n\t}\n\ttag := binary.LittleEndian.Uint16(buf[:2])\n\tif tag != _TAG_PCM && tag != _TAG_FLOAT32 {\n\t\treturn nil, fmt.Errorf(\"tag isn't for PCM wav data: %d\", tag)\n\t}\n\tchannels := int(binary.LittleEndian.Uint16(buf[2:4]))\n\tfrq := int(binary.LittleEndian.Uint32(buf[4:8]))\n\tbps := binary.LittleEndian.Uint32(buf[8:12])\n\tblock := int(binary.LittleEndian.Uint16(buf[12:14]))\n\tbitDepth := binary.LittleEndian.Uint16(buf[14:16])\n\tif bps != uint32(frq)*uint32(block) {\n\t\treturn nil, fmt.Errorf(\"bytes per sec is %d not %d\", bps, frq*block)\n\t}\n\tif block*8 != int(bitDepth)*channels {\n\t\treturn nil, fmt.Errorf(\"block align %d != %d\", block, int(bitDepth)*channels/8)\n\t}\n\taFreq := freq.T(frq) * freq.Hertz\n\tif tag == _TAG_FLOAT32 {\n\t\tif N != fmtStartChunkSize+2 {\n\t\t\t//return nil, fmt.Errorf(\"warning, wav format chunk too short but has full Float32 spec\\n\")\n\t\t}\n\t\treturn &Format{channels: channels, freq: aFreq, Codec: sample.SFloat32L}, nil\n\t}\n\tif tag != _TAG_PCM {\n\t\treturn nil, fmt.Errorf(\"unsupported format tag: %d\", tag)\n\t}\n\tif N != fmtStartChunkSize {\n\t\treturn nil, fmt.Errorf(\"bad format chunk size: %d\", N)\n\t}\n\tvar f *Format\n\tswitch bitDepth {\n\tcase 8:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SByte}\n\tcase 16:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt16L}\n\tcase 24:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt24L}\n\tcase 32:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt32L}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported bit depth: %d\", bitDepth)\n\t}\n\treturn f, nil\n}", "func (f *Format) Write(w io.Writer) error {\n\tbuf := make([]byte, fmtStartChunkSize+8, f.chunkSize())\n\tbuf[0] = 'f'\n\tbuf[1] = 'm'\n\tbuf[2] = 't'\n\tbuf[3] = ' '\n\tfreq := uint32(f.freq / freq.Hertz)\n\ttag := _TAG_PCM\n\tif f.Codec.IsFloat() {\n\t\tbuf = buf[:f.chunkSize()]\n\t\ttag = _TAG_FLOAT32\n\t}\n\tbinary.LittleEndian.PutUint32(buf[4:8], uint32(f.chunkSize()-8))\n\tbinary.LittleEndian.PutUint16(buf[8:10], uint16(tag))\n\tbinary.LittleEndian.PutUint16(buf[10:12], uint16(f.channels))\n\tbinary.LittleEndian.PutUint32(buf[12:16], freq)\n\tbpspc := f.Bytes()\n\tbinary.LittleEndian.PutUint32(buf[16:20], freq*uint32(f.channels)*uint32(bpspc))\n\tbinary.LittleEndian.PutUint16(buf[20:22], uint16(f.channels)*uint16(bpspc))\n\tbinary.LittleEndian.PutUint16(buf[22:24], uint16(f.Bits()))\n\tif tag == _TAG_FLOAT32 {\n\t\tbinary.LittleEndian.PutUint16(buf[24:26], uint16(0))\n\t}\n\tn, e := w.Write(buf)\n\tif e != nil {\n\t\treturn e\n\t}\n\tif n != len(buf) {\n\t\treturn fmt.Errorf(\"couldn't write all of hdr %d/%d bytes\", n, len(buf))\n\t}\n\treturn nil\n}", "func (this *channelMeterStruct) process(buffer []float64, sampleRate uint32) {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\n\t/*\n\t * Only perform processing if this channel is enabled.\n\t */\n\tif enabled {\n\t\tthis.mutex.RLock()\n\t\tcurrentValue := this.currentValue\n\t\tpeakValue := this.peakValue\n\t\tsampleCounter := this.sampleCounter\n\t\tthis.mutex.RUnlock()\n\t\tsampleRateFloat := float64(sampleRate)\n\t\tholdTimeSamples := uint64(PEAK_HOLD_TIME_SECONDS * sampleRateFloat)\n\t\tdecayExp := -1.0 / (TIME_CONSTANT * sampleRateFloat)\n\t\tdecayFactor := math.Pow(10.0, decayExp)\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor _, sample := range buffer {\n\t\t\tcurrentValue *= decayFactor\n\n\t\t\t/*\n\t\t\t * If we're above the hold time, let the peak indicator decay,\n\t\t\t * otherwise increment sample counter.\n\t\t\t */\n\t\t\tif sampleCounter > holdTimeSamples {\n\t\t\t\tpeakValue *= decayFactor\n\t\t\t} else {\n\t\t\t\tsampleCounter++\n\t\t\t}\n\n\t\t\tsampleAbs := math.Abs(sample)\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger amplitude, update current value.\n\t\t\t */\n\t\t\tif sampleAbs > currentValue {\n\t\t\t\tcurrentValue = sampleAbs\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger or equal amplitude, update peak value.\n\t\t\t */\n\t\t\tif sampleAbs >= peakValue {\n\t\t\t\tpeakValue = sampleAbs\n\t\t\t\tsampleCounter = 0\n\t\t\t}\n\n\t\t}\n\n\t\tthis.mutex.Lock()\n\t\tthis.currentValue = currentValue\n\t\tthis.peakValue = peakValue\n\t\tthis.sampleCounter = sampleCounter\n\t\tthis.mutex.Unlock()\n\t}\n\n}", "func (p *RelPublisher) registerChannels() {\n\tdcdChan := make(chan DcdRnd, 64)\n\tp.dcdChan = dcdChan\n\tp.dmx.RegisterChannel(dcdChan)\n}", "func (obj *Device) SetStreamSourceFreq(\n\tstreamNumber uint,\n\tfrequencyParameter uint,\n) Error {\n\tret, _, _ := syscall.Syscall(\n\t\tobj.vtbl.SetStreamSourceFreq,\n\t\t3,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(streamNumber),\n\t\tuintptr(frequencyParameter),\n\t)\n\treturn toErr(ret)\n}", "func (a *Client) SetCallMuted(params *SetCallMutedParams, authInfo runtime.ClientAuthInfoWriter) (*SetCallMutedNoContent, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewSetCallMutedParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"setCallMuted\",\n\t\tMethod: \"PUT\",\n\t\tPathPattern: \"/calls/{callId}/muted\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &SetCallMutedReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\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.(*SetCallMutedNoContent)\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 setCallMuted: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func (bc *BC) SetFormat(enc common.EncodingFormat) {\n\tswitch enc {\n\tcase common.QR200x200H:\n\t\tbc.enc = common.QR200x200H\n\t\tbc.w, bc.h = 200, 200\n\t\tbc.qr.level = qr.H\n\t\tbc.qr.mode = qr.Auto\n\n\tcase common.QR300x300H:\n\t\tbc.enc = common.QR300x300H\n\t\tbc.w, bc.h = 300, 300\n\t\tbc.qr.level = qr.H\n\t\tbc.qr.mode = qr.Auto\n\n\tcase common.DM200x200:\n\t\tbc.enc = common.DM200x200\n\t\tbc.w, bc.h = 200, 200\n\n\tcase common.DM300x300:\n\t\tbc.enc = common.DM300x300\n\t\tbc.w, bc.h = 300, 300\n\n\tdefault:\n\t\tpanic(\"Format is not recogized ?\")\n\t}\n}", "func Configure(s AudioSpec) {\n\tmasterSpec = &s\n\tmasterFreq = float64(s.Freq)\n\tmasterTzDur = time.Second / time.Duration(masterFreq)\n\tmasterCycleDurTz = Tz(masterFreq)\n\tSourceConfigure(s)\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (s *SourceControl) ConfigurePulseLengths(sizes SizeObject, reply *bool) error {\n\t*reply = false // handle the case that sizes fails the validation tests and we return early\n\tlog.Printf(\"ConfigurePulseLengths: %d samples (%d pre)\\n\", sizes.Nsamp, sizes.Npre)\n\tif !s.isSourceActive {\n\t\treturn fmt.Errorf(\"no source is active\")\n\t}\n\tif s.status.Npresamp == sizes.Npre && s.status.Nsamples == sizes.Nsamp {\n\t\treturn nil // no change requested\n\t}\n\tif s.ActiveSource.WritingIsActive() {\n\t\treturn fmt.Errorf(\"Stop writing before changing record lengths\")\n\t}\n\n\tf := func() {\n\t\terr := s.ActiveSource.ConfigurePulseLengths(sizes.Nsamp, sizes.Npre)\n\t\tif err == nil {\n\t\t\ts.status.Npresamp = sizes.Npre\n\t\t\ts.status.Nsamples = sizes.Nsamp\n\t\t}\n\t\ts.broadcastStatus()\n\t\ts.queuedResults <- err\n\t}\n\terr := s.runLaterIfActive(f)\n\t*reply = (err == nil)\n\treturn err\n}", "func (m *Mixer) SetFrequency(val uint) error {\n\tif !bool(C.al_set_mixer_frequency((*C.ALLEGRO_MIXER)(m), C.unsigned(val))) {\n\t\treturn fmt.Errorf(\"failed to set mixer frequency to %d\", val)\n\t}\n\treturn nil\n}", "func ConvertWav(fname string, sampleRate int, volume int) []int {\r\n var accum int\r\n var wavFormat, wavChannels, wavSamplesPerSec, wavBitsPerSample int\r\n var err error\r\n var pos, deltaPos float64\r\n \r\n fileData, err = ioutil.ReadFile(fname)\r\n if err != nil {\r\n utils.ERROR(\"Unable to read from \" + fname)\r\n }\r\n fileDataPos = 0\r\n \r\n s := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"RIFF\" {\r\n utils.ERROR(\"No RIFF tag found in \" + fname)\r\n }\r\n \r\n _ = getDword()\r\n \r\n s = string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"WAVE\" {\r\n utils.ERROR(\"No WAVE tag found in \" + fname)\r\n }\r\n\r\n dataSize := -1\r\n wavData := []float64{}\r\n \r\n // Read the chunks\r\n for {\r\n // Get the chunk ID\r\n if (fileDataPos + 3) >= len(fileData) {\r\n break\r\n }\r\n chunkId := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n\r\n // Get the chunk size\r\n chunkSize := getDword()\r\n \r\n if chunkId == \"fmt \" {\r\n wavFormat = getWord()\r\n wavChannels = getWord()\r\n wavSamplesPerSec = getDword()\r\n _ = getDword() // Average bytes per second\r\n _ = getWord() // Block alignment\r\n wavBitsPerSample = getWord()\r\n \r\n fileDataPos += chunkSize - 16\r\n \r\n if wavFormat != 1 || (wavBitsPerSample != 8 && wavBitsPerSample != 16) || wavChannels > 2 {\r\n utils.ERROR(\"Unsupported wav format in \" + fname)\r\n }\r\n \r\n deltaPos = 1.0\r\n if sampleRate > 0 {\r\n deltaPos = float64(wavSamplesPerSec) / float64(sampleRate)\r\n }\r\n pos = 1.0\r\n \r\n if deltaPos != 1.0 {\r\n utils.INFO(fmt.Sprintf(\"Resampling %s from %d to %d Hz\", fname, wavSamplesPerSec, sampleRate))\r\n }\r\n \r\n if wavChannels > 1 {\r\n utils.INFO(\"Converting sample to mono\")\r\n }\r\n \r\n if wavBitsPerSample != 8 {\r\n utils.INFO(\"Converting sample to 8-bit unsigned\")\r\n }\r\n \r\n } else if chunkId == \"data\" {\r\n dataSize = chunkSize\r\n \r\n utils.DEBUG(\"Found data chunk, bits=%d, channels=%d, chunk size=%d\", wavBitsPerSample, wavChannels, dataSize)\r\n \r\n sampleDiv := 0\r\n \r\n if wavBitsPerSample == 8 {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n fileDataPos++\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n accum += int(fileData[fileDataPos+1])\r\n fileDataPos += 2\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n } else {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0)\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 4\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0) + int(float64(getSword() + 32768) / 256.0) \r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n \r\n }\r\n\r\n } else {\r\n // Unhandled chunk type, just skip it.\r\n utils.DEBUG(\"Skipping unhandled WAV chunk \\\"%s\\\"\", chunkId)\r\n fileDataPos += chunkSize\r\n }\r\n }\r\n \r\n utils.INFO(fmt.Sprintf(\"Size of converted sample: %d bytes\", len(wavData)))\r\n \r\n wavDataInt := make([]int, len(wavData))\r\n for i := range wavData {\r\n wavDataInt[i] = int(math.Floor((wavData[i] * float64(volume)) / 100.0))\r\n }\r\n\r\n return wavDataInt\r\n}", "func (s *Filters) SetChannels(v []*string) *Filters {\n\ts.Channels = v\n\treturn s\n}", "func (s *SourceControl) ConfigureSimPulseSource(args *SimPulseSourceConfig, reply *bool) error {\n\tlog.Printf(\"ConfigureSimPulseSource: %d chan, rate=%.3f\\n\", args.Nchan, args.SampleRate)\n\terr := s.simPulses.Configure(args)\n\ts.clientUpdates <- ClientUpdate{\"SIMPULSE\", args}\n\t*reply = (err == nil)\n\tlog.Printf(\"Result is okay=%t and state={%d chan, rate=%.3f}\\n\", *reply, s.simPulses.nchan, s.simPulses.sampleRate)\n\treturn err\n}", "func SetPixFormat(fd uintptr, pixFmt PixFormat) error {\n\tformat := v4l2Format{StreamType: BufTypeVideoCapture}\n\tformat.setPixFormat(pixFmt)\n\n\tif err := Send(fd, VidiocSetFormat, uintptr(unsafe.Pointer(&format))); err != nil {\n\t\tswitch {\n\t\tcase errors.Is(err, ErrorUnsupported):\n\t\t\treturn fmt.Errorf(\"pix format: unsupported operation: %w\", err)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"pix format failed: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}", "func (d *decoder) readFmtChunk() error {\n\t// Read the entire chunk in one go\n\terr := binary.Read(d.reader, binary.LittleEndian, &d.fmt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Chunk header\n\theader := string(d.fmt.Header[:])\n\tswitch header {\n\tcase fmtChunkHeader:\n\t\t// This is the expected chunk header\n\tcase dsdChunkHeader:\n\t\treturn fmt.Errorf(\"fmt: expected fmt chunk but found DSD chunk\")\n\tcase dataChunkHeader:\n\t\treturn fmt.Errorf(\"fmt: expected fmt chunk but found data chunk\")\n\tdefault:\n\t\treturn fmt.Errorf(\"fmt: bad chunk header: %q\\nfmt chunk: % x\", header, d.fmt)\n\t}\n\n\t// Size of this chunk\n\tsize := binary.LittleEndian.Uint64(d.fmt.Size[:])\n\tif size != fmtChunkSize {\n\t\treturn fmt.Errorf(\"fmt: bad chunk size: %v\\nfmt chunk: % x\", size, d.fmt)\n\t}\n\n\t// Format version\n\tformatVersion := binary.LittleEndian.Uint32(d.fmt.Version[:])\n\tif formatVersion != fmtVersion {\n\t\treturn fmt.Errorf(\"fmt: bad format version: %v\\nfmt chunk: % x\", formatVersion, d.fmt)\n\t}\n\n\t// Format id\n\tformatId := binary.LittleEndian.Uint32(d.fmt.Identifier[:])\n\tif formatId != fmtIdentifier {\n\t\treturn fmt.Errorf(\"fmt: bad format id: %v\\nfmt chunk: % x\", formatId, d.fmt)\n\t}\n\n\t// Channel Type\n\tchannelType := binary.LittleEndian.Uint32(d.fmt.ChannelType[:])\n\tchannelTypeString, ok := fmtChannelType[channelType]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad channel type: %v\\nfmt chunk: % x\", channelType, d.fmt)\n\t}\n\n\t// Channel order corresponding to the ChannelType field\n\torder, _ := fmtChannelOrder[channelType]\n\n\t// Channel num\n\tchannelNum := binary.LittleEndian.Uint32(d.fmt.ChannelNum[:])\n\t_, ok = fmtChannelNum[channelNum]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad channel num: %v\\nfmt chunk: % x\", channelNum, d.fmt)\n\t}\n\tif channelNum != uint32(len(order)) {\n\t\treturn fmt.Errorf(\"fmt: mismatch between channel type %v and channel num %v:\\nfmt chunk: % x\", channelType, channelNum, d.fmt)\n\t}\n\n\t// Sampling frequency\n\tsamplingFrequency := binary.LittleEndian.Uint32(d.fmt.SamplingFrequency[:])\n\tsamplingFrequencyString, ok := fmtSamplingFrequency[samplingFrequency]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad sampling frequency: %v\\nfmt chunk: % x\", samplingFrequency, d.fmt)\n\t}\n\n\t// Bits per sample\n\tbitsPerSample := binary.LittleEndian.Uint32(d.fmt.BitsPerSample[:])\n\t_, ok = fmtBitsPerSample[bitsPerSample]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad bits per sample: %v\\nfmt chunk: % x\", bitsPerSample, d.fmt)\n\t}\n\n\t// Sample count\n\tsampleCount := binary.LittleEndian.Uint64(d.fmt.SampleCount[:])\n\n\t// Block size per channel\n\tblockSize := binary.LittleEndian.Uint32(d.fmt.BlockSize[:])\n\tif blockSize != fmtBlockSize {\n\t\treturn fmt.Errorf(\"fmt: bad block size: %v\\nfmt chunk: % x\", blockSize, d.fmt)\n\t}\n\n\t// Reserved\n\treserved := binary.LittleEndian.Uint32(d.fmt.Reserved[:])\n\tif reserved != fmtReserved {\n\t\treturn fmt.Errorf(\"fmt: bad reserved bytes: %#x\\nfmt chunk: % x\", reserved, d.fmt)\n\t}\n\n\t// Log the fields of the chunk (only active if a log output has been set)\n\td.logger.Print(\"\\nFmt Chunk\\n=========\\n\")\n\td.logger.Printf(\"Chunk header: %q\\n\", header)\n\td.logger.Printf(\"Size of this chunk: %v bytes\\n\", size)\n\td.logger.Printf(\"Format version: %v\\n\", formatVersion)\n\td.logger.Printf(\"Format id: %v\\n\", formatId)\n\td.logger.Printf(\"Channel type: %v (%s)\\n\", channelType, channelTypeString)\n\td.logger.Printf(\"Channel num: %v\\n\", channelNum)\n\tif len(order) > 1 {\n\t\tvar s string\n\t\tfor i, channel := range order {\n\t\t\tif i < len(order)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\td.logger.Printf(\"Channel order: %v\\n\", s)\n\t}\n\td.logger.Printf(\"Sampling frequency: %vHz (%s)\\n\", samplingFrequency, samplingFrequencyString)\n\td.logger.Printf(\"Bits per sample: %v\\n\", bitsPerSample)\n\td.logger.Printf(\"Sample count: %v\\n\", sampleCount)\n\td.logger.Printf(\"Block size per channel: %v bytes\\n\", blockSize)\n\n\t// Store the information that is useful\n\td.audio.Encoding = audio.DSD\n\td.audio.NumChannels = uint(channelNum)\n\td.audio.ChannelOrder = order\n\td.audio.SamplingFrequency = uint(samplingFrequency)\n\td.audio.BitsPerSample = uint(bitsPerSample)\n\td.audio.BlockSize = uint(blockSize)\n\n\t// Prepare the audio.Audio in d to hold the encoded samples\n\tlength := sampleCount\n\tif bitsPerSample == 1 {\n\t\tlength = (length + 7) / 8 // fit up to 8 samples into 1 byte\n\t}\n\tif (length % uint64(blockSize)) > 0 { // pad to the block size\n\t\tlength += uint64(blockSize) - (length % uint64(blockSize))\n\t}\n\tlength *= uint64(channelNum) // same amount for each channel\n\td.audio.EncodedSamples = make([]byte, length)\n\n\treturn nil\n}", "func (p *Pump) WavNumChannels() phono.NumChannels {\n\treturn p.wavNumChannels\n}", "func (o *ConnectorTypeAllOf) SetChannels(v []string) {\n\to.Channels = &v\n}", "func (rcv *impl) SetFormat(format string) Interface { rcv.TplText = format; return rcv }", "func NewMonoFmt() *Format {\n\treturn &Format{\n\t\tchannels: 1,\n\t\tfreq: 44100 * freq.Hertz,\n\t\tCodec: sample.SInt16L}\n}", "func Format() audio.Format {\n\treturn format\n}", "func DecodeJpegChannels(value int64) DecodeJpegAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"channels\"] = value\n\t}\n}", "func (mr *MockWebsocketClientStoreMockRecorder) SetChannels(clientID interface{}, channels ...interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\tvarargs := append([]interface{}{clientID}, channels...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"SetChannels\", reflect.TypeOf((*MockWebsocketClientStore)(nil).SetChannels), varargs...)\n}", "func (znp *Znp) UtilSetChannels(channels *Channels) (rsp *StatusResponse, err error) {\n\treq := &UtilSetChannels{Channels: channels}\n\terr = znp.ProcessRequest(unp.C_SREQ, unp.S_UTIL, 0x03, req, &rsp)\n\treturn\n}", "func (o *Wireless) SetChannels(v string) {\n\to.Channels = &v\n}", "func (s *SoundGroup) SetUserData(userdata interface{}) error {\n\tdata := *(*[]*C.char)(unsafe.Pointer(&userdata))\n\tres := C.FMOD_SoundGroup_SetUserData(s.cptr, unsafe.Pointer(&data))\n\treturn errs[res]\n}", "func (w *Writer) Format() audio.Format {\n\treturn w.fmt\n}", "func readHeaderFormat(reader *bytes.Reader) (*formatHeader, error) {\n\thdrFormat := formatHeader{}\n\terr := binary.Read(reader, binary.LittleEndian, &hdrFormat)\n\n\t/*\n\t * Check if format header was read.\n\t */\n\tif err != nil {\n\t\tmsg := err.Error()\n\t\treturn nil, fmt.Errorf(\"Failed to read format header: %s\", msg)\n\t} else {\n\t\tchunkId := hdrFormat.ChunkID\n\t\tchannelCount := hdrFormat.ChannelCount\n\t\tbitDepth := hdrFormat.BitDepth\n\t\tsampleRate := hdrFormat.SampleRate\n\t\tframeSize := channelCount * bitDepth\n\t\texpectedBlockAlign32 := uint32(frameSize / BITS_PER_BYTE)\n\t\texpectedBlockAlign16 := uint16(expectedBlockAlign32)\n\t\texpectedByteRate := expectedBlockAlign32 * sampleRate\n\t\tchunkSize := hdrFormat.ChunkSize\n\t\tchunkSize64 := int64(chunkSize)\n\t\tnumBytesSkip := chunkSize64 - MIN_CHUNK_SIZE_FORMAT\n\t\taudioFormat := hdrFormat.AudioFormat\n\t\tbyteRate := hdrFormat.ByteRate\n\t\tblockAlign := hdrFormat.BlockAlign\n\n\t\t/*\n\t\t * Skip optional fields in the format header.\n\t\t */\n\t\tif numBytesSkip > 0 {\n\n\t\t\t/*\n\t\t\t * If this is even, we need to skip one more.\n\t\t\t */\n\t\t\tif (numBytesSkip % 2) == 0 {\n\t\t\t\tnumBytesSkip += 1\n\t\t\t}\n\n\t\t\tamount := uint64(numBytesSkip)\n\t\t\tskipData(reader, amount)\n\t\t}\n\n\t\t/*\n\t\t * Check format header for validity.\n\t\t */\n\t\tif chunkId != ID_FORMAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid chunk id. Expected %#08x, found %#08x.\", ID_FORMAT, chunkId)\n\t\t} else if chunkSize < MIN_CHUNK_SIZE_FORMAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid chunk size. Expected at least %#08x, found %#08x.\", MIN_CHUNK_SIZE_FORMAT, chunkSize)\n\t\t} else if audioFormat != AUDIO_PCM && audioFormat != AUDIO_IEEE_FLOAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid audio format. Expected %#04x or %#04x, found %#04x.\", AUDIO_PCM, AUDIO_IEEE_FLOAT, audioFormat)\n\t\t} else if byteRate != expectedByteRate {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid byte rate. Expected %#08x, found %#08x.\", expectedByteRate, byteRate)\n\t\t} else if blockAlign != expectedBlockAlign16 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid block align. Expected %#04x, found %#04x.\", expectedBlockAlign16, blockAlign)\n\t\t} else if audioFormat == AUDIO_PCM && bitDepth != 8 && bitDepth != 16 && bitDepth != 24 && bitDepth != 32 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid bit depth for PCM format. Expected %#04x or %#04x or %#04x or %#04x, found %#04x.\", 8, 16, 24, 32, bitDepth)\n\t\t} else if audioFormat == AUDIO_IEEE_FLOAT && bitDepth != 32 && bitDepth != 64 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid bit depth for IEEE floating-point format. Expected %#04x or %#04x, found %#04x.\", 32, 64, bitDepth)\n\t\t} else {\n\t\t\treturn &hdrFormat, nil\n\t\t}\n\n\t}\n\n}", "func (e *encoder) configureHeader() error {\n\t// Header - Defaults\n\tif e.h.Depth == 0 {\n\t\te.h.Depth = 32\n\t}\n\tif e.h.Compression == \"\" {\n\t\te.h.Compression = CompressionGzip\n\t}\n\tif e.h.RasterMode == \"\" {\n\t\te.h.RasterMode = RasterModeNormal\n\t}\n\tif e.h.Format == \"\" {\n\t\tswitch e.m.ColorModel() {\n\t\tcase hdrcolor.RGBModel:\n\t\t\te.h.Format = FormatRGBE\n\t\tcase hdrcolor.XYZModel:\n\t\t\te.h.Format = FormatXYZE\n\t\tdefault:\n\t\t\treturn UnsupportedError(\"color model\")\n\t\t}\n\t}\n\n\t// Header - Format\n\tswitch e.h.Format {\n\tcase FormatRGBE:\n\t\te.channelSize = 1\n\t\te.nbOfchannel = 4\n\t\te.bytesAt = func(x, y int) []byte {\n\t\t\tr, g, b, _ := e.m.HDRAt(x, y).HDRRGBA()\n\t\t\treturn format.ToRadianceBytes(r, g, b)\n\t\t}\n\tcase FormatXYZE:\n\t\te.channelSize = 1\n\t\te.nbOfchannel = 4\n\t\te.bytesAt = func(x, y int) []byte {\n\t\t\txx, yy, zz, _ := e.m.HDRAt(x, y).HDRXYZA()\n\t\t\treturn format.ToRadianceBytes(xx, yy, zz)\n\t\t}\n\tcase FormatRGB:\n\t\te.channelSize = 4\n\t\te.nbOfchannel = 3\n\t\te.bytesAt = func(x, y int) []byte {\n\t\t\tr, g, b, _ := e.m.HDRAt(x, y).HDRRGBA()\n\t\t\treturn format.ToBytes(binary.LittleEndian, r, g, b)\n\t\t}\n\tcase FormatXYZ:\n\t\te.channelSize = 4\n\t\te.nbOfchannel = 3\n\t\te.bytesAt = func(x, y int) []byte {\n\t\t\txx, yy, zz, _ := e.m.HDRAt(x, y).HDRXYZA()\n\t\t\treturn format.ToBytes(binary.LittleEndian, xx, yy, zz)\n\t\t}\n\tcase FormatLogLuv:\n\t\te.channelSize = 1\n\t\te.nbOfchannel = 4\n\t\te.bytesAt = func(x, y int) []byte {\n\t\t\txx, yy, zz, _ := e.m.HDRAt(x, y).HDRXYZA()\n\t\t\treturn format.XYZToLogLuv(xx, yy, zz)\n\t\t}\n\t}\n\n\t// Header - Size\n\td := e.m.Bounds().Size()\n\te.h.Width = d.X\n\te.h.Height = d.Y\n\n\treturn nil\n}", "func (cfg *Config) SetSampleRate(sampleRate float64) {\n\tcfg.SampleRate = sampleRate\n}", "func (c *Sound) GetFormat() int {\n\treturn c.Format\n}", "func (this *channelStruct) WriteFloats(samples []float64) {\n\tthis.samples = append(this.samples, samples...)\n}", "func (h *handle) MPSSECBus(mask, value byte) error {\n\tb := [...]byte{gpioSetC, value, mask}\n\t_, err := h.Write(b[:])\n\treturn err\n}", "func NewStereoFmt() *Format {\n\treturn &Format{\n\t\tchannels: 2,\n\t\tfreq: 44100 * freq.Hertz,\n\t\tCodec: sample.SInt16L}\n}", "func (info TrackInfo) NChannels() int {\n\t// bit 28 - 1 = stereo audio; 0 = mono audio\n\tif info&0x10000000 != 0 {\n\t\t// stero audio.\n\t\treturn 2\n\t}\n\t// mono audio.\n\treturn 1\n}", "func SetMute(ctx context.Context, address, output, mute string) *nerr.E {\n\n\tvar err *nerr.E\n\t//Now we need to find out which input is being routed to the output\n\terr = SetMuteHelper(ctx, address, output, mute)\n\tif err != nil {\n\t\treturn nerr.Translate(err).Addf(\"error when making call: %s\", err)\n\t}\n\treturn nil\n}", "func (p *decoded) Channels() int {\n\treturn 2\n}", "func Channels(chs int) Option {\n\treturn func(args *Options) {\n\t\targs.Channels = chs\n\t}\n}", "func (client *Client) SetCasterConfigWithChan(request *SetCasterConfigRequest) (<-chan *SetCasterConfigResponse, <-chan error) {\n\tresponseChan := make(chan *SetCasterConfigResponse, 1)\n\terrChan := make(chan error, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tdefer close(responseChan)\n\t\tdefer close(errChan)\n\t\tresponse, err := client.SetCasterConfig(request)\n\t\tif err != nil {\n\t\t\terrChan <- err\n\t\t} else {\n\t\t\tresponseChan <- response\n\t\t}\n\t})\n\tif err != nil {\n\t\terrChan <- err\n\t\tclose(responseChan)\n\t\tclose(errChan)\n\t}\n\treturn responseChan, errChan\n}", "func (p *pwmGroup) Set(channel uint8, value uint32) {\n\tval := uint16(value)\n\tchannel &= 1\n\tp.setChanLevel(channel, val)\n}", "func (s *Sdr) SetDSP(state bool) error {\n\tvar v C.uint8_t\n\tif state {\n\t\tv = 1\n\t}\n\tif C.airspyhf_set_lib_dsp(s.handle, v) != C.AIRSPYHF_SUCCESS {\n\t\treturn fmt.Errorf(\"airspyhf.Sdr.SetDSP: failed to set DSP\")\n\t}\n\treturn nil\n}", "func (_obj *Apichannels) Channels_setStickers(params *TLchannels_setStickers, _opt ...map[string]string) (ret Bool, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\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, \"channels_setStickers\", _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 = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\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 (s *Stream) FeedAudioContent(buffer []int16, bufferSize uint) {\n\tC.FeedAudioContent(s.sw, (*C.short)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&buffer)).Data)), C.uint(bufferSize))\n}", "func (s SampleChannelDataInput) MarshalFields(e protocol.FieldEncoder) error {\n\n\tif s.ChannelName != nil {\n\t\tv := *s.ChannelName\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.PathTarget, \"channelName\", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata)\n\t}\n\tif s.EndTime != nil {\n\t\tv := *s.EndTime\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.QueryTarget, \"endTime\", protocol.TimeValue{V: v, Format: protocol.RFC822TimeFromat}, metadata)\n\t}\n\tif s.MaxMessages != nil {\n\t\tv := *s.MaxMessages\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.QueryTarget, \"maxMessages\", protocol.Int64Value(v), metadata)\n\t}\n\tif s.StartTime != nil {\n\t\tv := *s.StartTime\n\n\t\tmetadata := protocol.Metadata{}\n\t\te.SetValue(protocol.QueryTarget, \"startTime\", protocol.TimeValue{V: v, Format: protocol.RFC822TimeFromat}, metadata)\n\t}\n\treturn nil\n}", "func (e *Engine) streamCallback(in, out []float32) {\n\n\tvar left, right float64\n\n\t// if there are new playback events recently encountered append\n\t// them to the active playback events set\n\t//\n\t// NB. for some reason, we can only access activePlaybackEvents at a\n\t// rate of SampleRate / FramesPerBuffer hz (and more confusinhgly\n\t// FramesPerBuffer can vary with each call). This effectively creates\n\t// unlistenably amounts of stutter if the FramesPerBuffer is too high\n\t// (greater than 512 for 44100hz sample rate is already pushing it)\n\tfor i := 0; i < len(e.newPlaybackEvents); i++ {\n\t\te.activePlaybackEvents[<-e.newPlaybackEvents] = true\n\t}\n\n\t// for each (stereo interleaved) output frame\n\tfor n := 0; n < len(out); n += 2 {\n\t\t// clear the current output frame (to avoid explosive accumulation)\n\t\tout[n] = 0.0\n\t\tout[n+1] = 0.0\n\t\t// for each event in the active playback events\n\t\tfor playbackEvent, _ := range e.activePlaybackEvents {\n\t\t\t// accumulate a frame of audio from the event\n\t\t\t// into the output buffer's current frame\n\t\t\tleft, right = playbackEvent.tick()\n\t\t\tout[n] += float32(left)\n\t\t\tout[n+1] += float32(right)\n\t\t}\n\t}\n\n\t// monitor audio input (if not muted and device exists)\n\tif e.inputAmplitude != 0 && e.streamParameters.Input.Device != nil {\n\t\tswitch e.streamParameters.Input.Channels {\n\t\tcase 1:\n\t\t\t// mono\n\t\t\tfor n := 0; n < len(in); n++ {\n\t\t\t\tout[2*n] += in[n] * e.inputAmplitude\n\t\t\t\tout[2*n+1] += in[n] * e.inputAmplitude\n\t\t\t}\n\t\tcase 2:\n\t\t\t// stereo\n\t\t\tfor n := 0; n < len(in); n += 2 {\n\t\t\t\tout[n] += in[n] * e.inputAmplitude\n\t\t\t\tout[n+1] += in[n+1] * e.inputAmplitude\n\t\t\t}\n\t\t}\n\t}\n\n}", "func DataFormatVecPermuteSrcFormat(value string) DataFormatVecPermuteAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"src_format\"] = value\n\t}\n}", "func (c *Context) SetSampleRate(rate int) (err int) {\n\treturn int(C.rtlsdr_set_sample_rate((*C.rtlsdr_dev_t)(c.dev),\n\t\tC.uint32_t(rate)))\n}", "func channelsToSamples(channels []Channel) []float64 {\n\tchannelCount := len(channels)\n\tchannelCount16 := uint16(channelCount)\n\tchannelCount32 := uint32(channelCount)\n\tsamplesByChannel := make([][]float64, channelCount)\n\tmaxSampleCount := uint32(0)\n\n\t/*\n\t * Iterate over all channels and extract the samples for each.\n\t */\n\tfor i, currentChannel := range channels {\n\t\tcurrentSamples := currentChannel.Floats()\n\t\tsampleCount := len(currentSamples)\n\t\tsampleCount32 := uint32(sampleCount)\n\t\tsamplesByChannel[i] = currentSamples\n\n\t\t/*\n\t\t * If we found a channel with more samples, make its sample\n\t\t * count the new longest channel sample count.\n\t\t */\n\t\tif sampleCount32 > maxSampleCount {\n\t\t\tmaxSampleCount = sampleCount32\n\t\t}\n\n\t}\n\n\ttotalSampleCount := channelCount32 * maxSampleCount\n\tdata := make([]float64, totalSampleCount)\n\n\t/*\n\t * Iterate over the samples to reorder them by time.\n\t */\n\tfor i := uint32(0); i < maxSampleCount; i++ {\n\n\t\t/*\n\t\t * Iterate over the channels and extract the current sample.\n\t\t */\n\t\tfor j := uint16(0); j < channelCount16; j++ {\n\t\t\tcurrentChannel := samplesByChannel[j]\n\t\t\tcurrentChannelLength := len(currentChannel)\n\t\t\tcurrentChannelLength32 := uint32(currentChannelLength)\n\t\t\tcurrentSample := float64(0.0)\n\n\t\t\t/*\n\t\t\t * If the channel is long enough, read the sample from it,\n\t\t\t * otherwise pad with zeroes.\n\t\t\t */\n\t\t\tif i < currentChannelLength32 {\n\t\t\t\tcurrentSample = currentChannel[i]\n\t\t\t}\n\n\t\t\tj32 := uint32(j)\n\t\t\toffset := (channelCount32 * i) + j32\n\t\t\tdata[offset] = currentSample\n\t\t}\n\n\t}\n\n\treturn data\n}", "func determineFormat(channels int) int {\n\tswitch channels {\n\tcase 1:\n\t\treturn gl.RED\n\tcase 2:\n\t\treturn gl.RG\n\tcase 3:\n\t\treturn gl.RGB\n\tcase 4:\n\t\treturn gl.RGBA\n\t}\n\treturn gl.RGBA\n}", "func (d *DSP) SetUserData(userdata interface{}) error {\n\tdata := *(*[]*C.char)(unsafe.Pointer(&userdata))\n\tres := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&data))\n\treturn errs[res]\n}", "func (s *Server) SetMuteForSpeaker(ctx context.Context, in *SetMuteRequest) (*UpdateResponse, error) {\n\tif in.SpeakerId == \"\" {\n\t\treturn &UpdateResponse{ResponseCode: 400, Message: \"No speaker id specified\"}, nil\n\t}\n\terr := s.service.SetMuteForSpeaker(in.SpeakerId, in.IsMuted)\n\tif err != nil {\n\t\treturn &UpdateResponse{ResponseCode: 500, Message: err.Error()}, nil\n\t}\n\treturn &UpdateResponse{ResponseCode: 200}, nil\n}", "func NewAudioConfigFromSpeakerOutput(deviceName string) (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tdn := C.CString(deviceName)\n\tdefer C.free(unsafe.Pointer(dn))\n\tret := uintptr(C.audio_config_create_audio_output_from_a_speaker(&handle, dn))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func (v *Muxer) readSample() (s *SrsMp4Sample, err error) {\n if s, err = v.dec.readSample(v.mp4Url); err != nil {\n ol.E(nil, fmt.Sprintf(\"read mp4 sample failed, err is %v\", err))\n return\n }\n\n if s.handlerType == SrsMp4HandlerTypeForbidden {\n return nil, fmt.Errorf(\"invalid mp4 handler\")\n }\n\n if s.handlerType == SrsMp4HandlerTypeSOUN {\n s.codec = uint16(v.dec.acodec)\n s.sampleRate = uint8(v.dec.sampleRate)\n s.channels = uint8(v.dec.channels)\n s.soundBits = uint8(v.dec.soundBits)\n } else {\n s.codec = uint16(v.dec.vcodec)\n }\n\n ol.I(nil, fmt.Sprintf(\"read a mp4 sample:%v\", s))\n return\n}", "func (b *builder) SetFormat(format *pic.ImageFormat, colorSpace *pic.ColorSpace) {\n\tswitch *format {\n\tcase pic.SVG:\n\t\tb.RendererProvider = chart.SVG\n\tdefault:\n\t\tb.RendererProvider = chart.PNG\n\t\t*format = pic.PNG\n\t}\n\t*colorSpace = pic.RGB\n}", "func SetSFChannels(ctx log.Interface, conf util.Config) error {\n\tfor i, sfChannel := range conf.Concentrator.GetMultiSFChannels() {\n\t\terr := enableSFChannel(ctx, sfChannel, uint8(i))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (l *Logger) SetFormat(v string) {\n\tswitch v {\n\tcase \"json\":\n\t\tl.Formatter = &JSONFormatter{\n\t\t\tIgnoreFields: []string{\"ctx\"},\n\t\t\tTimestampFormat: time.RFC3339,\n\t\t}\n\tcase \"text\":\n\t\tl.Formatter = &TextFormatter{\n\t\t\tIgnoreFields: []string{\"ctx\"},\n\t\t\tTimestampFormat: time.RFC3339,\n\t\t}\n\t}\n}", "func (c *Context) SetCenterFreq(freq int) (err int) {\n\treturn int(C.rtlsdr_set_center_freq((*C.rtlsdr_dev_t)(c.dev),\n\t\tC.uint32_t(freq)))\n}", "func (st *Settings) Encode() {\n\tst.rawSettings = st.rawSettings[:0]\n\n\tif st.tableSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(HeaderTableSize>>8), byte(HeaderTableSize),\n\t\t\tbyte(st.tableSize>>24), byte(st.tableSize>>16),\n\t\t\tbyte(st.tableSize>>8), byte(st.tableSize),\n\t\t)\n\t}\n\n\tif st.enablePush {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(EnablePush>>8), byte(EnablePush),\n\t\t\t0, 0, 0, 1,\n\t\t)\n\t}\n\n\tif st.maxStreams != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxConcurrentStreams>>8), byte(MaxConcurrentStreams),\n\t\t\tbyte(st.maxStreams>>24), byte(st.maxStreams>>16),\n\t\t\tbyte(st.maxStreams>>8), byte(st.maxStreams),\n\t\t)\n\t}\n\n\tif st.windowSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxWindowSize>>8), byte(MaxWindowSize),\n\t\t\tbyte(st.windowSize>>24), byte(st.windowSize>>16),\n\t\t\tbyte(st.windowSize>>8), byte(st.windowSize),\n\t\t)\n\t}\n\n\tif st.frameSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxFrameSize>>8), byte(MaxFrameSize),\n\t\t\tbyte(st.frameSize>>24), byte(st.frameSize>>16),\n\t\t\tbyte(st.frameSize>>8), byte(st.frameSize),\n\t\t)\n\t}\n\n\tif st.headerSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxHeaderListSize>>8), byte(MaxHeaderListSize),\n\t\t\tbyte(st.headerSize>>24), byte(st.headerSize>>16),\n\t\t\tbyte(st.headerSize>>8), byte(st.headerSize),\n\t\t)\n\t}\n}", "func (st *Settings) Encode() {\n\tst.rawSettings = st.rawSettings[:0]\n\n\tif st.tableSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(HeaderTableSize>>8), byte(HeaderTableSize),\n\t\t\tbyte(st.tableSize>>24), byte(st.tableSize>>16),\n\t\t\tbyte(st.tableSize>>8), byte(st.tableSize),\n\t\t)\n\t}\n\n\tif st.enablePush {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(EnablePush>>8), byte(EnablePush),\n\t\t\t0, 0, 0, 1,\n\t\t)\n\t}\n\n\tif st.maxStreams != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxConcurrentStreams>>8), byte(MaxConcurrentStreams),\n\t\t\tbyte(st.maxStreams>>24), byte(st.maxStreams>>16),\n\t\t\tbyte(st.maxStreams>>8), byte(st.maxStreams),\n\t\t)\n\t}\n\n\tif st.windowSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxWindowSize>>8), byte(MaxWindowSize),\n\t\t\tbyte(st.windowSize>>24), byte(st.windowSize>>16),\n\t\t\tbyte(st.windowSize>>8), byte(st.windowSize),\n\t\t)\n\t}\n\n\tif st.frameSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxFrameSize>>8), byte(MaxFrameSize),\n\t\t\tbyte(st.frameSize>>24), byte(st.frameSize>>16),\n\t\t\tbyte(st.frameSize>>8), byte(st.frameSize),\n\t\t)\n\t}\n\n\tif st.headerSize != 0 {\n\t\tst.rawSettings = append(st.rawSettings,\n\t\t\tbyte(MaxHeaderListSize>>8), byte(MaxHeaderListSize),\n\t\t\tbyte(st.headerSize>>24), byte(st.headerSize>>16),\n\t\t\tbyte(st.headerSize>>8), byte(st.headerSize),\n\t\t)\n\t}\n}", "func (c *Context) SetFreqCorrection(ppm int) (err int) {\n\treturn int(C.rtlsdr_set_freq_correction((*C.rtlsdr_dev_t)(c.dev),\n\t\tC.int(ppm)))\n}", "func writer() {\n\n\tdefer WaitGroup.Done()\n\n\tvar opuslen int16\n\tvar err error\n\n\t// 16KB output buffer\n\tstdout := bufio.NewWriterSize(os.Stdout, 16384)\n\tdefer func() {\n\t\terr := stdout.Flush()\n\t\tif err != nil {\n\t\t\tlog.Println(\"error flushing stdout, \", err)\n\t\t}\n\t}()\n\n\tfor {\n\t\topus, ok := <-OutputChan\n\t\tif !ok {\n\t\t\t// if chan closed, exit\n\t\t\treturn\n\t\t}\n\n\t\t// write header\n\t\topuslen = int16(len(opus))\n\t\terr = binary.Write(stdout, binary.LittleEndian, &opuslen)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"error writing output: \", err)\n\t\t\treturn\n\t\t}\n\n\t\t// write opus data to stdout\n\t\terr = binary.Write(stdout, binary.LittleEndian, &opus)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"error writing output: \", err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func SetFormat(format LogFormat) {\n\tswitch format {\n\tcase FORMAT_CONSOLE:\n\t\tl = log.With().Caller().Logger().Output(zerolog.ConsoleWriter{\n\t\t\tOut: os.Stderr,\n\t\t\tTimeFormat: \"15:04:05.000Z\",\n\t\t})\n\tcase FORMAT_JSON:\n\t\tl = log.With().Caller().Logger().Output(os.Stderr)\n\t}\n}", "func NewAudioConfigFromDefaultSpeakerOutput() (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tret := uintptr(C.audio_config_create_audio_output_from_default_speaker(&handle))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func Decode(v *discordgo.VoiceConnection, c chan *discordgo.Packet) {\n\tif c == nil {\n\t\treturn\n\t}\n\n\tfor {\n\n\t\tif v.Ready == false || v.OpusRecv == nil {\n\t\t\tOnError(fmt.Sprintf(\"Discordgo not to receive opus packets. %+v : %+v\", v.Ready, v.OpusSend), nil)\n\t\t\treturn\n\t\t}\n\t\t\n\t\tp, ok := <-v.OpusRecv\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\tif speakers == nil {\n\t\t\tspeakers = make(map[uint32]*gopus.Decoder)\n\t\t}\n\n\t\t_, ok = speakers[p.SSRC]\n\t\tif !ok {\n\t\t\tspeakers[p.SSRC], err = gopus.NewDecoder(sampleRate, channels)\n\t\t\tif err != nil {\n\t\t\t\tOnError(\"error creating opus decoder\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tp.PCM, err = speakers[p.SSRC].Decode(p.Opus, sampleSize, false)\n\t\tif err != nil {\n\t\t\tOnError(\"Error decoding opus data\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\tc <- p\n\t}\n}", "func (f v4l2Format) setPixFormat(newPix PixFormat) {\n\t*(*PixFormat)(unsafe.Pointer(&f.fmt[0])) = newPix\n}", "func setInitOpts(fd int, options InitMsg) error {\n\toptlen := unsafe.Sizeof(options)\n\t_, _, err := setsockopt(fd, SCTP_INITMSG, uintptr(unsafe.Pointer(&options)), uintptr(optlen))\n\treturn err\n}", "func samplesToBytes(samples []float64, sampleFormat uint16, bitDepth uint16) ([]byte, error) {\n\n\t/*\n\t * Decide on the sample format.\n\t */\n\tswitch sampleFormat {\n\tcase AUDIO_PCM:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 8:\n\t\t\tres, err := samplesToBytesLPCM8(samples)\n\t\t\treturn res, err\n\t\tcase 16:\n\t\t\tres, err := samplesToBytesLPCM16(samples)\n\t\t\treturn res, err\n\t\tcase 24:\n\t\t\tres, err := samplesToBytesLPCM24(samples)\n\t\t\treturn res, err\n\t\tcase 32:\n\t\t\tres, err := samplesToBytesLPCM32(samples)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in LPCM format: %d\", bitDepth)\n\t\t}\n\n\tcase AUDIO_IEEE_FLOAT:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 32:\n\t\t\tres, err := samplesToBytesIEEE32(samples)\n\t\t\treturn res, err\n\t\tcase 64:\n\t\t\tres, err := samplesToBytesIEEE64(samples)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in IEEE floating-point format: %d\", bitDepth)\n\t\t}\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown sample format: %#04x\", sampleFormat)\n\t}\n\n}", "func Encode(w io.Writer, audio *WaveAudio) error {\n\t// Write RIFF header\n\t_, err := w.Write(RiffHeader)\n\tif err != nil {\n\t\treturn err\n\t}\n\triffSize := 4 + 8 + 16 + 8 + audio.DataSize()\n\terr = binary.Write(w, binary.LittleEndian, uint32(riffSize))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write file type\n\t_, err = w.Write(WaveHeader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write format\n\t_, err = w.Write(FmtHeader)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Write format length\n\terr = binary.Write(w, binary.LittleEndian, uint32(16))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.Format)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.Channels)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.SampleRate)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.SampleFreq())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.Sound())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.BitsPerSample)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write data\n\t_, err = w.Write(DataHeader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.LittleEndian, audio.DataSize())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Write raw data directly\n\t_, err = w.Write(audio.RawData)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *Music) Play(reader *bufio.Reader, volume100 int) {\n\tm.playing = true\n\tdefer func() {\n\t\tm.played <- true\n\t\tif m.stopping {\n\t\t\tm.stopped <- true\n\t\t}\n\t\tm.playing = false\n\t}()\n\n\tvolume := int(SampleAmp16bit * (float64(volume100) / 100.0))\n\toutputFileName := m.output\n\n\tif m.piano == nil {\n\t\tm.piano = NewPiano()\n\t}\n\n\tvar outputFile *os.File\n\tvar err error\n\n\t// output file\n\tif len(outputFileName) > 0 {\n\t\tif outputFileName == \"-\" {\n\t\t\toutputFile = os.Stdout\n\t\t\tm.quietMode = true\n\t\t} else {\n\t\t\topt := os.O_WRONLY | os.O_TRUNC | os.O_CREATE\n\t\t\toutputFile, err = os.OpenFile(outputFileName, opt, 0644)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, \"Error opening output file:\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\t\tdefer outputFile.Close()\n\t}\n\n\tif m.quietMode {\n\t\tPrintSheet = false\n\t\tPrintNotes = false\n\t}\n\n\t// sustain state\n\tsustain := &Sustain{\n\t\tattack: 8,\n\t\tdecay: 4,\n\t\tsustain: 4,\n\t\trelease: 9,\n\t\tbuf: make([]int16, quarterNote),\n\t}\n\n\t// read lines\n\tchord := &Chord{}\n\tbufWaveLimit := 1024 * 1024 * 100\n\tcontrolKeys := \"RDHTSAVC\"\n\tmeasures := \"WHQESTI\"\n\thands := \"0LR7\"\n\tzeroToNine := \"0123456789\"\n\ttempos := zeroToNine\n\tamplitudes := zeroToNine\n\tchordNumbers := zeroToNine\n\tignoredKeys := \"\\t |\"\n\tsustainTypes := \"ADSR\"\n\tsustainLevels := zeroToNine\n\tvoiceControls := \"DPVN\"\n\n\tvar (\n\t\tbufOutput []int16\n\t\tduration = 'Q' // default note duration\n\t\tdotted bool\n\t\trest rune\n\t\tctrl rune\n\t\tvoice Voice = m.piano // default voice is piano\n\t\tsustainType rune\n\t\thand = 'R' // default is middle C octave\n\t\thandLevel rune\n\t\tcount int // line counter\n\t\ttempo = 4 // normal speed\n\t\tamplitude = 9 // max volume\n\t\tmixNextLine bool\n\t\tbufMix []int16\n\t\tlineMix string\n\t\twaitNext bool\n\t\tblockComment bool\n\t)\n\n\tfor {\n\t\tline, done := nextMusicLine(reader)\n\t\tif done {\n\t\t\tbreak\n\t\t}\n\t\tif strings.HasPrefix(line, \"#\") {\n\t\t\tif strings.HasPrefix(line, \"##\") {\n\t\t\t\t// ignore block comment\n\t\t\t\tif blockComment {\n\t\t\t\t\tblockComment = false\n\t\t\t\t} else {\n\t\t\t\t\tblockComment = true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// ignore comments\n\t\t\t\tif PrintSheet {\n\t\t\t\t\tfmt.Println(line)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif blockComment {\n\t\t\tcontinue\n\t\t}\n\t\tif strings.HasSuffix(line, \"VN\") {\n\t\t\t// include next line to mixer\n\t\t\tmixNextLine = true\n\t\t} else {\n\t\t\tmixNextLine = false\n\t\t}\n\t\tvar bufWave []int16\n\t\tfor _, key := range line {\n\t\t\tkeystr := string(key)\n\t\t\tif strings.ContainsAny(keystr, ignoredKeys) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ctrl == 0 && strings.ContainsAny(keystr, controlKeys) {\n\t\t\t\tctrl = key\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ctrl > 0 {\n\t\t\t\tswitch ctrl {\n\t\t\t\tcase 'D': // duration\n\t\t\t\t\tif strings.ContainsAny(keystr, measures) {\n\t\t\t\t\t\tduration = key\n\t\t\t\t\t}\n\t\t\t\t\tif key == 'D' {\n\t\t\t\t\t\tdotted = true\n\t\t\t\t\t}\n\t\t\t\tcase 'R': // reset\n\t\t\t\t\tif strings.ContainsAny(keystr, measures) {\n\t\t\t\t\t\trest = key\n\t\t\t\t\t}\n\t\t\t\tcase 'H': // hand\n\t\t\t\t\tif strings.ContainsAny(keystr, hands) {\n\t\t\t\t\t\thand = key\n\t\t\t\t\t}\n\t\t\t\tcase 'T': // tempo\n\t\t\t\t\tif strings.ContainsAny(keystr, tempos) {\n\t\t\t\t\t\ttempo = strings.Index(tempos, keystr)\n\t\t\t\t\t}\n\t\t\t\tcase 'S': // sustain\n\t\t\t\t\tif strings.ContainsAny(keystr, sustainTypes) {\n\t\t\t\t\t\tsustainType = key\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif strings.ContainsAny(keystr, sustainLevels) {\n\t\t\t\t\t\tlevel := strings.Index(sustainLevels, keystr)\n\t\t\t\t\t\tswitch sustainType {\n\t\t\t\t\t\tcase 'A':\n\t\t\t\t\t\t\tsustain.attack = level\n\t\t\t\t\t\tcase 'D':\n\t\t\t\t\t\t\tsustain.decay = level\n\t\t\t\t\t\tcase 'S':\n\t\t\t\t\t\t\tsustain.sustain = level\n\t\t\t\t\t\tcase 'R':\n\t\t\t\t\t\t\tsustain.release = level\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'A': // amplitude\n\t\t\t\t\tif strings.ContainsAny(keystr, amplitudes) {\n\t\t\t\t\t\tamplitude = strings.Index(amplitudes, keystr)\n\t\t\t\t\t}\n\t\t\t\tcase 'V': // voice\n\t\t\t\t\tif strings.ContainsAny(keystr, voiceControls) {\n\t\t\t\t\t\tswitch key {\n\t\t\t\t\t\tcase 'D': // default voice\n\t\t\t\t\t\t\tvoice.ComputerVoice(true)\n\t\t\t\t\t\tcase 'P':\n\t\t\t\t\t\t\tvoice = m.piano\n\t\t\t\t\t\t\tif voice.NaturalVoiceFound() {\n\t\t\t\t\t\t\t\tvoice.ComputerVoice(false)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'V':\n\t\t\t\t\t\t\tif m.violin == nil {\n\t\t\t\t\t\t\t\tm.violin = NewViolin()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvoice = m.violin\n\t\t\t\t\t\t\tvoice.ComputerVoice(false)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tcase 'C': // chord\n\t\t\t\t\tif strings.ContainsAny(keystr, chordNumbers) {\n\t\t\t\t\t\tchord.count = 0\n\t\t\t\t\t\tchord.number = strings.Index(chordNumbers, keystr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif rest > 0 {\n\t\t\t\t\tbufRest := restNote(rest, dotted, tempo)\n\t\t\t\t\tif bufRest != nil {\n\t\t\t\t\t\tif voice.NaturalVoice() {\n\t\t\t\t\t\t\treleaseNote(sustain.buf, 0, sustain.Ratio())\n\t\t\t\t\t\t\tmixSoundWave(bufRest, sustain.buf)\n\t\t\t\t\t\t\tclearBuffer(sustain.buf)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbufWave = append(bufWave, bufRest...)\n\t\t\t\t\t}\n\t\t\t\t\trest = 0\n\t\t\t\t}\n\t\t\t\tctrl = 0\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch hand {\n\t\t\tcase '0': // octave 0\n\t\t\t\thandLevel = 1000\n\t\t\tcase 'L': // octave 1, 2, 3\n\t\t\t\thandLevel = 2000\n\t\t\tcase 'R': // octave 4, 5, 6\n\t\t\t\thandLevel = 3000\n\t\t\tcase '7', '8': // octave 7, 8\n\t\t\t\thandLevel = 4000\n\t\t\t}\n\t\t\tnote := &Note{\n\t\t\t\tkey: handLevel + key,\n\t\t\t\tvolume: volume,\n\t\t\t\tamplitude: amplitude,\n\t\t\t\tduration: duration,\n\t\t\t\tdotted: dotted,\n\t\t\t\ttempo: tempo,\n\t\t\t\tsamples: 0,\n\t\t\t}\n\t\t\tnote.measure()\n\t\t\tif voice.GetNote(note, sustain) {\n\t\t\t\tdotted = false\n\t\t\t\tif chord.number > 0 {\n\t\t\t\t\t// playing a chord\n\t\t\t\t\tchord.count++\n\t\t\t\t\tif chord.buf == nil {\n\t\t\t\t\t\tchord.buf = make([]int16, len(note.buf))\n\t\t\t\t\t\tcopy(chord.buf, note.buf)\n\t\t\t\t\t\tif voice.NaturalVoice() {\n\t\t\t\t\t\t\t//copyBuffer(sustain.buf, chord.buf)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmixSoundWave(chord.buf, note.buf)\n\t\t\t\t\t\tif voice.NaturalVoice() {\n\t\t\t\t\t\t\t//mixSoundWave(sustain.buf, note.buf)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif chord.count == chord.number {\n\t\t\t\t\t\tif voice.NaturalVoice() {\n\t\t\t\t\t\t\trelease := len(note.buf) / 10 * sustain.sustain\n\t\t\t\t\t\t\tratio := sustain.Ratio()\n\t\t\t\t\t\t\treleaseNote(sustain.buf, release, ratio)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnote.buf = chord.buf\n\t\t\t\t\t\tchord.Reset()\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif PrintNotes {\n\t\t\t\t\t\t\tfmt.Printf(\"%v-\", m.piano.keyNoteMap[note.key])\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvoice.SustainNote(note, sustain)\n\t\t\t\tbufWave = append(bufWave, note.buf...)\n\t\t\t\tif len(bufWave) > bufWaveLimit {\n\t\t\t\t\tfmt.Fprintln(os.Stderr, \"Line wave buffer exceeds 100MB limit.\")\n\t\t\t\t\tos.Exit(1)\n\t\t\t\t}\n\t\t\t\tif PrintNotes {\n\t\t\t\t\tfmt.Printf(\"%v \", m.piano.keyNoteMap[note.key])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvoiceName := strings.Split(fmt.Sprintf(\"%T\", voice), \".\")[1]\n\t\t\t\tnoteName := m.piano.keyNoteMap[note.key]\n\t\t\t\tfmt.Printf(\"%s: Invalid note: %s (%s)\\n\", voiceName, keystr, noteName)\n\t\t\t}\n\t\t}\n\t\tif mixNextLine {\n\t\t\tif bufMix == nil {\n\t\t\t\tbufMix = make([]int16, len(bufWave))\n\t\t\t\tcopy(bufMix, bufWave)\n\t\t\t\tlineMix = line\n\t\t\t} else {\n\t\t\t\tlineMix += \"\\n\" + line\n\t\t\t\tmixSoundWave(bufMix, bufWave)\n\t\t\t}\n\t\t\tcount++\n\t\t\tclearBuffer(sustain.buf)\n\t\t\tcontinue\n\t\t}\n\t\tif bufMix != nil {\n\t\t\tmixSoundWave(bufMix, bufWave)\n\t\t\tbufWave = bufMix\n\t\t\tbufMix = nil\n\t\t\tline = lineMix + \"\\n\" + line\n\t\t}\n\t\tif PrintNotes {\n\t\t\tfmt.Println()\n\t\t}\n\t\tif outputFile == nil {\n\t\t\tif len(bufWave) > 0 {\n\t\t\t\tif waitNext {\n\t\t\t\t\tm.WaitLine() // wait until previous line is done playing\n\t\t\t\t}\n\t\t\t\t// prepare next line while playing\n\t\t\t\tgo m.Playback(bufWave, bufWave)\n\t\t\t\tif PrintSheet {\n\t\t\t\t\tfmt.Println(line)\n\t\t\t\t}\n\t\t\t\twaitNext = true\n\t\t\t} else if PrintSheet {\n\t\t\t\tfmt.Println(line)\n\t\t\t}\n\t\t} else {\n\t\t\t// saving to file\n\t\t\tbuf := make([]int16, 2*len(bufWave))\n\t\t\tfor i, bar := range bufWave {\n\t\t\t\tbuf[i*2] = bar\n\t\t\t\tbuf[i*2+1] = bar\n\t\t\t}\n\t\t\tbufOutput = append(bufOutput, buf...)\n\t\t\tif PrintSheet {\n\t\t\t\tfmt.Println(line)\n\t\t\t}\n\t\t}\n\t\tclearBuffer(sustain.buf)\n\t\tcount++\n\t\tif m.stopping {\n\t\t\tbreak\n\t\t}\n\t}\n\tif waitNext {\n\t\tm.WaitLine()\n\t}\n\n\tif outputFile != nil {\n\t\t// save wave to file\n\t\tbuflen := len(bufOutput)\n\t\theader := NewWaveHeader(2, SampleRate, 16, buflen*2)\n\t\t_, err = header.WriteHeader(outputFile)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, \"Error writing to output file:\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tbuf := int16ToByteBuf(bufOutput)\n\t\t_, err := outputFile.Write(buf)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, \"Error writing to output file:\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tif outputFileName != \"-\" {\n\t\t\tfmt.Printf(\"wrote %s bytes to '%s'\\n\", numberComma(int64(len(buf))), outputFileName)\n\t\t}\n\t}\n}", "func (o AlarmContactOutput) ChannelsSms() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AlarmContact) pulumi.StringPtrOutput { return v.ChannelsSms }).(pulumi.StringPtrOutput)\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func (r *RecordStream) Channels() int {\n\treturn int(r.createReply.Channels)\n}", "func (r *Report) setupReportFormat(format string) {\n\tswitch format {\n\tcase \"simple\":\n\t\tsetupSimpleReport(r)\n\tcase \"template\":\n\t\tsetupTemplateReport(r)\n\tcase \"json\":\n\t\tsetupJSONReport(r)\n\tcase \"dyff\":\n\t\tsetupDyffReport(r)\n\tdefault:\n\t\tsetupDiffReport(r)\n\t}\n}", "func ConvDataFormat(value string) ConvAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"data_format\"] = value\n\t}\n}", "func (c *Sound) Unmarshal(data map[string]interface{}) {\n\tc.Component.Unmarshal(data)\n\tc.Filename = data[\"format\"].(string)\n\tc.Format = int(data[\"format\"].(float64))\n}", "func (f *File) Play() error {\n\t// initialize the underlying APIs for audio transmission\n\tportaudio.Initialize()\n\tdefer portaudio.Terminate()\n\n\t// create a buffer for audio to be put into\n\t// hardcode 16-bit sample until i figure out a better way to do this\n\tbufLen := int(BufSize * f.AudioData.NumChannels)\n\tbuf := make([]int16, bufLen)\n\n\t// create the audio stream to write to\n\tstream, err := portaudio.OpenDefaultStream(0, int(f.AudioData.NumChannels), float64(f.AudioData.SampleRate), BufSize, buf)\n\tif err != nil {\n\t\treturn errors.NewFromErrorCodeInfo(errors.AudioFileOutputStreamNotOpened, err.Error())\n\t}\n\tdefer stream.Close()\n\tdefer stream.Stop()\n\tstream.Start()\n\n\t// get audio data (without WAV header)\n\tdata := f.AudioData.AudioData()\n\tstep := bufLen * 2 // *2 since we need twice as many bytes to fill up `bufLen` in16s\n\n\tf.playing = true\n\tdefer func() { f.playing = false }()\n\n\tfor i := 0; i < len(data); i += step {\n\t\t// check if we should stop (user called f.Stop())\n\t\tif f.shouldStop {\n\t\t\tf.shouldStop = false\n\t\t\tbreak\n\t\t}\n\t\t// need to convert each 2-bytes in [i, i+step] to 1 little endian int16\n\t\tfor j := 0; j < bufLen; j++ {\n\t\t\tk := j * 2\n\t\t\tbuf[j] = int16(binary.LittleEndian.Uint16(data[i+k : i+k+2]))\n\t\t}\n\t\t// write the converted data into the stream\n\t\terr := stream.Write()\n\t\tif err != nil {\n\t\t\treturn errors.NewFromErrorCodeInfo(errors.AudioFileNotWritableStream, err.Error())\n\t\t}\n\t}\n\n\treturn nil\n}", "func DataFormatVecPermuteDstFormat(value string) DataFormatVecPermuteAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"dst_format\"] = value\n\t}\n}", "func TestSetFormat(t *testing.T) {\n\ttestFormat := \"15:04\"\n\tout := strings.Builder{}\n\tSetOutput(&out)\n\tSetLevelStr(\"FATAL\")\n\tSetTimeFormat(testFormat)\n\tt.Run(\"test setting of time format\", func(t *testing.T) {\n\t\tcurrentTime := time.Now().Format(testFormat)\n\t\tprintAllLevels(\"test format\")\n\t\tif strings.Count(out.String(), \" \"+currentTime+\" \") != 2 {\n\t\t\tt.Errorf(\"Log should contain time in format '%s':\\n%v\", testFormat, out.String())\n\t\t}\n\t})\n\tSetTimeFormat(DefaultTimeFormat)\n}", "func DecodeWavDesiredChannels(value int64) DecodeWavAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"desired_channels\"] = value\n\t}\n}", "func Conv3DDataFormat(value string) Conv3DAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"data_format\"] = value\n\t}\n}", "func (instance *Instance) SetFloat32(fieldName string, value float32) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func IsFormatSupported(p StreamParameters, args ...interface{}) error {\n\ts := &Stream{}\n\terr := s.init(p, args...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn newError(C.Pa_IsFormatSupported(s.inParams, s.outParams, C.double(p.SampleRate)))\n}", "func (w *wavData) writeNote(note string, time float32, amplitude float32, channels []int, blend bool, reset bool, relativeDuration int) {\n\tvar (\n\t\tnumChannels = w.numChannels\n\t\tsampleRate = w.sampleRate\n\n\t\t// to prevent sound artifacts\n\t\tfadeSeconds float32 = 0.001\n\n\t\t// calculating properties of given note\n\t\tsemitone, _ = semitoneFromNote(note)\n\t\tfrequency = float32(frequencyFromSemitone(semitone)) * math.Pi * 2 / float32(sampleRate)\n\n\t\t// amount of blocks to be written\n\t\tblocksOut = int(math.Round(float64(sampleRate) * float64(time)))\n\t\t// reduces sound artifacts by fading at last fadeSeconds\n\t\tnonZero = float32(blocksOut) - float32(sampleRate)*fadeSeconds\n\t\t// fade interval in samples\n\t\tfade = float32(sampleRate)*fadeSeconds + 1\n\n\t\t// index of start and stop samples\n\t\tstart = int(w.pointer)\n\t\tstop = len(w.data)\n\n\t\t// k = cached index of data\n\t\t// d = sample data value\n\t\tk int\n\t\td float32\n\t)\n\n\t// by default write to all channels\n\tif len(channels) == 0 {\n\t\tfor i := 0; i < int(numChannels); i++ {\n\t\t\tchannels = append(channels, i)\n\t\t}\n\t}\n\n\tskipChannels := make([]bool, numChannels)\n\tfor i := 0; i < len(skipChannels); i++ {\n\t\tskipChannels[i] = channels[i] == -1\n\t}\n\n\t// update existing data\n\tfor i := 0; i < blocksOut; i++ {\n\t\t// iterate through specified channels\n\t\tfor j := 0; j < len(channels); j++ {\n\t\t\tk = start + i*int(numChannels) + channels[j]\n\t\t\td = 0\n\n\t\t\tif frequency > 0 {\n\t\t\t\td = amplitude * float32(math.Sin(float64(frequency)*float64(i)))\n\t\t\t\tif float32(i) < fade {\n\t\t\t\t\td *= float32(i) / fade\n\t\t\t\t} else if float32(i) > nonZero {\n\t\t\t\t\td *= float32(blocksOut-i+1) / fade\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif blend {\n\t\t\t\tw.data[k] = d + w.data[k]\n\t\t\t} else {\n\t\t\t\tw.data[k] = d\n\t\t\t}\n\t\t}\n\t}\n\n\tend := maxInt(start+blocksOut*int(numChannels), stop) * (w.bitsPerSample >> 3)\n\tw.chunkSize = uint32(end + len(w.header) - 8)\n\tw.subChunk2Size = uint32(end)\n\n\tbinary.LittleEndian.PutUint32(w.header[4:8], w.chunkSize)\n\tbinary.LittleEndian.PutUint32(w.header[40:44], w.subChunk2Size)\n\n\tif !reset {\n\t\tw.pointer = uint(start + blocksOut*int(numChannels))\n\t}\n}", "func (s *Sink) Samplerate() uint {\n\treturn s.samplerate\n}", "func downmixMultipleSamplesToMono(samples []int16, channels int) (newSamples []int16) {\n\tnewSamples = make([]int16, len(samples)/channels)\n\tfor i := 0; i < len(samples); i++ {\n\t\toldSample := samples[i : i+channels]\n\t\tnewSamples[i/channels] = downmixSingleSampleToMono(oldSample...)\n\t}\n\treturn\n}" ]
[ "0.5295923", "0.5125696", "0.5005388", "0.47287038", "0.4358399", "0.4321472", "0.42238", "0.42012027", "0.41856876", "0.4119033", "0.41061252", "0.40895164", "0.40395626", "0.4019459", "0.40040785", "0.39999402", "0.39751828", "0.396199", "0.39446145", "0.3919544", "0.38918856", "0.38766477", "0.38611555", "0.38588157", "0.38560784", "0.38299218", "0.38097507", "0.3804753", "0.37810406", "0.3777731", "0.37707087", "0.3746518", "0.372231", "0.37219507", "0.371498", "0.37113276", "0.37096205", "0.3698899", "0.36921233", "0.36782995", "0.36645803", "0.36593", "0.36567482", "0.36380342", "0.361681", "0.36158398", "0.36133143", "0.36110336", "0.36054158", "0.36042264", "0.35915533", "0.35865363", "0.358365", "0.35726604", "0.3570535", "0.3559009", "0.3554444", "0.35512125", "0.3546217", "0.35450587", "0.35449922", "0.35380572", "0.35362667", "0.35353908", "0.35353085", "0.35295314", "0.35293883", "0.3525446", "0.35101148", "0.3503077", "0.3502863", "0.34998515", "0.3494123", "0.3494123", "0.34893134", "0.34883907", "0.3484148", "0.34793988", "0.34763643", "0.34726498", "0.34661055", "0.34659824", "0.34588933", "0.3452482", "0.34524438", "0.34510073", "0.34500307", "0.34490004", "0.3448094", "0.34469146", "0.34407285", "0.34395778", "0.34187824", "0.3418626", "0.34179854", "0.3415385", "0.3407813", "0.34057227", "0.34050435", "0.3400406" ]
0.6834549
0
Gets the input signal format for a dsp units read/process callback, to determine which speakers the signal will be processed on and how many channels will be processed. source_speakermode is informational, when channelmask describes what bits are active, and numchannels describes how many channels are in a buffer, source_speakermode describes where the channels originated from. For example if numchannels = 2 then this could describe for the DSP if the original signal started from a stereo signal or a 5.1 signal. In the 5.1 signal the channels described might only represent 2 surround speakers for example.
func (d *DSP) ChannelFormat() (ChannelMask, int, SpeakerMode, error) { var channelmask C.FMOD_CHANNELMASK var numchannels C.int var source_speakermode C.FMOD_SPEAKERMODE res := C.FMOD_DSP_GetChannelFormat(d.cptr, &channelmask, &numchannels, &source_speakermode) return ChannelMask(channelmask), int(numchannels), SpeakerMode(source_speakermode), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Format) Channels() int {\n\treturn f.channels\n}", "func (d *DSP) OutputChannelFormat(inmask ChannelMask, inchannels int, inspeakermode SpeakerMode) (ChannelMask, int, SpeakerMode, error) {\n\tvar outmask C.FMOD_CHANNELMASK\n\tvar outchannels C.int\n\tvar outspeakermode C.FMOD_SPEAKERMODE\n\tres := C.FMOD_DSP_GetOutputChannelFormat(d.cptr, C.FMOD_CHANNELMASK(inmask), C.int(inchannels), C.FMOD_SPEAKERMODE(inspeakermode), &outmask, &outchannels, &outspeakermode)\n\treturn ChannelMask(outmask), int(outchannels), SpeakerMode(outspeakermode), errs[res]\n}", "func determineFormat(channels int) int {\n\tswitch channels {\n\tcase 1:\n\t\treturn gl.RED\n\tcase 2:\n\t\treturn gl.RG\n\tcase 3:\n\t\treturn gl.RGB\n\tcase 4:\n\t\treturn gl.RGBA\n\t}\n\treturn gl.RGBA\n}", "func readHeaderFormat(reader *bytes.Reader) (*formatHeader, error) {\n\thdrFormat := formatHeader{}\n\terr := binary.Read(reader, binary.LittleEndian, &hdrFormat)\n\n\t/*\n\t * Check if format header was read.\n\t */\n\tif err != nil {\n\t\tmsg := err.Error()\n\t\treturn nil, fmt.Errorf(\"Failed to read format header: %s\", msg)\n\t} else {\n\t\tchunkId := hdrFormat.ChunkID\n\t\tchannelCount := hdrFormat.ChannelCount\n\t\tbitDepth := hdrFormat.BitDepth\n\t\tsampleRate := hdrFormat.SampleRate\n\t\tframeSize := channelCount * bitDepth\n\t\texpectedBlockAlign32 := uint32(frameSize / BITS_PER_BYTE)\n\t\texpectedBlockAlign16 := uint16(expectedBlockAlign32)\n\t\texpectedByteRate := expectedBlockAlign32 * sampleRate\n\t\tchunkSize := hdrFormat.ChunkSize\n\t\tchunkSize64 := int64(chunkSize)\n\t\tnumBytesSkip := chunkSize64 - MIN_CHUNK_SIZE_FORMAT\n\t\taudioFormat := hdrFormat.AudioFormat\n\t\tbyteRate := hdrFormat.ByteRate\n\t\tblockAlign := hdrFormat.BlockAlign\n\n\t\t/*\n\t\t * Skip optional fields in the format header.\n\t\t */\n\t\tif numBytesSkip > 0 {\n\n\t\t\t/*\n\t\t\t * If this is even, we need to skip one more.\n\t\t\t */\n\t\t\tif (numBytesSkip % 2) == 0 {\n\t\t\t\tnumBytesSkip += 1\n\t\t\t}\n\n\t\t\tamount := uint64(numBytesSkip)\n\t\t\tskipData(reader, amount)\n\t\t}\n\n\t\t/*\n\t\t * Check format header for validity.\n\t\t */\n\t\tif chunkId != ID_FORMAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid chunk id. Expected %#08x, found %#08x.\", ID_FORMAT, chunkId)\n\t\t} else if chunkSize < MIN_CHUNK_SIZE_FORMAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid chunk size. Expected at least %#08x, found %#08x.\", MIN_CHUNK_SIZE_FORMAT, chunkSize)\n\t\t} else if audioFormat != AUDIO_PCM && audioFormat != AUDIO_IEEE_FLOAT {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid audio format. Expected %#04x or %#04x, found %#04x.\", AUDIO_PCM, AUDIO_IEEE_FLOAT, audioFormat)\n\t\t} else if byteRate != expectedByteRate {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid byte rate. Expected %#08x, found %#08x.\", expectedByteRate, byteRate)\n\t\t} else if blockAlign != expectedBlockAlign16 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid block align. Expected %#04x, found %#04x.\", expectedBlockAlign16, blockAlign)\n\t\t} else if audioFormat == AUDIO_PCM && bitDepth != 8 && bitDepth != 16 && bitDepth != 24 && bitDepth != 32 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid bit depth for PCM format. Expected %#04x or %#04x or %#04x or %#04x, found %#04x.\", 8, 16, 24, 32, bitDepth)\n\t\t} else if audioFormat == AUDIO_IEEE_FLOAT && bitDepth != 32 && bitDepth != 64 {\n\t\t\treturn nil, fmt.Errorf(\"Format header contains invalid bit depth for IEEE floating-point format. Expected %#04x or %#04x, found %#04x.\", 32, 64, bitDepth)\n\t\t} else {\n\t\t\treturn &hdrFormat, nil\n\t\t}\n\n\t}\n\n}", "func (obj *Device) GetStreamSourceFreq(\n\tstreamNumber uint,\n) (divider uint32, err Error) {\n\tret, _, _ := syscall.Syscall(\n\t\tobj.vtbl.GetStreamSourceFreq,\n\t\t3,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(streamNumber),\n\t\tuintptr(unsafe.Pointer(&divider)),\n\t)\n\terr = toErr(ret)\n\treturn\n}", "func (d *DSP) SetChannelFormat(channelmask ChannelMask, numchannels int, source_speakermode SpeakerMode) error {\n\tres := C.FMOD_DSP_SetChannelFormat(d.cptr, C.FMOD_CHANNELMASK(channelmask), C.int(numchannels), C.FMOD_SPEAKERMODE(source_speakermode))\n\treturn errs[res]\n}", "func (p *decoded) Channels() int {\n\treturn 2\n}", "func NewAudioSource(c *Config) (*AudioSource, error) {\n\t// create the command and start it, but don't read from the stdout yet.\n\t// not until we attach the listener\n\t// should we do the spectrum analysis here? or raw samples.\n\t// we need to support time-based analysis or just frequency\n\t// based. I only want frequency, but maybe the \"Sample\"\n\t// type should actually be a type with methods for \"TimeDomainAnalysis\"\n\t// and \"FrequencyDomainAnalysis\" and we just call whichever one...\n\t// that way I can implement the FrequencyDomainAnalysis first.\n\t// but first.\n\n\t// we can\n\tcmd := exec.Command(c.FFMpegPath,\n\t\t\"-i\", c.AudioFile, //our audio file\n\t\t\"-vn\", // no video\n\t\t\"-ar\", strconv.Itoa(samplingRate), // get sampling rate\n\t\t\"-ac\", \"1\", //mono\n\t\t\"-f\", \"f64be\", // raw f64 output\n\t\t\"-c:a\", \"pcm_f64be\", // we can get ffmpeg to output float64 data!\n\t\t\"-\", // output to stdout\n\t)\n\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tas := &AudioSource{\n\t\tCmd: cmd,\n\t\tsamplesPerFrame: samplingRate / c.FPS,\n\t\tstdout: stdout,\n\t}\n\n\treturn as, cmd.Start()\n}", "func (r *RecordStream) Channels() int {\n\treturn int(r.createReply.Channels)\n}", "func (c *Sound) GetFormat() int {\n\treturn c.Format\n}", "func (info TrackInfo) NChannels() int {\n\t// bit 28 - 1 = stereo audio; 0 = mono audio\n\tif info&0x10000000 != 0 {\n\t\t// stero audio.\n\t\treturn 2\n\t}\n\t// mono audio.\n\treturn 1\n}", "func extractSampleRate(data []byte) uint32 {\n\t// Skip 40 bits (28 of the OGG header + 12 of the Opus header) and read the\n\t// next 4 bits to extract the sample rate as an int.\n\tif len(data) < 44 {\n\t\tlog.Panicf(\"unexpected data length: %v\", len(data))\n\t}\n\n\treturn binary.LittleEndian.Uint32(data[40:44])\n}", "func (audio *Audio) Channels() int {\n\treturn audio.channels\n}", "func (e *Engine) SetInputChannels(numberOfChannels int) error {\n\tif !e.initialized {\n\t\treturn errorEngineNotInitialized\n\t}\n\t// return error if the input device does not exist\n\tif e.streamParameters.Input.Device == nil {\n\t\treturn errorDeviceDoesNotExist\n\t}\n\t// error if numberOfChannels is not mono or stereo\n\t// or if we are assigning stereo to a mono only device\n\tunsupportedNumberOfChannels := (numberOfChannels < 1) || (numberOfChannels > 2) ||\n\t\t(numberOfChannels == 2 && e.streamParameters.Input.Device.MaxInputChannels == 1)\n\tif unsupportedNumberOfChannels {\n\t\treturn errorUnsupportedNumberOfChannels\n\t}\n\t// successfully assign (a correct) number of channels\n\te.streamParameters.Input.Channels = numberOfChannels\n\treturn nil\n}", "func (p *Pump) WavNumChannels() phono.NumChannels {\n\treturn p.wavNumChannels\n}", "func reader() {\n\n\tvar err error\n\n\tdefer func() {\n\t\tclose(EncodeChan)\n\t\tWaitGroup.Done()\n\t}()\n\n\t// Create a 16KB input buffer\n\tstdin := bufio.NewReaderSize(os.Stdin, 16384)\n\n\t// Loop over the stdin input and pass the data to the encoder.\n\tfor {\n\n\t\tbuf := make([]int16, AudioFrameSize*AudioChannels)\n\n\t\terr = binary.Read(stdin, binary.LittleEndian, &buf)\n\t\tif err == io.EOF {\n\t\t\t// Okay! There's nothing left, time to quit.\n\t\t\treturn\n\t\t}\n\n\t\tif err == io.ErrUnexpectedEOF {\n\t\t\t// Well there's just a tiny bit left, lets encode it, then quit.\n\t\t\tEncodeChan <- buf\n\t\t\treturn\n\t\t}\n\n\t\tif err != nil {\n\t\t\t// Oh no, something went wrong!\n\t\t\tlog.Println(\"error reading from stdin,\", err)\n\t\t\treturn\n\t\t}\n\n\t\t// write pcm data to the EncodeChan\n\t\tEncodeChan <- buf\n\t}\n\n}", "func (o *AudioStreamSample) GetMixRate() gdnative.Int {\n\t//log.Println(\"Calling AudioStreamSample.GetMixRate()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"AudioStreamSample\", \"get_mix_rate\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (j *JustAddPowerReciever) AudioVideoInputs(ctx context.Context) (map[string]string, error) {\n\ttoReturn := make(map[string]string)\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", j.Address)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tj.Log.Debug(\"ip address\", zap.Any(\"IP\", ipAddress.IP))\n\n\tif err != nil {\n\t\treturn toReturn, fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", j.Address, err)\n\t}\n\n\tresult, err := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/details/channel\", j.Address), \"\", \"GET\")\n\n\tif err != nil {\n\t\tj.Log.Debug(\"error when making request\", zap.Error(err))\n\t\treturn toReturn, fmt.Errorf(\"error when making request: %w\", err)\n\t}\n\n\tvar jsonResult JustAddPowerChannelIntResult\n\tgerr := json.Unmarshal(result, &jsonResult)\n\tif gerr != nil {\n\t\tj.Log.Debug(\"error unmarshaling response\", zap.Error(gerr))\n\t\treturn toReturn, fmt.Errorf(\"error when unmarshaling response: %w\", gerr)\n\t}\n\n\tj.Log.Debug(\"Result\", zap.Any(\"result\", result), zap.Any(\"jsonResult\", jsonResult))\n\tj.Log.Debug(\"len of IP\", zap.Int(\"lenght\", len(ipAddress.IP)))\n\n\ttransmissionChannel := fmt.Sprintf(\"%v.%v.%v.%v\",\n\t\tipAddress.IP[0], ipAddress.IP[1], ipAddress.IP[2], jsonResult.Data)\n\n\ttoReturn[\"\"] = transmissionChannel\n\treturn toReturn, nil\n}", "func Format() audio.Format {\n\treturn format\n}", "func convertToOpusFrames(videoBuf *bytes.Buffer, start string, duration string) ([][]byte, error) {\n\trun := exec.Command(\"ffmpeg\", \"-i\", \"pipe:0\", \"-f\", \"s16le\", \"-ar\", strconv.Itoa(frameRate), \"-ac\", strconv.Itoa(channels), \"-ss\", start, \"-t\", duration, \"pipe:1\")\n\tffmpegOut, _ := run.StdoutPipe()\n\tffmpegIn, _ := run.StdinPipe()\n\n\tgo func() {\n\t\tdefer ffmpegIn.Close()\n\t\tffmpegIn.Write(videoBuf.Bytes())\n\t}()\n\n\tffmpegbuf := bufio.NewReader(ffmpegOut)\n\n\terr := run.Start()\n\tif err != nil {\n\t\treturn nil, errors.New(\"Error converting video\")\n\t}\n\n\topusEncoder, _ := gopus.NewEncoder(frameRate, channels, gopus.Audio)\n\topusFrames := make([][]byte, 0)\n\tfor {\n\t\t// CDF: This represents the bytes of a single frame. 20ms * 48 samples/ms * 2 channels * 2 bytes per sample\n\t\tframeBytes := make([]byte, frameSize*channels*2)\n\t\t_, err := io.ReadFull(ffmpegbuf, frameBytes)\n\t\t// If EOF or UnexpectedEOF is received, return all opusFrames because either all of the audio data was converted\n\t\t// into opusFrames or we have some audio data (<20ms) that won't fit into a valid opus frame so throw it away for now\n\t\tif err != nil {\n\t\t\treturn opusFrames, nil\n\t\t}\n\n\t\tbytesReader := bytes.NewReader(frameBytes)\n\t\tframeBuf := make([]int16, frameSize*channels)\n\t\terr = binary.Read(bytesReader, binary.LittleEndian, &frameBuf)\n\t\tif err != nil {\n\t\t\t// This branch should almost never be ran. The only time it could be is if the video data\n\t\t\t// fit perfectly into 20ms opus frames with no remaining data.\n\t\t\tfmt.Println(\"binary.Read EOF reached\")\n\t\t\treturn opusFrames, nil\n\t\t}\n\n\t\topusFrame, err := opusEncoder.Encode(frameBuf, frameSize, maxBytes)\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"Error encoding audio\")\n\t\t}\n\t\topusFrames = append(opusFrames, opusFrame)\n\t}\n}", "func (p Plexer) NumChannels() int {\n\treturn len(p.channels)\n}", "func (self *ToneSource) GetType() int {\n\treturn afp.PIPE_SOURCE\n}", "func (info TrackInfo) SampleRate() int {\n\t// bits 23-0 - audio sample rate\n\treturn int(info & 0xFFFFFF)\n}", "func (e *encoder) writeFmtChunk() error {\n\t// Chunk header\n\theader := fmtChunkHeader\n\tcopy(e.fmt.Header[:], header)\n\n\t// Size of this chunk\n\tsize := uint64(fmtChunkSize)\n\tbinary.LittleEndian.PutUint64(e.fmt.Size[:], size)\n\n\t// Format version\n\tformatVersion := uint32(fmtVersion)\n\tbinary.LittleEndian.PutUint32(e.fmt.Version[:], formatVersion)\n\n\t// Format id\n\tformatId := uint32(fmtIdentifier)\n\tbinary.LittleEndian.PutUint32(e.fmt.Identifier[:], formatId)\n\n\t// Channel type\n\tvar channelType uint32\n\tfor key, order := range fmtChannelOrder {\n\t\tif reflect.DeepEqual(e.audio.ChannelOrder, order) {\n\t\t\tchannelType = key\n\t\t}\n\t}\n\tif channelType == 0 {\n\t\tvar s string\n\t\tfor i, channel := range e.audio.ChannelOrder {\n\t\t\tif i < len(e.audio.ChannelOrder)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"fmt: unsupported channel ordering: %v\", s)\n\t}\n\tchannelTypeString, _ := fmtChannelType[channelType]\n\tbinary.LittleEndian.PutUint32(e.fmt.ChannelType[:], channelType)\n\n\t// Channel num\n\tchannelNum := uint32(e.audio.NumChannels)\n\tif channelNum > 1 && (channelNum != uint32(len(e.audio.ChannelOrder))) {\n\t\treturn fmt.Errorf(\"fmt: mismatch between num channels and channel order: %v, %v\", channelNum, e.audio.ChannelOrder)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.ChannelNum[:], channelNum)\n\n\t// SamplingFrequency\n\tsamplingFrequency := uint32(e.audio.SamplingFrequency)\n\tsamplingFrequencyString, ok := fmtSamplingFrequency[samplingFrequency]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: unsupported sampling frequency: %v\", samplingFrequency)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.SamplingFrequency[:], samplingFrequency)\n\n\t// Bits per sample\n\tbitsPerSample := uint32(e.audio.BitsPerSample)\n\t_, ok = fmtBitsPerSample[bitsPerSample]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: unsupported bits per sample: %v\", bitsPerSample)\n\t}\n\tbinary.LittleEndian.PutUint32(e.fmt.BitsPerSample[:], bitsPerSample)\n\n\t// SampleCount\n\n\t// Log the fields of the chunk (only active if a log output has been set)\n\te.logger.Print(\"\\nFmt Chunk\\n=========\\n\")\n\te.logger.Printf(\"Chunk header: %q\\n\", header)\n\te.logger.Printf(\"Size of this chunk: %v\\n\", size)\n\te.logger.Printf(\"Format version: %v\\n\", formatVersion)\n\te.logger.Printf(\"Format id: %v\\n\", formatId)\n\te.logger.Printf(\"Channel type: %v (%s)\\n\", channelType, channelTypeString)\n\te.logger.Printf(\"Channel num: %v\\n\", channelNum)\n\tif len(e.audio.ChannelOrder) > 1 {\n\t\tvar s string\n\t\tfor i, channel := range e.audio.ChannelOrder {\n\t\t\tif i < len(e.audio.ChannelOrder)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\te.logger.Printf(\"Channel order: %v\\n\", s)\n\t}\n\te.logger.Printf(\"Sampling frequency: %vHz (%s)\\n\", samplingFrequency, samplingFrequencyString)\n\te.logger.Printf(\"Bits per sample: %v\\n\", bitsPerSample)\n\n\t// Write the entire chunk in one go\n\terr := binary.Write(e.writer, binary.LittleEndian, &e.fmt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *Pump) WavAudioFormat() int {\n\treturn p.wavAudioFormat\n}", "func (e *Engine) streamCallback(in, out []float32) {\n\n\tvar left, right float64\n\n\t// if there are new playback events recently encountered append\n\t// them to the active playback events set\n\t//\n\t// NB. for some reason, we can only access activePlaybackEvents at a\n\t// rate of SampleRate / FramesPerBuffer hz (and more confusinhgly\n\t// FramesPerBuffer can vary with each call). This effectively creates\n\t// unlistenably amounts of stutter if the FramesPerBuffer is too high\n\t// (greater than 512 for 44100hz sample rate is already pushing it)\n\tfor i := 0; i < len(e.newPlaybackEvents); i++ {\n\t\te.activePlaybackEvents[<-e.newPlaybackEvents] = true\n\t}\n\n\t// for each (stereo interleaved) output frame\n\tfor n := 0; n < len(out); n += 2 {\n\t\t// clear the current output frame (to avoid explosive accumulation)\n\t\tout[n] = 0.0\n\t\tout[n+1] = 0.0\n\t\t// for each event in the active playback events\n\t\tfor playbackEvent, _ := range e.activePlaybackEvents {\n\t\t\t// accumulate a frame of audio from the event\n\t\t\t// into the output buffer's current frame\n\t\t\tleft, right = playbackEvent.tick()\n\t\t\tout[n] += float32(left)\n\t\t\tout[n+1] += float32(right)\n\t\t}\n\t}\n\n\t// monitor audio input (if not muted and device exists)\n\tif e.inputAmplitude != 0 && e.streamParameters.Input.Device != nil {\n\t\tswitch e.streamParameters.Input.Channels {\n\t\tcase 1:\n\t\t\t// mono\n\t\t\tfor n := 0; n < len(in); n++ {\n\t\t\t\tout[2*n] += in[n] * e.inputAmplitude\n\t\t\t\tout[2*n+1] += in[n] * e.inputAmplitude\n\t\t\t}\n\t\tcase 2:\n\t\t\t// stereo\n\t\t\tfor n := 0; n < len(in); n += 2 {\n\t\t\t\tout[n] += in[n] * e.inputAmplitude\n\t\t\t\tout[n+1] += in[n+1] * e.inputAmplitude\n\t\t\t}\n\t\t}\n\t}\n\n}", "func IsFormatSupported(p StreamParameters, args ...interface{}) error {\n\ts := &Stream{}\n\terr := s.init(p, args...)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn newError(C.Pa_IsFormatSupported(s.inParams, s.outParams, C.double(p.SampleRate)))\n}", "func (d *DSP) NumInputs() (int, error) {\n\tvar numinputs C.int\n\tres := C.FMOD_DSP_GetNumInputs(d.cptr, &numinputs)\n\treturn int(numinputs), errs[res]\n}", "func ParseFormat(r io.Reader, N int) (*Format, error) {\n\tif N < fmtStartChunkSize {\n\t\treturn nil, fmt.Errorf(\"format chunk too small: %d\", N)\n\t}\n\tbuf := make([]byte, N)\n\tn, e := r.Read(buf)\n\tif e != nil && e != io.EOF {\n\t\treturn nil, e\n\t}\n\tif n != N {\n\t\treturn nil, fmt.Errorf(\"only read %d/%d bytes of format\", n, N)\n\t}\n\ttag := binary.LittleEndian.Uint16(buf[:2])\n\tif tag != _TAG_PCM && tag != _TAG_FLOAT32 {\n\t\treturn nil, fmt.Errorf(\"tag isn't for PCM wav data: %d\", tag)\n\t}\n\tchannels := int(binary.LittleEndian.Uint16(buf[2:4]))\n\tfrq := int(binary.LittleEndian.Uint32(buf[4:8]))\n\tbps := binary.LittleEndian.Uint32(buf[8:12])\n\tblock := int(binary.LittleEndian.Uint16(buf[12:14]))\n\tbitDepth := binary.LittleEndian.Uint16(buf[14:16])\n\tif bps != uint32(frq)*uint32(block) {\n\t\treturn nil, fmt.Errorf(\"bytes per sec is %d not %d\", bps, frq*block)\n\t}\n\tif block*8 != int(bitDepth)*channels {\n\t\treturn nil, fmt.Errorf(\"block align %d != %d\", block, int(bitDepth)*channels/8)\n\t}\n\taFreq := freq.T(frq) * freq.Hertz\n\tif tag == _TAG_FLOAT32 {\n\t\tif N != fmtStartChunkSize+2 {\n\t\t\t//return nil, fmt.Errorf(\"warning, wav format chunk too short but has full Float32 spec\\n\")\n\t\t}\n\t\treturn &Format{channels: channels, freq: aFreq, Codec: sample.SFloat32L}, nil\n\t}\n\tif tag != _TAG_PCM {\n\t\treturn nil, fmt.Errorf(\"unsupported format tag: %d\", tag)\n\t}\n\tif N != fmtStartChunkSize {\n\t\treturn nil, fmt.Errorf(\"bad format chunk size: %d\", N)\n\t}\n\tvar f *Format\n\tswitch bitDepth {\n\tcase 8:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SByte}\n\tcase 16:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt16L}\n\tcase 24:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt24L}\n\tcase 32:\n\t\tf = &Format{channels: channels, freq: aFreq, Codec: sample.SInt32L}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported bit depth: %d\", bitDepth)\n\t}\n\treturn f, nil\n}", "func channelsToSamples(channels []Channel) []float64 {\n\tchannelCount := len(channels)\n\tchannelCount16 := uint16(channelCount)\n\tchannelCount32 := uint32(channelCount)\n\tsamplesByChannel := make([][]float64, channelCount)\n\tmaxSampleCount := uint32(0)\n\n\t/*\n\t * Iterate over all channels and extract the samples for each.\n\t */\n\tfor i, currentChannel := range channels {\n\t\tcurrentSamples := currentChannel.Floats()\n\t\tsampleCount := len(currentSamples)\n\t\tsampleCount32 := uint32(sampleCount)\n\t\tsamplesByChannel[i] = currentSamples\n\n\t\t/*\n\t\t * If we found a channel with more samples, make its sample\n\t\t * count the new longest channel sample count.\n\t\t */\n\t\tif sampleCount32 > maxSampleCount {\n\t\t\tmaxSampleCount = sampleCount32\n\t\t}\n\n\t}\n\n\ttotalSampleCount := channelCount32 * maxSampleCount\n\tdata := make([]float64, totalSampleCount)\n\n\t/*\n\t * Iterate over the samples to reorder them by time.\n\t */\n\tfor i := uint32(0); i < maxSampleCount; i++ {\n\n\t\t/*\n\t\t * Iterate over the channels and extract the current sample.\n\t\t */\n\t\tfor j := uint16(0); j < channelCount16; j++ {\n\t\t\tcurrentChannel := samplesByChannel[j]\n\t\t\tcurrentChannelLength := len(currentChannel)\n\t\t\tcurrentChannelLength32 := uint32(currentChannelLength)\n\t\t\tcurrentSample := float64(0.0)\n\n\t\t\t/*\n\t\t\t * If the channel is long enough, read the sample from it,\n\t\t\t * otherwise pad with zeroes.\n\t\t\t */\n\t\t\tif i < currentChannelLength32 {\n\t\t\t\tcurrentSample = currentChannel[i]\n\t\t\t}\n\n\t\t\tj32 := uint32(j)\n\t\t\toffset := (channelCount32 * i) + j32\n\t\t\tdata[offset] = currentSample\n\t\t}\n\n\t}\n\n\treturn data\n}", "func (*PhoneGroupCallStreamChannels) TypeName() string {\n\treturn \"phone.groupCallStreamChannels\"\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func InputSource(in Input) sound.Source {\n\treturn &chn{\n\t\tForm: in,\n\t\tin: in,\n\t\tch: in.C()}\n}", "func DepthwiseConv2dNativeBackpropInputDataFormat(value string) DepthwiseConv2dNativeBackpropInputAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"data_format\"] = value\n\t}\n}", "func NewFormat(chans int, freq freq.T, sc sample.Codec) *Format {\n\treturn &Format{\n\t\tchannels: chans,\n\t\tfreq: freq,\n\t\tCodec: sc}\n}", "func getProcessorFun(config Config) func(ctx processor.Context) error {\n\tformat := strings.ToLower(config.DebugFormat)\n\tif _, hasKey := validDebugFormats[format]; !hasKey {\n\t\tif format != \"\" {\n\t\t\tpanic(fmt.Sprintf(\"Wrong debug-format value: '%s'\", format))\n\t\t}\n\t}\n\n\treturn func(ctx processor.Context) error {\n\n\t\tinput := ctx.GetInputMessage(\"input\")\n\n\t\tswitch msg := input.(type) {\n\t\tcase *base.Bytes:\n\t\t\tfmt.Printf(\"%s\\n\", string(*msg))\n\n\t\tcase *base.Any:\n\t\t\tvar msgStr []byte\n\t\t\tvar err error\n\t\t\tswitch format {\n\t\t\tcase \"yaml\":\n\t\t\t\tfallthrough\n\t\t\tcase \"yml\":\n\t\t\t\tmsgStr, err = yaml.Marshal(msg)\n\t\t\t\tfmt.Printf(\"---\\n%s\", msgStr)\n\t\t\tcase \"json\":\n\t\t\t\tmsgStr, err = json.Marshal(msg)\n\t\t\t\tfmt.Printf(\"%s\\n\", msgStr)\n\t\t\tcase \"json-indent\":\n\t\t\t\tfallthrough\n\t\t\tdefault:\n\t\t\t\tmsgStr, err = json.MarshalIndent(msg, \"\", \" \")\n\t\t\t\tfmt.Printf(\"\\n%s\\n\", msgStr)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func GetConvolutionFilter(target uint32, format uint32, xtype uint32, image unsafe.Pointer) {\n C.glowGetConvolutionFilter(gpGetConvolutionFilter, (C.GLenum)(target), (C.GLenum)(format), (C.GLenum)(xtype), image)\n}", "func GetFileOpusData(filePath string, channels, opusFrameSize, sampleRate int) ([][]byte, error) {\n\tcmd := exec.Command(\"ffmpeg\", \"-i\", filePath, \"-f\", \"s16le\", \"-ar\", strconv.Itoa(sampleRate), \"-ac\", strconv.Itoa(channels), \"pipe:1\")\n\n\tcmdout, err := cmd.StdoutPipe()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpcmdata := bufio.NewReader(cmdout)\n\n\terr = cmd.Start()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// crate encoder to convert audio to opus codec\n\topusEncoder, err := opus.NewEncoder(sampleRate, channels, opus.AppVoIP)\n\n\tif err != nil {\n\t\treturn nil, errors.New(\"new opus encoder error\")\n\t}\n\n\topusOutput := make([][]byte, 0)\n\n\tfor {\n\t\t// read pcm data from ffmpeg stdout\n\t\taudiobuf := make([]int16, opusFrameSize*channels)\n\t\terr = binary.Read(pcmdata, binary.LittleEndian, &audiobuf)\n\n\t\tif err == io.EOF || err == io.ErrUnexpectedEOF {\n\t\t\treturn opusOutput, nil\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"error reading from ffmpeg stdout\")\n\t\t}\n\n\t\t// convert raw pcm to opus\n\t\topus := make([]byte, 1000)\n\t\tn, err := opusEncoder.Encode(audiobuf, opus)\n\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"encoding error\")\n\t\t}\n\n\t\t// append bytes to output\n\t\topusOutput = append(opusOutput, opus[:n])\n\t}\n}", "func (m *Muxer) CtxFormat() *avformat.Context {\n\treturn m.ctxFormat\n}", "func makeInputDevice(phaseSetting uint, ch <-chan int) func() int {\n\tcallCount := 0\n\treturn func() (n int) {\n\t\tdefer func() { callCount++ }()\n\t\tif callCount == 0 {\n\t\t\tn = int(phaseSetting)\n\t\t} else {\n\t\t\tn = <-ch\n\t\t}\n\t\treturn\n\t}\n}", "func Conv2DBackpropInputDataFormat(value string) Conv2DBackpropInputAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"data_format\"] = value\n\t}\n}", "func ConvertWav(fname string, sampleRate int, volume int) []int {\r\n var accum int\r\n var wavFormat, wavChannels, wavSamplesPerSec, wavBitsPerSample int\r\n var err error\r\n var pos, deltaPos float64\r\n \r\n fileData, err = ioutil.ReadFile(fname)\r\n if err != nil {\r\n utils.ERROR(\"Unable to read from \" + fname)\r\n }\r\n fileDataPos = 0\r\n \r\n s := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"RIFF\" {\r\n utils.ERROR(\"No RIFF tag found in \" + fname)\r\n }\r\n \r\n _ = getDword()\r\n \r\n s = string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"WAVE\" {\r\n utils.ERROR(\"No WAVE tag found in \" + fname)\r\n }\r\n\r\n dataSize := -1\r\n wavData := []float64{}\r\n \r\n // Read the chunks\r\n for {\r\n // Get the chunk ID\r\n if (fileDataPos + 3) >= len(fileData) {\r\n break\r\n }\r\n chunkId := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n\r\n // Get the chunk size\r\n chunkSize := getDword()\r\n \r\n if chunkId == \"fmt \" {\r\n wavFormat = getWord()\r\n wavChannels = getWord()\r\n wavSamplesPerSec = getDword()\r\n _ = getDword() // Average bytes per second\r\n _ = getWord() // Block alignment\r\n wavBitsPerSample = getWord()\r\n \r\n fileDataPos += chunkSize - 16\r\n \r\n if wavFormat != 1 || (wavBitsPerSample != 8 && wavBitsPerSample != 16) || wavChannels > 2 {\r\n utils.ERROR(\"Unsupported wav format in \" + fname)\r\n }\r\n \r\n deltaPos = 1.0\r\n if sampleRate > 0 {\r\n deltaPos = float64(wavSamplesPerSec) / float64(sampleRate)\r\n }\r\n pos = 1.0\r\n \r\n if deltaPos != 1.0 {\r\n utils.INFO(fmt.Sprintf(\"Resampling %s from %d to %d Hz\", fname, wavSamplesPerSec, sampleRate))\r\n }\r\n \r\n if wavChannels > 1 {\r\n utils.INFO(\"Converting sample to mono\")\r\n }\r\n \r\n if wavBitsPerSample != 8 {\r\n utils.INFO(\"Converting sample to 8-bit unsigned\")\r\n }\r\n \r\n } else if chunkId == \"data\" {\r\n dataSize = chunkSize\r\n \r\n utils.DEBUG(\"Found data chunk, bits=%d, channels=%d, chunk size=%d\", wavBitsPerSample, wavChannels, dataSize)\r\n \r\n sampleDiv := 0\r\n \r\n if wavBitsPerSample == 8 {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n fileDataPos++\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n accum += int(fileData[fileDataPos+1])\r\n fileDataPos += 2\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n } else {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0)\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 4\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0) + int(float64(getSword() + 32768) / 256.0) \r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n \r\n }\r\n\r\n } else {\r\n // Unhandled chunk type, just skip it.\r\n utils.DEBUG(\"Skipping unhandled WAV chunk \\\"%s\\\"\", chunkId)\r\n fileDataPos += chunkSize\r\n }\r\n }\r\n \r\n utils.INFO(fmt.Sprintf(\"Size of converted sample: %d bytes\", len(wavData)))\r\n \r\n wavDataInt := make([]int, len(wavData))\r\n for i := range wavData {\r\n wavDataInt[i] = int(math.Floor((wavData[i] * float64(volume)) / 100.0))\r\n }\r\n\r\n return wavDataInt\r\n}", "func (g *PhoneGroupCallStreamChannels) TypeInfo() tdp.Type {\n\ttyp := tdp.Type{\n\t\tName: \"phone.groupCallStreamChannels\",\n\t\tID: PhoneGroupCallStreamChannelsTypeID,\n\t}\n\tif g == nil {\n\t\ttyp.Null = true\n\t\treturn typ\n\t}\n\ttyp.Fields = []tdp.Field{\n\t\t{\n\t\t\tName: \"Channels\",\n\t\t\tSchemaName: \"channels\",\n\t\t},\n\t}\n\treturn typ\n}", "func (m *SnmpMetricCfg) GetValidConversions() ([]ConversionMode, ConversionMode, error) {\n\tswitch m.DataSrcType {\n\tcase \"INTEGER\",\n\t\t\"Integer32\",\n\t\t\"Gauge32\",\n\t\t\"UInteger32\",\n\t\t\"Unsigned32\":\n\t\treturn []ConversionMode{FLOAT, INTEGER}, INTEGER, nil\n\tcase \"Counter32\",\n\t\t\"Counter64\":\n\t\treturn []ConversionMode{FLOAT, INTEGER}, INTEGER, nil\n\tcase \"COUNTER32\",\n\t\t\"COUNTER64\",\n\t\t\"COUNTERXX\": // raw and cooked increment of Counter32\n\t\tif m.GetRate == true {\n\t\t\treturn []ConversionMode{FLOAT, INTEGER}, FLOAT, nil\n\t\t} else {\n\t\t\treturn []ConversionMode{FLOAT, INTEGER}, INTEGER, nil\n\t\t}\n\tcase \"TimeTicks\", \"TIMETICKS\": // raw and cooked to second of timeticks\n\t\treturn []ConversionMode{FLOAT, INTEGER}, INTEGER, nil\n\tcase \"BITSCHK\":\n\t\treturn []ConversionMode{FLOAT, INTEGER, BOOLEAN}, BOOLEAN, nil\n\tcase \"BITS\": // no conversion neeeded (not triggered)\n\t\treturn []ConversionMode{STRING}, STRING, nil\n\tcase \"ENUM\": // no conversion neeeded (not triggered)\n\t\treturn []ConversionMode{STRING}, STRING, nil\n\tcase \"OCTETSTRING\": // no conversion needed (not triggered)\n\t\treturn []ConversionMode{STRING, INTEGER}, STRING, nil\n\tcase \"OID\": // no conversion neeeded (not triggered)\n\t\treturn []ConversionMode{STRING}, STRING, nil\n\tcase \"HWADDR\", \"IpAddress\": // no conversion neeeded (not triggered)\n\t\treturn []ConversionMode{STRING}, STRING, nil\n\tcase \"STRINGPARSER\":\n\t\treturn []ConversionMode{FLOAT, INTEGER, BOOLEAN, STRING}, FLOAT, nil\n\tcase \"MULTISTRINGPARSER\": // no conversion needed\n\t\treturn []ConversionMode{NONE}, NONE, nil\n\tcase \"STRINGEVAL\":\n\t\treturn []ConversionMode{FLOAT, INTEGER, BOOLEAN, STRING}, FLOAT, nil\n\tcase \"CONDITIONEVAL\": // not conversion will be triggered\n\t\treturn []ConversionMode{INTEGER}, INTEGER, nil\n\tdefault:\n\t\treturn []ConversionMode{NONE}, NONE, errors.New(\"UnkNown DataSourceType:\" + m.DataSrcType + \" in metric Config \" + m.ID)\n\t}\n}", "func (pipe *pipe) SampleFormat() SampleFormat {\n\treturn pipe.format\n}", "func (*PhoneGroupCallStreamChannels) TypeID() uint32 {\n\treturn PhoneGroupCallStreamChannelsTypeID\n}", "func unaryExprReadChannels(unaryExpr *ast.UnaryExpr) []*ast.Ident {\n\tswitch x := unaryExpr.X.(type) {\n\tcase *ast.Ident:\n\t\t// e.g: `<-channel`\n\t\treturn []*ast.Ident{x}\n\tcase *ast.CallExpr:\n\t\t// e.g: `<-fn()`\n\t\t// todo: handle\n\t}\n\treturn nil\n}", "func (m *Mixer) Channels() ChannelConf {\n\treturn ChannelConf(C.al_get_mixer_channels((*C.ALLEGRO_MIXER)(m)))\n}", "func DecodeAndCropJpegChannels(value int64) DecodeAndCropJpegAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"channels\"] = value\n\t}\n}", "func bytesToSamples(data []byte, sampleFormat uint16, bitDepth uint16) ([]float64, error) {\n\n\t/*\n\t * Decide on the sample format.\n\t */\n\tswitch sampleFormat {\n\tcase AUDIO_PCM:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 8:\n\t\t\tres, err := bytesToSamplesLPCM8(data)\n\t\t\treturn res, err\n\t\tcase 16:\n\t\t\tres, err := bytesToSamplesLPCM16(data)\n\t\t\treturn res, err\n\t\tcase 24:\n\t\t\tres, err := bytesToSamplesLPCM24(data)\n\t\t\treturn res, err\n\t\tcase 32:\n\t\t\tres, err := bytesToSamplesLPCM32(data)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in LPCM format: %d\", bitDepth)\n\t\t}\n\n\tcase AUDIO_IEEE_FLOAT:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 32:\n\t\t\tres, err := bytesToSamplesIEEE32(data)\n\t\t\treturn res, err\n\t\tcase 64:\n\t\t\tres, err := bytesToSamplesIEEE64(data)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in IEEE floating-point format: %d\", bitDepth)\n\t\t}\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown sample format: %#04x\", sampleFormat)\n\t}\n\n}", "func GetFormat(src string) (Format, bool) {\n\t// is it a filename with an extension?\n\ttmp := filepath.Ext(src)\n\tisFile := true\n\t// fmt.Println(\"tmp\", tmp)\n\tif tmp == \"\" {\n\t\ttmp = src\n\t\tisFile = false\n\t}\n\n\tswitch tmp {\n\tcase \"\":\n\t\treturn FormatUnknown, isFile\n\n\tcase \"FZP\", \"fzp\", \".FZP\", \".fzp\":\n\t\treturn FormatFzp, isFile\n\n\tcase \"JSON\", \"json\", \".JSON\", \".json\":\n\t\treturn FormatJSON, isFile\n\n\tcase \"YAML\", \"yaml\", \"yml\", \".YAML\", \".yaml\", \".yml\":\n\t\treturn FormatYAML, isFile\n\n\tdefault:\n\t\treturn FormatNotSupported, isFile\n\t}\n}", "func (a *AudioData) ChannelCount() int {\n\treturn a.format.ChannelCount\n}", "func (snd *HwSound) step() (uint16, uint16) {\n\tvar lmix, rmix int64\n\tvar chbuf [4]int64\n\n\t// Master enable\n\tif snd.SndGCnt.Value&(1<<15) == 0 {\n\t\treturn uint16(snd.SndBias.Value), uint16(snd.SndBias.Value)\n\t}\n\n\tscans := []int{\n\t\thw.SCANCODE_0,\n\t\thw.SCANCODE_1,\n\t\thw.SCANCODE_2,\n\t\thw.SCANCODE_3,\n\t\thw.SCANCODE_4,\n\t\thw.SCANCODE_5,\n\t\thw.SCANCODE_6,\n\t\thw.SCANCODE_7,\n\t\thw.SCANCODE_8,\n\t\thw.SCANCODE_9,\n\t}\n\n\tkeys := hw.GetKeyboardState()\n\tmask := 0xFFFF\n\tpressed := 0\n\tfor i := 0; i < len(scans); i++ {\n\t\tif keys[scans[i]] != 0 {\n\t\t\tpressed |= 1 << uint(i)\n\t\t}\n\t}\n\tif pressed != 0 {\n\t\tmask = pressed\n\t}\n\n\tfor i := 0; i < 16; i++ {\n\t\tvar sample int64\n\n\t\tcntrl := snd.Ch[i].SndCnt.Value\n\t\tvoice := &snd.voice[i]\n\n\t\tif !voice.on {\n\t\t\tcontinue\n\t\t}\n\t\tif mask&(1<<uint(i)) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tvoice.tmr += cTimerStepPerSample\n\t\tfor voice.tmr >= 0x10000 {\n\t\t\tif voice.delay >= 0 {\n\t\t\t\tvoice.delay--\n\t\t\t} else {\n\t\t\t\tvoice.pos++\n\t\t\t}\n\t\t\tvoice.tmr = uint32(snd.Ch[i].SndTmr.Value) + (voice.tmr - 0x10000)\n\t\t}\n\t\tif voice.delay >= 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch voice.mode {\n\t\tcase kMode8bit:\n\t\t\tif int(voice.pos) >= len(voice.mem) {\n\t\t\t\tvoice.pos = voice.pos + snd.loopChannel(i) - uint(len(voice.mem))\n\t\t\t\tif voice.pos == kPosNoLoop {\n\t\t\t\t\tsnd.stopChannel(i)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tsample = int64(int8(voice.mem[voice.pos])) << 8\n\t\tcase kMode16bit, kModeAdpcm:\n\t\t\tif int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\tvoice.pos = voice.pos + snd.loopChannel(i) - uint(len(voice.mem)/2)\n\t\t\t\tif voice.pos == kPosNoLoop || int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\t\tsnd.stopChannel(i)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tsample = int64(int16(binary.LittleEndian.Uint16(voice.mem[voice.pos*2:])))\n\t\tcase kModePsgNoise:\n\t\t\tfor int(voice.pos*2+1) >= len(voice.mem) {\n\t\t\t\tvoice.pos -= uint(len(voice.mem)) / 2\n\t\t\t}\n\t\t\tsample = int64(int16(binary.LittleEndian.Uint16(voice.mem[voice.pos*2:])))\n\t\t}\n\n\t\t// Convert into fixed point to keep some precision\n\t\tsample <<= 8\n\n\t\t// Apply volume divider\n\t\tsample >>= voldiv[(cntrl>>8)&3]\n\n\t\t// Apply channel volume\n\t\tsample = mulvol64(sample, int64(cntrl&127))\n\n\t\tif i < 4 {\n\t\t\t// Save copy of channels used in capture\n\t\t\tchbuf[i] = sample\n\n\t\t\t// Check specific \"Channel 1/3 disable\" bit\n\t\t\tif i == 1 && snd.SndGCnt.Value&(1<<12) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif i == 3 && snd.SndGCnt.Value&(1<<13) != 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\t// Apply panning\n\t\tpan := int64((cntrl >> 16) & 127)\n\t\tlsample := mulvol64(sample, 127-pan)\n\t\trsample := mulvol64(sample, pan)\n\n\t\t// Mix\n\t\tlmix += int64(lsample)\n\t\trmix += int64(rsample)\n\t}\n\n\t// Handle capture\n\tfor i := 0; i < 2; i++ {\n\t\tcap := &snd.capture[i]\n\t\tif cap.on {\n\t\t\tvar sample int64\n\t\t\tif !cap.single {\n\t\t\t\tif i == 0 {\n\t\t\t\t\tsample = lmix\n\t\t\t\t} else {\n\t\t\t\t\tsample = rmix\n\t\t\t\t}\n\t\t\t\tif sample > 0x7FFF00 {\n\t\t\t\t\tsample = 0x7FFF00\n\t\t\t\t}\n\t\t\t\tif sample < -0x800000 {\n\t\t\t\t\tsample = -0x800000\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsample = chbuf[i*2]\n\t\t\t}\n\t\t\tif cap.add {\n\t\t\t\tpanic(\"capture with addition\")\n\t\t\t}\n\n\t\t\tcap.tmr += cTimerStepPerSample\n\t\t\tfor cap.tmr >= 0x10000 {\n\t\t\t\tif cap.bit8 {\n\t\t\t\t\tsnd.Bus.Write8(cap.wpos, uint8(sample>>16))\n\t\t\t\t\tcap.wpos++\n\t\t\t\t} else {\n\t\t\t\t\tsnd.Bus.Write16(cap.wpos, uint16(sample>>8))\n\t\t\t\t\tcap.wpos += 2\n\t\t\t\t}\n\n\t\t\t\tcap.tmr = uint32(cap.reset) + (cap.tmr - 0x10000)\n\t\t\t\tif cap.wpos >= *cap.regdad+*cap.reglen*4 {\n\t\t\t\t\tif cap.loop {\n\t\t\t\t\t\tcap.wpos = *cap.regdad\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcap.on = false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch (snd.SndGCnt.Value >> 8) & 3 {\n\tcase 1:\n\t\tlmix = chbuf[1]\n\tcase 2:\n\t\tlmix = chbuf[3]\n\tcase 3:\n\t\tlmix = chbuf[1] + chbuf[3]\n\t}\n\tswitch (snd.SndGCnt.Value >> 10) & 3 {\n\tcase 1:\n\t\trmix = chbuf[1]\n\tcase 2:\n\t\trmix = chbuf[3]\n\tcase 3:\n\t\trmix = chbuf[1] + chbuf[3]\n\t}\n\n\t// Apply master volume\n\tgvol := int64(snd.SndGCnt.Value & 127)\n\tlmix = mulvol64(lmix, gvol)\n\trmix = mulvol64(rmix, gvol)\n\n\t// Adjust volume after mixing\n\tlmix >>= 6\n\trmix >>= 6\n\n\t// Convert from fixed into integer (strip fraction)\n\tlmix >>= 8\n\trmix >>= 8\n\n\t// Bias\n\tlmix += int64(snd.SndBias.Value)\n\trmix += int64(snd.SndBias.Value)\n\n\t// Clamp\n\tif lmix < 0 {\n\t\tlmix = 0\n\t} else if lmix > 0x3FF {\n\t\tlmix = 0x3FF\n\t}\n\tif rmix < 0 {\n\t\trmix = 0\n\t} else if rmix > 0x3FF {\n\t\trmix = 0x3FF\n\t}\n\n\treturn uint16(lmix), uint16(rmix)\n}", "func DecodeJpegChannels(value int64) DecodeJpegAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"channels\"] = value\n\t}\n}", "func (s *Source) Samplerate() (n uint) {\n\ts.ifOpen(func() {\n\t\tn = uint(C.aubio_source_get_samplerate(s.s))\n\t})\n\treturn\n}", "func sampleFormat(p *profile.Profile, sampleIndex string, mean bool) (value, meanDiv sampleValueFunc, v *profile.ValueType, err error) {\n\tif len(p.SampleType) == 0 {\n\t\treturn nil, nil, nil, fmt.Errorf(\"profile has no samples\")\n\t}\n\tindex, err := p.SampleIndexByName(sampleIndex)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\tvalue = valueExtractor(index)\n\tif mean {\n\t\tmeanDiv = valueExtractor(0)\n\t}\n\tv = p.SampleType[index]\n\treturn\n}", "func convRate(baud int) (uint32, error) {\n\tv, ok := knownRates[baud]\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"unsupported baud rate: %v\", baud)\n\t}\n\treturn v, nil\n}", "func (m *Media) GetCalleeDevice()(DeviceInfoable) {\n return m.calleeDevice\n}", "func GetConvolutionFilter(target uint32, format uint32, xtype uint32, image unsafe.Pointer) {\n\tC.glowGetConvolutionFilter(gpGetConvolutionFilter, (C.GLenum)(target), (C.GLenum)(format), (C.GLenum)(xtype), image)\n}", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (d *decoder) readFmtChunk() error {\n\t// Read the entire chunk in one go\n\terr := binary.Read(d.reader, binary.LittleEndian, &d.fmt)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Chunk header\n\theader := string(d.fmt.Header[:])\n\tswitch header {\n\tcase fmtChunkHeader:\n\t\t// This is the expected chunk header\n\tcase dsdChunkHeader:\n\t\treturn fmt.Errorf(\"fmt: expected fmt chunk but found DSD chunk\")\n\tcase dataChunkHeader:\n\t\treturn fmt.Errorf(\"fmt: expected fmt chunk but found data chunk\")\n\tdefault:\n\t\treturn fmt.Errorf(\"fmt: bad chunk header: %q\\nfmt chunk: % x\", header, d.fmt)\n\t}\n\n\t// Size of this chunk\n\tsize := binary.LittleEndian.Uint64(d.fmt.Size[:])\n\tif size != fmtChunkSize {\n\t\treturn fmt.Errorf(\"fmt: bad chunk size: %v\\nfmt chunk: % x\", size, d.fmt)\n\t}\n\n\t// Format version\n\tformatVersion := binary.LittleEndian.Uint32(d.fmt.Version[:])\n\tif formatVersion != fmtVersion {\n\t\treturn fmt.Errorf(\"fmt: bad format version: %v\\nfmt chunk: % x\", formatVersion, d.fmt)\n\t}\n\n\t// Format id\n\tformatId := binary.LittleEndian.Uint32(d.fmt.Identifier[:])\n\tif formatId != fmtIdentifier {\n\t\treturn fmt.Errorf(\"fmt: bad format id: %v\\nfmt chunk: % x\", formatId, d.fmt)\n\t}\n\n\t// Channel Type\n\tchannelType := binary.LittleEndian.Uint32(d.fmt.ChannelType[:])\n\tchannelTypeString, ok := fmtChannelType[channelType]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad channel type: %v\\nfmt chunk: % x\", channelType, d.fmt)\n\t}\n\n\t// Channel order corresponding to the ChannelType field\n\torder, _ := fmtChannelOrder[channelType]\n\n\t// Channel num\n\tchannelNum := binary.LittleEndian.Uint32(d.fmt.ChannelNum[:])\n\t_, ok = fmtChannelNum[channelNum]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad channel num: %v\\nfmt chunk: % x\", channelNum, d.fmt)\n\t}\n\tif channelNum != uint32(len(order)) {\n\t\treturn fmt.Errorf(\"fmt: mismatch between channel type %v and channel num %v:\\nfmt chunk: % x\", channelType, channelNum, d.fmt)\n\t}\n\n\t// Sampling frequency\n\tsamplingFrequency := binary.LittleEndian.Uint32(d.fmt.SamplingFrequency[:])\n\tsamplingFrequencyString, ok := fmtSamplingFrequency[samplingFrequency]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad sampling frequency: %v\\nfmt chunk: % x\", samplingFrequency, d.fmt)\n\t}\n\n\t// Bits per sample\n\tbitsPerSample := binary.LittleEndian.Uint32(d.fmt.BitsPerSample[:])\n\t_, ok = fmtBitsPerSample[bitsPerSample]\n\tif !ok {\n\t\treturn fmt.Errorf(\"fmt: bad bits per sample: %v\\nfmt chunk: % x\", bitsPerSample, d.fmt)\n\t}\n\n\t// Sample count\n\tsampleCount := binary.LittleEndian.Uint64(d.fmt.SampleCount[:])\n\n\t// Block size per channel\n\tblockSize := binary.LittleEndian.Uint32(d.fmt.BlockSize[:])\n\tif blockSize != fmtBlockSize {\n\t\treturn fmt.Errorf(\"fmt: bad block size: %v\\nfmt chunk: % x\", blockSize, d.fmt)\n\t}\n\n\t// Reserved\n\treserved := binary.LittleEndian.Uint32(d.fmt.Reserved[:])\n\tif reserved != fmtReserved {\n\t\treturn fmt.Errorf(\"fmt: bad reserved bytes: %#x\\nfmt chunk: % x\", reserved, d.fmt)\n\t}\n\n\t// Log the fields of the chunk (only active if a log output has been set)\n\td.logger.Print(\"\\nFmt Chunk\\n=========\\n\")\n\td.logger.Printf(\"Chunk header: %q\\n\", header)\n\td.logger.Printf(\"Size of this chunk: %v bytes\\n\", size)\n\td.logger.Printf(\"Format version: %v\\n\", formatVersion)\n\td.logger.Printf(\"Format id: %v\\n\", formatId)\n\td.logger.Printf(\"Channel type: %v (%s)\\n\", channelType, channelTypeString)\n\td.logger.Printf(\"Channel num: %v\\n\", channelNum)\n\tif len(order) > 1 {\n\t\tvar s string\n\t\tfor i, channel := range order {\n\t\t\tif i < len(order)-1 {\n\t\t\t\ts += channel.String() + \", \"\n\t\t\t} else {\n\t\t\t\ts += channel.String()\n\t\t\t}\n\t\t}\n\t\td.logger.Printf(\"Channel order: %v\\n\", s)\n\t}\n\td.logger.Printf(\"Sampling frequency: %vHz (%s)\\n\", samplingFrequency, samplingFrequencyString)\n\td.logger.Printf(\"Bits per sample: %v\\n\", bitsPerSample)\n\td.logger.Printf(\"Sample count: %v\\n\", sampleCount)\n\td.logger.Printf(\"Block size per channel: %v bytes\\n\", blockSize)\n\n\t// Store the information that is useful\n\td.audio.Encoding = audio.DSD\n\td.audio.NumChannels = uint(channelNum)\n\td.audio.ChannelOrder = order\n\td.audio.SamplingFrequency = uint(samplingFrequency)\n\td.audio.BitsPerSample = uint(bitsPerSample)\n\td.audio.BlockSize = uint(blockSize)\n\n\t// Prepare the audio.Audio in d to hold the encoded samples\n\tlength := sampleCount\n\tif bitsPerSample == 1 {\n\t\tlength = (length + 7) / 8 // fit up to 8 samples into 1 byte\n\t}\n\tif (length % uint64(blockSize)) > 0 { // pad to the block size\n\t\tlength += uint64(blockSize) - (length % uint64(blockSize))\n\t}\n\tlength *= uint64(channelNum) // same amount for each channel\n\td.audio.EncodedSamples = make([]byte, length)\n\n\treturn nil\n}", "func (t *Track) extractCodec() {\n\tif t.isAudio {\n\t\tt.extractAudioCodec()\n\t} else {\n\t\tt.extractVideoCodec()\n\t}\n}", "func (this *signalGenerator) Process(in []float64, out []float64, sampleRate uint32) {\n\tthis.mutex.RLock()\n\tinputAmplitude, _ := this.getNumericValue(\"input_amplitude\")\n\tinputGain, _ := this.getNumericValue(\"input_gain\")\n\tsignalType, _ := this.getDiscreteValue(\"signal_type\")\n\tsignalFrequency, _ := this.getNumericValue(\"signal_frequency\")\n\tsignalAmplitude, _ := this.getNumericValue(\"signal_amplitude\")\n\tsignalGain, _ := this.getNumericValue(\"signal_gain\")\n\tthis.mutex.RUnlock()\n\tinputAmplitudeFloat := float64(inputAmplitude)\n\tfacInputGain := decibelsToFactor(inputGain)\n\tfacInput := (0.01 * inputAmplitudeFloat) * facInputGain\n\tfacSignalGain := decibelsToFactor(signalGain)\n\tsignalAmplitudeFloat := float64(signalAmplitude)\n\tfacSignal := (0.01 * signalAmplitudeFloat) * facSignalGain\n\tphase := this.phase\n\tsignalFrequencyFloat := float64(signalFrequency)\n\tsampleRateFloat := float64(sampleRate)\n\tphaseIncrement := MATH_TWO_PI * (signalFrequencyFloat / sampleRateFloat)\n\ttwoOverPi := 2.0 / math.Pi\n\tn := len(in)\n\tnFloat := float64(n)\n\n\t/*\n\t * Generate the appropriate signal.\n\t */\n\tswitch signalType {\n\tcase \"sine\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := math.Sin(currentPhase)\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"triangle\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := 0.0\n\n\t\t\t/*\n\t\t\t * Check whether the waveform is rising or falling.\n\t\t\t */\n\t\t\tif currentPhase < math.Pi {\n\t\t\t\tsignal = (twoOverPi * currentPhase) - 1.0\n\t\t\t} else {\n\t\t\t\tsignal = 3.0 - (twoOverPi * currentPhase)\n\t\t\t}\n\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"square\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := signFloat(math.Pi - currentPhase)\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"sawtooth\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := currentPhase / math.Pi\n\n\t\t\t/*\n\t\t\t * Check whether we're after the phase jump.\n\t\t\t */\n\t\t\tif currentPhase > math.Pi {\n\t\t\t\tsignal -= 2.0\n\t\t\t}\n\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"noise\":\n\t\tprng := this.prng\n\n\t\t/*\n\t\t * Check if pseudo-random number generator is initialized.\n\t\t */\n\t\tif prng == nil {\n\t\t\tprng = random.CreatePRNG(1337)\n\t\t\tthis.prng = prng\n\t\t}\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tr := prng.NextFloat()\n\t\t\tuniform := (1.0 - (2.0 * r))\n\t\t\tout[i] = (facInput * sample) + (facSignal * uniform)\n\t\t}\n\n\t\tbreak\n\t}\n\n\tthis.phase = phase\n}", "func NewMonoFmt() *Format {\n\treturn &Format{\n\t\tchannels: 1,\n\t\tfreq: 44100 * freq.Hertz,\n\t\tCodec: sample.SInt16L}\n}", "func ConvDataFormat(value string) ConvAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"data_format\"] = value\n\t}\n}", "func (w *Writer) Format() audio.Format {\n\treturn w.fmt\n}", "func read_hybrid_profile(wps *WavpackStream, wpmd *WavpackMetadata) int {\n\tvar byteptr []byte = wpmd.data\n\tvar byte_idx int = 0\n\n\tif (wps.wphdr.flags & HYBRID_BITRATE) != 0 {\n\t\twps.w.slow_level[0] = exp2s(int(byteptr[byte_idx]&0xff) +\n\t\t\t(int(byteptr[byte_idx+1]&0xff) << 8))\n\t\tbyte_idx += 2\n\n\t\tif (wps.wphdr.flags & (MONO_FLAG | FALSE_STEREO)) == 0 {\n\t\t\twps.w.slow_level[1] = exp2s(int(byteptr[byte_idx]&0xff) + (int(byteptr[byte_idx+1]&0xff) << 8))\n\t\t\tbyte_idx += 2\n\t\t}\n\t}\n\n\twps.w.bitrate_acc[0] = uint((int(byteptr[byte_idx]&0xff) + (int(byteptr[byte_idx+1]&0xff) << 8)) << 16)\n\tbyte_idx += 2\n\n\tif (wps.wphdr.flags & (MONO_FLAG | FALSE_STEREO)) == 0 {\n\t\twps.w.bitrate_acc[1] = uint((int(byteptr[byte_idx]&0xff) + (int(byteptr[byte_idx+1]&0xff) << 8)) << 16)\n\t\tbyte_idx += 2\n\t}\n\n\tif byte_idx < wpmd.byte_length {\n\t\twps.w.bitrate_delta[0] = exp2s((int(byteptr[byte_idx]&0xff) + (int(byteptr[byte_idx+1]&0xff) << 8)))\n\t\tbyte_idx += 2\n\n\t\tif (wps.wphdr.flags & (MONO_FLAG | FALSE_STEREO)) == 0 {\n\t\t\twps.w.bitrate_delta[1] = exp2s((int(byteptr[byte_idx]&0xff) + (int(byteptr[byte_idx+1]&0xff) << 8)))\n\t\t\tbyte_idx += 2\n\t\t}\n\n\t\tif byte_idx < wpmd.byte_length {\n\t\t\treturn FALSE\n\t\t}\n\t} else {\n\t\twps.w.bitrate_delta[1] = 0\n\t\twps.w.bitrate_delta[0] = 0\n\t}\n\n\treturn TRUE\n}", "func (s *Sink) Samplerate() uint {\n\treturn s.samplerate\n}", "func SDPFilter(msgIn *sdp.Message, byteIn []byte) (*sdp.Message, []byte) {\n\tmsgOut := &sdp.Message{}\n\n\tmsgOut.Name = \"Stream\"\n\tmsgOut.Origin = sdp.Origin{\n\t\tUsername: \"-\",\n\t\tNetworkType: \"IN\",\n\t\tAddressType: \"IP4\",\n\t\tAddress: \"127.0.0.1\",\n\t}\n\n\tfor i, m := range msgIn.Medias {\n\t\tvar attributes []sdp.Attribute\n\t\tfor _, attr := range m.Attributes {\n\t\t\tif attr.Key == \"rtpmap\" /*|| attr.Key == \"fmtp\"*/ {\n\t\t\t\tattributes = append(attributes, attr)\n\t\t\t}\n\t\t}\n\n\t\t// control attribute is mandatory, and is the path that is appended\n\t\t// to the stream path in SETUP\n\t\tattributes = append(attributes, sdp.Attribute{\n\t\t\tKey: \"control\",\n\t\t\tValue: \"trackID=\" + strconv.FormatInt(int64(i), 10),\n\t\t})\n\n\t\tmsgOut.Medias = append(msgOut.Medias, sdp.Media{\n\t\t\tBandwidths: m.Bandwidths,\n\t\t\tDescription: sdp.MediaDescription{\n\t\t\t\tType: m.Description.Type,\n\t\t\t\tProtocol: \"RTP/AVP\", // override protocol\n\t\t\t\tFormats: m.Description.Formats,\n\t\t\t},\n\t\t\tAttributes: attributes,\n\t\t})\n\t}\n\n\tsdps := sdp.Session{}\n\tsdps = msgOut.Append(sdps)\n\tbyteOut := sdps.AppendTo(nil)\n\n\treturn msgOut, byteOut\n}", "func ConvertToKudosSettingsInput(slackCommand *slackmodel.SlackCommandRequest) (*slackmodel.KudosSettingsInput, error) {\n\tret := new(slackmodel.KudosSettingsInput)\n\tret.TeamId = slackCommand.TeamId\n\tret.ChannelId = slackCommand.ChannelId\n\tret.UserIds = utils.ExtractUserIdsFromText(slackCommand.Text, \"\")\n\n\tremainingText := slackCommand.Text\n\tif strings.HasPrefix(slackCommand.Text, string(slackmodel.Add_Member)) {\n\t\tret.CommandType = slackmodel.Add_Member\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.Add_Member), \"\", 1)\n\t} else if strings.HasPrefix(slackCommand.Text, string(slackmodel.Del_Member)) {\n\t\tret.CommandType = slackmodel.Del_Member\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.Del_Member), \"\", 1)\n\t} else if strings.HasPrefix(slackCommand.Text, string(slackmodel.List_Member)) {\n\t\tret.CommandType = slackmodel.List_Member\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.List_Member), \"\", 1)\n\t} else if strings.HasPrefix(slackCommand.Text, string(slackmodel.Add_Group)) {\n\t\tret.CommandType = slackmodel.Add_Group\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.Add_Group), \"\", 1)\n\t} else if strings.HasPrefix(slackCommand.Text, string(slackmodel.Del_Group)) {\n\t\tret.CommandType = slackmodel.Del_Group\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.Del_Group), \"\", 1)\n\t} else if strings.HasPrefix(slackCommand.Text, string(slackmodel.List_Group)) {\n\t\tret.CommandType = slackmodel.List_Group\n\t\tremainingText = strings.Replace(remainingText, string(slackmodel.List_Group), \"\", 1)\n\t}\n\n\tret.GroupId = utils.ExtractGroupId(strings.Trim(remainingText, \" \"))\n\treturn ret, nil\n}", "func Conv(input string, tocode string, fromcode string) (string, error) {\n\th, err := Open(tocode, fromcode)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer h.Close()\n\treturn h.Conv(input)\n}", "func (this *Stats) InputBitRate() float32 { return float32(this.ptr.f_input_bitrate) }", "func (g *PhoneGroupCallStreamChannels) GetChannels() (value []GroupCallStreamChannel) {\n\tif g == nil {\n\t\treturn\n\t}\n\treturn g.Channels\n}", "func (pstFile *File) GetFormatType() (string, error) {\n\tformatType, err := pstFile.Read(2, 10)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tswitch binary.LittleEndian.Uint16(formatType) {\n\tcase 14:\n\t\treturn FormatTypeANSI, nil\n\tcase 15:\n\t\treturn FormatTypeANSI, nil\n\tcase 21:\n\t\treturn FormatTypeUnicode, nil\n\tcase 23:\n\t\treturn FormatTypeUnicode, nil\n\tcase 36:\n\t\treturn FormatTypeUnicode4k, nil\n\tdefault:\n\t\treturn \"\", errors.New(\"unsupported format type\")\n\t}\n}", "func TestStringSenderToReceiverOptions(t *testing.T) {\n\tvar line = \"{7072}\"\n\tr := NewReader(strings.NewReader(line))\n\tr.line = line\n\n\terr := r.parseSenderToReceiver()\n\trequire.Equal(t, err, nil)\n\n\trecord := r.currentFEDWireMessage.SenderToReceiver\n\trequire.Equal(t, record.String(), \"{7072} \")\n\trequire.Equal(t, record.Format(FormatOptions{VariableLengthFields: true}), \"{7072}*\")\n\trequire.Equal(t, record.String(), record.Format(FormatOptions{VariableLengthFields: false}))\n}", "func processStreamInfoBlock(b []byte) (flacStreamInfo, error) {\n\tif err := checkLen(b, 34); err != nil {\n\t\treturn nil, err\n\t}\n\tsi := flacStreamInfo{}\n\tsi[MinimumBlockSizeKey] = getUint16AsInt(b[0:2])\n\tsi[MaximumBlockSizeKey] = getUint16AsInt(b[2:4])\n\tsi[MinimumFrameSizeKey] = getUint24AsInt(b[4:7])\n\tsi[MaximumFrameSizeKey] = getUint24AsInt(b[7:10])\n\tsi[SampleRateKey] = getUint24AsInt(b[10:13]) >> 4\n\tsi[ChannelsKey] = ((b[12] >> 1) & 0x07) + 1\n\tsi[SampleSizeKey] = ((b[12] & 0x01) << 4) + (b[13] >> 4) + 1\n\tsi[TotalSamplesKey] = getInt64(append([]byte{0, 0, 0, b[13] & 0x0F}, b[14:18]...))\n\tsi[MD5Key] = b[18:]\n\treturn si, nil\n}", "func (a *AudioData) SampleRate() int {\n\treturn a.format.SampleRate\n}", "func (this *fileStruct) SampleFormat() uint16 {\n\treturn this.sampleFormat\n}", "func samplesToBytes(samples []float64, sampleFormat uint16, bitDepth uint16) ([]byte, error) {\n\n\t/*\n\t * Decide on the sample format.\n\t */\n\tswitch sampleFormat {\n\tcase AUDIO_PCM:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 8:\n\t\t\tres, err := samplesToBytesLPCM8(samples)\n\t\t\treturn res, err\n\t\tcase 16:\n\t\t\tres, err := samplesToBytesLPCM16(samples)\n\t\t\treturn res, err\n\t\tcase 24:\n\t\t\tres, err := samplesToBytesLPCM24(samples)\n\t\t\treturn res, err\n\t\tcase 32:\n\t\t\tres, err := samplesToBytesLPCM32(samples)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in LPCM format: %d\", bitDepth)\n\t\t}\n\n\tcase AUDIO_IEEE_FLOAT:\n\n\t\t/*\n\t\t * Decide on the bit depth.\n\t\t */\n\t\tswitch bitDepth {\n\t\tcase 32:\n\t\t\tres, err := samplesToBytesIEEE32(samples)\n\t\t\treturn res, err\n\t\tcase 64:\n\t\t\tres, err := samplesToBytesIEEE64(samples)\n\t\t\treturn res, err\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported bit depth for audio in IEEE floating-point format: %d\", bitDepth)\n\t\t}\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unknown sample format: %#04x\", sampleFormat)\n\t}\n\n}", "func (m *IncomingContext) GetSourceParticipantId()(*string) {\n return m.sourceParticipantId\n}", "func (w *Wav) GetData() (interface{}, error) {\n\tbytePerSample := int(w.BitsPerSample / 8)\n\tsampleParser, err := GetSampleParser(w.BitsPerSample, w.WaveFormat)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif w.NumChannels == 1 {\n\t\tsample := parseMonoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\tif w.NumChannels == 2 {\n\t\tsample := parseStereoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\treturn nil, errors.New(\"failed to sampled data from wav file\")\n}", "func (m *ItemTranslateExchangeIdsPostRequestBody) GetSourceIdType()(*iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.ExchangeIdFormat) {\n val, err := m.GetBackingStore().Get(\"sourceIdType\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.ExchangeIdFormat)\n }\n return nil\n}", "func NewAudioConfigFromStreamInput(stream AudioInputStream) (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tret := uintptr(C.audio_config_create_audio_input_from_stream(&handle, stream.getHandle()))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func NextSample() []Value {\n\tsmp := make([]Value, masterSpec.Channels)\n\tvar fireSample []Value\n\tfor _, fire := range mixLiveFires {\n\t\tif fireTz := fire.FireAt(nowTz); fireTz > 0 {\n\t\t\tfireSample = mixSourceAt(fire.Source, fire.Volume, fire.Pan, fireTz)\n\t\t\tfor c := 0; c < masterSpec.Channels; c++ {\n\t\t\t\tsmp[c] += fireSample[c]\n\t\t\t}\n\t\t}\n\t}\n\t//\tdebug.Printf(\"*Mixer.nextSample %+v\\n\", sample)\n\tnowTz++\n\tout := make([]Value, masterSpec.Channels)\n\tfor c := 0; c < masterSpec.Channels; c++ {\n\t\tout[c] = mixLogarithmicRangeCompression(smp[c])\n\t}\n\tif nowTz > nextCycleTz {\n\t\tmixCycle()\n\t}\n\treturn out\n}", "func RecordChannels(m proto.ChannelMap) RecordOption {\n\tif len(m) == 0 {\n\t\tpanic(\"pulse: invalid channel map\")\n\t}\n\treturn func(r *RecordStream) {\n\t\tr.createRequest.ChannelMap = m\n\t\tr.createRequest.Channels = byte(len(m))\n\t}\n}", "func samplesToChannels(samples []float64, channelCount uint16) []Channel {\n\tchannels := make([]Channel, channelCount)\n\tchannelCount32 := uint32(channelCount)\n\tsize := len(samples)\n\tsize32 := uint32(size)\n\tsamplesPerChannel := size32 / channelCount32\n\n\t/*\n\t * Extract each channel from the sample data.\n\t */\n\tfor i := uint16(0); i < channelCount; i++ {\n\t\tcurrentSamples := make([]float64, samplesPerChannel)\n\t\ti32 := uint32(i)\n\n\t\t/*\n\t\t * Extract each sample for this channel.\n\t\t */\n\t\tfor j := uint32(0); j < samplesPerChannel; j++ {\n\t\t\tidx := (j * channelCount32) + i32\n\t\t\tcurrentSamples[j] = samples[idx]\n\t\t}\n\n\t\t/*\n\t\t * Data structure representing this channel.\n\t\t */\n\t\tchannel := channelStruct{\n\t\t\tsamples: currentSamples,\n\t\t}\n\n\t\tchannels[i] = &channel\n\t}\n\n\treturn channels\n}", "func (t *Track) extractAudioCodec() {\n\tt.codec = \"mp4a.40.2\"\n}", "func getRxModeType(mode uint8) interfaces.Interface_RxMode_Type {\n\tswitch mode {\n\tcase 1:\n\t\treturn interfaces.Interface_RxMode_POLLING\n\tcase 2:\n\t\treturn interfaces.Interface_RxMode_INTERRUPT\n\tcase 3:\n\t\treturn interfaces.Interface_RxMode_ADAPTIVE\n\tcase 4:\n\t\treturn interfaces.Interface_RxMode_DEFAULT\n\tdefault:\n\t\treturn interfaces.Interface_RxMode_UNKNOWN\n\t}\n}", "func GetFormats(urls dna.StringArray) (formatStr dna.String, IsSong dna.Bool) {\n\tswitch getType(urls.Join(\"\")) {\n\tcase \"mp3\", \"m4a\", \"flac\":\n\t\tformatStr, IsSong = getStringifiedSongUrls(urls), IS_SONG\n\t\treturn formatStr, IsSong\n\tcase \"mp4\", \"flv\":\n\t\tformatStr, IsSong = getStringifiedVideoUrls(urls), IS_VIDEO\n\t\treturn formatStr, IsSong\n\tdefault:\n\t\tpanic(\"Wrong type. Cannot indentify song or video\")\n\t}\n\treturn \"\", false\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (m *Media) GetCallerDevice()(DeviceInfoable) {\n return m.callerDevice\n}", "func (fr *FormatReaders) fileFormatSelector(hdr *image.Header) {\n\tvar r io.Reader\n\tvar err error\n\tfFmt := hdr.Format\n\tswitch fFmt {\n\tcase \"gz\":\n\t\tr, err = fr.gzReader()\n\t\tif err == nil {\n\t\t\tfr.Archived = true\n\t\t\tfr.ArchiveGz = true\n\t\t}\n\tcase \"zst\":\n\t\tr, err = fr.zstReader()\n\t\tif err == nil {\n\t\t\tfr.Archived = true\n\t\t\tfr.ArchiveZstd = true\n\t\t}\n\tcase \"qcow2\":\n\t\tr, err = fr.qcow2NopReader(hdr)\n\t\tfr.Convert = true\n\tcase \"xz\":\n\t\tr, err = fr.xzReader()\n\t\tif err == nil {\n\t\t\tfr.Archived = true\n\t\t\tfr.ArchiveXz = true\n\t\t}\n\tcase \"vmdk\":\n\t\tr = nil\n\t\tfr.Convert = true\n\tcase \"vdi\":\n\t\tr = nil\n\t\tfr.Convert = true\n\tcase \"vhd\":\n\t\tr = nil\n\t\tfr.Convert = true\n\tcase \"vhdx\":\n\t\tr = nil\n\t\tfr.Convert = true\n\t}\n\tif err == nil && r != nil {\n\t\tfr.appendReader(rdrTypM[fFmt], r)\n\t}\n}", "func (ds *DriverXML) ReadPINFormat(name string) string {\n\tresult := \"\"\n\tfor _, s := range ds.Signals.Signals {\n\t\tif s.Name == name {\n\t\t\treturn s.Format\n\t\t}\n\t}\n\tfor _, i := range ds.Inits.Inits {\n\t\tif i.Name == name {\n\t\t\treturn i.Format\n\t\t}\n\t}\n\treturn result\n}", "func (v *Muxer) readSample() (s *SrsMp4Sample, err error) {\n if s, err = v.dec.readSample(v.mp4Url); err != nil {\n ol.E(nil, fmt.Sprintf(\"read mp4 sample failed, err is %v\", err))\n return\n }\n\n if s.handlerType == SrsMp4HandlerTypeForbidden {\n return nil, fmt.Errorf(\"invalid mp4 handler\")\n }\n\n if s.handlerType == SrsMp4HandlerTypeSOUN {\n s.codec = uint16(v.dec.acodec)\n s.sampleRate = uint8(v.dec.sampleRate)\n s.channels = uint8(v.dec.channels)\n s.soundBits = uint8(v.dec.soundBits)\n } else {\n s.codec = uint16(v.dec.vcodec)\n }\n\n ol.I(nil, fmt.Sprintf(\"read a mp4 sample:%v\", s))\n return\n}", "func (inputs *input) getInputs() error {\n\n\tflag.IntVar(&inputs.limit, \"l\", 0, \"limit for queue length\")\n\tflag.StringVar(&inputs.host, \"h\", \"\", \"redis host\")\n\tflag.StringVar(&inputs.port, \"p\", \"\", \"redis port\")\n\tflag.StringVar(&inputs.source, \"s\", \"\", \"source queue name\")\n\tflag.StringVar(&inputs.destination, \"d\", \"\", \"destination queue name\")\n\tflag.StringVar(&inputs.how, \"t\", \"\", \"Type : LTR = Left to Right\\nRTL = Right to Left\\nLTL = Left to Left\\nRTR = Right to Right\")\n\tflag.BoolVar(&inputs.daemonMode, \"daemon\", false, \"Use if you want to run as a daemon\")\n\thelp := flag.Bool(\"help\", false, \"-help\")\n\tflag.Parse()\n\n\tif flag.NFlag() < 5 || *help {\n\t\tflag.PrintDefaults()\n\t\treturn fmt.Errorf(\"All Flags are required\")\n\t}\n\n\tinputs.how = strings.ToUpper(inputs.how)\n\n\treturn nil\n}", "func NewAudioConfigFromSpeakerOutput(deviceName string) (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tdn := C.CString(deviceName)\n\tdefer C.free(unsafe.Pointer(dn))\n\tret := uintptr(C.audio_config_create_audio_output_from_a_speaker(&handle, dn))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (audio *Audio) SampleRate() int {\n\treturn audio.sampleRate\n}", "func readSamples(r io.Reader, sampleCount int) (output []int16, nSamples int, err error) {\n\tbytesToRead := 2 * sampleCount // read 16 bit values\n\tbytesArray := make([]byte, bytesToRead)\n\tn, err := r.Read(bytesArray)\n\tif err != nil {\n\t\treturn\n\t}\n\treadValueCount := n / 2\n\t// nSamples = readValueCount / 2\n\t// log(fmt.Sprintf(\"nSamples: %d\", nSamples), teamlog.Debug)\n\toutput = make([]int16, readValueCount)\n\tvar unsignedValue uint16\n\tfor i := 0; i < readValueCount; i++ {\n\t\t//binary.Read(r, binary.LittleEndian, &sample)\n\t\tunsignedValue = binary.LittleEndian.Uint16(bytesArray[i*2 : (i+1)*2])\n\t\toutput[i] = int16(unsignedValue)\n\t}\n\treturn\n}", "func (o AlarmContactOutput) ChannelsSms() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AlarmContact) pulumi.StringPtrOutput { return v.ChannelsSms }).(pulumi.StringPtrOutput)\n}" ]
[ "0.48352265", "0.48280677", "0.4459511", "0.42831096", "0.42622006", "0.4255585", "0.42393675", "0.42374885", "0.42180178", "0.41943738", "0.41906402", "0.41728717", "0.41143495", "0.40816045", "0.40525606", "0.40086615", "0.40031055", "0.3980295", "0.39530417", "0.39446703", "0.39375782", "0.39222202", "0.39085835", "0.38979602", "0.38904658", "0.38810086", "0.38582268", "0.38517016", "0.3842754", "0.38424304", "0.3819439", "0.38152707", "0.38145766", "0.38085964", "0.3781461", "0.37645414", "0.3764273", "0.3753006", "0.37241548", "0.37067908", "0.37028813", "0.36880228", "0.36877716", "0.36657047", "0.36632952", "0.36585134", "0.36306503", "0.3629102", "0.36247537", "0.36178052", "0.36105156", "0.36009985", "0.35994956", "0.35947245", "0.35887167", "0.35830337", "0.35797378", "0.35585788", "0.3548981", "0.35467255", "0.3539458", "0.3537733", "0.35350928", "0.3526851", "0.3525593", "0.35132837", "0.35132045", "0.35127", "0.3496002", "0.34958276", "0.3485127", "0.3482421", "0.34823078", "0.34797573", "0.34762624", "0.34704304", "0.34682387", "0.34653333", "0.3460632", "0.34595808", "0.34417525", "0.34400615", "0.34398827", "0.34356084", "0.34305635", "0.34292975", "0.3426782", "0.34184343", "0.341569", "0.3415548", "0.34154922", "0.3415358", "0.34135318", "0.34132382", "0.3410227", "0.34081736", "0.3395046", "0.33934298", "0.33930025", "0.33903608" ]
0.55644387
0
Call the DSP process function to retrieve the output signal format for a DSP based on input values. inmask: Channel bitmask representing the speakers enabled for the incoming signal. For example a 5.1 signal could have inchannels 2 that represent CHANNELMASK_SURROUND_LEFT and CHANNELMASK_SURROUND_RIGHT. inchannels: Number of channels for the incoming signal. inspeakermode: Speaker mode for the incoming signal. A DSP unit may be an up mixer or down mixer for example. In this case if you specified 6 in for a downmixer, it may provide you with 2 out for example. Generally the input values will be reproduced for the output values, but some DSP units will want to alter the output format.
func (d *DSP) OutputChannelFormat(inmask ChannelMask, inchannels int, inspeakermode SpeakerMode) (ChannelMask, int, SpeakerMode, error) { var outmask C.FMOD_CHANNELMASK var outchannels C.int var outspeakermode C.FMOD_SPEAKERMODE res := C.FMOD_DSP_GetOutputChannelFormat(d.cptr, C.FMOD_CHANNELMASK(inmask), C.int(inchannels), C.FMOD_SPEAKERMODE(inspeakermode), &outmask, &outchannels, &outspeakermode) return ChannelMask(outmask), int(outchannels), SpeakerMode(outspeakermode), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *signalGenerator) Process(in []float64, out []float64, sampleRate uint32) {\n\tthis.mutex.RLock()\n\tinputAmplitude, _ := this.getNumericValue(\"input_amplitude\")\n\tinputGain, _ := this.getNumericValue(\"input_gain\")\n\tsignalType, _ := this.getDiscreteValue(\"signal_type\")\n\tsignalFrequency, _ := this.getNumericValue(\"signal_frequency\")\n\tsignalAmplitude, _ := this.getNumericValue(\"signal_amplitude\")\n\tsignalGain, _ := this.getNumericValue(\"signal_gain\")\n\tthis.mutex.RUnlock()\n\tinputAmplitudeFloat := float64(inputAmplitude)\n\tfacInputGain := decibelsToFactor(inputGain)\n\tfacInput := (0.01 * inputAmplitudeFloat) * facInputGain\n\tfacSignalGain := decibelsToFactor(signalGain)\n\tsignalAmplitudeFloat := float64(signalAmplitude)\n\tfacSignal := (0.01 * signalAmplitudeFloat) * facSignalGain\n\tphase := this.phase\n\tsignalFrequencyFloat := float64(signalFrequency)\n\tsampleRateFloat := float64(sampleRate)\n\tphaseIncrement := MATH_TWO_PI * (signalFrequencyFloat / sampleRateFloat)\n\ttwoOverPi := 2.0 / math.Pi\n\tn := len(in)\n\tnFloat := float64(n)\n\n\t/*\n\t * Generate the appropriate signal.\n\t */\n\tswitch signalType {\n\tcase \"sine\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := math.Sin(currentPhase)\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"triangle\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := 0.0\n\n\t\t\t/*\n\t\t\t * Check whether the waveform is rising or falling.\n\t\t\t */\n\t\t\tif currentPhase < math.Pi {\n\t\t\t\tsignal = (twoOverPi * currentPhase) - 1.0\n\t\t\t} else {\n\t\t\t\tsignal = 3.0 - (twoOverPi * currentPhase)\n\t\t\t}\n\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"square\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := signFloat(math.Pi - currentPhase)\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"sawtooth\":\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tiFloat := float64(i)\n\t\t\tupdatedPhase := phase + (iFloat * phaseIncrement)\n\t\t\tcurrentPhase := math.Mod(updatedPhase, MATH_TWO_PI)\n\t\t\tsignal := currentPhase / math.Pi\n\n\t\t\t/*\n\t\t\t * Check whether we're after the phase jump.\n\t\t\t */\n\t\t\tif currentPhase > math.Pi {\n\t\t\t\tsignal -= 2.0\n\t\t\t}\n\n\t\t\tout[i] = (facInput * sample) + (facSignal * signal)\n\t\t}\n\n\t\tphase += nFloat * phaseIncrement\n\t\tphase = math.Mod(phase, MATH_TWO_PI)\n\t\tbreak\n\tcase \"noise\":\n\t\tprng := this.prng\n\n\t\t/*\n\t\t * Check if pseudo-random number generator is initialized.\n\t\t */\n\t\tif prng == nil {\n\t\t\tprng = random.CreatePRNG(1337)\n\t\t\tthis.prng = prng\n\t\t}\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor i, sample := range in {\n\t\t\tr := prng.NextFloat()\n\t\t\tuniform := (1.0 - (2.0 * r))\n\t\t\tout[i] = (facInput * sample) + (facSignal * uniform)\n\t\t}\n\n\t\tbreak\n\t}\n\n\tthis.phase = phase\n}", "func (_HbSwap *HbSwapFilterer) WatchInputmask(opts *bind.WatchOpts, sink chan<- *HbSwapInputmask) (event.Subscription, error) {\n\n\tlogs, sub, err := _HbSwap.contract.WatchLogs(opts, \"Inputmask\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(HbSwapInputmask)\n\t\t\t\tif err := _HbSwap.contract.UnpackLog(event, \"Inputmask\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func (j *JustAddPowerReciever) AudioVideoInputs(ctx context.Context) (map[string]string, error) {\n\ttoReturn := make(map[string]string)\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", j.Address)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tj.Log.Debug(\"ip address\", zap.Any(\"IP\", ipAddress.IP))\n\n\tif err != nil {\n\t\treturn toReturn, fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", j.Address, err)\n\t}\n\n\tresult, err := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/details/channel\", j.Address), \"\", \"GET\")\n\n\tif err != nil {\n\t\tj.Log.Debug(\"error when making request\", zap.Error(err))\n\t\treturn toReturn, fmt.Errorf(\"error when making request: %w\", err)\n\t}\n\n\tvar jsonResult JustAddPowerChannelIntResult\n\tgerr := json.Unmarshal(result, &jsonResult)\n\tif gerr != nil {\n\t\tj.Log.Debug(\"error unmarshaling response\", zap.Error(gerr))\n\t\treturn toReturn, fmt.Errorf(\"error when unmarshaling response: %w\", gerr)\n\t}\n\n\tj.Log.Debug(\"Result\", zap.Any(\"result\", result), zap.Any(\"jsonResult\", jsonResult))\n\tj.Log.Debug(\"len of IP\", zap.Int(\"lenght\", len(ipAddress.IP)))\n\n\ttransmissionChannel := fmt.Sprintf(\"%v.%v.%v.%v\",\n\t\tipAddress.IP[0], ipAddress.IP[1], ipAddress.IP[2], jsonResult.Data)\n\n\ttoReturn[\"\"] = transmissionChannel\n\treturn toReturn, nil\n}", "func ProcessOutChannel(wg *sync.WaitGroup, scConfig *common.SCConfiguration) {\n\t//qdr throws out the data on this channel ,listen to data coming out of qdrEventOutCh\n\t//Send back the acknowledgement to publisher\n\tpostProcessFn := func(address string, status channel.Status) {\n\t\tif pub, ok := scConfig.PubSubAPI.HasPublisher(address); ok {\n\t\t\tif status == channel.SUCCESS {\n\t\t\t\tlocalmetrics.UpdateEventAckCount(address, localmetrics.SUCCESS)\n\t\t\t} else {\n\t\t\t\tlocalmetrics.UpdateEventAckCount(address, localmetrics.FAILED)\n\t\t\t}\n\t\t\tif pub.EndPointURI != nil {\n\t\t\t\tlog.Debugf(\"posting event status %s to publisher %s\", channel.Status(status), pub.Resource)\n\t\t\t\trestClient := restclient.New()\n\t\t\t\t_ = restClient.Post(pub.EndPointURI,\n\t\t\t\t\t[]byte(fmt.Sprintf(`{eventId:\"%s\",status:\"%s\"}`, pub.ID, status)))\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Warnf(\"could not send ack to publisher ,`publisher` for address %s not found\", address)\n\t\t\tlocalmetrics.UpdateEventAckCount(address, localmetrics.FAILED)\n\t\t}\n\t}\n\tpostHandler := func(err error, endPointURI *types.URI, address string) {\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"error posting request at %s : %s\", endPointURI, err)\n\t\t\tlocalmetrics.UpdateEventReceivedCount(address, localmetrics.FAILED)\n\t\t} else {\n\t\t\tlocalmetrics.UpdateEventReceivedCount(address, localmetrics.SUCCESS)\n\t\t}\n\t}\n\n\tfor { //nolint:gosimple\n\t\tselect { //nolint:gosimple\n\t\tcase d := <-scConfig.EventOutCh: // do something that is put out by QDR\n\t\t\tswitch d.Data.Type() {\n\t\t\tcase channel.HWEvent:\n\t\t\t\tevent, err := v1hwevent.GetCloudNativeEvents(*d.Data)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"error marshalling event data when reading from amqp %v\\n %#v\", err, d)\n\t\t\t\t\tlog.Infof(\"data %#v\", d.Data)\n\t\t\t\t} else if d.Type == channel.EVENT {\n\t\t\t\t\tif d.Status == channel.NEW {\n\t\t\t\t\t\tif d.ProcessEventFn != nil { // always leave event to handle by default method for events\n\t\t\t\t\t\t\tif err := d.ProcessEventFn(event); err != nil {\n\t\t\t\t\t\t\t\tlog.Errorf(\"error processing data %v\", err)\n\t\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.FAILED)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if sub, ok := scConfig.PubSubAPI.HasSubscription(d.Address); ok {\n\t\t\t\t\t\t\tif sub.EndPointURI != nil {\n\t\t\t\t\t\t\t\trestClient := restclient.New()\n\t\t\t\t\t\t\t\tevent.ID = sub.ID // set ID to the subscriptionID\n\t\t\t\t\t\t\t\terr := restClient.PostHwEvent(sub.EndPointURI, event)\n\t\t\t\t\t\t\t\tpostHandler(err, sub.EndPointURI, d.Address)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlog.Warnf(\"endpoint uri not given, posting event to log %#v for address %s\\n\", event, d.Address)\n\t\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.SUCCESS)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlog.Warnf(\"subscription not found, posting event %#v to log for address %s\\n\", event, d.Address)\n\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.FAILED)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if d.Status == channel.SUCCESS || d.Status == channel.FAILED { // event sent ,ack back to publisher\n\t\t\t\t\t\tpostProcessFn(d.Address, d.Status)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tevent, err := v1event.GetCloudNativeEvents(*d.Data)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"error marshalling event data when reading from amqp %v\\n %#v\", err, d)\n\t\t\t\t\tlog.Infof(\"data %#v\", d.Data)\n\t\t\t\t} else if d.Type == channel.EVENT {\n\t\t\t\t\tif d.Status == channel.NEW {\n\t\t\t\t\t\tif d.ProcessEventFn != nil { // always leave event to handle by default method for events\n\t\t\t\t\t\t\tif err := d.ProcessEventFn(event); err != nil {\n\t\t\t\t\t\t\t\tlog.Errorf(\"error processing data %v\", err)\n\t\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.FAILED)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if sub, ok := scConfig.PubSubAPI.HasSubscription(d.Address); ok {\n\t\t\t\t\t\t\tif sub.EndPointURI != nil {\n\t\t\t\t\t\t\t\trestClient := restclient.New()\n\t\t\t\t\t\t\t\tevent.ID = sub.ID // set ID to the subscriptionID\n\t\t\t\t\t\t\t\terr := restClient.PostEvent(sub.EndPointURI, event)\n\t\t\t\t\t\t\t\tpostHandler(err, sub.EndPointURI, d.Address)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tlog.Warnf(\"endpoint uri not given, posting event to log %#v for address %s\\n\", event, d.Address)\n\t\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.SUCCESS)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlog.Warnf(\"subscription not found, posting event %#v to log for address %s\\n\", event, d.Address)\n\t\t\t\t\t\t\tlocalmetrics.UpdateEventReceivedCount(d.Address, localmetrics.FAILED)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if d.Status == channel.SUCCESS || d.Status == channel.FAILED { // event sent ,ack back to publisher\n\t\t\t\t\t\tpostProcessFn(d.Address, d.Status)\n\t\t\t\t\t}\n\t\t\t\t} else if d.Type == channel.STATUS {\n\t\t\t\t\tif d.Status == channel.SUCCESS {\n\t\t\t\t\t\tlocalmetrics.UpdateStatusAckCount(d.Address, localmetrics.SUCCESS)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.Errorf(\"failed to receive status request to address %s\", d.Address)\n\t\t\t\t\t\tlocalmetrics.UpdateStatusAckCount(d.Address, localmetrics.FAILED)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // end switch\n\t\tcase <-scConfig.CloseCh:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (d *DSP) ChannelFormat() (ChannelMask, int, SpeakerMode, error) {\n\tvar channelmask C.FMOD_CHANNELMASK\n\tvar numchannels C.int\n\tvar source_speakermode C.FMOD_SPEAKERMODE\n\tres := C.FMOD_DSP_GetChannelFormat(d.cptr, &channelmask, &numchannels, &source_speakermode)\n\treturn ChannelMask(channelmask), int(numchannels), SpeakerMode(source_speakermode), errs[res]\n}", "func (d *day14b) Process(line string) {\n\tif strings.HasPrefix(line, \"mask = \") {\n\t\td.orMask = 0\n\t\td.andMask = 1<<36 - 1\n\t\td.floatBits = nil\n\t\tfmt.Println(\"msk:\", line[7:])\n\t\tfor i, c := range line[7:] {\n\t\t\tswitch c {\n\t\t\tcase 'X':\n\t\t\t\td.floatBits = append(d.floatBits, 35-i)\n\t\t\tcase '1':\n\t\t\t\td.orMask = d.orMask | uint64(1<<(35-i))\n\t\t\tcase '0':\n\t\t\t\t//d.andMask = d.andMask ^ uint64(1<<(35-i))\n\t\t\tdefault:\n\t\t\t\tpanic(\"unknown: \" + line)\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"and: %036b\\n\", d.andMask)\n\t\tfmt.Printf(\"or : %036b\\n\", d.orMask)\n\t\tfmt.Printf(\"floats: %v\\n\", d.floatBits)\n\t}\n\tif strings.HasPrefix(line, \"mem[\") {\n\t\tend := strings.Index(line, \"]\")\n\t\toffset, err := strconv.ParseUint(line[4:end], 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tnum, err := strconv.ParseUint(line[end+4:], 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf(\"ori: %036b\\n\", offset)\n\t\toffset = (offset & d.andMask) | d.orMask\n\n\t\tmax := 1 << len(d.floatBits)\n\t\tfor i := 0; i < max; i++ {\n\t\t\torMask2, andMask2 := calcMasks(i, d.floatBits)\n\t\t\tsubOffset := (offset & andMask2) | orMask2\n\t\t\tfmt.Println(\"writing\", num, \"to\", subOffset)\n\t\t\td.memory[subOffset] = num\n\t\t}\n\t}\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func genOutput(inPath, outPath, voiceType string) {\n\tfmt.Println(\"Processing ...\")\n\tvar wg sync.WaitGroup\n\tcontent, err := utils.ReadPdf(inPath)\n\tfmt.Println(\"Content from Pdf ::\", content)\n\tutils.FatalErr(err)\n\tconst maxLen = 10000\n\tsplits := SplitStr(content, maxLen)\n\tfor i, v := range splits {\n\t\twg.Add(1)\n\t\tgo utils.GenAudio(v, voiceType, outPath, i, &wg)\n\t}\n\twg.Wait()\n}", "func (fan _Fan) FanIn(done <-chan bool) Pipeline {\n\tvar wg sync.WaitGroup\n\tout := make(chan X)\n\n\toutput := func(pl Pipeline) {\n\t\tdefer wg.Done()\n\t\tfor val := range pl {\n\t\t\tselect {\n\t\t\tcase out <- val:\n\t\t\tcase <-done:\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\twg.Add(len(fan))\n\tfor _, val := range fan {\n\t\tgo output(val)\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(out)\n\t}()\n\n\treturn out\n}", "func reader() {\n\n\tvar err error\n\n\tdefer func() {\n\t\tclose(EncodeChan)\n\t\tWaitGroup.Done()\n\t}()\n\n\t// Create a 16KB input buffer\n\tstdin := bufio.NewReaderSize(os.Stdin, 16384)\n\n\t// Loop over the stdin input and pass the data to the encoder.\n\tfor {\n\n\t\tbuf := make([]int16, AudioFrameSize*AudioChannels)\n\n\t\terr = binary.Read(stdin, binary.LittleEndian, &buf)\n\t\tif err == io.EOF {\n\t\t\t// Okay! There's nothing left, time to quit.\n\t\t\treturn\n\t\t}\n\n\t\tif err == io.ErrUnexpectedEOF {\n\t\t\t// Well there's just a tiny bit left, lets encode it, then quit.\n\t\t\tEncodeChan <- buf\n\t\t\treturn\n\t\t}\n\n\t\tif err != nil {\n\t\t\t// Oh no, something went wrong!\n\t\t\tlog.Println(\"error reading from stdin,\", err)\n\t\t\treturn\n\t\t}\n\n\t\t// write pcm data to the EncodeChan\n\t\tEncodeChan <- buf\n\t}\n\n}", "func ProcessInChannel(wg *sync.WaitGroup, scConfig *common.SCConfiguration) {\n\tdefer wg.Done()\n\tfor { //nolint:gosimple\n\t\tselect {\n\t\tcase d := <-scConfig.EventInCh:\n\t\t\tif d.Type == channel.LISTENER {\n\t\t\t\tlog.Warnf(\"amqp disabled,no action taken: request to create listener address %s was called,but transport is not enabled\", d.Address)\n\t\t\t} else if d.Type == channel.SENDER {\n\t\t\t\tlog.Warnf(\"no action taken: request to create sender for address %s was called,but transport is not enabled\", d.Address)\n\t\t\t} else if d.Type == channel.EVENT && d.Status == channel.NEW {\n\t\t\t\tif e, err := v1event.GetCloudNativeEvents(*d.Data); err != nil {\n\t\t\t\t\tlog.Warnf(\"error marshalling event data\")\n\t\t\t\t} else {\n\t\t\t\t\tlog.Warnf(\"amqp disabled,no action taken(can't send to a desitination): logging new event %s\\n\", e.String())\n\t\t\t\t}\n\t\t\t\tout := channel.DataChan{\n\t\t\t\t\tAddress: d.Address,\n\t\t\t\t\tData: d.Data,\n\t\t\t\t\tStatus: channel.SUCCESS,\n\t\t\t\t\tType: channel.EVENT,\n\t\t\t\t\tProcessEventFn: d.ProcessEventFn,\n\t\t\t\t}\n\t\t\t\tif d.OnReceiveOverrideFn != nil {\n\t\t\t\t\tif err := d.OnReceiveOverrideFn(*d.Data, &out); err != nil {\n\t\t\t\t\t\tlog.Errorf(\"error onReceiveOverrideFn %s\", err)\n\t\t\t\t\t\tout.Status = channel.FAILED\n\t\t\t\t\t} else {\n\t\t\t\t\t\tout.Status = channel.SUCCESS\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tscConfig.EventOutCh <- &out\n\t\t\t} else if d.Type == channel.STATUS && d.Status == channel.NEW {\n\t\t\t\tlog.Warnf(\"amqp disabled,no action taken(can't send to a destination): logging new status check %v\\n\", d)\n\t\t\t\tout := channel.DataChan{\n\t\t\t\t\tAddress: d.Address,\n\t\t\t\t\tData: d.Data,\n\t\t\t\t\tStatus: channel.SUCCESS,\n\t\t\t\t\tType: channel.EVENT,\n\t\t\t\t\tProcessEventFn: d.ProcessEventFn,\n\t\t\t\t}\n\t\t\t\tif d.OnReceiveOverrideFn != nil {\n\t\t\t\t\tif err := d.OnReceiveOverrideFn(*d.Data, &out); err != nil {\n\t\t\t\t\t\tlog.Errorf(\"error onReceiveOverrideFn %s\", err)\n\t\t\t\t\t\tout.Status = channel.FAILED\n\t\t\t\t\t} else {\n\t\t\t\t\t\tout.Status = channel.SUCCESS\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tcase <-scConfig.CloseCh:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (d *Demodulator) Process(input []byte) (power, ddm, sdm, ident float64) {\n\tiqToComplex128(input, d.iqData)\n\tmult(d.iqData, d.nco, d.lpfIn[history:history+d.n])\n\t//lowpass(d.lpfIn, d.lpfOut)\n\tmult(d.iqData, d.nco, d.lpfOut[history:history+d.n])\n\t// TODO: subsample lpfOut here?\n\tabs(d.lpfOut[history:history+d.n], d.fftData) // Demodulate the AM signal\n\ts := d.fft.Transform(d.fftData)\n\tcarrier := cmplx.Abs(s[0])\n\tmod150 := (cmplx.Abs(s[15]) + cmplx.Abs(s[len(s)-15])) / carrier * 100\n\tmod90 := (cmplx.Abs(s[9]) + cmplx.Abs(s[len(s)-9])) / carrier * 100\n\tddm = (mod150 - mod90) // 150 Hz dominance (DDM > 0): Fly UP/LEFT\n\tsdm = (mod150 + mod90)\n\tident = (cmplx.Abs(s[102]) + cmplx.Abs(s[len(s)-102])) / carrier * 100\n\tcarrier = carrier / float64(len(s))\n\tpower = 20 * math.Log10(carrier) // Carrier power in dBFS\n\treturn\n}", "func (e *Engine) streamCallback(in, out []float32) {\n\n\tvar left, right float64\n\n\t// if there are new playback events recently encountered append\n\t// them to the active playback events set\n\t//\n\t// NB. for some reason, we can only access activePlaybackEvents at a\n\t// rate of SampleRate / FramesPerBuffer hz (and more confusinhgly\n\t// FramesPerBuffer can vary with each call). This effectively creates\n\t// unlistenably amounts of stutter if the FramesPerBuffer is too high\n\t// (greater than 512 for 44100hz sample rate is already pushing it)\n\tfor i := 0; i < len(e.newPlaybackEvents); i++ {\n\t\te.activePlaybackEvents[<-e.newPlaybackEvents] = true\n\t}\n\n\t// for each (stereo interleaved) output frame\n\tfor n := 0; n < len(out); n += 2 {\n\t\t// clear the current output frame (to avoid explosive accumulation)\n\t\tout[n] = 0.0\n\t\tout[n+1] = 0.0\n\t\t// for each event in the active playback events\n\t\tfor playbackEvent, _ := range e.activePlaybackEvents {\n\t\t\t// accumulate a frame of audio from the event\n\t\t\t// into the output buffer's current frame\n\t\t\tleft, right = playbackEvent.tick()\n\t\t\tout[n] += float32(left)\n\t\t\tout[n+1] += float32(right)\n\t\t}\n\t}\n\n\t// monitor audio input (if not muted and device exists)\n\tif e.inputAmplitude != 0 && e.streamParameters.Input.Device != nil {\n\t\tswitch e.streamParameters.Input.Channels {\n\t\tcase 1:\n\t\t\t// mono\n\t\t\tfor n := 0; n < len(in); n++ {\n\t\t\t\tout[2*n] += in[n] * e.inputAmplitude\n\t\t\t\tout[2*n+1] += in[n] * e.inputAmplitude\n\t\t\t}\n\t\tcase 2:\n\t\t\t// stereo\n\t\t\tfor n := 0; n < len(in); n += 2 {\n\t\t\t\tout[n] += in[n] * e.inputAmplitude\n\t\t\t\tout[n+1] += in[n+1] * e.inputAmplitude\n\t\t\t}\n\t\t}\n\t}\n\n}", "func processAudio(out []float32) {\n\tfor i := range out {\n\t\tout[i] = 0\n\t\tfor _, t := range toneMap {\n\t\t\tout[i] += t.next()\n\t\t}\n\t}\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func (_HbSwap *HbSwapCallerSession) InputmaskCnt() (*big.Int, error) {\n\treturn _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts)\n}", "func Input(c *cli.Context) error {\n\tvar file string\n\tfmt.Println(\"Enter the output file name\")\n\tfmt.Scan(&file)\n\tif file == \"\" {\n\t\tfile = inputFileName\n\t}\n\n\tvar str string\n\tfmt.Println(\"Enter the music you want to play\")\n\tfmt.Scan(&str)\n\n\tvar score []uint8\n\tfor _, t := range str {\n\t\tscore = append(score, values.Scale(fmt.Sprintf(\"%c\", t)))\n\t}\n\n\tdivision, err := smf.NewDivision(ticks, smf.NOSMTPE)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmidi, err := smf.NewSMF(smf.Format0, *division)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttrack := &smf.Track{}\n\terr = midi.AddTrack(track)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar list []*smf.MIDIEvent\n\tfor i, t := range score {\n\t\tvar d uint32\n\t\tif i != 0 {\n\t\t\td = onDeltaTime\n\t\t}\n\t\ttoneOn, err := smf.NewMIDIEvent(d, smf.NoteOnStatus, 0x00, t, 0x64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlist = append(list, toneOn)\n\t\ttoneOff, err := smf.NewMIDIEvent(offDeltaTime, smf.NoteOffStatus, 0x00, t, 0x64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlist = append(list, toneOff)\n\t}\n\n\tfor _, l := range list {\n\t\tif err := track.AddEvent(l); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tmetaEvent, err := smf.NewMetaEvent(21, smf.MetaEndOfTrack, []byte{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := track.AddEvent(metaEvent); err != nil {\n\t\treturn err\n\t}\n\n\toutputMidi, err := os.Create(fmt.Sprintf(\"./%s.mid\", file))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer outputMidi.Close()\n\n\twriter := bufio.NewWriter(outputMidi)\n\tsmfio.Write(writer, midi)\n\treturn writer.Flush()\n}", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (p *Concatenator) In() *scipipe.InPort { return p.InPort(\"in\") }", "func (_HbSwap *HbSwapFilterer) FilterInputmask(opts *bind.FilterOpts) (*HbSwapInputmaskIterator, error) {\n\n\tlogs, sub, err := _HbSwap.contract.FilterLogs(opts, \"Inputmask\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &HbSwapInputmaskIterator{contract: _HbSwap.contract, event: \"Inputmask\", logs: logs, sub: sub}, nil\n}", "func (runner *McRunner) processOutput() {\n\trunner.WaitGroup.Add(1)\n\tdefer runner.WaitGroup.Done()\n\tfor {\n\t\tselect {\n\t\tcase <-runner.killChannel:\n\t\t\treturn\n\t\tdefault:\n\t\t\tbuf := make([]byte, 256)\n\t\t\tn, err := runner.outPipe.Read(buf)\n\t\t\tstr := string(buf[:n])\n\n\t\t\tif (err == nil) && (n > 1) {\n\t\t\t\tif runner.Settings.PassthroughStdOut {\n\t\t\t\t\tfmt.Print(str)\n\t\t\t\t}\n\t\t\t\tmsgExp, _ := regexp.Compile(\"\\\\[.*\\\\] \\\\[.*INFO\\\\] \\\\[.*DedicatedServer\\\\]: <.*>\")\n\t\t\t\ttpsExp, _ := regexp.Compile(\"\\\\[.*\\\\] \\\\[.*INFO\\\\] \\\\[.*DedicatedServer\\\\]: Dim\")\n\t\t\t\tplayerExp, _ := regexp.Compile(\"\\\\[.*\\\\] \\\\[.*INFO\\\\] \\\\[.*DedicatedServer\\\\]: There are\")\n\t\t\t\tdoneExp, _ := regexp.Compile(\"\\\\[.*\\\\] \\\\[.*INFO\\\\] \\\\[.*DedicatedServer\\\\]: Done\")\n\n\t\t\t\tif runner.State == Starting {\n\t\t\t\t\tif doneExp.Match(buf) {\n\t\t\t\t\t\trunner.State = Running\n\t\t\t\t\t\tfmt.Println(\"Minecraft server done loading.\")\n\t\t\t\t\t}\n\t\t\t\t} else if runner.State == Running {\n\t\t\t\t\tif msgExp.Match(buf) {\n\t\t\t\t\t\trunner.MessageChannel <- str[strings.Index(str, \"<\"):]\n\t\t\t\t\t} else if tpsExp.Match(buf) {\n\t\t\t\t\t\tcontent := str[strings.Index(str, \"Dim\"):]\n\n\t\t\t\t\t\tnumExp, _ := regexp.Compile(\"[+-]?([0-9]*[.])?[0-9]+\")\n\t\t\t\t\t\tnums := numExp.FindAllString(content, -1)\n\t\t\t\t\t\tdim, _ := strconv.Atoi(nums[0])\n\t\t\t\t\t\ttps, _ := strconv.ParseFloat(nums[len(nums)-1], 32)\n\n\t\t\t\t\t\tm := make(map[int]float32)\n\t\t\t\t\t\tm[dim] = float32(tps)\n\n\t\t\t\t\t\trunner.tpsChannel <- m\n\t\t\t\t\t} else if playerExp.Match(buf) {\n\t\t\t\t\t\tcontent := str[strings.Index(str, \"There\"):]\n\n\t\t\t\t\t\tnumExp, _ := regexp.Compile(\"[+-]?([0-9]*[.])?[0-9]+\")\n\t\t\t\t\t\tplayers, _ := strconv.Atoi(numExp.FindString(content))\n\n\t\t\t\t\t\trunner.playerChannel <- players\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func FanIn(CerChannel, DwrChannel, CcrChannel <-chan Sig) <-chan Sig {\n\tchannel := make(chan Sig)\n\tgo func() {\n\t\tfor {\n\t\t\tchannel <- <-CerChannel\n\t\t}\n\t}()\n\tgo func() {\n\t\tfor {\n\t\t\tchannel <- <-DwrChannel\n\t\t}\n\t}()\n\tgo func() {\n\t\tfor {\n\t\t\tchannel <- <-CcrChannel\n\t\t}\n\t}()\n\treturn channel\n}", "func (_HbSwap *HbSwapCaller) InputmaskCnt(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _HbSwap.contract.Call(opts, out, \"inputmaskCnt\")\n\treturn *ret0, err\n}", "func (_HbSwap *HbSwapSession) InputmaskCnt() (*big.Int, error) {\n\treturn _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts)\n}", "func Int16ToStringIn(vs ...string) predicate.Conversion {\n\tv := make([]interface{}, len(vs))\n\tfor i := range v {\n\t\tv[i] = vs[i]\n\t}\n\treturn predicate.Conversion(func(s *sql.Selector) {\n\t\t// if not arguments were provided, append the FALSE constants,\n\t\t// since we can't apply \"IN ()\". This will make this predicate falsy.\n\t\tif len(v) == 0 {\n\t\t\ts.Where(sql.False())\n\t\t\treturn\n\t\t}\n\t\ts.Where(sql.In(s.C(FieldInt16ToString), v...))\n\t})\n}", "func (j *JustAddPowerReciever) SetAudioVideoInput(ctx context.Context, output, input string) error {\n\tj.Log.Debug(\"Setting receiver to transmitter\")\n\n\tgo j.checkTransmitterChannel(input)\n\n\tj.Log.Debug(\"Routing from, to\", zap.String(\"from\", j.Address), zap.String(\"to\", input))\n\n\tipAddress, err := net.ResolveIPAddr(\"ip\", input)\n\tipAddress.IP = ipAddress.IP.To4()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when resolving IP Address [%s]: %w\", input, err)\n\t}\n\n\tchannel := fmt.Sprintf(\"%v\", ipAddress.IP[3])\n\n\tj.Log.Debug(\"channel\", zap.String(\"channel\", channel))\n\n\tresult, errrr := justAddPowerRequest(fmt.Sprintf(\"http://%s/cgi-bin/api/command/channel\", j.Address), channel, \"POST\")\n\n\tif errrr != nil {\n\t\treturn fmt.Errorf(\"Error when making request: %w\", errrr)\n\t}\n\n\tvar jsonResult JustAddPowerChannelResult\n\terr = json.Unmarshal(result, &jsonResult)\n\n\tj.Log.Debug(\"Result\", zap.Any(\"jsonResult\", jsonResult))\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error when unpacking json\")\n\t}\n\treturn nil\n}", "func SetInput(ctx context.Context, address, output, input string) *nerr.E {\n\tin, err := strconv.Atoi(input)\n\tif err != nil {\n\t\treturn nerr.Translate(err).Addf(\"error when making call: %s\", err)\n\t}\n\turl := fmt.Sprintf(\"http://%s/cgi-bin/config.cgi\", address)\n\tpayload := strings.NewReader(\"\")\n\tif output == \"1\" {\n\t\tpayload = strings.NewReader(fmt.Sprintf(`\n\t\t{\n\t\t\t\"setConfig\":{\n\t\t\t\t\"video\":{\n\t\t\t\t\t\"vidOut\":{\n\t\t\t\t\t\t\"hdmiOut\":{\n\t\t\t\t\t\t\t\"hdmiOutA\":{\n\t\t\t\t\t\t\t\t\"videoSrc\":%v\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}`, in))\n\t} else if output == \"2\" {\n\t\tpayload = strings.NewReader(fmt.Sprintf(`\n\t\t{\n\t\t\t\"setConfig\":{\n\t\t\t\t\"video\":{\n\t\t\t\t\t\"vidOut\":{\n\t\t\t\t\t\t\"hdmiOut\":{\n\t\t\t\t\t\t\t\"hdmiOutB\":{\n\t\t\t\t\t\t\t\t\"videoSrc\":%v\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}`, in))\n\t} else {\n\t\treturn nerr.Create(\"Invalid Output. Valid Output names are 1 and 2\", \"\")\n\t}\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\treq = AddHeaders(req)\n\treq = req.WithContext(ctx)\n\tres, gerr := http.DefaultClient.Do(req)\n\tif gerr != nil {\n\t\treturn nerr.Translate(gerr).Addf(\"error when making call: %s\", gerr)\n\t}\n\tdefer res.Body.Close()\n\treturn nil\n}", "func (module *OscModule) DSP(timestamp int64) {\n\tbuflen := module.GetBufferLength()\n\tsr := module.GetSampleRate()\n\n\tvar pmodInput []float64\n\tvar fmodInput []float64\n\tvar ampInput []float64\n\n\toutput := module.Outlets[0].Buffer\n\n\t// Check if inlet is connected for phase modulation\n\tif module.Inlets[0].Connections.Len() > 0 {\n\t\tpmodInput = module.Inlets[0].Buffer\n\t}\n\n\tif module.Inlets[1].Connections.Len() > 0 {\n\t\tfmodInput = module.Inlets[1].Buffer\n\t}\n\n\tif module.Inlets[2].Connections.Len() > 0 {\n\t\tampInput = module.Inlets[2].Buffer\n\t}\n\n\tfor i := int32(0); i < buflen; i++ {\n\t\tpmod := 0.0\n\n\t\tif pmodInput != nil {\n\t\t\tpmod = pmodInput[i]\n\t\t}\n\n\t\tif fmodInput != nil {\n\t\t\tinc := fmodInput[i] / sr\n\t\t\tmodule.Inc = inc\n\t\t}\n\n\t\tif ampInput != nil {\n\t\t\tamp := ampInput[i]\n\t\t\tmodule.Amplitude = amp\n\t\t}\n\n\t\toutput[i] = module.Process(pmod)\n\t}\n}", "func (p PowerControl) In(val interface{}) {\n\tp.in <- val\n}", "func (m *Message) AllDSP() ([]*DSP, error) {\n\tpss, err := m.ParseAll(\"DSP\")\n\treturn pss.([]*DSP), err\n}", "func (e *Engine) callback(in []float32, out [][]float32) {\n\tfor k := 0; k < e.chunks; k++ {\n\t\tif msg := e.messages.Receive(); msg != nil {\n\t\t\te.handle(msg)\n\t\t}\n\n\t\tvar (\n\t\t\tframeSize = e.frameSize\n\t\t\toffset = frameSize * k\n\t\t\tinput = e.graph.in\n\t\t\tleftOut = e.graph.leftOut\n\t\t\trightOut = e.graph.rightOut\n\t\t\tgain = e.gain\n\t\t)\n\t\tfor i := 0; i < frameSize; i++ {\n\t\t\tinput[i] = float64(in[offset+i])\n\t\t}\n\t\tfor _, p := range e.graph.Processors() {\n\t\t\tp.ProcessFrame(frameSize)\n\t\t}\n\t\tfor i := range out {\n\t\t\tfor j := 0; j < frameSize; j++ {\n\t\t\t\tif i%2 == 0 {\n\t\t\t\t\tout[i][offset+j] = float32(leftOut[j]) * gain\n\t\t\t\t} else {\n\t\t\t\t\tout[i][offset+j] = float32(rightOut[j]) * gain\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func Transform(ctx context.Context, parallelism int, bufferSize int, in chan OutResult,\n\ttransformer func(interface{}) (interface{}, error), errhandler func(error),\n) chan InOutResult {\n\t// TODO: can we have a channel factory to do this?\n\toutChan := make(chan InOutResult, bufferSize)\n\tvar wg sync.WaitGroup\n\tif parallelism < 1 {\n\t\tparallelism = 1\n\t}\n\twg.Add(parallelism)\n\ti := func() {\n\t\tdefer wg.Done()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\tout := simpleInOut{\n\t\t\t\t\tsimpleOut: simpleOut{err: ctx.Err()},\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase outChan <- out:\n\t\t\t\tdefault:\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\tcase sr, ok := <-in:\n\t\t\t\t// do stuff, write to out maybe\n\t\t\t\tif !ok {\n\t\t\t\t\t// channel is closed, time to exit\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif sr.Err() != nil {\n\t\t\t\t\tif errhandler != nil {\n\t\t\t\t\t\terrhandler(sr.Err())\n\t\t\t\t\t}\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tres, err := transformer(sr.Output())\n\t\t\t\tif err == ErrSkip {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tout := simpleInOut{\n\t\t\t\t\tsimpleOut: simpleOut{err: err, out: res},\n\t\t\t\t\tin: sr.Output(),\n\t\t\t\t}\n\t\t\t\t// TODO: this section will never cancel if this write blocks. Problem?\n\t\t\t\toutChan <- out\n\t\t\t}\n\t\t}\n\t}\n\tfor x := 0; x < parallelism; x++ {\n\t\tgo i()\n\t}\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(outChan)\n\t}()\n\treturn outChan\n}", "func (m *moduleService) VifInput() *dpdk.Ring {\n\treturn m.vifInput\n}", "func HandleIn(em *Emulator, a int, b int) {\n addr := em.GetReg(b)\n \n if em.getPortAccess(addr) {\n data := em.LoadIOPort(addr)\n em.SetReg(a, data)\n em.LogInstruction(\"in %s, %s -- ports[0x%02X] = 0x%02X\", RegisterNames[a],\n RegisterNames[b], addr, data)\n \n } else {\n em.LogInstruction(\"in %s, %s -- not authorised\", RegisterNames[a], RegisterNames[b])\n }\n \n em.timer += 6;\n}", "func (p *ProxyHandler) handleInRequest(src grpc.ServerStream, dst grpc.ClientStream) error {\n\tmethodName, ok := grpc.MethodFromServerStream(src)\n\tif !ok {\n\t\treturn grpc.Errorf(codes.Internal, \"lowLevelServerStream not exists in context\")\n\t}\n\n\tcfg, ok := p.cfgManager.GetPartitionCfg()\n\tif ok && len(cfg.Ingress) > 0 {\n\t\tif err := p.processIngressNetwork(src, dst, cfg); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\trule, ok := p.cfgManager.GetFailpointCfg(methodName)\n\tif !ok {\n\t\treturn p.processNormal(src, dst)\n\t}\n\n\treturn p.processWithRule(src, dst, rule)\n}", "func handleInput(input string) string {\n\tswitch {\n\t// quit command\n\tcase input == \"quit\":\n\t\tfmt.Println(\"Quitting\")\n\t\tos.Exit(0)\n\t\treturn \"\"\n\tcase input == \"exit\":\n\t\tfmt.Println(\"Quitting\")\n\t\tos.Exit(0)\n\t\treturn \"\"\n\n\t// help command\n\tcase input == \"help\":\n\t\treturn \"This is the help command!\"\n\n\t// return last element\n\tcase input == \"last\":\n\t\treturn strconv.Itoa(lastResult)\n\n\t\t// clear screen\n\tcase input == \"clear\":\n\t\treturn \"\\033[H\\033[2J\"\n\n\t// conversions\n\tcase strings.Contains(input, \" as \"):\n\t\tparams := strings.Split(input, \" as \")\n\t\t//params[0] is the number argument f.e. '0x1234 as dec'\n\t\tif params[0] == \"last\" {\n\t\t\treturn convertNumberToOutputFormat(lastResult, params[1])\n\t\t}\n\n\t\tif strings.ContainsAny(input, \"&|^><~\") {\n\t\t\tresult, ok := calculateValue(params[0])\n\t\t\tif ok != true {\n\t\t\t\treturn \"Could not apply bitwise operation!\"\n\t\t\t}\n\t\t\treturn convertNumberToOutputFormat(result, params[1])\n\n\t\t}\n\t\tinputNumber, ok := convertInputToInt(params[0])\n\t\tif ok != true {\n\t\t\treturn \"Input number has wrong format!\"\n\t\t}\n\t\treturn convertNumberToOutputFormat(inputNumber, params[1])\n\n\t// calculations\n\tcase strings.ContainsAny(input, \"&|^><~+-*/\"):\n\t\tresult, ok := calculateValue(input)\n\t\tif ok != true {\n\t\t\treturn \"Could not apply bitwise operation!\"\n\t\t}\n\t\treturn strconv.Itoa(result)\n\tdefault:\n\t\treturn \"Unknown command!\"\n\t}\n}", "func ConvertNetmask(in uint8) (string, error) {\n\tif in > 32 {\n\t\treturn \"\", fmt.Errorf(\"invalid netmask\")\n\t}\n\toctets := map[uint8]uint8{\n\t\t1: 0,\n\t\t2: 0,\n\t\t3: 0,\n\t\t4: 0,\n\t}\n\tvar idx uint8 = 1\n\tfor in > 0 && idx < 5 {\n\t\tif (in / 8) > 0 {\n\t\t\tin = in - 8\n\t\t\toctets[idx] = 255\n\t\t} else {\n\t\t\tmod := in % 8\n\t\t\toctets[idx] = 255 - uint8(math.Pow(2, float64(8-mod))) + 1\n\t\t\tin = 0\n\t\t}\n\t\tidx++\n\t}\n\treturn fmt.Sprintf(\"%d.%d.%d.%d\", octets[1], octets[2], octets[3],\n\t\toctets[4]), nil\n}", "func fanIn(input1, input2 <-chan string) <-chan string {\n\tc := make(chan string)\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase s := <-input1:\n\t\t\t\tc <- s\n\t\t\tcase s := <-input2:\n\t\t\t\tc <- s\n\t\t\t}\n\t\t}\n\t}()\n\t\n\treturn c\n}", "func (d *DSP) SetChannelFormat(channelmask ChannelMask, numchannels int, source_speakermode SpeakerMode) error {\n\tres := C.FMOD_DSP_SetChannelFormat(d.cptr, C.FMOD_CHANNELMASK(channelmask), C.int(numchannels), C.FMOD_SPEAKERMODE(source_speakermode))\n\treturn errs[res]\n}", "func InMessage(messengerID, msg, stringBuffer string) (outServerMsg string, err error) {\n\tif msg == \"info\" {\n\t\toutServerMsg, err = controlsystemhome.GetInfoControlSystemHomeInterfaces()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tstr, errr := controlled.GetInfoControlledsString()\n\t\tif errr != nil {\n\t\t\terr = errr\n\t\t\treturn\n\t\t}\n\t\toutServerMsg += \"\\n\" + str\n\t\treturn\n\t}\n\n\toutServerMsg, err = commandrecord.UsedTextCommand(msg, stringBuffer)\n\treturn\n}", "func (_HbSwap *HbSwapFilterer) ParseInputmask(log types.Log) (*HbSwapInputmask, error) {\n\tevent := new(HbSwapInputmask)\n\tif err := _HbSwap.contract.UnpackLog(event, \"Inputmask\", log); err != nil {\n\t\treturn nil, err\n\t}\n\treturn event, nil\n}", "func (ch *RingChannel) In() chan<- interface{} {\n\treturn ch.input\n}", "func (i *UI) read(opts *readOptions) (string, error) {\n\ti.once.Do(i.setDefault)\n\n\t// sigCh is channel which is watch Interruptted signal (SIGINT)\n\tsigCh := make(chan os.Signal, 1)\n\tsignal.Notify(sigCh, os.Interrupt)\n\tdefer signal.Stop(sigCh)\n\n\tvar resultStr string\n\tvar resultErr error\n\tdoneCh := make(chan struct{})\n\n\tgo func() {\n\t\tdefer close(doneCh)\n\n\t\tif opts.mask {\n\t\t\tf, ok := i.Reader.(*os.File)\n\t\t\tif !ok {\n\t\t\t\tresultErr = fmt.Errorf(\"reader must be a file\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ti.mask, i.maskVal = opts.mask, opts.maskVal\n\t\t\tresultStr, resultErr = i.rawRead(f)\n\t\t} else {\n\t\t\tline, err := i.bReader.ReadString('\\n')\n\t\t\tif err != nil && err != io.EOF {\n\t\t\t\tresultErr = fmt.Errorf(\"failed to read the input: %s\", err)\n\t\t\t}\n\n\t\t\tresultStr = strings.TrimSuffix(line, \"\\n\")\n\t\t}\n\t}()\n\n\tselect {\n\tcase <-sigCh:\n\t\treturn \"\", ErrInterrupted\n\tcase <-doneCh:\n\t\treturn resultStr, resultErr\n\t}\n}", "func Uint16ToStringIn(vs ...string) predicate.Conversion {\n\tv := make([]interface{}, len(vs))\n\tfor i := range v {\n\t\tv[i] = vs[i]\n\t}\n\treturn predicate.Conversion(func(s *sql.Selector) {\n\t\t// if not arguments were provided, append the FALSE constants,\n\t\t// since we can't apply \"IN ()\". This will make this predicate falsy.\n\t\tif len(v) == 0 {\n\t\t\ts.Where(sql.False())\n\t\t\treturn\n\t\t}\n\t\ts.Where(sql.In(s.C(FieldUint16ToString), v...))\n\t})\n}", "func (p PowerControl) SetIn(in chan interface{}) {\n\tp.in = in\n}", "func notifyChanLimiter(maxSpeed time.Duration, inChan chan struct{}, outChan chan struct{}) {\n\n\t// we wait for an initial inChan message and then watch for spam to stop.\n\t// when inChan closes, the func exits\n\tfor range inChan {\n\t\tlog.Infoln(\"channel notify limiter witnessed an upstream message on inChan\")\n\n\t\t// Label for following for-select loop\n\t\tnotifyChannel:\n\t\t\tfor {\n\t\t\t\tlog.Debugln(\"channel notify limiter waiting to receive another inChan or notify after\", maxSpeed)\n\t\t\t\tselect {\n\t\t\t\tcase <-time.After(maxSpeed):\n\t\t\t\t\tlog.Debugln(\"channel notify limiter reached\", maxSpeed, \". Sending output\")\n\t\t\t\t\toutChan <- struct{}{}\n\t\t\t\t\t// break out of the for-select loop and go through next inChan loop iteration if any.\n\t\t\t\t\tbreak notifyChannel\n\t\t\t\tcase <-inChan:\n\t\t\t\t\tlog.Debugln(\"channel notify limiter witnessed an upstream message on inChan and is waiting an additional\", maxSpeed, \"before sending output\")\n\t\t\t\t}\n\t\t\t}\n\n\t\tlog.Debugln(\"channel notify limiter finished going through notifications\")\n\t}\n}", "func (m *SignalConfigRequest) String() (result string) {\n\tvar current_float float64\n\tspace3 := \" \"\n\tspace6 := space3 + space3\n\tspace9 := space6 + space3\n\tresult = \"\\n \\\"ietf-dots-signal-channel:signal-config\\\":\\n\"\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space3, \"mitigating-config\")\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"heartbeat-interval\")\n\tif m.SignalConfigs.MitigatingConfig.HeartbeatInterval.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.MitigatingConfig.HeartbeatInterval.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"missing-hb-allowed\")\n\tif m.SignalConfigs.MitigatingConfig.MissingHbAllowed.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.MitigatingConfig.MissingHbAllowed.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"max-retransmit\")\n\tif m.SignalConfigs.MitigatingConfig.MaxRetransmit.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.MitigatingConfig.MaxRetransmit.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ack-timeout\")\n\tif m.SignalConfigs.MitigatingConfig.AckTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.AckTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ack-random-factor\")\n\tif m.SignalConfigs.MitigatingConfig.AckRandomFactor.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.AckRandomFactor.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:max-payloads\")\n\tif m.SignalConfigs.MitigatingConfig.MaxPayload.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.MitigatingConfig.MaxPayload.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-max-retransmit\")\n\tif m.SignalConfigs.MitigatingConfig.NonMaxRetransmit.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.MitigatingConfig.NonMaxRetransmit.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-timeout\")\n\tif m.SignalConfigs.MitigatingConfig.NonTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.NonTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-receive-timeout\")\n\tif m.SignalConfigs.MitigatingConfig.NonReceiveTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.NonReceiveTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-probing-wait\")\n\tif m.SignalConfigs.MitigatingConfig.NonProbingWait.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.NonProbingWait.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-partial-wait\")\n\tif m.SignalConfigs.MitigatingConfig.NonPartialWait.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.MitigatingConfig.NonPartialWait.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space3, \"idle-config\")\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"heartbeat-interval\")\n\tif m.SignalConfigs.IdleConfig.HeartbeatInterval.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.IdleConfig.HeartbeatInterval.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"missing-hb-allowed\")\n\tif m.SignalConfigs.IdleConfig.MissingHbAllowed.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.IdleConfig.MissingHbAllowed.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"max-retransmit\")\n\tif m.SignalConfigs.IdleConfig.MaxRetransmit.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.IdleConfig.MaxRetransmit.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ack-timeout\")\n\tif m.SignalConfigs.IdleConfig.AckTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.AckTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ack-random-factor\")\n\tif m.SignalConfigs.IdleConfig.AckRandomFactor.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.AckRandomFactor.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:max-payloads\")\n\tif m.SignalConfigs.IdleConfig.MaxPayload.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.IdleConfig.MaxPayload.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-max-retransmit\")\n\tif m.SignalConfigs.IdleConfig.NonMaxRetransmit.CurrentValue != nil {\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %d\\n\", space9, \"current-value\", *m.SignalConfigs.IdleConfig.NonMaxRetransmit.CurrentValue)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-timeout\")\n\tif m.SignalConfigs.IdleConfig.NonTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.NonTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-receive-timeout\")\n\tif m.SignalConfigs.IdleConfig.NonReceiveTimeout.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.NonReceiveTimeout.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-probing-wait\")\n\tif m.SignalConfigs.IdleConfig.NonProbingWait.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.NonProbingWait.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\tresult += fmt.Sprintf(\"%s\\\"%s\\\":\\n\", space6, \"ietf-dots-robust-trans:non-partial-wait\")\n\tif m.SignalConfigs.IdleConfig.NonPartialWait.CurrentValue != nil {\n\t\tcurrent_float, _ = m.SignalConfigs.IdleConfig.NonPartialWait.CurrentValue.Round(2).Float64()\n\t\tresult += fmt.Sprintf(\"%s\\\"%s\\\": %f\\n\", space9, \"current-value-decimal\", current_float)\n\t}\n\treturn\n}", "func getProcessorFun(config Config) func(ctx processor.Context) error {\n\tformat := strings.ToLower(config.DebugFormat)\n\tif _, hasKey := validDebugFormats[format]; !hasKey {\n\t\tif format != \"\" {\n\t\t\tpanic(fmt.Sprintf(\"Wrong debug-format value: '%s'\", format))\n\t\t}\n\t}\n\n\treturn func(ctx processor.Context) error {\n\n\t\tinput := ctx.GetInputMessage(\"input\")\n\n\t\tswitch msg := input.(type) {\n\t\tcase *base.Bytes:\n\t\t\tfmt.Printf(\"%s\\n\", string(*msg))\n\n\t\tcase *base.Any:\n\t\t\tvar msgStr []byte\n\t\t\tvar err error\n\t\t\tswitch format {\n\t\t\tcase \"yaml\":\n\t\t\t\tfallthrough\n\t\t\tcase \"yml\":\n\t\t\t\tmsgStr, err = yaml.Marshal(msg)\n\t\t\t\tfmt.Printf(\"---\\n%s\", msgStr)\n\t\t\tcase \"json\":\n\t\t\t\tmsgStr, err = json.Marshal(msg)\n\t\t\t\tfmt.Printf(\"%s\\n\", msgStr)\n\t\t\tcase \"json-indent\":\n\t\t\t\tfallthrough\n\t\t\tdefault:\n\t\t\t\tmsgStr, err = json.MarshalIndent(msg, \"\", \" \")\n\t\t\t\tfmt.Printf(\"\\n%s\\n\", msgStr)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func handleNat44InterfaceOutputFeature(ifIdx uint32, isInside, isAdd bool, vppChan govppapi.Channel, stopwatch *measure.Stopwatch) error {\n\tdefer func(t time.Time) {\n\t\tstopwatch.TimeLog(nat.Nat44InterfaceAddDelOutputFeature{}).LogTimeEntry(time.Since(t))\n\t}(time.Now())\n\n\treq := &nat.Nat44InterfaceAddDelOutputFeature{\n\t\tSwIfIndex: ifIdx,\n\t\tIsInside: boolToUint(isInside),\n\t\tIsAdd: boolToUint(isAdd),\n\t}\n\n\treply := &nat.Nat44InterfaceAddDelOutputFeatureReply{}\n\tif err := vppChan.SendRequest(req).ReceiveReply(reply); err != nil {\n\t\treturn err\n\t}\n\tif reply.Retval != 0 {\n\t\treturn fmt.Errorf(\"%s returned %d\", reply.GetMessageName(), reply.Retval)\n\t}\n\n\treturn nil\n}", "func AnyFanIn(inps ...<-chan Any) (out <-chan Any) {\n\tcha := make(chan Any)\n\n\twg := new(sync.WaitGroup)\n\twg.Add(len(inps))\n\n\tgo fanInAnyWaitAndClose(cha, wg) // Spawn \"close(out)\" once all inps are done\n\n\tfor i := range inps {\n\t\tgo fanInAny(cha, inps[i], wg) // Spawn \"output(c)\"s\n\t}\n\n\treturn cha\n}", "func fanBoolIn(chans []chan BoolTuple, out chan BoolTuple) {\n\twg := sync.WaitGroup{}\n\twg.Add(len(chans))\n\tfor _, ch := range chans {\n\t\tgo func(ch chan BoolTuple) {\n\t\t\tfor t := range ch {\n\t\t\t\tout <- t\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(ch)\n\t}\n\twg.Wait()\n\tclose(out)\n}", "func FanIn(done <-chan interface{}, channels ...<-chan interface{}) <-chan interface{} {\n\tvar wg sync.WaitGroup\n\tmultiplexedStream := make(chan interface{})\n\tmultiple := func(c <-chan interface{}) {\n\t\tdefer wg.Done()\n\n\t\tfor i := range c {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\treturn\n\t\t\tcase multiplexedStream <- i:\n\t\t\t}\n\t\t}\n\t}\n\n\twg.Add(len(channels))\n\tfor _, c := range channels {\n\t\tgo multiple(c)\n\t}\n\n\t// Wait all read operations over\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(multiplexedStream)\n\t}()\n\n\treturn multiplexedStream\n}", "func (fn *formulaFuncs) IMSIN(argsList *list.List) formulaArg {\n\tif argsList.Len() != 1 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"IMSIN requires 1 argument\")\n\t}\n\tvalue := argsList.Front().Value.(formulaArg).Value()\n\tinumber, err := strconv.ParseComplex(str2cmplx(value), 128)\n\tif err != nil {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, err.Error())\n\t}\n\treturn newStringFormulaArg(cmplx2str(cmplx.Sin(inumber), value[len(value)-1:]))\n}", "func ProcessInputMessage(m string, kl int) float32 {\n\tmf := []string{}\n\n\tsplitMessageIntoParts(m, kl, &mf)\n\treturn discoverMessageParts(mf, kl)\n}", "func (d *DSP) Output(index int) (DSP, DspConnection, error) {\n\tvar output DSP\n\tvar outputconnection DspConnection\n\tres := C.FMOD_DSP_GetOutput(d.cptr, C.int(index), &output.cptr, &outputconnection.cptr)\n\treturn output, outputconnection, errs[res]\n}", "func processInputImage(img *gmagick.MagickWand, opts *Options) (*gmagick.MagickWand, *Color) {\n\tlog.Printf(\"Processing %v, h: %v, h:%v\", img.GetImageFilename(), img.GetImageHeight(), img.GetImageWidth())\n\tif int(img.GetImageWidth()) != opts.TileWidth || int(img.GetImageHeight()) != opts.TileHeight {\n\t\tlog.Printf(\"Img size doesn't match h:%v, w:%v\", opts.TileHeight, opts.TileWidth)\n\t\tscaled := img.Clone()\n\t\tscaled.ScaleImage(uint(opts.TileWidth), uint(opts.TileHeight))\n\t\tlog.Print(\"Scaled\")\n\n\t\terr := scaled.GetLastError()\n\t\tif err.Error() != GmagickNoError {\n\t\t\tlog.Println(\"Cannot scale %v: %v\", img, err.Error())\n\t\t\treturn nil, nil\n\t\t}\n\t\tvar px = getAverageColor(scaled)\n\t\treturn scaled, px\n\t}\n\tvar px = getAverageColor(img)\n\treturn img, px\n}", "func (inputs *input) getInputs() error {\n\n\tflag.IntVar(&inputs.limit, \"l\", 0, \"limit for queue length\")\n\tflag.StringVar(&inputs.host, \"h\", \"\", \"redis host\")\n\tflag.StringVar(&inputs.port, \"p\", \"\", \"redis port\")\n\tflag.StringVar(&inputs.source, \"s\", \"\", \"source queue name\")\n\tflag.StringVar(&inputs.destination, \"d\", \"\", \"destination queue name\")\n\tflag.StringVar(&inputs.how, \"t\", \"\", \"Type : LTR = Left to Right\\nRTL = Right to Left\\nLTL = Left to Left\\nRTR = Right to Right\")\n\tflag.BoolVar(&inputs.daemonMode, \"daemon\", false, \"Use if you want to run as a daemon\")\n\thelp := flag.Bool(\"help\", false, \"-help\")\n\tflag.Parse()\n\n\tif flag.NFlag() < 5 || *help {\n\t\tflag.PrintDefaults()\n\t\treturn fmt.Errorf(\"All Flags are required\")\n\t}\n\n\tinputs.how = strings.ToUpper(inputs.how)\n\n\treturn nil\n}", "func NewAudioConfigFromSpeakerOutput(deviceName string) (*AudioConfig, error) {\n\tvar handle C.SPXHANDLE\n\tdn := C.CString(deviceName)\n\tdefer C.free(unsafe.Pointer(dn))\n\tret := uintptr(C.audio_config_create_audio_output_from_a_speaker(&handle, dn))\n\tif ret != C.SPX_NOERROR {\n\t\treturn nil, common.NewCarbonError(ret)\n\t}\n\treturn newAudioConfigFromHandle(handle)\n}", "func (d *day14a) Process(line string) {\n\tif strings.HasPrefix(line, \"mask = \") {\n\t\td.orMask = 0\n\t\td.andMask = 1<<36 - 1\n\t\tfmt.Printf(\"and: %36b\\n\", d.andMask)\n\t\tfmt.Printf(\"or: %36b\\n\", d.orMask)\n\t\tfor i, c := range line[7:] {\n\t\t\tswitch c {\n\t\t\tcase 'X':\n\t\t\t\tcontinue\n\t\t\tcase '1':\n\t\t\t\td.orMask = d.orMask | uint64(1<<(35-i))\n\t\t\tcase '0':\n\t\t\t\td.andMask = d.andMask ^ uint64(1<<(35-i))\n\t\t\tdefault:\n\t\t\t\tpanic(\"unknown: \" + line)\n\t\t\t}\n\t\t}\n\t\tfmt.Printf(\"and: %36b\\n\", d.andMask)\n\t\tfmt.Printf(\"or: %36b\\n\", d.orMask)\n\t}\n\tif strings.HasPrefix(line, \"mem[\") {\n\t\tend := strings.Index(line, \"]\")\n\t\toffset, err := strconv.Atoi(line[4:end])\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tnum, err := strconv.ParseUint(line[end+4:], 10, 64)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trealNum := (num & d.andMask) | d.orMask\n\t\td.memory[offset] = realNum\n\t}\n}", "func convert(in <-chan []byte, out chan<- *flux.Series) {\n\tfor {\n\t\tselect {\n\t\tcase data := <-in:\n\t\t\tm, err := commons.ParseMetric(data)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error parsing Metric Collection: %v\", err)\n\t\t\t} else {\n\t\t\t\tout <- &flux.Series{\n\t\t\t\t\tName: m.FormatFQName(),\n\t\t\t\t\tColumns: []string{\"time\", \"value\"},\n\t\t\t\t\tPoints: [][]interface{}{{m.Timestamp.Unix(), m.Value}},\n\t\t\t\t} // series\n\t\t\t} // err\n\t\t} // select\n\t} // for\n}", "func (ap *App) Process(wparams *WinParams, pparams *ProcessParams, gparams *GaborParams) (err error) {\n\tap.LoadSound(wparams)\n\n\tif ap.Sound.Buf == nil {\n\t\tgi.PromptDialog(nil, gi.DlgOpts{Title: \"Sound buffer is empty\", Prompt: \"Open a sound file before processing\"}, gi.AddOk, gi.NoCancel, nil, nil)\n\t\treturn errors.New(\"Load a sound file and try again\")\n\t}\n\n\tif wparams.SegmentEnd <= wparams.SegmentStart {\n\t\tgi.PromptDialog(nil, gi.DlgOpts{Title: \"End <= Start\", Prompt: \"SegmentEnd must be greater than SegmentStart.\"}, gi.AddOk, gi.NoCancel, nil, nil)\n\t\treturn errors.New(\"SegmentEnd <= SegmentStart\")\n\t}\n\n\tif wparams.Resize {\n\t\tduration := wparams.SegmentEnd - wparams.SegmentStart\n\t\tstepMs := wparams.StepMs\n\t\tsizeXMs := float64(gparams.GaborSet.SizeX) * stepMs\n\t\tstrideXMs := float64(gparams.GaborSet.StrideX) * stepMs\n\t\tadd := 0.0\n\t\tif duration < sizeXMs {\n\t\t\tadd = sizeXMs - duration\n\t\t} else { // duration is longer than one filter so find the next stride end\n\t\t\td := duration\n\t\t\td -= sizeXMs\n\t\t\trem := float64(int(d) % int(strideXMs))\n\t\t\tif rem > 0 {\n\t\t\t\tadd = strideXMs - rem\n\t\t\t}\n\t\t}\n\t\tif wparams.SegmentStart-add < 0 {\n\t\t\twparams.SegmentEnd += add\n\t\t} else {\n\t\t\twparams.SegmentStart -= add / 2\n\t\t\twparams.SegmentEnd += add / 2\n\t\t}\n\t\tap.GUI.UpdateWindow()\n\t}\n\n\tsr := ap.Sound.SampleRate()\n\tif sr <= 0 {\n\t\tfmt.Println(\"sample rate <= 0\")\n\t\treturn errors.New(\"sample rate <= 0\")\n\n\t}\n\twparams.WinSamples = sound.MSecToSamples(wparams.WinMs, sr)\n\twparams.StepSamples = sound.MSecToSamples(wparams.StepMs, sr)\n\n\t// round up to nearest step interval\n\tsegmentMs := wparams.SegmentEnd - wparams.SegmentStart\n\tsegmentMs = segmentMs + wparams.StepMs*float64(int(segmentMs)%int(wparams.StepMs))\n\tsteps := int(segmentMs / wparams.StepMs)\n\twparams.StepsTotal = steps + 2*wparams.BorderSteps\n\n\twinSamplesHalf := wparams.WinSamples/2 + 1\n\tpparams.Mel.FBank.NFilters = 32\n\tpparams.Mel.InitFilters(wparams.WinSamples, ap.Sound.SampleRate(), &pparams.MelFilters) // call after non-default values are set!\n\tap.Window.SetShape([]int{wparams.WinSamples}, nil, nil)\n\tpparams.Power.SetShape([]int{winSamplesHalf}, nil, nil)\n\tpparams.LogPower.CopyShapeFrom(&pparams.Power)\n\tpparams.PowerSegment.SetShape([]int{winSamplesHalf, wparams.StepsTotal}, nil, nil)\n\tif pparams.Dft.CompLogPow {\n\t\tpparams.LogPowerSegment.CopyShapeFrom(&pparams.PowerSegment)\n\t}\n\tgparams.FftCoefs = make([]complex128, wparams.WinSamples)\n\tgparams.Fft = fourier.NewCmplxFFT(len(gparams.FftCoefs))\n\n\tpparams.Mel.FBank.LoHz = 0\n\n\t// 2 reasons for this code\n\t// 1 - the amount of signal handed to the fft has a \"border\" (some extra signal) to avoid edge effects.\n\t// On the first step there is no signal to act as the \"border\" so we pad the data handed on the front.\n\t// 2 - signals needs to be aligned when the number when multiple signals are input (e.g. 100 and 300 ms)\n\t// so that the leading edge (right edge) is the same time point.\n\t// This code does this by generating negative offsets for the start of the processing.\n\t// Also see SndToWindow for the use of the step values\n\tstepsBack := wparams.BorderSteps\n\twparams.Steps = make([]int, wparams.StepsTotal)\n\tfor i := 0; i < wparams.StepsTotal; i++ {\n\t\twparams.Steps[i] = wparams.StepSamples * (i - stepsBack)\n\t}\n\n\tpparams.MelFBank.SetShape([]int{pparams.Mel.FBank.NFilters}, nil, nil)\n\tpparams.MelFBankSegment.SetShape([]int{pparams.Mel.FBank.NFilters, wparams.StepsTotal}, nil, nil)\n\tpparams.Energy.SetShape([]int{wparams.StepsTotal}, nil, nil)\n\tif pparams.Mel.MFCC {\n\t\tpparams.MFCCDct.SetShape([]int{pparams.Mel.FBank.NFilters}, nil, nil)\n\t\tpparams.MFCCSegment.SetShape([]int{pparams.Mel.NCoefs, wparams.StepsTotal}, nil, nil)\n\t\tpparams.MFCCDeltas.SetShape([]int{pparams.Mel.NCoefs, wparams.StepsTotal}, nil, nil)\n\t\tpparams.MFCCDeltaDeltas.SetShape([]int{pparams.Mel.NCoefs, wparams.StepsTotal}, nil, nil)\n\t}\n\tsamples := sound.MSecToSamples(wparams.SegmentEnd-wparams.SegmentStart, ap.Sound.SampleRate())\n\tsiglen := len(ap.Signal.Values) - samples*ap.Sound.Channels()\n\tsiglen = siglen / ap.Sound.Channels()\n\n\tpparams.Power.SetZeros()\n\tpparams.LogPower.SetZeros()\n\tpparams.PowerSegment.SetZeros()\n\tpparams.LogPowerSegment.SetZeros()\n\tpparams.MelFBankSegment.SetZeros()\n\tpparams.MFCCSegment.SetZeros()\n\tpparams.Energy.SetZeros()\n\n\tfor s := 0; s < int(wparams.StepsTotal); s++ {\n\t\terr := ap.ProcessStep(s, wparams, pparams, gparams)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor s := 0; s < wparams.StepsTotal; s++ {\n\t\te := 0.0\n\t\tfor f := 0; f < pparams.LogPowerSegment.Shape.Dim(1); f++ {\n\t\t\te += pparams.LogPowerSegment.FloatValRowCell(f, s)\n\t\t}\n\t\tpparams.Energy.SetFloat1D(s, e)\n\t}\n\n\tfor s := 0; s < wparams.StepsTotal; s++ {\n\t\tpparams.MFCCSegment.SetFloatRowCell(0, s, pparams.Energy.FloatVal1D(s))\n\t}\n\n\t// calculate the MFCC deltas (change in MFCC coeficient over time - basically first derivative)\n\t// One source of the equation - https://priv\tacycanada.net/mel-frequency-cepstral-coefficient/#Mel-filterbank-Computation\n\n\t//denominator = 2 * sum([i**2 for i in range(1, N+1)])\n\t// N: For each frame, calculate delta features based on preceding and following N frames\n\tN := 2\n\tif pparams.Mel.MFCC && pparams.Mel.Deltas {\n\t\tfor s := 0; s < int(wparams.StepsTotal); s++ {\n\t\t\tprv := 0.0\n\t\t\tnxt := 0.0\n\t\t\tfor i := 0; i < pparams.Mel.NCoefs; i++ {\n\t\t\t\tnume := 0.0\n\t\t\t\tfor n := 1; n <= N; n++ {\n\t\t\t\t\tsprv := s - n\n\t\t\t\t\tsnxt := s + n\n\t\t\t\t\tif sprv < 0 {\n\t\t\t\t\t\tsprv = 0\n\t\t\t\t\t}\n\t\t\t\t\tif snxt > wparams.StepsTotal-1 {\n\t\t\t\t\t\tsnxt = wparams.StepsTotal - 1\n\t\t\t\t\t}\n\t\t\t\t\tprv += pparams.MFCCSegment.FloatValRowCell(i, sprv)\n\t\t\t\t\tnxt += pparams.MFCCSegment.FloatValRowCell(i, snxt)\n\t\t\t\t\tnume += float64(n) * (nxt - prv)\n\n\t\t\t\t\tdenom := n * n\n\t\t\t\t\td := nume / 2.0 * float64(denom)\n\t\t\t\t\tpparams.MFCCDeltas.SetFloatRowCell(i, s, d)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor s := 0; s < int(wparams.StepsTotal); s++ {\n\t\t\tprv := 0.0\n\t\t\tnxt := 0.0\n\t\t\tfor i := 0; i < pparams.Mel.NCoefs; i++ {\n\t\t\t\tnume := 0.0\n\t\t\t\tfor n := 1; n <= N; n++ {\n\t\t\t\t\tsprv := s - n\n\t\t\t\t\tsnxt := s + n\n\t\t\t\t\tif sprv < 0 {\n\t\t\t\t\t\tsprv = 0\n\t\t\t\t\t}\n\t\t\t\t\tif snxt > wparams.StepsTotal-1 {\n\t\t\t\t\t\tsnxt = wparams.StepsTotal - 1\n\t\t\t\t\t}\n\t\t\t\t\tprv += pparams.MFCCDeltas.FloatValRowCell(i, sprv)\n\t\t\t\t\tnxt += pparams.MFCCDeltas.FloatValRowCell(i, snxt)\n\t\t\t\t\tnume += float64(n) * (nxt - prv)\n\n\t\t\t\t\tdenom := n * n\n\t\t\t\t\td := nume / 2.0 * float64(denom)\n\t\t\t\t\tpparams.MFCCDeltaDeltas.SetFloatRowCell(i, s, d)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (p *SingleProcess) In(val interface{}) {\n\tp.in <- val\n}", "func CheckInput(sc ServerConfig) {\n\tfor {\n\t\tenvelope, ok := <-sc.Input\n\t\tif !ok {\n\t\t\tpanic(\"channels closed..\")\n\t\t}\n\t\tfmt.Printf(\"Received msg from %d to %d\\n\", envelope.SendBy, envelope.SendTo)\n\t\tsc.N_msgRcvd++\n\t}\n}", "func ProcessRecalboxSettingsForm(data map[string]interface{}) (err error) {\n\tpythonFile := viper.GetString(\"recalbox.pythonSettingsFile\")\n\n\tfor k, v := range data {\n\t\tvalue := fmt.Sprintf(\"%v\", v)\n\t\tif _, ok := v.(string); ok {\n\t\t\tvalue = \"'\" + v.(string) + \"'\"\n\t\t}\n\n\t\tnormalizedKey := strings.Replace(k, \"-\", \".\", -1)\n\t\t_, err = exec.Command(\"python\", pythonFile, \"-command\", \"save\", \"-key\", normalizedKey, \"-value\", value).CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif data[\"audio-volume\"] != nil {\n\t\tconfigScript := viper.GetString(\"recalbox.configScript\")\n\t\t_, err = exec.Command(configScript, \"volume\", fmt.Sprintf(\"%v\", data[\"audio-volume\"])).CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func userInput(inVal string, rangeLower float64, rangeHigher float64, ok bool) string {\n\tscanner := bufio.NewScanner(os.Stdin)\n\tfmt.Println(inVal)\n\tvar input string\n\tfor scanner.Scan() {\n\t\tif ok {\n\t\t\ti, err := strconv.ParseInt(scanner.Text(), 10, 64)\n\t\t\tif err == nil && float64(i) >= rangeLower && float64(i) <= rangeHigher {\n\t\t\t\tinput = scanner.Text()\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else {\n\t\t\ti, err := strconv.ParseFloat(scanner.Text(), 64)\n\t\t\tif err == nil && i >= rangeLower && i <= rangeHigher {\n\t\t\t\tinput = scanner.Text()\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfmt.Println(inVal)\n\t}\n\treturn input\n}", "func (i *in) Underlying() interface{} {\n\treturn i.midiIn\n}", "func Vfix16(input []float32, inputStride int, output []int16, outputStride int) {\n\tC.vDSP_vfix16((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.short)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))\n}", "func InoutFree(i **Input) {\n\tC.avfilter_inout_free((**C.struct_AVFilterInOut)(unsafe.Pointer(i)))\n}", "func (f *Format) Channels() int {\n\treturn f.channels\n}", "func (m *Messenger) HandleOptIn(f OptInHandler) {\n\tm.optInHandlers = append(m.optInHandlers, f)\n}", "func decodeBool16(mask uint64) func(b []byte) float64 {\n\treturn func(b []byte) float64 {\n\t\tu := binary.BigEndian.Uint16(b)\n\t\tif mask > 0 {\n\t\t\tu = u & uint16(mask)\n\t\t}\n\t\tif u > 0 {\n\t\t\treturn 1\n\t\t}\n\t\treturn 0\n\t}\n}", "func (m *modules) Process(samplesIn [][]float32, midiIn []midi.Event) (samplesOut [][]float32, midiOut []midi.Event) {\n\tsamples, midi := samplesIn, midiIn\n\n\tsamples, midi = m.keyboard.Process(samples, midi)\n\tsamples, midi = m.dspEngine.Process(samples, midi)\n\n\treturn samples, midi\n}", "func flac2wav(in os.File, n Namer) (os.File, error) {\n\tout := n(in)\n\tcmd := exec.Command(\"flac\",\n\t\t\"-f\", // overwrite any existing file\n\t\t\"--silent\",\t// output is useless because we are multiplexing goroutines\n\t\t\"-d\", in.Name(), // decode file (input)\n\t\t\"-o\", out.Name()) // output file\n\tcmd.Stderr = os.Stderr\n\tcmd.Stdout = os.Stdout\n\terr := cmd.Run()\n\treturn out, err\n}", "func (m *transformSource) generateInouts(ctx blueprint.ModuleContext, g generatorBackend) []inout {\n\tvar inouts []inout\n\tre := regexp.MustCompile(m.Properties.Out.Match)\n\n\tfor _, source := range m.sourceInfo(ctx, g) {\n\t\tio := m.Properties.inoutForSrc(re, source, m.generateCommon.Properties.Depfile,\n\t\t\tm.generateCommon.Properties.Rsp_content != nil)\n\t\tinouts = append(inouts, io)\n\t}\n\n\treturn inouts\n}", "func OutputSelector(outputType uint32) (serializer.Serializable, error) {\n\tvar seri serializer.Serializable\n\tswitch byte(outputType) {\n\tcase OutputSigLockedSingleOutput:\n\t\tseri = &SigLockedSingleOutput{}\n\tcase OutputSigLockedDustAllowanceOutput:\n\t\tseri = &SigLockedDustAllowanceOutput{}\n\tcase OutputTreasuryOutput:\n\t\tseri = &TreasuryOutput{}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%w: type %d\", ErrUnknownOutputType, outputType)\n\t}\n\treturn seri, nil\n}", "func (this *channelMeterStruct) process(buffer []float64, sampleRate uint32) {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\n\t/*\n\t * Only perform processing if this channel is enabled.\n\t */\n\tif enabled {\n\t\tthis.mutex.RLock()\n\t\tcurrentValue := this.currentValue\n\t\tpeakValue := this.peakValue\n\t\tsampleCounter := this.sampleCounter\n\t\tthis.mutex.RUnlock()\n\t\tsampleRateFloat := float64(sampleRate)\n\t\tholdTimeSamples := uint64(PEAK_HOLD_TIME_SECONDS * sampleRateFloat)\n\t\tdecayExp := -1.0 / (TIME_CONSTANT * sampleRateFloat)\n\t\tdecayFactor := math.Pow(10.0, decayExp)\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor _, sample := range buffer {\n\t\t\tcurrentValue *= decayFactor\n\n\t\t\t/*\n\t\t\t * If we're above the hold time, let the peak indicator decay,\n\t\t\t * otherwise increment sample counter.\n\t\t\t */\n\t\t\tif sampleCounter > holdTimeSamples {\n\t\t\t\tpeakValue *= decayFactor\n\t\t\t} else {\n\t\t\t\tsampleCounter++\n\t\t\t}\n\n\t\t\tsampleAbs := math.Abs(sample)\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger amplitude, update current value.\n\t\t\t */\n\t\t\tif sampleAbs > currentValue {\n\t\t\t\tcurrentValue = sampleAbs\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger or equal amplitude, update peak value.\n\t\t\t */\n\t\t\tif sampleAbs >= peakValue {\n\t\t\t\tpeakValue = sampleAbs\n\t\t\t\tsampleCounter = 0\n\t\t\t}\n\n\t\t}\n\n\t\tthis.mutex.Lock()\n\t\tthis.currentValue = currentValue\n\t\tthis.peakValue = peakValue\n\t\tthis.sampleCounter = sampleCounter\n\t\tthis.mutex.Unlock()\n\t}\n\n}", "func PipeChan(capacity int) (inputCh chan notify.EventInfo, outputCh chan notify.EventInfo) {\n\n\t// A set of channels which store all elements received from input\n\tchannels := make(chan chan notify.EventInfo, 1000)\n\n\tinputCh = make(chan notify.EventInfo, capacity)\n\n\t// A goroutine which receives elements from inputCh and creates\n\t// new channels when needed.\n\tgo func() {\n\t\t// Create the first channel\n\t\tcurrCh := make(chan notify.EventInfo, capacity)\n\t\tchannels <- currCh\n\n\t\tfor elem := range inputCh {\n\t\t\t// Prepare next channel with a double capacity when\n\t\t\t// half of the current channel is already filled.\n\t\t\tif len(currCh) >= cap(currCh)/2 {\n\t\t\t\tclose(currCh)\n\t\t\t\tcurrCh = make(chan notify.EventInfo, cap(currCh)*2)\n\t\t\t\tchannels <- currCh\n\t\t\t}\n\t\t\t// Prepare next channel with half capacity when\n\t\t\t// current channel is 1/4 filled\n\t\t\tif len(currCh) >= capacity && len(currCh) <= cap(currCh)/4 {\n\t\t\t\tclose(currCh)\n\t\t\t\tcurrCh = make(chan notify.EventInfo, cap(currCh)/2)\n\t\t\t\tchannels <- currCh\n\t\t\t}\n\t\t\t// Send element to current channel\n\t\t\tcurrCh <- elem\n\t\t}\n\n\t\tclose(currCh)\n\t\tclose(channels)\n\t}()\n\n\t// Copy elements from infinite channel set to the output\n\toutputCh = make(chan notify.EventInfo, capacity)\n\tgo func() {\n\t\tfor {\n\t\t\tcurrCh, ok := <-channels\n\t\t\tif !ok {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tfor v := range currCh {\n\t\t\t\toutputCh <- v\n\t\t\t}\n\t\t}\n\t\tclose(outputCh)\n\t}()\n\treturn inputCh, outputCh\n}", "func (wrapper *TvmWrapper) Infer(moduleInfo *moduleInfo, input []float32) ([]float32, error) {\n\tdefer runtime.GC()\n\tgraphmod := moduleInfo.graphModule\n\tinputShape := moduleInfo.inputShape\n\toutputShape := moduleInfo.outputShape\n\n\t// set input\n\tfuncp, err := graphmod.GetFunction(\"set_input\")\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\t// TODO : use device type\n\tinputForTvm, err := gotvm.Empty(inputShape, \"float32\", gotvm.CPU(0))\n\tif err != nil {\n\t\tfmt.Print(err)\n\t\treturn nil, err\n\t}\n\tinputForTvm.CopyFrom(input)\n\t_, err = funcp.Invoke(\"input\", inputForTvm)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\n\t// start to inference function\n\tfuncp, err = graphmod.GetFunction(\"run\")\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\t_, err = funcp.Invoke()\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\n\t// Allocate output array to receive output data from inference function\n\tout, err := gotvm.Empty(outputShape)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\n\t// get output from inference function\n\tfuncp, err = graphmod.GetFunction(\"get_output\")\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\t_, err = funcp.Invoke(int64(0), out)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn nil, err\n\t}\n\toutAsSlice, _ := out.AsSlice()\n\treturn outAsSlice.([]float32), nil\n}", "func decodeMask(mask string) (uint32, error) {\n\timask, err := strconv.Atoi(mask)\n\tvar outmask uint32\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"Error decoding netmask\")\n\t}\n\tif imask > 32 || imask < 0 {\n\t\treturn 0, errors.New(\"Mask out of bounds\")\n\t}\n\tfor i := 0; i < imask; i++ {\n\t\toutmask += 1 << i\n\t}\n\treturn outmask, nil\n}", "func (t *splitter) OnIn(s string) {\n\tt.Out1 <- s\n\tt.Out2 <- s\n}", "func (m *Processor) Process(pipeID string, sampleRate signal.SampleRate, numChannels int) (func(signal.Float64) error, error) {\n\treturn func(b signal.Float64) error {\n\t\tif m.ErrorOnCall != nil {\n\t\t\treturn m.ErrorOnCall\n\t\t}\n\t\tm.advance(b.Size())\n\t\treturn nil\n\t}, nil\n}", "func nicInfoFlagsToFIDL(info stack.NICInfo) socket.InterfaceFlags {\n\tifs := info.Context.(*ifState)\n\tvar bits socket.InterfaceFlags\n\tflags := info.Flags\n\tif flags.Loopback {\n\t\tbits |= socket.InterfaceFlagsLoopback\n\t}\n\tif flags.Running {\n\t\tbits |= socket.InterfaceFlagsRunning\n\t}\n\tif flags.Promiscuous {\n\t\tbits |= socket.InterfaceFlagsPromisc\n\t}\n\t// Check `IsUpLocked` because netstack interfaces are always defined to be\n\t// `Up` in gVisor.\n\tifs.mu.Lock()\n\tif ifs.IsUpLocked() {\n\t\tbits |= socket.InterfaceFlagsUp\n\t}\n\tifs.mu.Unlock()\n\t// Approximate that all interfaces support multicasting.\n\tbits |= socket.InterfaceFlagsMulticast\n\treturn bits\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (i *Iec62056) Signin(address string) ([]byte, ValueCollection, error) {\n\tif len(address) > 32 {\n\t\treturn nil, nil, ErrAddressTooLong\n\t}\n\n\t// Say hello :)\n\tsignin := fmt.Sprintf(\"/?%s!\\r\\n\", address)\n\ti.port.Write([]byte(signin))\n\n\t// Read \"identify\" line\n\tidentify, err := i.read(1000, &LineFeed)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// read message\n\tpayload, err := i.read(3000, &FrameEnd)\n\tif err != nil {\n\t\treturn identify, nil, err\n\t}\n\n\t// read and ignore checksum\n\t_, err = i.read(1, nil)\n\tif err != nil {\n\t\treturn identify, nil, err\n\t}\n\n\tcollection, err := NewValueCollection(payload)\n\t//\tfmt.Printf(\"ID: \\033[32m%v\\033[0m\\nPayload:\\n\\033[32m%v\\033[0m\\nBCC: 0x\\033[32m%x\\033[0m\\nCalculated BCC: 0x\\033[32m%x\\033[0m\\n\", string(identify), string(payload[1:]), checksum[0], bcc(payload))\n\treturn identify, collection, err\n}", "func outputSamplesProg(tb testing.TB, events *ebpf.Map, sampleSizes ...byte) *ebpf.Program {\n\ttb.Helper()\n\n\t// Requires at least 4.9 (0515e5999a46 \"bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type\")\n\ttestutils.SkipOnOldKernel(tb, \"4.9\", \"perf events support\")\n\n\tconst bpfFCurrentCPU = 0xffffffff\n\n\tvar maxSampleSize byte\n\tfor _, sampleSize := range sampleSizes {\n\t\tif sampleSize < 2 {\n\t\t\ttb.Fatalf(\"Sample size %d is too small to contain size and counter\", sampleSize)\n\t\t}\n\t\tif sampleSize > maxSampleSize {\n\t\t\tmaxSampleSize = sampleSize\n\t\t}\n\t}\n\n\t// Fill a buffer on the stack, and stash context somewhere\n\tinsns := asm.Instructions{\n\t\tasm.LoadImm(asm.R0, ^int64(0), asm.DWord),\n\t\tasm.Mov.Reg(asm.R9, asm.R1),\n\t}\n\n\tbufDwords := int(maxSampleSize/8) + 1\n\tfor i := 0; i < bufDwords; i++ {\n\t\tinsns = append(insns,\n\t\t\tasm.StoreMem(asm.RFP, int16(i+1)*-8, asm.R0, asm.DWord),\n\t\t)\n\t}\n\n\tfor i, sampleSize := range sampleSizes {\n\t\tinsns = append(insns,\n\t\t\t// Restore stashed context.\n\t\t\tasm.Mov.Reg(asm.R1, asm.R9),\n\t\t\t// map\n\t\t\tasm.LoadMapPtr(asm.R2, events.FD()),\n\t\t\t// flags\n\t\t\tasm.LoadImm(asm.R3, bpfFCurrentCPU, asm.DWord),\n\t\t\t// buffer\n\t\t\tasm.Mov.Reg(asm.R4, asm.RFP),\n\t\t\tasm.Add.Imm(asm.R4, int32(bufDwords*-8)),\n\t\t\t// buffer[0] = size\n\t\t\tasm.StoreImm(asm.R4, 0, int64(sampleSize), asm.Byte),\n\t\t\t// buffer[1] = i\n\t\t\tasm.StoreImm(asm.R4, 1, int64(i&math.MaxUint8), asm.Byte),\n\t\t\t// size\n\t\t\tasm.Mov.Imm(asm.R5, int32(sampleSize)),\n\t\t\tasm.FnPerfEventOutput.Call(),\n\t\t)\n\t}\n\n\tinsns = append(insns, asm.Return())\n\n\tprog, err := ebpf.NewProgram(&ebpf.ProgramSpec{\n\t\tLicense: \"GPL\",\n\t\tType: ebpf.XDP,\n\t\tInstructions: insns,\n\t})\n\tif err != nil {\n\t\ttb.Fatal(err)\n\t}\n\ttb.Cleanup(func() { prog.Close() })\n\n\treturn prog\n}", "func (p *Payload) GetInDev() uint32 {\n\treturn uint32(C.nfq_get_indev(p.nfad))\n}", "func InputArtnetUniverse(addr ArtnetAddress) (chan dmx.DMXFrame, error) {\n\n // Initialise the input channel list if needed \n if inputUniverseChannels == nil {\n inputUniverseChannels = make(map[uint16] chan dmx.DMXFrame)\n }\n\n // Build the Art-Net encoded address for lookup\n portAddr := addr.Encode()\n\n // Check if an output channel already exists\n _, exists := inputUniverseChannels[portAddr]\n\n if exists {\n return nil, errors.New(\"Universe already has a channel\")\n }\n\n // Build store and return a new channel\n dmx := make(chan dmx.DMXFrame)\n inputUniverseChannels[portAddr] = dmx\n return dmx, nil\n}", "func main() {\n\tflag.UintVar(&inport1, \"inport1\", 0, \"port for 1st receiver\")\n\tflag.UintVar(&inport2, \"inport2\", 1, \"port for 2nd receiver\")\n\tflag.UintVar(&outport, \"outport\", 0, \"port for sender\")\n\n\t// Init YANFF system at requested number of cores.\n\tflow.SystemInit(16)\n\n\t// Receive packets from 0 and 1 ports\n\tinputFlow1 := flow.SetReceiver(uint8(inport1))\n\tinputFlow2 := flow.SetReceiver(uint8(inport2))\n\n\toutputFlow := flow.SetMerger(inputFlow1, inputFlow2)\n\tflow.SetSender(outputFlow, uint8(outport))\n\n\t// Begin to process packets.\n\tflow.SystemStart()\n}", "func Example_4() {\n\t// open input file.\n\tinputFile, err := os.Open(\"_testdata/sample1.wav\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to open input file: %v\", err)\n\t}\n\tdefer inputFile.Close()\n\n\t// asset sink.\n\tasset := &audio.Asset{}\n\n\t// read wav pipeline.\n\twavFile, err := pipe.New(\n\t\t&pipe.Line{\n\t\t\t// wav pump.\n\t\t\tPump: &wav.Pump{ReadSeeker: inputFile},\n\t\t\t// in-memory asset.\n\t\t\tSinks: pipe.Sinks(asset),\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to bind import pipeline: %v\", err)\n\t}\n\tdefer wavFile.Close()\n\n\terr = pipe.Wait(wavFile.Run(context.Background(), 512))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to execute import pipeline: %v\", err)\n\t}\n\n\t// track pump.\n\ttrack := audio.NewTrack(asset.SampleRate(), asset.NumChannels())\n\n\t// add samples.\n\ttrack.AddClip(198450, asset.Clip(0, 44100))\n\ttrack.AddClip(66150, asset.Clip(44100, 44100))\n\ttrack.AddClip(132300, asset.Clip(0, 44100))\n\n\t// create output file.\n\toutputFile, err := os.Create(\"_testdata/out4.wav\")\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create output file: %v\", err)\n\t}\n\tdefer outputFile.Close()\n\n\t// pipeline to process clips.\n\tp, err := pipe.New(\n\t\t&pipe.Line{\n\t\t\t// track with clips.\n\t\t\tPump: track,\n\t\t\tSinks: pipe.Sinks(\n\t\t\t\t// wav sink.\n\t\t\t\t&wav.Sink{\n\t\t\t\t\tWriteSeeker: outputFile,\n\t\t\t\t\tBitDepth: signal.BitDepth16,\n\t\t\t\t},\n\t\t\t\t// portaudio sink.\n\t\t\t\t&portaudio.Sink{},\n\t\t\t),\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to bind playback and save pipeline: %v\", err)\n\t}\n\tdefer p.Close()\n\n\t// run the pipeline.\n\terr = pipe.Wait(p.Run(context.Background(), 512))\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to execute playback and save pipeline: %v\", err)\n\t}\n}", "func Conv(input string, tocode string, fromcode string) (string, error) {\n\th, err := Open(tocode, fromcode)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer h.Close()\n\treturn h.Conv(input)\n}", "func (nims *NetInterfaceModeSelect) Ints(ctx context.Context) ([]int, error) {\n\tif len(nims.fields) > 1 {\n\t\treturn nil, errors.New(\"ent: NetInterfaceModeSelect.Ints is not achievable when selecting more than 1 field\")\n\t}\n\tvar v []int\n\tif err := nims.Scan(ctx, &v); err != nil {\n\t\treturn nil, err\n\t}\n\treturn v, nil\n}", "func handler() {\n\n\t//get mime type\n\tif pMimeType != \"\" {\n\t\tv := Formatters[\"MIME-TYPE\"]\n\t\t_, resmsg := v.Format(v.Mode, pMimeType)\n\t\tfmt.Println(resmsg)\n\t\treturn\n\t}\n\t//get mime list\n\tif pMimeList {\n\t\tv := Formatters[\"MIME-LIST\"]\n\t\t_, resmsg := v.Format(v.Mode, pMimeType)\n\t\tfmt.Println(resmsg)\n\t\treturn\n\t}\n\t//encode\n\tif pEncData != \"\" {\n\t\tv := Formatters[\"ENC-DATA\"]\n\t\trescode, resmsg := v.Format(v.Mode, pEncData)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//encode-url\n\tif pEncUrl != \"\" {\n\t\tv := Formatters[\"ENC-URL\"]\n\t\trescode, resmsg := v.Format(v.Mode, pEncUrl)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//decode\n\tif pDecData != \"\" {\n\t\tv := Formatters[\"DEC-DATA\"]\n\t\trescode, resmsg := v.Format(v.Mode, pDecData)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//decode-url\n\tif pDecUrl != \"\" {\n\t\tv := Formatters[\"DEC-URL\"]\n\t\trescode, resmsg := v.Format(v.Mode, pDecUrl)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//encode:b64\n\tif pBase64Enc != \"\" {\n\t\tv := Formatters[\"B64-ENC-DATA\"]\n\t\trescode, resmsg := v.Format(v.Mode, pBase64Enc)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//encode-url:b64\n\tif pBase64UrlEnc != \"\" {\n\t\tv := Formatters[\"B64-ENC-URL\"]\n\t\trescode, resmsg := v.Format(v.Mode, pBase64UrlEnc)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//decode:b64\n\tif pBase64Dec != \"\" {\n\t\tv := Formatters[\"B64-DEC-DATA\"]\n\t\trescode, resmsg := v.Format(v.Mode, pBase64Dec)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//decode-url:b64\n\tif pBase64UrlDec != \"\" {\n\t\tv := Formatters[\"B64-DEC-URL\"]\n\t\trescode, resmsg := v.Format(v.Mode, pBase64UrlDec)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//html-esc\n\tif pHtmlEsc != \"\" {\n\t\tv := Formatters[\"HTML-ENC-DATA\"]\n\t\trescode, resmsg := v.Format(v.Mode, pHtmlEsc)\n\t\tshowStatus(rescode, resmsg)\n\t\treturn\n\t}\n\t//html-esc-url\n\tif pHtmlUrlEsc != \"\" {\n\t\tv := Formatters[\"HTML-ENC-URL\"]\n\t\trescode, resmsg := v.Format(v.Mode, pHtmlUrlEsc)\n\t\tif !pHttpServe {\n\t\t\tshowStatus(rescode, resmsg)\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\t//qrcode\n\tif pQRCodeGen != \"\" {\n\t\tv := Formatters[\"QR-CODE-GEN\"]\n\t\trescode, resmsg := v.Format(v.Mode, pQRCodeGen)\n\t\tif !pHttpServe {\n\t\t\tshowStatus(rescode, resmsg)\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\t//serve http\n\tif pHttpServe {\n\t\tinitHttpRouters()\n\t\treturn\n\t}\n\n}", "func openIn(d Driver, number int, name string) (in In, err error) {\n\tins, err := d.Ins()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't find MIDI input ports: %v\", err)\n\t}\n\n\tif number >= 0 {\n\t\tfor _, port := range ins {\n\t\t\tif number == port.Number() {\n\t\t\t\tin = port\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", number)\n\t\t}\n\t} else {\n\t\tif name != \"\" {\n\t\t\tfor _, port := range ins {\n\t\t\t\tif strings.Contains(port.String(), name) {\n\t\t\t\t\tin = port\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif in == nil {\n\t\t\treturn nil, fmt.Errorf(\"can't find MIDI input port %v\", name)\n\t\t}\n\t}\n\n\t// should not happen here, since we already returned above\n\tif in == nil {\n\t\tpanic(\"unreachable\")\n\t}\n\n\terr = in.Open()\n\treturn\n}", "func ConfigFlagsProcess() (err error) {\n\n\t// Read if not yet read\n\tif Config.When == \"\" {\n\t\terr = ConfigRead()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Reset if requested\n\tif flagConfigReset {\n\t\tConfigReset()\n\t}\n\n\t// Set the flags as desired\n\tif flagConfigHTTP {\n\t\tConfig.Secure = false\n\t}\n\tif flagConfigHTTPS {\n\t\tConfig.Secure = true\n\t}\n\tif flagConfig.Hub == \"-\" {\n\t\tConfig.Hub = notehub.DefaultAPIService\n\t} else if flagConfig.Hub != \"\" {\n\t\tConfig.Hub = flagConfig.Hub\n\t}\n\tif flagConfig.Root == \"-\" {\n\t\tConfig.Root = \"\"\n\t} else if flagConfig.Root != \"\" {\n\t\tConfig.Root = flagConfig.Root\n\t}\n\tif flagConfig.Key == \"-\" {\n\t\tConfig.Key = \"\"\n\t} else if flagConfig.Key != \"\" {\n\t\tConfig.Key = flagConfig.Key\n\t}\n\tif flagConfig.Cert == \"-\" {\n\t\tConfig.Cert = \"\"\n\t} else if flagConfig.Cert != \"\" {\n\t\tConfig.Cert = flagConfig.Cert\n\t}\n\tif flagConfig.App == \"-\" {\n\t\tConfig.App = \"\"\n\t} else if flagConfig.App != \"\" {\n\t\tConfig.App = flagConfig.App\n\t}\n\tif flagConfig.Device == \"-\" {\n\t\tConfig.Device = \"\"\n\t} else if flagConfig.Device != \"\" {\n\t\tConfig.Device = flagConfig.Device\n\t}\n\tif flagConfig.Product == \"-\" {\n\t\tConfig.Product = \"\"\n\t} else if flagConfig.Product != \"\" {\n\t\tConfig.Product = flagConfig.Product\n\t}\n\tif flagConfig.Interface == \"-\" {\n\t\tconfigResetInterface()\n\t} else if flagConfig.Interface != \"\" {\n\t\tConfig.Interface = flagConfig.Interface\n\t}\n\tif flagConfig.Port != \"\" {\n\t\tConfig.Port = flagConfig.Port\n\t}\n\tif flagConfig.PortConfig != -1 {\n\t\tConfig.PortConfig = flagConfig.PortConfig\n\t}\n\n\t// Save if requested\n\tif flagConfigSave {\n\t\tConfigWrite()\n\t\tConfigShow()\n\t}\n\n\t// Override, just for this session, with env vars\n\tstr := os.Getenv(\"NOTE_INTERFACE\")\n\tif str != \"\" {\n\t\tConfig.Interface = str\n\t}\n\tstr = os.Getenv(\"NOTE_PORT\")\n\tif str != \"\" {\n\t\tConfig.Port = str\n\t\tstr := os.Getenv(\"NOTE_PORT_CONFIG\")\n\t\tstrint, err2 := strconv.Atoi(str)\n\t\tif err2 != nil {\n\t\t\tstrint = Config.PortConfig\n\t\t}\n\t\tConfig.PortConfig = strint\n\t}\n\n\t// Done\n\treturn nil\n\n}", "func Interface(ctx context.Context, i, ch uint8) (gate, key, vel control.CV, err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"midi.Interface: %v\", err)\n\t\t}\n\t}()\n\n\tdrv, err := portmididrv.New()\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tins, err := drv.Ins()\n\tif len(ins) <= int(i) {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tin := ins[i]\n\tif err := in.Open(); err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\trd := reader.New(reader.NoLogger())\n\n\tgateCh := make(chan modular.V)\n\tkeyCh := make(chan modular.V)\n\tvelCh := make(chan modular.V)\n\n\trd.Channel.NoteOn = func(p *reader.Position, channel, key, vel uint8) {\n\t\tif channel != ch {\n\t\t\treturn\n\t\t}\n\t\tgateCh <- 1\n\t\tkeyCh <- modular.V(key)\n\t\tvelCh <- modular.V(vel) / 127\n\t}\n\n\trd.Channel.NoteOff = func(p *reader.Position, channel, key, vel uint8) {\n\t\tif channel != ch {\n\t\t\treturn\n\t\t}\n\t\tgateCh <- 0\n\t\tvelCh <- 0\n\t}\n\n\tgo func() {\n\t\tdefer func() {\n\t\t\tclose(gateCh)\n\t\t\tclose(keyCh)\n\t\t\tclose(velCh)\n\t\t}()\n\t\tif err := rd.ListenTo(in); err != nil {\n\t\t\tpanic(fmt.Errorf(\"midi.Interface: %v\", err))\n\t\t}\n\t}()\n\n\treturn gateCh, keyCh, velCh, nil\n}", "func (r *Resampler) Write(p []byte) (out []byte, err error) {\n\t//fmt.Println(\"Write channels:\", r.channels)\n\tif r.resampler == nil {\n\t\terr = errors.New(\"soxr resampler is nil\")\n\t\treturn\n\t}\n\tif len(p) == 0 {\n\t\treturn\n\t}\n\tframesIn := len(p) / r.frameSize / r.channels\n\tif framesIn == 0 {\n\t\terr = errors.New(\"Incomplete input frame data\")\n\t\treturn\n\t}\n\tif len(p)%(r.frameSize*r.channels) != 0 {\n\t\terr = errors.New(\"Fragmented last frame in input data\")\n\t\treturn\n\t}\n\tframesOut := int(float64(framesIn) * (r.outRate / r.inRate))\n\tif framesOut == 0 {\n\t\terr = errors.New(\"Not enough input to generate output\")\n\t\treturn\n\t}\n\n\tdataIn := C.CBytes(p)\n\tdataOut := C.malloc(C.size_t(framesOut*r.channels*r.frameSize + 4))\n\tvar soxErr C.soxr_error_t\n\tvar read1, read2, done1, done2 C.size_t = 0, 0, 0, 0\n\tbuf := make([]byte, 0)\n\tsoxErr = C.soxr_process(r.resampler, C.soxr_in_t(dataIn), C.size_t(framesIn), &read1, C.soxr_out_t(dataOut), C.size_t(framesOut), &done1)\n\tif C.GoString(soxErr) != \"\" && C.GoString(soxErr) != \"0\" {\n\t\terr = errors.New(C.GoString(soxErr))\n\t\tgoto cleanup\n\t}\n\n\tbuf = append(buf, C.GoBytes(dataOut, C.int(int(done1)*r.channels*r.frameSize))...)\n\t// Consume any data left in the resampling filter\n\tsoxErr = C.soxr_process(r.resampler, C.soxr_in_t(nil), C.size_t(0), &read2, C.soxr_out_t(dataOut), C.size_t(framesOut), &done2)\n\tif C.GoString(soxErr) != \"\" && C.GoString(soxErr) != \"0\" {\n\t\terr = errors.New(C.GoString(soxErr))\n\t\tgoto cleanup\n\t}\n\n\tbuf = append(buf, C.GoBytes(dataOut, C.int(int(done2)*r.channels*r.frameSize))...)\n\t// If we have read all input and flushed all output, avoid to report short writes due\n\t// to output frames missing because of downsampling or other odd reasons.\n\tout = r.toChannels(buf, len(buf), 2)\ncleanup:\n\tC.free(dataIn)\n\tC.free(dataOut)\n\tC.free(unsafe.Pointer(soxErr))\n\treturn\n}", "func (o EntityRecognizerOutput) InputDataConfig() EntityRecognizerInputDataConfigOutput {\n\treturn o.ApplyT(func(v *EntityRecognizer) EntityRecognizerInputDataConfigOutput { return v.InputDataConfig }).(EntityRecognizerInputDataConfigOutput)\n}", "func (md *MassDns) DoFromChan(rtype string, input <-chan string) error {\n\t// is resolvers set\n\tvar rf string\n\tif md.userResolversPath != \"\" {\n\t\trf = md.userResolversPath\n\t}\n\tif md.tempResolversPath != \"\" {\n\t\trf = md.tempResolversPath\n\t}\n\tif rf == \"\" {\n\t\treturn errors.New(\"Resolvers not set\")\n\t}\n\n\t// is massdns binary path or command set\n\tif md.binaryPath == \"\" {\n\t\treturn errors.New(\"Massdns binary/command not found\")\n\t}\n\n\t// setup massdns with input from STDIN\n\tcmd := exec.Command(\n\t\tmd.binaryPath,\n\t\t\"-r\", rf,\n\t\t\"-t\", rtype,\n\t\t\"-o\", \"S\",\n\t)\n\n\tvar wg sync.WaitGroup\n\twg.Add(1)\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// write to massdns STDIN from chan\n\tgo func() {\n\t\tdefer stdin.Close()\n\t\tfor d := range input {\n\t\t\tstdin.Write([]byte(d + \"\\n\"))\n\t\t}\n\t}()\n\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmdScanner := bufio.NewScanner(stdout)\n\n\t// read and parse STDOUT from massdns\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor cmdScanner.Scan() {\n\t\t\trr, err := converter(cmdScanner.Text())\n\t\t\tif err != nil {\n\t\t\t\t// log.Fatal(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmd.output <- rr\n\t\t}\n\t}()\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn err\n\t}\n\tif err := cmd.Wait(); err != nil {\n\t\treturn err\n\t}\n\n\twg.Wait()\n\treturn nil\n}", "func (ctx Context) MulInf(inputs ...chan float64) (output chan float64) {\n\toutput = make(chan float64, ctx.StreamBufferSize)\n\n\tgo func() {\n\t\tdefer close(output)\n\n\t\tfor product := range inputs[0] {\n\t\t\tfor _, input := range inputs[1:] {\n\t\t\t\tproduct *= <-input\n\t\t\t}\n\n\t\t\toutput <- product\n\t\t}\n\t}()\n\n\treturn output\n}", "func ConvertWav(fname string, sampleRate int, volume int) []int {\r\n var accum int\r\n var wavFormat, wavChannels, wavSamplesPerSec, wavBitsPerSample int\r\n var err error\r\n var pos, deltaPos float64\r\n \r\n fileData, err = ioutil.ReadFile(fname)\r\n if err != nil {\r\n utils.ERROR(\"Unable to read from \" + fname)\r\n }\r\n fileDataPos = 0\r\n \r\n s := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"RIFF\" {\r\n utils.ERROR(\"No RIFF tag found in \" + fname)\r\n }\r\n \r\n _ = getDword()\r\n \r\n s = string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n if s != \"WAVE\" {\r\n utils.ERROR(\"No WAVE tag found in \" + fname)\r\n }\r\n\r\n dataSize := -1\r\n wavData := []float64{}\r\n \r\n // Read the chunks\r\n for {\r\n // Get the chunk ID\r\n if (fileDataPos + 3) >= len(fileData) {\r\n break\r\n }\r\n chunkId := string(fileData[fileDataPos : fileDataPos+4])\r\n fileDataPos += 4\r\n\r\n // Get the chunk size\r\n chunkSize := getDword()\r\n \r\n if chunkId == \"fmt \" {\r\n wavFormat = getWord()\r\n wavChannels = getWord()\r\n wavSamplesPerSec = getDword()\r\n _ = getDword() // Average bytes per second\r\n _ = getWord() // Block alignment\r\n wavBitsPerSample = getWord()\r\n \r\n fileDataPos += chunkSize - 16\r\n \r\n if wavFormat != 1 || (wavBitsPerSample != 8 && wavBitsPerSample != 16) || wavChannels > 2 {\r\n utils.ERROR(\"Unsupported wav format in \" + fname)\r\n }\r\n \r\n deltaPos = 1.0\r\n if sampleRate > 0 {\r\n deltaPos = float64(wavSamplesPerSec) / float64(sampleRate)\r\n }\r\n pos = 1.0\r\n \r\n if deltaPos != 1.0 {\r\n utils.INFO(fmt.Sprintf(\"Resampling %s from %d to %d Hz\", fname, wavSamplesPerSec, sampleRate))\r\n }\r\n \r\n if wavChannels > 1 {\r\n utils.INFO(\"Converting sample to mono\")\r\n }\r\n \r\n if wavBitsPerSample != 8 {\r\n utils.INFO(\"Converting sample to 8-bit unsigned\")\r\n }\r\n \r\n } else if chunkId == \"data\" {\r\n dataSize = chunkSize\r\n \r\n utils.DEBUG(\"Found data chunk, bits=%d, channels=%d, chunk size=%d\", wavBitsPerSample, wavChannels, dataSize)\r\n \r\n sampleDiv := 0\r\n \r\n if wavBitsPerSample == 8 {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n fileDataPos++\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(fileData[fileDataPos])\r\n accum += int(fileData[fileDataPos+1])\r\n fileDataPos += 2\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n } else {\r\n if wavChannels == 1 {\r\n samplesInChunk := dataSize / 2\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0)\r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / float64(sampleDiv)))\r\n }\r\n }\r\n } else if wavChannels == 2 {\r\n samplesInChunk := dataSize / 4\r\n wavData = []float64{}\r\n for int(pos) <= samplesInChunk {\r\n nextPos := int(pos + deltaPos)\r\n if int(pos) < nextPos {\r\n accum = 0\r\n sampleDiv = 0\r\n for int(pos) < nextPos {\r\n accum += int(float64(getSword() + 32768) / 256.0) + int(float64(getSword() + 32768) / 256.0) \r\n pos += 1.0 \r\n sampleDiv++\r\n }\r\n }\r\n if sampleDiv != 0 {\r\n wavData = append(wavData, math.Floor(float64(accum) / (float64(sampleDiv) * 2.0)))\r\n }\r\n }\r\n }\r\n \r\n }\r\n\r\n } else {\r\n // Unhandled chunk type, just skip it.\r\n utils.DEBUG(\"Skipping unhandled WAV chunk \\\"%s\\\"\", chunkId)\r\n fileDataPos += chunkSize\r\n }\r\n }\r\n \r\n utils.INFO(fmt.Sprintf(\"Size of converted sample: %d bytes\", len(wavData)))\r\n \r\n wavDataInt := make([]int, len(wavData))\r\n for i := range wavData {\r\n wavDataInt[i] = int(math.Floor((wavData[i] * float64(volume)) / 100.0))\r\n }\r\n\r\n return wavDataInt\r\n}" ]
[ "0.50638205", "0.44060135", "0.42906445", "0.4268434", "0.4255104", "0.41529015", "0.4103482", "0.40764487", "0.40747222", "0.4050626", "0.4050197", "0.40423712", "0.4041674", "0.40154868", "0.39812818", "0.39705202", "0.39572638", "0.39440972", "0.393307", "0.38762024", "0.38541654", "0.38415974", "0.38361564", "0.38197106", "0.38180923", "0.3817768", "0.38163984", "0.37837756", "0.37477165", "0.37403464", "0.37204036", "0.36912692", "0.36896437", "0.36872515", "0.36599204", "0.36466092", "0.36350772", "0.36300516", "0.36175194", "0.36027616", "0.35986066", "0.35948506", "0.35820964", "0.35773298", "0.35723194", "0.35672653", "0.3564802", "0.35636392", "0.35582906", "0.35570148", "0.35533234", "0.35321632", "0.3528993", "0.35174462", "0.35173792", "0.3503692", "0.34980047", "0.3497152", "0.34963048", "0.34822127", "0.34700763", "0.34651616", "0.34646243", "0.34602064", "0.34553692", "0.3453791", "0.3452431", "0.34390968", "0.34390837", "0.3437212", "0.34365383", "0.3435077", "0.3434251", "0.34249172", "0.34239566", "0.34156004", "0.34135354", "0.34128842", "0.34058198", "0.34055978", "0.340528", "0.34046423", "0.34031293", "0.34018987", "0.33975205", "0.33894217", "0.33790052", "0.33771136", "0.3375767", "0.33689937", "0.33665532", "0.33619043", "0.33591652", "0.33569393", "0.33561713", "0.33536002", "0.3343931", "0.33412516", "0.33408764", "0.33358487" ]
0.5386741
0
Calls the DSP unit's reset function, which will clear internal buffers and reset the unit back to an initial state. Calling this function is useful if the DSP unit relies on a history to process itself (ie an echo filter). If you disconnected the unit and reconnected it to a different part of the network with a different sound, you would want to call this to reset the units state (ie clear and reset the echo filter) so that you dont get left over artifacts from the place it used to be connected.
func (d *DSP) Reset() error { res := C.FMOD_DSP_Reset(d.cptr) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (arg1 *UConverter) Reset()", "func (self *SinglePad) Reset() {\n self.Object.Call(\"reset\")\n}", "func (sm3 *SM3) Reset() {\n\t// Reset digest\n\tsm3.digest[0] = 0x7380166f\n\tsm3.digest[1] = 0x4914b2b9\n\tsm3.digest[2] = 0x172442d7\n\tsm3.digest[3] = 0xda8a0600\n\tsm3.digest[4] = 0xa96f30bc\n\tsm3.digest[5] = 0x163138aa\n\tsm3.digest[6] = 0xe38dee4d\n\tsm3.digest[7] = 0xb0fb0e4e\n\n\tsm3.length = 0 // Reset numberic states\n\tsm3.unhandleMsg = []byte{}\n}", "func (b *BrainFuck) reset() {\n\tb.memory.cu = 0\n}", "func (e *Engine) Reset() error {\n\treturn e.graph.Reset(e.fadeIn, e.frameSize, e.backend.SampleRate())\n}", "func (c *Cipher) Reset() {\n\tfor i := range c.state {\n\t\tc.state[i] = 0\n\t}\n\tfor i := range c.buf {\n\t\tc.buf[i] = 0\n\t}\n}", "func (self *PhysicsP2) Reset() {\n self.Object.Call(\"reset\")\n}", "func (omx OmxPlayer) Reset() (error) {\n\tomx.player = nil\n\tomx.omxIn = nil\n\tomx.omxKill()\n\treturn nil\n}", "func (device *SilentStepperBrick) Reset() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionReset), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (b *Buffer) Reset() {\n b.size = 0\n b.offset = 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 *counter) reset() {\n\tc.messages, c.samples = 0, 0\n}", "func (c *counter) reset() {\n\tc.messages, c.samples = 0, 0\n}", "func (m *MockImpl) Reset() {\n\tm.recording = make([]Transaction, 0)\n\tm.simulateGetError = nil\n\tm.simulateAddError = nil\n}", "func (hc *cmdCollector) Reset() {\n}", "func Reset() {\n\treset()\n}", "func (buf *Buffer) reset() {\n\tbuf.DNCReports = nil\n\tbuf.DNCReports = make([]DNCReport, 0)\n\tbuf.CNIReports = nil\n\tbuf.CNIReports = make([]CNIReport, 0)\n\tbuf.NPMReports = nil\n\tbuf.NPMReports = make([]NPMReport, 0)\n\tbuf.CNSReports = nil\n\tbuf.CNSReports = make([]CNSReport, 0)\n\tpayloadSize = 0\n}", "func (c *CmdBuff) Reset() {\n\tc.ClearText(true)\n\tc.SetActive(false)\n\tc.fireBufferCompleted(c.GetText(), c.GetSuggestion())\n}", "func (c *ChannelData) Reset() {\n\tc.Raw = c.Raw[:0]\n\tc.Length = 0\n\tc.Data = c.Data[:0]\n}", "func (b *Buffer) Reset() {\n\tb.start = 0\n\tb.used = 0\n}", "func (r *Resampler) Reset() (err error) {\n\tif r.resampler == nil {\n\t\treturn errors.New(\"soxr resampler is nil\")\n\t}\n\tC.soxr_clear(r.resampler)\n\treturn\n}", "func (st *State) Reset() {\n\tst.vars = nil\n\tst.unused = nil\n\tst.states = nil\n}", "func (s *Statistics) reset() {\n\ts.cycles++\n\ts.totalMessagesCleared += s.messagesCleared\n\n\ts.memoryCleared = 0\n\ts.messagesCleared = 0\n}", "func (c *cmdCollector) Reset() {}", "func Reset() {\n\tC.yices_reset()\n}", "func (a *Agent) Reset() {\n\ta.Sketch.Reset()\n\ta.Buf = nil // TODO: pool\n}", "func (d *Decoder) Reset() {\n\td.buffer = []byte{}\n\td.complete = false\n\td.total = 0\n\td.frames = []frameInfo{}\n\td.cache = map[string]struct{}{}\n\n\td.progress = 0\n\td.speed = 0\n\td.start = time.Time{}\n\td.lastChunk = time.Time{}\n\td.readInterval = 0\n}", "func (b *FixedBuffer) Reset() {\n\tb.w = 0\n\tb.r = 0\n}", "func (g *Float32s) Reset() {\r\n\t// No state\r\n}", "func (tto *TtoT) Reset() {\n\ttto.PutChar(dg.ASCIIFF)\n\tlog.Println(\"INFO: TTO Reset\")\n}", "func (d *Detector) Reset() {\n\tC.fvad_reset(d.fvad)\n}", "func (ts *TextState) Reset() {\n\tts.Tm = transform.IdentityMatrix()\n\tts.Tlm = transform.IdentityMatrix()\n}", "func (cc *computer) reset() {\n\tcc.accumulator = 0\n\tcc.instrPointer = 0\n\tcc.history = make([]int, len(cc.instructions))\n}", "func (cb *Buffer) Reset() {\n\tcb.wpos = len(cb.buffer)\n\tcb.rpos = cb.wpos\n\tcb.full = false\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 (b *batch) Reset() {\n\tb.batch.Clear()\n\tb.size = 0\n}", "func (device *DCV2Bricklet) Reset() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionReset), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (hs *HandshakeState) Reset() {\n\ths.patternIndex = 0\n\n\t// TODO: maybe leave them alone if were passed from config?\n\ths.localStatic, hs.localEphemeral = nil, nil\n\ths.remoteStaticPub, hs.remoteEphemeralPub = nil, nil\n\n\tif hs.ss != nil {\n\t\ths.ss.Reset()\n\t\ths.ss = nil\n\t}\n\n\tif hs.SendCipherState != nil {\n\t\ths.SendCipherState.Reset()\n\t\ths.SendCipherState = nil\n\t}\n\n\tif hs.RecvCipherState != nil {\n\t\ths.RecvCipherState.Reset()\n\t\ths.RecvCipherState = nil\n\t}\n}", "func (c *Calculator) Reset() {\n\tlog.Printf(\"Reset.\\n\")\n\tvalue = 0\n\tc.returnResult()\n}", "func (s *Stream) Reset() {\n\ts.stream.reset()\n\ts.b = s.b[:0]\n}", "func (r *Radio) Reset() {\n}", "func (b *Buffer) Reset() {\n\tb.mux.Lock()\n\tdefer b.mux.Unlock()\n\n\tb.data = make([]byte, len(b.data))\n\tb.dataSize = 0\n\tb.head, b.tail = 0, 0\n}", "func (self *PhysicsP2) ResetI(args ...interface{}) {\n self.Object.Call(\"reset\", args)\n}", "func (b *BrokerState) Reset() {\n\tif b.commandClient != nil && b.initialized {\n\t\tlog.Info(fmt.Sprintf(\"[Broker %s] Resetting connection\", b.host))\n\t\tb.commandClient.Stop()\n\t\tb.initialized = false\n\t\tb.commandClient.Start()\n\t}\n}", "func (b *Buffer) Reset() {\n\tif len(b.bufs) > 0 {\n\t\tb.curBuf = b.bufs[0]\n\t\tb.curBufLen = len(b.bufs[0])\n\t\tb.curBufIdx = 0\n\t\tb.curIdx = 0\n\t}\n}", "func (b *batch) Reset() {\n\tb.writes = b.writes[:0]\n\tb.size = 0\n}", "func (d *Display) resetBuffer() {\n\td.width = d.device.Width()\n\td.height = d.device.Height()\n\td.buffer = make([][]byte, d.height)\n\tfor y := range d.buffer {\n\t\td.buffer[y] = make([]byte, d.width)\n\t}\n}", "func (w *Wire) Reset(id uint32) {\n\tw.SetOutput(false)\n\tw.SetValue(Unknown)\n\tw.SetID(id)\n\tw.input = nil\n\tw.DisconnectOutputs()\n}", "func (b *MemoryBackend) Reset() {\n\tb.mu.Lock()\n\tdefer b.mu.Unlock()\n\n\tb.Notices = b.Notices[:0]\n}", "func reset() {\n\tterm.Sync()\n}", "func (s *dataSet) Reset() {\n\ts.dataPtr = len(s.buf)\n\ts.dataWritten = 0\n\ts.idxPtr = 0\n\ts.idxWritten = 0\n}", "func (r *RAMOutputStream) Reset() {\n\tr.currentBuffer = nil\n\tr.currentBufferIndex = -1\n\tr.bufferPosition = 0\n\tr.bufferStart = 0\n\tr.bufferLength = 0\n\tr.file.setLength(0)\n\tif r.crc != nil {\n\t\tr.crc.Reset()\n\t}\n}", "func (c *Client) Reset() error {\n\terr := c.writeMsg(\"RSET\\r\\n\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmsg, err := c.readMsg(singleLineMessageTerminator)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.isError(msg) {\n\t\treturn fmt.Errorf(\"Unknown error returned %v\", msg)\n\t}\n\n\tfmt.Print(\"Calling reset\\n\")\n\n\treturn nil\n}", "func (buffer *Buffer) Reset() {\n\tbuffer.B.Reset()\n}", "func (b *Buffer) Reset() {\n\tb.buf = b.buf[:0]\n}", "func (app *Application) reset() {\n\tapp.sandbox.Flush()\n}", "func (d *Die) reset() {\n\td.Result = nil\n\td.Dropped = false\n}", "func (c *Curl) Reset() {\n\tfor i := range c.state {\n\t\tc.state[i] = 0\n\t}\n\tc.direction = SpongeAbsorbing\n}", "func (dc *DatadogCollector) Reset() {}", "func (sm *StateMachine) Reset(in *Msg) {\n\tsm.state = 0\n\tsm.stateEntered = false\n\tsm.plugin.SetMemory(in, StateKey, 0)\n\tsm.plugin.SetMemory(in, stateEnteredKey, false)\n\tsm.resetFn(in)\n}", "func (c *Counter) Reset() {\n\tc.global.Store(0)\n\tc.window.Store(0)\n}", "func (device *IndustrialDigitalIn4V2Bricklet) Reset() (err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Set(uint8(FunctionReset), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn 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 (c *Client) Reset() error {\n\tif err := c.hello(); err != nil {\n\t\treturn err\n\t}\n\tif _, _, err := c.cmd(250, \"RSET\"); err != nil {\n\t\treturn err\n\t}\n\tc.rcpts = nil\n\treturn nil\n}", "func (h *handler) Reset(ctx context.Context, initialPacket ip.Packet) error {\n\treturn h.toTun.Write(ctx, initialPacket.(Packet).Reset())\n}", "func (w *buffer) reset() {\n\tfor i := range (*w)[:cap(*w)] {\n\t\t(*w)[i] = 0\n\t}\n\t*w = (*w)[:0]\n}", "func (m *MsgBuffer) Reset() {\n\tm.Buffer.Reset()\n\tm.bs = m.bs[:0]\n\tm.err = nil\n}", "func (tr *trooper) reset() {\n\ttr.trash()\n\ttr.addCenter()\n\tfor cnt, b := range tr.bits {\n\t\tb.reset(tr.ipos[cnt])\n\t}\n\ttr.healthChanged(tr.health())\n}", "func (b *Buffer) Reset() {\n\tb.Line = b.Line[:0]\n\tb.Val = b.Val[:0]\n}", "func (e *Zero) Reset() {}", "func Reset() {\n\tTopicDelimiter = \".\"\n\tGen = \"\"\n\tOut = \"\"\n\tFileDir = \"\"\n\tDryRun = false\n\tRecurse = false\n\tVerbose = false\n\tNow = time.Now()\n\tCompiledFiles = make(map[string]*parser.Frugal)\n}", "func (gn *Gen) Reset() {\n\n}", "func (b *Buffer) Reset() {\n\tb.B = b.B[:0]\n}", "func (d *Decoder) reset() {\n\tif unread := len(d.buf) - d.r1; unread == 0 {\n\t\t// No bytes in the buffer, so we can start from the beginning without\n\t\t// needing to copy anything (and get better cache behaviour too).\n\t\td.buf = d.buf[:0]\n\t\td.r1 = 0\n\t} else if !d.complete && unread <= maxSlide {\n\t\t// Slide the unread portion of the buffer to the\n\t\t// start so that when we read more data,\n\t\t// there's less chance that we'll need to grow the buffer.\n\t\tcopy(d.buf, d.buf[d.r1:])\n\t\td.r1 = 0\n\t\td.buf = d.buf[:unread]\n\t}\n\td.r0 = d.r1\n\td.escBuf = d.escBuf[:0]\n}", "func (cpu *CPU) Reset() {\n\tcpu.setFlags(0x34)\n\tcpu.A = 0\n\tcpu.X = 0\n\tcpu.Y = 0\n\tcpu.S = 0xFD\n\tcpu.write(0x4017, 0)\n\tcpu.write(0x4015, 0)\n\tfor i := 0x4000; i <= 0x400F; i++ {\n\t\tcpu.write(uint16(i), 0)\n\t}\n}", "func (b *Packet) Reset() {\n\tb._buf = b._buf[:0]\n\tb._read_pos = 0\n\tb._write_pos = 0\n}", "func (e *Encoder) Reset() {\n\te.buf.Reset()\n\te.tmp.Reset()\n}", "func (b *batch) Reset() {\n\tb.Batch.Reset()\n\tb.size = 0\n}", "func (r *BasicResampler) Reset() {\n\tr.sampleAggregates = r.sampleAggregates[:0]\n}", "func (bs *Scope) Reset() {\n\tbs.call([]byte(\"!\"))\n}", "func (m *ram) Reset() (err error) {\n\tfor i := 0; i < len(m.b); i++ {\n\t\tm.b[i] = 0\n\t}\n\treturn\n}", "func (d *Driver) Clear() {\n\tfor i := 0; i < len(d.buff); i++ {\n\t\td.buff[i] = 0\n\t}\n}", "func (t *Timer) Reset() {\n\tt.currentTime = t.getCurrentTimeMs()\n\tt.lastTime = t.currentTime\n\tt.tick = 0\n}", "func Reset() {\n\tstats.Reset()\n}", "func Reset() {\n\tstopMux.Lock()\n\tstoppedAt = nil\n\tstoppedFor = 0\n\tstopMux.Unlock()\n}", "func (e *ObservableEditableBuffer) ResetBuffer() {\n\te.filtertagobservers = false\n\te.seq = 0\n\te.f = NewTypeBuffer([]rune{}, e)\n}", "func (v *VsctlMock) Reset() {\n\tv.ReceivedArgs = [][]string{}\n}", "func (p *Buffer) Reset() {\n\tp.buf = p.buf[0:0] // for reading/writing\n\tp.index = 0 // for reading\n\tp.err = nil\n\tp.array_indexes = nil\n}", "func (p *Puck) Reset(name ...string) error {\n\tcmd := []byte(\"reset();\\n\")\n\terr := p.command(name, cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (t *Ticker) Reset() {\n\tt.resetCh <- struct{}{}\n}", "func (c *piController) reset() {\n\tc.errIntegral = 0\n}", "func (s *MemorySession) Reset() error {\n\t// reset counter and stores\n\ts.Counter.Reset()\n\ts.Incoming.Reset()\n\ts.Outgoing.Reset()\n\n\treturn nil\n}", "func (ml *MemoryLogger) Reset() {\n\tml.RingBuffer.Reset()\n}", "func (s *State) Reset() {\n\ts.hash = 0\n\ts.clen = 0\n\ts.tail = nil\n}", "func (s *Stentor) Reset() {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tfor sr := range s.subscribers {\n\t\ts.unsubscribe(sr)\n\t}\n\ts.subscribers = make(map[<-chan G]chan G)\n}", "func (f *fixture) Reset(ctx context.Context) error {\n\tif f.startChrome && f.cr != nil {\n\t\tif err := UnmountAllSmbMounts(ctx, f.cr); err != nil {\n\t\t\ttesting.ContextLog(ctx, \"Failed to unmount all SMB mounts: \", err)\n\t\t}\n\t}\n\treturn removeAllContents(ctx, f.guestDir)\n}", "func (c *CTR) Reset() {\n\tc.blocks = 0\n\tc.ks = nil\n}", "func (pl *Payload) reset() {\n\tpl.DNCReports = nil\n\tpl.DNCReports = make([]DNCReport, 0)\n\tpl.CNIReports = nil\n\tpl.CNIReports = make([]CNIReport, 0)\n\tpl.NPMReports = nil\n\tpl.NPMReports = make([]NPMReport, 0)\n\tpl.CNSReports = nil\n\tpl.CNSReports = make([]CNSReport, 0)\n}", "func (pl *Payload) reset() {\n\tpl.DNCReports = nil\n\tpl.DNCReports = make([]DNCReport, 0)\n\tpl.CNIReports = nil\n\tpl.CNIReports = make([]CNIReport, 0)\n\tpl.NPMReports = nil\n\tpl.NPMReports = make([]NPMReport, 0)\n\tpl.CNSReports = nil\n\tpl.CNSReports = make([]CNSReport, 0)\n}", "func (f *Fuse) reset() {\n\tf.failCounter = 0\n\tf.retries = 0\n}" ]
[ "0.6649226", "0.65367544", "0.6495995", "0.6388265", "0.637604", "0.6363151", "0.6282432", "0.62760276", "0.62608284", "0.6229693", "0.62016773", "0.6187488", "0.6187488", "0.6184149", "0.6158358", "0.61490536", "0.61389786", "0.61118644", "0.6105895", "0.6100138", "0.60918987", "0.60719573", "0.6036754", "0.6034216", "0.60293406", "0.6022263", "0.6020778", "0.60099274", "0.5988042", "0.5985776", "0.5984092", "0.5967004", "0.5948087", "0.5947538", "0.59429383", "0.5938193", "0.59105194", "0.59093523", "0.59089875", "0.59001744", "0.5897904", "0.5873841", "0.58694756", "0.5864667", "0.58632076", "0.5862692", "0.5859992", "0.58566314", "0.58561903", "0.5848418", "0.58427393", "0.58313215", "0.5830319", "0.5823779", "0.5823566", "0.58213943", "0.580988", "0.5807331", "0.5807256", "0.57968616", "0.57962435", "0.5791314", "0.5782969", "0.5781713", "0.5769709", "0.5768294", "0.57675403", "0.5755499", "0.5745148", "0.5741836", "0.5740348", "0.5731756", "0.5728601", "0.572763", "0.5725907", "0.57225955", "0.57139313", "0.5710554", "0.570822", "0.57023364", "0.5696355", "0.5690309", "0.5689994", "0.5685414", "0.5680354", "0.5679768", "0.5676179", "0.5674619", "0.56744725", "0.56686753", "0.5660892", "0.5656493", "0.5655289", "0.5655115", "0.56529635", "0.56528413", "0.56499046", "0.5640546", "0.5640546", "0.563668" ]
0.6552612
1
/ DSP parameter control. Sets a DSP unit's floating point parameter by index. To find out the parameter names and range, see the see also field. index: Parameter index for this unit. Find the number of parameters with "DSP.NumParameters". value: Floating point parameter value to be passed to the DSP unit. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) SetParameterFloat(index int, value float64) error { res := C.FMOD_DSP_SetParameterFloat(d.cptr, C.int(index), C.float(value)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func (p *Param) SetValue(value float64) error {\n\tvar ferr C.FMOD_RESULT\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_SetValue(p.param, C.float(value))\n\t})\n\treturn base.ResultToError(ferr)\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (b *fixedResolutionValues) SetValueAt(n int, v float64) {\n\tb.values[n] = v\n}", "func (def *Definition) SetValueWithIndex(name string, index []uint32, x interface{}) error {\n\ttyp, err := def.SearchType(name)\n\tif err != nil {\n\t\tCentral.Log.Debugf(\"Search type error: %v\", err)\n\t\treturn err\n\t}\n\tif len(index) == 2 && typ.Type() != FieldTypeMultiplefield && index[1] > 0 {\n\t\treturn NewGenericError(62)\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Set value %s with index=%#v value=%v\", name, index, x)\n\t}\n\tvar val IAdaValue\n\tif !typ.HasFlagSet(FlagOptionPE) {\n\t\tCentral.Log.Debugf(\"Search name ....%s\", name)\n\t\tval = def.Search(name)\n\t\tif val == nil {\n\t\t\treturn NewGenericError(63, name)\n\t\t}\n\t} else {\n\t\tCentral.Log.Debugf(\"Search indexed period group ....%s %d\", name, index)\n\t\tval, err = def.SearchByIndex(name, index, true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif val == nil {\n\t\t\treturn NewGenericError(127, name)\n\t\t}\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Found value to add to %s[%d,%d] type=%v %T %T index=%#v\", val.Type().Name(),\n\t\t\tval.PeriodIndex(), val.MultipleIndex(), val.Type().Type().name(), val, val.Type(), index)\n\t}\n\tswitch val.Type().Type() {\n\tcase FieldTypeMultiplefield:\n\t\tsv := val.(*StructureValue)\n\t\tst := sv.Type().(*StructureType)\n\t\t//sv.Type().\n\t\t//\tsv.Elements = append(sv.Elements, subValue)\n\t\t// if len(sv.Elements) == 0 {\n\t\t// \te := &structureElement{}\n\t\t// \tCentral.Log.Debugf(\"Add empty element to %s\",sv.Type().Name())\n\t\t// \tsv.Elements = append(sv.Elements, e)\n\t\t// }\n\t\t// if len(sv.Elements[0].Values) >= int(index[0]) {\n\t\t// \tCentral.Log.Debugf(\"Adapt %#v\", st.SubTypes)\n\t\t// \tsubValue := sv.Elements[0].Values[int(index[0]-1)]\n\t\t// \terr = subValue.SetValue(x)\n\t\t// } else {\n\t\tsubValue, serr := st.SubTypes[0].Value()\n\t\tif serr != nil {\n\t\t\treturn serr\n\t\t}\n\t\terr = subValue.SetValue(x)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpeIndex := uint32(0)\n\t\tcurIndex := 0\n\t\tif typ.HasFlagSet(FlagOptionPE) {\n\t\t\tif len(index) > 0 {\n\t\t\t\tpeIndex = index[curIndex]\n\t\t\t\tcurIndex++\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tmuIndex := uint32(0)\n\t\tif typ.Type() == FieldTypeMultiplefield || typ.HasFlagSet(FlagOptionMUGhost) {\n\t\t\tif len(index) > curIndex {\n\t\t\t\tmuIndex = index[curIndex]\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tCentral.Log.Debugf(\"Set indexes to PE=%d MU=%d current=%d\", peIndex, muIndex, curIndex)\n\t\terr = sv.addValue(subValue, peIndex, muIndex)\n\t\t// subValue.setMultipleIndex(index[0])\n\t\t// sv.Elements[0].Values = append(sv.Elements[0].Values, subValue)\n\t\t// }\n\t\tif Central.IsDebugLevel() {\n\t\t\tCentral.Log.Debugf(\"Add Multiple field, elements=%d\", len(sv.Elements))\n\t\t}\n\tdefault:\n\t\terr = val.SetValue(x)\n\t}\n\treturn err\n}", "func (cmd *ControlModuleVoltage) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 1000\n\n\treturn nil\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterInt(index, value int) error {\n\tres := C.FMOD_DSP_SetParameterInt(d.cptr, C.int(index), C.int(value))\n\treturn errs[res]\n}", "func FloatVarP(pv *float64, short rune, long string, value float64, description string) {\n\tif err := parseShortAndLongFlag(short, long); err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionFloat{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (this *NamedParameterQuery) SetValue(parameterName string, parameterValue interface{}) {\n\n\tfor _, position := range this.positions[parameterName] {\n\t\tthis.parameters[position] = parameterValue\n\t}\n}", "func (d *DSP) SetParameterBool(index int, value bool) error {\n\tres := C.FMOD_DSP_SetParameterBool(d.cptr, C.int(index), getBool(value))\n\treturn errs[res]\n}", "func (o *Sensorefficiency) SetValue(v string) {\n\to.Value = v\n}", "func (uni *Uniform4fv) Set(idx int, v0, v1, v2, v3 float32) {\n\n\tpos := idx * 4\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n\tuni.v[pos+3] = v3\n}", "func (s *Slider) Float(f *Float) *Slider {\n\ts.float = f\n\treturn s\n}", "func (f *Flags) Float(spec string, p *float64, name, usage string) {\n\tf.addOption(spec, name, usage, func(name, value string) error {\n\t\tf, err := strconv.ParseFloat(value, 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid %s argument '%s'\", name, value)\n\t\t}\n\t\t*p = f\n\t\treturn nil\n\t})\n}", "func (c *Constructor[_]) FloatVar(ptr *float64, name string, value float64, help string) {\n\t*ptr = value\n\tc.define(name, paramFloat, help).floatptr = ptr\n}", "func (na *NArray) SetValue(v float32) *NArray {\n\n\tfor i := range na.Data {\n\t\tna.Data[i] = v\n\t}\n\treturn na\n}", "func FloatVar(pv *float64, flag string, value float64, description string) {\n\tshort, long, err := parseSingleFlag(flag)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionFloat{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (cmd *Odometer) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 10\n\n\treturn nil\n}", "func (tu *TimingUpdate) SetValue(f float64) *TimingUpdate {\n\ttu.mutation.ResetValue()\n\ttu.mutation.SetValue(f)\n\treturn tu\n}", "func (uni *Uniform1fv) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (this *parameter) Float() float64 {\n\tif this.Values == nil {\n\t\treturn 0\n\t} else {\n\t\treturn reflekt.AsFloat(this.Values[0])\n\t}\n}", "func (uni *Uniform3fv) Set(idx int, v0, v1, v2 float32) {\n\n\tpos := idx * 3\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n}", "func (s *f64) SetSample(i int, value float64) {\n\ts.buffer[i] = float64(value)\n}", "func (cmd *EngineRPM) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 4\n\n\treturn nil\n}", "func (z *Float) Set(x *Float) *Float {}", "func (ms DoubleDataPoint) SetValue(v float64) {\n\t(*ms.orig).Value = v\n}", "func (cmd *FuelPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload) * 3\n\n\treturn nil\n}", "func (tuo *TimingUpdateOne) SetValue(f float64) *TimingUpdateOne {\n\ttuo.mutation.ResetValue()\n\ttuo.mutation.SetValue(f)\n\treturn tuo\n}", "func Float(name string, value float, usage string) *float {\n\tp := new(float);\n\tFloatVar(p, name, value, usage);\n\treturn p;\n}", "func (s *FeatureParameter) SetValue(v string) *FeatureParameter {\n\ts.Value = &v\n\treturn s\n}", "func (p FloatFormalParam) GetValue() string {\n\treturn p.Value\n}", "func FloatVar(p *float, name string, value float, usage string) {\n\tadd(name, newFloatValue(value, p), usage)\n}", "func (s *Float32Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Float32Value, err = cast.ToFloat32E(v)\n\treturn err\n}", "func (cmd *MafAirFlowRate) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 100\n\n\treturn nil\n}", "func (s *Parameter) SetValue(v string) *Parameter {\n\ts.Value = &v\n\treturn s\n}", "func (cmd *Fuel) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 255\n\n\treturn nil\n}", "func (d *Detector) SetSampleRate(x int) error {\n\terrno := C.fvad_set_sample_rate(d.fvad, C.int(x))\n\tif errno != 0 {\n\t\treturn fmt.Errorf(\"invalid sample rate: %v\", x)\n\t}\n\treturn nil\n}", "func (m *Measurement) SetValue(value string) {\n\tm.Values[\"value\"] = value\n}", "func (l *Libvirt) DomainSetNumaParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(254, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (p *Property) SetValue(v int) {\n\t// change the member value of property\n\tp.value = v\n}", "func (cmd *TimingAdvance) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload/2) - 64\n\n\treturn nil\n}", "func (cmd *ThrottlePosition) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 255\n\n\treturn nil\n}", "func (f Fill) SetValue(value float64) Fill {\n\tf.value = value\n\treturn f\n}", "func VPI(index int32) Device {\n return Device{KDLVPI, index}\n}", "func (c *SquareChannel) SetValue(address uint16, data uint8) {\n\tswitch address {\n\t// Sweep period, negate, shift\n\tcase 0xFF10:\n\t\tc.SweepPeriodData = (data >> 4) & 0x7\n\t\tc.SweepNegate = (data & 0x8) == 0x8\n\t\tc.SweepShift = data & 0x7\n\t\tbreak\n\t// Duty, Length load (64-L)\n\tcase 0xFF11:\n\t\tfallthrough\n\tcase 0xFF16:\n\t\tc.DutyCounter = (data >> 6) & 0x3\n\t\tc.LengthData = data & 0x3F\n\t\tbreak\n\t// Starting volume, Envelope add mode, period\n\tcase 0xFF12:\n\t\tfallthrough\n\tcase 0xFF17:\n\t\t// DAC\n\t\tc.DACEnabled = (data & 0xF8) != 0\n\t\tc.VolumeData = (data >> 4) & 0xF\n\t\tc.envelopeAddMode = (data & 0x8) == 0x8\n\t\tc.envelopePeriodData = (data & 0x7)\n\t\tc.Volume = c.VolumeData\n\t\tbreak\n\t// Frequency LSB\n\tcase 0xFF13:\n\t\tfallthrough\n\tcase 0xFF18:\n\t\tc.FrequencyData = (c.FrequencyData & 0x700) | uint16(data)\n\t\tbreak\n\t// Trigger, Length enable, Frequency MSB\n\tcase 0xFF14:\n\t\tfallthrough\n\tcase 0xFF19:\n\t\tc.FrequencyData = (c.FrequencyData & 0xFF) | (uint16(data)&0x7)<<8\n\t\tc.LengthEnabled = (data & 0x40) == 0x40\n\t\tc.Trigger = (data & 0x80) == 0x80\n\t\tif c.Trigger {\n\t\t\tc.executeTrigger()\n\t\t}\n\t\tbreak\n\t}\n}", "func (s *Scale) SetValue(v float64) *Scale {\n\ts.Value = &v\n\treturn s\n}", "func (m *FloatArray) Set(first *float32, numberOfFloats int32) {\n\tgl.ProgramUniform1fv(m.program, m.uniform, numberOfFloats, first)\n}", "func (adaType *AdaSuperType) SetFractional(x uint32) {\n}", "func (p *Param) GetValue() (float64, error) {\n\tvar ferr C.FMOD_RESULT\n\tvar value C.float\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_GetValue(p.param, &value)\n\t})\n\treturn float64(value), base.ResultToError(ferr)\n}", "func (neuron *Neuron) SetValue(x float64) {\n\tneuron.Value = &x\n}", "func (s *CategoricalParameter) SetValue(v []*string) *CategoricalParameter {\n\ts.Value = v\n\treturn s\n}", "func (s *CurrentMetricData) SetValue(v float64) *CurrentMetricData {\n\ts.Value = &v\n\treturn s\n}", "func (me *TPositiveFloatType) Set(s string) { (*xsdt.Float)(me).Set(s) }", "func (e *Exponential) setParameters(p []Parameter) {\n\tif len(p) != e.NumParameters() {\n\t\tpanic(\"exponential: incorrect number of parameters to set\")\n\t}\n\tif p[0].Name != \"Rate\" {\n\t\tpanic(\"exponential: \" + panicNameMismatch)\n\t}\n\te.Rate = p[0].Value\n}", "func (v *V) SetAt(i int, f float64) Vector {\n\tif i < 0 || i >= v.Dim() {\n\t\tpanic(ErrIndex)\n\t}\n\tv.Data[i] = f\n\treturn v\n}", "func (ms SummaryDataPointValueAtQuantile) SetValue(v float64) {\n\tms.orig.Value = v\n}", "func (gdt *Array) Set(idx Int, value Variant) {\n\targ0 := gdt.getBase()\n\targ1 := idx.getBase()\n\targ2 := value.getBase()\n\n\tC.go_godot_array_set(GDNative.api, arg0, arg1, arg2)\n}", "func (t Texture3D) SetParameter(paramName uint32, param int32) {\n\tt.Bind()\n\tgl.TexParameteri(gl.TEXTURE_3D, paramName, param)\n\tt.Unbind()\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (z *Float) SetInt(x *Int) *Float {}", "func (f *Float) Set(x *Float) *Float {\n\tf.doinit()\n\tC.mpf_set(&f.i[0], &x.i[0])\n\treturn f\n}", "func (cmd *VehicleSpeed) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (geom Geometry) SetPoint(index int, x, y, z float64) {\n\tC.OGR_G_SetPoint(\n\t\tgeom.cval,\n\t\tC.int(index),\n\t\tC.double(x),\n\t\tC.double(y),\n\t\tC.double(z))\n}", "func (self *SinglePad) ProcessButtonFloat(buttonCode int, value interface{}) {\n self.Object.Call(\"processButtonFloat\", buttonCode, value)\n}", "func ParamUnit(name, description string) *float64 {\n\tf := &unitFlag{}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func (s *UpdateParam) SetValue(v string) *UpdateParam {\n\ts.Value = &v\n\treturn s\n}", "func (w *Wire) SetValue(value WireValue) {\n\tw.ovnum &^= valueMask\n\tw.ovnum |= (uint32(value) << valueShift) & valueMask\n}", "func (native *OpenGL) TexParameterf(target uint32, pname uint32, param float32) {\n\tgl.TexParameterf(target, pname, param)\n}", "func (cmd *TransmissionActualGear) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\t// A & B are not used in the calculation\n\tcmd.Value = float32(payload>>16) / 1000\n\n\treturn nil\n}", "func (s *Uint16Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Uint16Value, err = cast.ToUint16E(v)\n\treturn err\n}", "func (c *Constructor[_]) Float(name string, value float64, help string) *float64 {\n\tp := new(float64)\n\tc.FloatVar(p, name, value, help)\n\treturn p\n}", "func FloatP(short rune, long string, value float64, description string) *float64 {\n\tvar v float64\n\tFloatVarP(&v, short, long, value, description)\n\treturn &v\n}", "func (r *ClusterUpdateRequest) Parameter(name string, value interface{}) *ClusterUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (s *MetricData) SetValue(v float64) *MetricData {\n\ts.Value = &v\n\treturn s\n}", "func (v Vector) Set(n int, data float64) {\n\tv.data[n] = data\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (cmd *EngineLoad) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 255\n\n\treturn nil\n}", "func (na *NArray) Set(v float32, indices ...int) {\n\n\tna.Data[na.Index(indices...)] = v\n}", "func (wv *Spectrum) Set(v float32) {\n\tfor k := 0; k < 4; k++ {\n\t\twv.C[k] = v\n\t}\n\n}", "func (r *ManagedServiceUpdateRequest) Parameter(name string, value interface{}) *ManagedServiceUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (blood *bloodGeneral) Set(name string, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.FieldByName(name)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tpanic(\"Cannot find \" + name + \" in BloodGeneral struct\")\n\t}\n\n\treturn\n}", "func (ms Float64Slice) SetAt(i int, val float64) {\n\t(*ms.getOrig())[i] = val\n}", "func FloatSet(z *big.Float, x *big.Float,) *big.Float", "func (vn *VecN) Set(i int, val float64) {\n\tvn.vec[i] = val\n}", "func ParamUnitD(name, description string, defaultValue float64) *float64 {\n\tf := &unitFlag{\n\t\tset: true,\n\t\tvalue: defaultValue,\n\t}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n C.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func (o *StorageServiceStreamThroughputPostParams) SetValue(value int32) {\n\to.Value = value\n}", "func (d *Decimal) SetValue(v int64) {\n\t(*accounting.Decimal)(d).\n\t\tSetValue(v)\n}", "func (uni *Uniform4fv) SetPos(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (s *Float64Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Float64Value, err = cast.ToFloat64E(v)\n\treturn err\n}", "func (node VindexParam) Format(buf *TrackedBuffer) {\n\tbuf.astPrintf(node, \"%s=%s\", node.Key.String(), node.Val)\n}", "func (items Float64Slice) Value(index int) interface{} { return items[index] }", "func (uni *UniformMatrix3f) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (ctx *Context) ParamByIndex(index int) string {\n\treturn ctx.PathParams.ByIndex(index)\n}" ]
[ "0.730031", "0.63892376", "0.61994886", "0.616037", "0.60324955", "0.60086614", "0.59501296", "0.59367436", "0.56427574", "0.54124695", "0.53410953", "0.530274", "0.52750516", "0.52205086", "0.51486", "0.5143942", "0.51195776", "0.5106912", "0.5082823", "0.50812966", "0.5072602", "0.50615525", "0.5060006", "0.5057996", "0.505037", "0.5039193", "0.5026279", "0.5008619", "0.49984735", "0.49585208", "0.49535194", "0.49304646", "0.4924333", "0.49168864", "0.4906971", "0.49023065", "0.49021232", "0.48885876", "0.48534575", "0.4849347", "0.48490354", "0.48364222", "0.48219737", "0.4820228", "0.48089868", "0.47875535", "0.47213385", "0.4710241", "0.47073546", "0.46880606", "0.4683847", "0.46785727", "0.46618167", "0.4661747", "0.46602613", "0.46328825", "0.46273613", "0.46217042", "0.4621011", "0.46196365", "0.4613895", "0.46111172", "0.4610217", "0.46056888", "0.45968813", "0.45860997", "0.45831302", "0.45769364", "0.45759055", "0.45727724", "0.45674154", "0.45665345", "0.45660552", "0.45619667", "0.45513827", "0.4548651", "0.45475844", "0.4545527", "0.45250365", "0.45241788", "0.4523307", "0.45179537", "0.45037243", "0.45004275", "0.44967288", "0.4490894", "0.44890586", "0.44797832", "0.44743887", "0.44733298", "0.44679445", "0.44668883", "0.44641098", "0.44605306", "0.44590384", "0.44588137", "0.44561222", "0.44454563", "0.44450098", "0.44421294" ]
0.67198724
1
Sets a DSP unit's integer parameter by index. To find out the parameter names and range, see the see also field. index: Parameter index for this unit. Find the number of parameters with "DSP.NumParameters". value: Integer parameter value to be passed to the DSP unit. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) SetParameterInt(index, value int) error { res := C.FMOD_DSP_SetParameterInt(d.cptr, C.int(index), C.int(value)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (def *Definition) SetValueWithIndex(name string, index []uint32, x interface{}) error {\n\ttyp, err := def.SearchType(name)\n\tif err != nil {\n\t\tCentral.Log.Debugf(\"Search type error: %v\", err)\n\t\treturn err\n\t}\n\tif len(index) == 2 && typ.Type() != FieldTypeMultiplefield && index[1] > 0 {\n\t\treturn NewGenericError(62)\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Set value %s with index=%#v value=%v\", name, index, x)\n\t}\n\tvar val IAdaValue\n\tif !typ.HasFlagSet(FlagOptionPE) {\n\t\tCentral.Log.Debugf(\"Search name ....%s\", name)\n\t\tval = def.Search(name)\n\t\tif val == nil {\n\t\t\treturn NewGenericError(63, name)\n\t\t}\n\t} else {\n\t\tCentral.Log.Debugf(\"Search indexed period group ....%s %d\", name, index)\n\t\tval, err = def.SearchByIndex(name, index, true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif val == nil {\n\t\t\treturn NewGenericError(127, name)\n\t\t}\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Found value to add to %s[%d,%d] type=%v %T %T index=%#v\", val.Type().Name(),\n\t\t\tval.PeriodIndex(), val.MultipleIndex(), val.Type().Type().name(), val, val.Type(), index)\n\t}\n\tswitch val.Type().Type() {\n\tcase FieldTypeMultiplefield:\n\t\tsv := val.(*StructureValue)\n\t\tst := sv.Type().(*StructureType)\n\t\t//sv.Type().\n\t\t//\tsv.Elements = append(sv.Elements, subValue)\n\t\t// if len(sv.Elements) == 0 {\n\t\t// \te := &structureElement{}\n\t\t// \tCentral.Log.Debugf(\"Add empty element to %s\",sv.Type().Name())\n\t\t// \tsv.Elements = append(sv.Elements, e)\n\t\t// }\n\t\t// if len(sv.Elements[0].Values) >= int(index[0]) {\n\t\t// \tCentral.Log.Debugf(\"Adapt %#v\", st.SubTypes)\n\t\t// \tsubValue := sv.Elements[0].Values[int(index[0]-1)]\n\t\t// \terr = subValue.SetValue(x)\n\t\t// } else {\n\t\tsubValue, serr := st.SubTypes[0].Value()\n\t\tif serr != nil {\n\t\t\treturn serr\n\t\t}\n\t\terr = subValue.SetValue(x)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpeIndex := uint32(0)\n\t\tcurIndex := 0\n\t\tif typ.HasFlagSet(FlagOptionPE) {\n\t\t\tif len(index) > 0 {\n\t\t\t\tpeIndex = index[curIndex]\n\t\t\t\tcurIndex++\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tmuIndex := uint32(0)\n\t\tif typ.Type() == FieldTypeMultiplefield || typ.HasFlagSet(FlagOptionMUGhost) {\n\t\t\tif len(index) > curIndex {\n\t\t\t\tmuIndex = index[curIndex]\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tCentral.Log.Debugf(\"Set indexes to PE=%d MU=%d current=%d\", peIndex, muIndex, curIndex)\n\t\terr = sv.addValue(subValue, peIndex, muIndex)\n\t\t// subValue.setMultipleIndex(index[0])\n\t\t// sv.Elements[0].Values = append(sv.Elements[0].Values, subValue)\n\t\t// }\n\t\tif Central.IsDebugLevel() {\n\t\t\tCentral.Log.Debugf(\"Add Multiple field, elements=%d\", len(sv.Elements))\n\t\t}\n\tdefault:\n\t\terr = val.SetValue(x)\n\t}\n\treturn err\n}", "func (node *Configuration) SetInt(parameter uint8, value uint32) error {\n\treturn node.zwSendDataRequest(CommandClassConfiguration,\n\t\t[]uint8{configurationSet, parameter, 4, uint8((value >> 24) & (0xff)),\n\t\t\tuint8((value >> 16) & (0xff)), uint8((value >> 8) & (0xff)),\n\t\t\tuint8(value & 0xff)})\n}", "func (b *fixedResolutionValues) SetValueAt(n int, v float64) {\n\tb.values[n] = v\n}", "func (instance *Instance) SetInt(fieldName string, value int) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (z *Float) SetInt(x *Int) *Float {}", "func (g *GPIOControllerPCF8574T) Set(index int, on bool) {\n\tif index < 0 || index > pinCount {\n\t\tfmt.Printf(\"Input out of range for gpio: %d\", index)\n\t\treturn\n\t}\n\n\tg.mutex.Lock()\n\tdefer g.mutex.Unlock()\n\tif on {\n\t\tg.valuePinMask |= (1 << index)\n\t} else {\n\t\tg.valuePinMask &= ((1 << index) ^ 0xff)\n\t}\n\tg.sync()\n}", "func (z *Rat) SetInt(x *Int) *Rat {}", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (spriteBatch *SpriteBatch) Set(index int, args ...float32) error {\n\treturn spriteBatch.addv(spriteBatch.texture.getVerticies(), generateModelMatFromArgs(args), index)\n}", "func (gdt *Array) Set(idx Int, value Variant) {\n\targ0 := gdt.getBase()\n\targ1 := idx.getBase()\n\targ2 := value.getBase()\n\n\tC.go_godot_array_set(GDNative.api, arg0, arg1, arg2)\n}", "func (cache *cache) SetValue(index, value int) error {\n\tbs := []byte(strconv.Itoa(value))\n\tsetItem := memcache.Item{\n\t\tKey: strconv.Itoa(index),\n\t\tValue: bs}\n\tif err := cache.client.Set(&setItem); err != nil {\n\t\treturn err\n\t}\n\tif MaxCalculatedIndex < index {\n\t\tMaxCalculatedIndex = index\n\t}\n\treturn nil\n}", "func (v Value) SetIndex(i int, x interface{}) {\n\tpanic(message)\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func (m *RecurrencePattern) SetIndex(value *WeekIndex)() {\n m.index = value\n}", "func (this *NamedParameterQuery) SetValue(parameterName string, parameterValue interface{}) {\n\n\tfor _, position := range this.positions[parameterName] {\n\t\tthis.parameters[position] = parameterValue\n\t}\n}", "func SetPort(v string) func(*Manager) error {\n\treturn func(c *Manager) error {\n\t\tport, err := strconv.Atoi(v)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Invalid port; non-number.\")\n\t\t}\n\t\tif port < 65536 && port > -1 {\n\t\t\tc.samport = v\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"Invalid port.\")\n\t}\n}", "func (mmSetIndex *mIndexModifierMockSetIndex) Set(f func(ctx context.Context, pn insolar.PulseNumber, index record.Index) (err error)) *IndexModifierMock {\n\tif mmSetIndex.defaultExpectation != nil {\n\t\tmmSetIndex.mock.t.Fatalf(\"Default expectation is already set for the IndexModifier.SetIndex method\")\n\t}\n\n\tif len(mmSetIndex.expectations) > 0 {\n\t\tmmSetIndex.mock.t.Fatalf(\"Some expectations are already set for the IndexModifier.SetIndex method\")\n\t}\n\n\tmmSetIndex.mock.funcSetIndex = f\n\treturn mmSetIndex.mock\n}", "func (_Abi *AbiCaller) GuardianSetIndex(opts *bind.CallOpts) (uint32, error) {\n\tvar out []interface{}\n\terr := _Abi.contract.Call(opts, &out, \"guardian_set_index\")\n\n\tif err != nil {\n\t\treturn *new(uint32), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(uint32)).(*uint32)\n\n\treturn out0, err\n\n}", "func (p *IntVector) Set(i int, x int)\t{ p.a[i] = x }", "func (debugging *debuggingOpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tdebugging.recordEntry(\"TexParameteri\", target, pname, param)\n\tdebugging.gl.TexParameteri(target, pname, param)\n\tdebugging.recordExit(\"TexParameteri\")\n}", "func (na *NArray) Set(v float32, indices ...int) {\n\n\tna.Data[na.Index(indices...)] = v\n}", "func (n *Node) SetInt(i int64)", "func (uni *Uniform4fv) Set(idx int, v0, v1, v2, v3 float32) {\n\n\tpos := idx * 4\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n\tuni.v[pos+3] = v3\n}", "func (self *Graphics) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func (s *IntSetting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.IntValue, err = cast.ToIntE(v)\n\treturn err\n}", "func (bitmap *bitmap) Set(index int) {\n\tbitmap.set(index, 1)\n}", "func (me *TSAFPTPortugueseVatNumber) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (o *FakeObject) SetIndex(i int, value interface{}) {\n\treflect.ValueOf(o.Value).Index(i).Set(reflect.ValueOf(value))\n}", "func (native *OpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tgl.TexParameteri(target, pname, param)\n}", "func (self *Graphics) SetChildIndexI(args ...interface{}) {\n self.Object.Call(\"setChildIndex\", args)\n}", "func (s *Int16Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Int16Value, err = cast.ToInt16E(v)\n\treturn err\n}", "func (self *SinglePad) SetIndexA(member int) {\n self.Object.Set(\"index\", member)\n}", "func SetIntValue(cfg *viper.Viper, name string, v *int) {\n\tif cfg.IsSet(name) {\n\t\t*v = cfg.GetInt(name)\n\t}\n}", "func (s *IntSliceSetting) SetValue(v interface{}) error {\n\tvar err error\n\tvar tmp []string\n\ttmp, err = cast.ToStringSliceE(v)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"int slice parsing failed at interim string step: %s\", err.Error())\n\t}\n\t*s.IntSliceValue, err = cast.ToIntSliceE(tmp)\n\treturn err\n}", "func (uni *Uniform3fv) Set(idx int, v0, v1, v2 float32) {\n\n\tpos := idx * 3\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n}", "func (z *Numeric) SetInt(x int) *Numeric {\n\tif x == 0 {\n\t\treturn z.SetZero()\n\t}\n\n\tif x < 0 {\n\t\tz.sign = numericNegative\n\t} else {\n\t\tz.sign = numericPositive\n\t}\n\n\tz.weight = -1\n\tz.digits = make([]int16, 0, 1) // as x!=0 there is at least 1 1000-base digit\n\tfor x != 0 {\n\t\td := mathh.AbsInt16(int16(x % numericBase))\n\t\tx /= numericBase\n\t\tif d != 0 || len(z.digits) > 0 { // avoid tailing zero\n\t\t\tz.digits = append([]int16{d}, z.digits...)\n\t\t}\n\t\tz.weight++\n\t}\n\n\treturn z\n}", "func (self *TileSprite) SetChildIndexI(args ...interface{}) {\n self.Object.Call(\"setChildIndex\", args)\n}", "func (s *UintSetting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.UintValue, err = cast.ToUintE(v)\n\treturn err\n}", "func (arguments Sequence) Index(c *Compiler, this Expression, indices ...Expression) (expression Expression, err error) {\n\texpression = c.NewExpression()\n\n\tif len(indices) != 1 {\n\t\treturn expression, c.NewError(\"arguments takes 1 integer index\")\n\t}\n\tvar index = indices[0]\n\n\texpression.Type = arguments.Subtype()\n\texpression.Go.WriteB(this.Go)\n\texpression.Go.WriteString(`[I.IndexList(`)\n\texpression.Go.WriteB(index.Go)\n\texpression.Go.WriteString(`,len(`)\n\texpression.Go.WriteB(this.Go)\n\texpression.Go.WriteString(`))]`)\n\n\treturn expression, nil\n}", "func (d *DSP) SetParameterFloat(index int, value float64) error {\n\tres := C.FMOD_DSP_SetParameterFloat(d.cptr, C.int(index), C.float(value))\n\treturn errs[res]\n}", "func (part *PartSupported) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpart.Value = uint32(payload)\n\n\treturn nil\n}", "func (d *DynamicArr) Set(index int, value interface{}) error {\n\tif index < 0 {\n\t\treturn errors.New(\"Index has to be greater than or equal to zero\")\n\t}\n\n\tfor index > d.capacity {\n\t\td.growSize()\n\t\td.length = d.capacity\n\t}\n\n\td.array[index] = value\n\td.length++\n\treturn nil\n}", "func TexParameteri(target, pname Enum, param int) {\n\tgl.TexParameteri(uint32(target), uint32(pname), int32(param))\n}", "func (s *f64) SetSample(i int, value float64) {\n\ts.buffer[i] = float64(value)\n}", "func (cmd *IntakeManifoldPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (instance *Instance) SetUint(fieldName string, value uint) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (f *Flags) Int(spec string, p *int, name, usage string) {\n\tf.addOption(spec, name, usage, func(name, value string) error {\n\t\ti, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid %s argument '%s'\", name, value)\n\t\t}\n\t\t*p = i\n\t\treturn nil\n\t})\n}", "func (n Nodes) SetIndex(i int, node *Node)", "func (nu *NodeUpdate) SetValue(i int) *NodeUpdate {\n\tnu.value = &i\n\tnu.addvalue = nil\n\treturn nu\n}", "func (l *Libvirt) DomainSetNumaParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(254, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (self *PhysicsP2) Mpxi(v int) int{\n return self.Object.Call(\"mpxi\", v).Int()\n}", "func (vn *VecN) Set(i int, val float64) {\n\tvn.vec[i] = val\n}", "func (uni *Uniform1fv) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (q *quartileIndex) Set(at int, val bool) {\n\tcur := q.bits.Get(at)\n\tif cur && val {\n\t\treturn\n\t}\n\tif !cur && !val {\n\t\treturn\n\t}\n\tq.bits.Set(at, val)\n\tvar delta int\n\tif val {\n\t\tdelta = 1\n\t} else {\n\t\tdelta = -1\n\t}\n\tfor i, o := range q.offsets {\n\t\tif at < o {\n\t\t\tq.counts[i] += delta\n\t\t}\n\t}\n}", "func (instance *Instance) SetInt16(fieldName string, value int16) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (c *Chip8) SetIndex() {\n\tc.index = c.inst & 0x0FFF\n}", "func (req MinRequest) Index(index interface{}) MinRequest {\n\treq.index = index\n\treturn req\n}", "func (d *DSP) SetParameterBool(index int, value bool) error {\n\tres := C.FMOD_DSP_SetParameterBool(d.cptr, C.int(index), getBool(value))\n\treturn errs[res]\n}", "func (cmd *Odometer) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 10\n\n\treturn nil\n}", "func (nuo *NodeUpdateOne) SetValue(i int) *NodeUpdateOne {\n\tnuo.value = &i\n\tnuo.addvalue = nil\n\treturn nuo\n}", "func (ms Int64DataPoint) SetValue(v int64) {\n\t(*ms.orig).Value = v\n}", "func (v Vector) Set(n int, data float64) {\n\tv.data[n] = data\n}", "func (cmd *ControlModuleVoltage) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 1000\n\n\treturn nil\n}", "func (gl *WebGL) TexParameteri(target GLEnum, param GLEnum, value int) {\n\tgl.context.Call(\"texParameteri\", target, param, value)\n}", "func (m *Metadata) SetInt(value string, v int64) error {\n\tif err := validInt(value); err != nil {\n\t\treturn err\n\t}\n\tm.mu.Lock()\n\tm.valuesInt[value] = v\n\tm.mu.Unlock()\n\treturn nil\n}", "func (cpu *CPU) set_N(i uint16) {\r\n\tcpu.regs[2] = (cpu.regs[2] & 0xfb) | ((i & 1) << 2)\r\n}", "func ProgramParameteri(program uint32, pname uint32, value int32) {\n\tsyscall.Syscall(gpProgramParameteri, 3, uintptr(program), uintptr(pname), uintptr(value))\n}", "func (_Casper *CasperCaller) Index(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Casper.contract.Call(opts, out, \"index\")\n\treturn *ret0, err\n}", "func (e *Engine) setIndex(index int64) {\n\te.Index = index\n\te.Name = naming.Name(index)\n}", "func (args Arguments) Int(index int) int {\n\tvar s int\n\tvar ok bool\n\tif s, ok = args.Get(index).(int); !ok {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Int(%d) failed because object wasn't correct type: %v\", index, args.Get(index)))\n\t}\n\treturn s\n}", "func (s *Uint16Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Uint16Value, err = cast.ToUint16E(v)\n\treturn err\n}", "func (p *Property) SetValue(v int) {\n\t// change the member value of property\n\tp.value = v\n}", "func (m *CardMutation) SetValue(i int) {\n\tm.value = &i\n\tm.addvalue = nil\n}", "func (access IntAccess) Set(row int, val int) {\n access.rawData[access.indices[row]] = val\n}", "func (this *Value) SetIndex(index int, val interface{}) {\n\tif this.parsedType == ARRAY && index >= 0 {\n\t\tswitch parsedValue := this.parsedValue.(type) {\n\t\tcase []*Value:\n\t\t\tif index < len(parsedValue) {\n\t\t\t\t// if we've already parsed the object, store it there\n\t\t\t\tswitch val := val.(type) {\n\t\t\t\tcase *Value:\n\t\t\t\t\tparsedValue[index] = val\n\t\t\t\tdefault:\n\t\t\t\t\tparsedValue[index] = NewValue(val)\n\t\t\t\t}\n\t\t\t}\n\t\tcase nil:\n\t\t\t// if not store it in alias\n\t\t\tif this.alias == nil {\n\t\t\t\tthis.alias = make(map[string]*Value)\n\t\t\t}\n\t\t\tswitch val := val.(type) {\n\t\t\tcase *Value:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = val\n\t\t\tdefault:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = NewValue(val)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (m *NumberTokenMutation) SetValue(i int) {\n\tm.value = &i\n\tm.addvalue = nil\n}", "func (s *Shader) setUniform(name string, value int32) {\n location:=gl.GetUniformLocation(s.idPrograma, gl.Str(name + \"\\x00\"))\n if location != -1 { // Si existe ese nombre de variable\n gl.Uniform1i(location, value)\n }\n}", "func (e *Element) SetIndex(value int) {\n\tif e.Scene != nil {\n\t\te.Scene.Resize.Notify()\n\t}\n\n\tif e.Parent != nil {\n\t\te.Parent.projectIndex(&value)\n\t\te.Parent.children.ReIndex(e.index, value)\n\t\te.Parent.updateIndexes(e.index, value) // this will set the index\n\t}\n}", "func (ps *PrjnStru) SetNIdxSt(n *[]int32, avgmax *minmax.AvgMax32, idxst *[]int32, tn *etensor.Int32) int32 {\n\tln := tn.Len()\n\ttnv := tn.Values\n\t*n = make([]int32, ln)\n\t*idxst = make([]int32, ln)\n\tidx := int32(0)\n\tavgmax.Init()\n\tfor i := 0; i < ln; i++ {\n\t\tnv := tnv[i]\n\t\t(*n)[i] = nv\n\t\t(*idxst)[i] = idx\n\t\tidx += nv\n\t\tavgmax.UpdateVal(float32(nv), int32(i))\n\t}\n\tavgmax.CalcAvg()\n\treturn idx\n}", "func (v *Posit16x2) Put(i int, x Posit16) { v.impl[i] = x }", "func (a *api) SetInt(raw bool) {\n\ta.Commentf(\"%s constructs a field element from a big integer.\", rawname(\"SetInt\", raw))\n\ta.rawcomment(raw)\n\ta.Printf(\"func (x %s) %s(y *big.Int) %s\", a.PointerType(), rawname(\"SetInt\", raw), a.PointerType())\n\ta.EnterBlock()\n\n\ta.Comment(\"Reduce if outside range.\")\n\ta.Linef(\"if y.Sign() < 0 || y.Cmp(%s) >= 0 {\", a.Name(\"p\"))\n\ta.Linef(\"y = new(big.Int).Mod(y, %s)\", a.Name(\"p\"))\n\ta.Linef(\"}\")\n\n\ta.Comment(\"Copy bytes into field element.\")\n\ta.Linef(\"b := y.Bytes()\")\n\ta.Linef(\"i := 0\")\n\ta.Linef(\"for ; i < len(b); i++ {\")\n\ta.Linef(\"x[i] = b[len(b)-1-i]\")\n\ta.Linef(\"}\")\n\ta.Linef(\"for ; i < %s; i++ {\", a.Size())\n\ta.Linef(\"x[i] = 0\")\n\ta.Linef(\"}\")\n\n\tif !raw && a.Montgomery() {\n\t\ta.Comment(\"Encode into the Montgomery domain.\")\n\t\ta.Call(\"Encode\", \"x\", \"x\")\n\t}\n\n\ta.Linef(\"return x\")\n\ta.LeaveBlock()\n}", "func Index(v int) predicate.Step {\n\treturn predicate.Step(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldIndex), v))\n\t})\n}", "func (cmd *VehicleSpeed) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (na *NArray) SetValue(v float32) *NArray {\n\n\tfor i := range na.Data {\n\t\tna.Data[i] = v\n\t}\n\treturn na\n}", "func (req *MinRequest) Index(index interface{}) *MinRequest {\n\treq.index = index\n\treturn req\n}", "func (z *Int) Set(x *Int) *Int {}", "func (c *Constructor[_]) IntVar(ptr *int, name string, value int, help string) {\n\t*ptr = value\n\tc.define(name, paramInt, help).intptr = ptr\n}", "func (_m *MockMutableSeriesIterators) SetAt(idx int, iter SeriesIterator) {\n\t_m.ctrl.Call(_m, \"SetAt\", idx, iter)\n}", "func (pal *CGBPalette) updateIndex(value byte) {\n\tpal.index = value & 0x3F\n\tpal.inc = bits.Test(value, 7)\n}", "func (self *TileSprite) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func TPUReplicatedInputIndex(value int64) TPUReplicatedInputAttr {\n\treturn func(m optionalAttr) {\n\t\tm[\"index\"] = value\n\t}\n}", "func TexParameteri(target, pname GLEnum, param int32) {\n\tgl.TexParameteri(uint32(target), uint32(pname), param)\n}", "func (cmd *AbsoluteBarometricPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = int(payload)\n\n\treturn nil\n}", "func (p *Param) SetValue(value float64) error {\n\tvar ferr C.FMOD_RESULT\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_SetValue(p.param, C.float(value))\n\t})\n\treturn base.ResultToError(ferr)\n}", "func setVertexIntProperty(vertex *graphson.Vertex, key string, value int) {\n\tsetVertexTypedProperty(\"int\", vertex, key, value)\n}" ]
[ "0.7169632", "0.6071059", "0.58062094", "0.5665194", "0.55637103", "0.5485978", "0.5457712", "0.543184", "0.5402546", "0.5304153", "0.52988124", "0.5242471", "0.5222786", "0.5219914", "0.5194405", "0.5133261", "0.5110956", "0.5038237", "0.5031877", "0.50287044", "0.5028011", "0.50048786", "0.50012946", "0.49588308", "0.49586993", "0.4948084", "0.49325296", "0.49296927", "0.49192375", "0.49027905", "0.48804316", "0.4863697", "0.48524472", "0.485178", "0.48480657", "0.48423567", "0.48353252", "0.48306164", "0.48264754", "0.4816008", "0.48033592", "0.479765", "0.47931027", "0.47892904", "0.47823846", "0.47797337", "0.47686544", "0.47672367", "0.47603226", "0.4759188", "0.47578993", "0.4745898", "0.4724042", "0.47166047", "0.47161558", "0.4711609", "0.47099563", "0.47005764", "0.46979067", "0.46969804", "0.46883067", "0.4678803", "0.46543068", "0.4654064", "0.46489626", "0.46476844", "0.46445423", "0.46370605", "0.46349573", "0.46344545", "0.4630735", "0.4619243", "0.46168086", "0.4616713", "0.461431", "0.4610111", "0.46086928", "0.46073222", "0.46039063", "0.46033394", "0.45969546", "0.45936865", "0.4592502", "0.4590382", "0.45843974", "0.45736885", "0.45666596", "0.45648882", "0.4561848", "0.45616207", "0.4560611", "0.4555571", "0.4552499", "0.45485166", "0.45405334", "0.45362717", "0.45312154", "0.45291576", "0.45201775", "0.4515138" ]
0.6759115
1
Sets a DSP unit's boolean parameter by index. To find out the parameter names and range, see the see also field. index: Parameter index for this unit. Find the number of parameters with "DSP.NumParameters". value: Boolean parameter value to be passed to the DSP unit. Should be TRUE or FALSE. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) SetParameterBool(index int, value bool) error { res := C.FMOD_DSP_SetParameterBool(d.cptr, C.int(index), getBool(value)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (b *BoolMatrixLinear) SetBool(i, j int, value bool) bool {\n\tif i > b.heigh || j > b.width {\n\t\treturn false\n\t}\n\tb.matrix[i*b.width+j] = value\n\treturn true\n}", "func (node *Configuration) SetBool(parameter uint8, value bool) error {\n\tv := uint8(0)\n\tif value {\n\t\tv = 1\n\t}\n\treturn node.zwSendDataRequest(CommandClassConfiguration,\n\t\t[]uint8{configurationSet, parameter, 1, v})\n}", "func (instance *Instance) SetBoolean(fieldName string, value bool) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tintValue := 0\n\tif value {\n\t\tintValue = 1\n\t}\n\tretcode := int(C.RTI_Connector_set_boolean_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.int(intValue)))\n\treturn checkRetcode(retcode)\n}", "func WriteBool(buffer []byte, offset int, value bool) {\n if value {\n buffer[offset] = 1\n } else {\n buffer[offset] = 0\n }\n}", "func (m *BoolMatrix) Set(x, y int64, v bool) error {\n\treturn m.bs.Set(m.index(x, y), v)\n}", "func (args Arguments) Bool(index int) bool {\n\tvar s bool\n\tvar ok bool\n\tif s, ok = args.Get(index).(bool); !ok {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Bool(%d) failed because object wasn't correct type: %v\", index, args.Get(index)))\n\t}\n\treturn s\n}", "func (g *GPIOControllerPCF8574T) Set(index int, on bool) {\n\tif index < 0 || index > pinCount {\n\t\tfmt.Printf(\"Input out of range for gpio: %d\", index)\n\t\treturn\n\t}\n\n\tg.mutex.Lock()\n\tdefer g.mutex.Unlock()\n\tif on {\n\t\tg.valuePinMask |= (1 << index)\n\t} else {\n\t\tg.valuePinMask &= ((1 << index) ^ 0xff)\n\t}\n\tg.sync()\n}", "func (access BoolAccess) Set(row int, val bool) {\n access.rawData[access.indices[row]] = val\n}", "func (s *BoolSetting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.BoolValue, err = cast.ToBoolE(v)\n\treturn err\n}", "func (a *BooleanArchive) SetValue(entryIndex int, value bool) {\n\tif entryIndex >= a.size {\n\t\toutOfBoundsError := errors.New(\"index out of range\")\n\t\tpanic(outOfBoundsError)\n\t}\n\ta.setValueUnchecked(entryIndex, value)\n\ta.resetCache()\n}", "func (p *Stream) WriteBool(v bool) {\n\tswitch v {\n\tcase true:\n\t\tp.writeFrame[p.writeIndex] = 2\n\tcase false:\n\t\tp.writeFrame[p.writeIndex] = 3\n\t}\n\tp.writeIndex++\n\tif p.writeIndex == streamBlockSize {\n\t\tp.gotoNextWriteFrame()\n\t}\n}", "func (m *DeviceHealthScriptBooleanParameter) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.DeviceHealthScriptParameter.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteBoolValue(\"defaultValue\", m.GetDefaultValue())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func WriteBool(p thrift.TProtocol, value bool, name string, field int16) error {\n\treturn WriteBoolWithContext(context.Background(), p, value, name, field)\n}", "func (s *settableBool) Set(v string) error {\n\tb, err := strconv.ParseBool(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\ts.val = b\n\ts.isSet = true\n\treturn nil\n}", "func (r *R1_eg) setBit(idx1 int, value int) {\n\tr.Values[idx1] = value\n}", "func (this *parameter) Bool() bool {\n\tif this.Values == nil {\n\t\treturn false\n\t} else {\n\t\treturn reflekt.AsBool(this.Values[0])\n\t}\n}", "func SetBit(b byte, idx uint, flag bool) byte {\n\tif idx < 0 || idx > 7 {\n\t\tlog.Panic(\"the idx must be from 0 to 7\")\n\t}\n\tif flag {\n\t\treturn b | (1 << idx)\n\t}\n\treturn b &^ (1 << idx)\n}", "func (v *Verifier) SetBoolean(key BooleanKey, value bool) ApiVerifier {\n\tv.Inputs.Flags.BooleanFlags[key] = value\n\treturn v\n}", "func (obj *Value) SetBoolean(v bool) {\n\tobj.Candy().Guify(\"g_value_set_boolean\", obj, v)\n}", "func BoolIdx(list []bool, indices []int, element bool) (int, bool) {\n\tif len(indices) > 0 {\n\t\tvalueIndex := indices[0]\n\t\tif !list[valueIndex] {\n\t\t\tif !element {\n\t\t\t\treturn 0, true\n\t\t\t}\n\t\t\treturn 1, len(indices) >= 2\n\t\t}\n\t\treturn 0, element\n\t}\n\treturn 0, false\n}", "func (a *atomicBool) Set(boolValue bool) bool {\n\tintValue := int32(falseValue)\n\tif boolValue {\n\t\tintValue = trueValue\n\t}\n\treturn toTruthy(atomic.SwapInt32(&a.value, intValue))\n}", "func (w *Writer) Bool(v bool) {\n\tw.buf = strconv.AppendBool(w.buf, v)\n}", "func SetBoolValue(model ModelT, t TermT, val int32) int32 {\n\treturn int32(C.yices_model_set_bool(ymodel(model), C.term_t(t), C.int32_t(val)))\n}", "func (v *Value) SetBool(b bool) {\n\tif b == true {\n\t\tC.zj_SetBool(v.V, true)\n\t} else {\n\t\tC.zj_SetBool(v.V, false)\n\t}\n}", "func (m FieldMap) SetBool(tag Tag, value bool) FieldMap {\n\treturn m.SetField(tag, FIXBoolean(value))\n}", "func (m *Metadata) SetBool(value string, v bool) error {\n\tif err := validBool(value); err != nil {\n\t\treturn err\n\t}\n\tm.mu.Lock()\n\tm.valuesBool[value] = v\n\tm.mu.Unlock()\n\treturn nil\n}", "func (c *Constructor[_]) BoolVar(ptr *bool, name string, value bool, help string) {\n\t*ptr = value\n\tc.define(name, paramBool, help).boolptr = ptr\n}", "func (s *BoolSliceSetting) SetValue(v interface{}) error {\n\tvar err error\n\tvar tmp []string\n\ttmp, err = cast.ToStringSliceE(v)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"bool slice parsing failed at interim string step: %s\", err.Error())\n\t}\n\t*s.BoolSliceValue, err = cast.ToBoolSliceE(tmp)\n\treturn err\n}", "func (builder *BitVectorBuilderData) Set(i uint64, val bool) {\n\tbuilder.vec.set(i, val)\n}", "func (cv *ConVar) SetBool(value bool) error {\n\tif value {\n\t\treturn cv.write(reflect.Int, 1, 2)\n\t}\n\treturn cv.write(reflect.Int, 0, 2)\n}", "func (kv KeyValueStore) SetBool(key string, val bool) error {\n\treturn kv.Set(key, boolToString(val))\n}", "func (v *Value) SetBool(val bool) {\n\tC.g_value_set_boolean(v.Native(), gbool(val))\n}", "func (f *Flagger) Bool(name, shorthand string, value bool, usage string) {\n\tf.cmd.Flags().BoolP(name, shorthand, value, usage)\n\tf.cfg.BindPFlag(name, f.cmd.Flags().Lookup(name))\n}", "func (m *DeviceHealthScriptBooleanParameter) SetDefaultValue(value *bool)() {\n err := m.GetBackingStore().Set(\"defaultValue\", value)\n if err != nil {\n panic(err)\n }\n}", "func (r postQueryPublishedBoolean) Set(value bool) postWithPrismaPublishedSetParams {\n\n\treturn postWithPrismaPublishedSetParams{\n\t\tdata: builder.Field{\n\t\t\tName: \"published\",\n\t\t\tValue: value,\n\t\t},\n\t}\n\n}", "func (i *NullBool) Set(v bool) {\n\ti.Bool = v\n\ti.Valid = true\n}", "func BoolVar(p *bool, name string, value bool) {\n\t*p = value\n\tfuncs = append(funcs, func() bool {\n\t\tif s := os.Getenv(name); s != \"\" {\n\t\t\tv, err := strconv.ParseBool(s)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(name, err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t*p = v\n\t\t}\n\t\treturn true\n\t})\n}", "func BoolVarP(pv *bool, short rune, long string, value bool, description string) {\n\tif err := parseShortAndLongFlag(short, long); err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionBool{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (c Channel) WriteBool(name string, value bool) error {\n\tcName := C.CString(name)\n\tdefer C.free(unsafe.Pointer(cName))\n\n\terrno := C.iio_channel_attr_write_bool(c.handle, cName, C.bool(value))\n\tif errno < 0 {\n\t\treturn syscall.Errno(-errno)\n\t}\n\t// otherwise it's the number of bytes, which we're not interested in\n\t// at this time\n\treturn nil\n}", "func (enc *Encoder) Bool(v bool) {\n\tenc.grow(5)\n\tr := enc.getPreviousRune()\n\tif r != '[' {\n\t\tenc.writeByte(',')\n\t}\n\tif v {\n\t\tenc.writeString(\"true\")\n\t} else {\n\t\tenc.writeString(\"false\")\n\t}\n}", "func (se *SimpleElement) SetBool(value bool) {\n\tse.value = formatBool(value)\n}", "func (xs *Sheet) WriteBool(row int, col int, value int, format *Format) int {\n\tfo := uintptr(0)\n\tif nil != format {\n\t\tfo = format.self\n\t}\n\n\ttmp, _, _ := xs.xb.lib.NewProc(\"xlSheetWriteBoolW\").\n\t\tCall(xs.self, I(row), I(col), I(value), fo)\n\n\treturn int(tmp)\n}", "func (v *Value) BoolAt(i int) (bool, error) {\n\tif v.kind != kindArray {\n\t\treturn false, errors.New(\"JSON value is not an array\")\n\t}\n\tif i >= len(v.arrayContent) {\n\t\treturn false, errors.New(\"Index is out of bounds of array\")\n\t}\n\tvalue, err := v.arrayContent[i].Bool()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn value, nil\n}", "func assignValueBool(params map[string]interface{}, name string, out *bool) error {\n\tif raw, ok := params[name]; ok {\n\t\tval, ok := raw.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Expecting %s to be a boolean\", name)\n\t\t}\n\t\t*out = val\n\t\tdelete(params, name)\n\t}\n\treturn nil\n}", "func (rw *ReadWrite) PutBool(b bool) *ReadWrite {\n\ttrace.ClientServer.Println(\" ->\", b)\n\tif b {\n\t\trw.w.WriteByte(1)\n\t} else {\n\t\trw.w.WriteByte(0)\n\t}\n\treturn rw\n}", "func (_Mapping *MappingTransactor) SetBytesBool(opts *bind.TransactOpts, value [32]byte, setBool bool) (*types.Transaction, error) {\n\treturn _Mapping.contract.Transact(opts, \"setBytesBool\", value, setBool)\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func (z *Int) SetBit(x *Int, i int, b uint) *Int {}", "func BoolVar(p *bool, name string, value bool, usage string) {\n\tex.FlagSet.BoolVar(p, name, value, usage)\n}", "func BoolVar(p *bool, name string, value bool, usage string) {\n\tadd(name, newBoolValue(value, p), usage)\n}", "func SetBoolSlot(fbb *flatbuffers.Builder, slot int, value bool) {\n\tif value {\n\t\tSetByteSlot(fbb, slot, 1)\n\t} else {\n\t\tSetByteSlot(fbb, slot, 0)\n\t}\n}", "func WriteBool(w io.Writer, v bool) error {\n\td := make([]byte, 1, 1)\n\tswitch v {\n\tcase true:\n\t\td[0] = 1\n\tcase false:\n\t\td[0] = 0\n\t}\n\t_, err := w.Write(d)\n\treturn err\n}", "func (_Mapping *MappingSession) SetBytesBool(value [32]byte, setBool bool) (*types.Transaction, error) {\n\treturn _Mapping.Contract.SetBytesBool(&_Mapping.TransactOpts, value, setBool)\n}", "func eeNumBool(v bool) (n eeNum) {\r\n\t*n.bool() = v\r\n\treturn\r\n}", "func SetBooleanValue(literal core.Literal, value bool, hl *core.Transaction) error {\n\tif !IsBoolean(literal, hl) {\n\t\treturn errors.New(\"GetBooleanValue called with non-Boolean Literal\")\n\t}\n\tif value == true {\n\t\tliteral.SetLiteralValue(\"true\", hl)\n\t} else {\n\t\tliteral.SetLiteralValue(\"false\", hl)\n\t}\n\treturn nil\n}", "func Bool(name string, value string, usage string, aliases ...string) *Value {\n\treturn newBool(flag.Var, name, value, usage, aliases...)\n}", "func Bool(name string, value bool, usage string) *bool {\n\tp := new(bool);\n\tBoolVar(p, name, value, usage);\n\treturn p;\n}", "func (bA *CompactBitArray) SetIndex(i int, v bool) bool {\n\tif bA == nil {\n\t\treturn false\n\t}\n\n\tif i < 0 || i >= bA.Count() {\n\t\treturn false\n\t}\n\n\tif v {\n\t\tbA.Elems[i>>3] |= (1 << uint8(7-(i%8)))\n\t} else {\n\t\tbA.Elems[i>>3] &= ^(1 << uint8(7-(i%8)))\n\t}\n\n\treturn true\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func BoolVar(pv *bool, flag string, value bool, description string) {\n\tshort, long, err := parseSingleFlag(flag)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionBool{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (f *FilterWrap) Bool(s string) {\n\tf.boolClause = s\n}", "func (c *Config) SetBool(k string, b bool) {\n\tc.SetString(k, strconv.FormatBool(b))\n}", "func (m *CassandraDB) SetBoolValue(\n\tctx context.Context, id string, field string, value bool) error {\n\tvar member *membersys.MembershipAgreement = new(membersys.MembershipAgreement)\n\tvar batch *gocql.Batch\n\tvar encodedProto []byte\n\tvar stmt *gocql.Query\n\tvar err error\n\n\t// Retrieve the protobuf with all data from Cassandra. Use a quorum\n\t// read to make sure we aren't missing any recent updates.\n\tstmt = m.sess.Query(\n\t\t\"SELECT pb_data FROM members WHERE key = ?\",\n\t\tappend([]byte(memberPrefix), []byte(id)...)).WithContext(ctx).\n\t\tConsistency(gocql.Quorum)\n\tdefer stmt.Release()\n\n\terr = stmt.Scan(&encodedProto)\n\tif err == gocql.ErrNotFound {\n\t\treturn grpc.Errorf(codes.NotFound, \"No member found for %s: %s\", id,\n\t\t\terr.Error())\n\t}\n\tif err != nil {\n\t\treturn grpc.Errorf(codes.Internal, \"Error running query: %s\",\n\t\t\terr.Error())\n\t}\n\n\t// Decode the protobuf which was written to the column.\n\terr = proto.Unmarshal(encodedProto, member)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif field == \"has_key\" {\n\t\tmember.MemberData.HasKey = proto.Bool(value)\n\t} else {\n\t\treturn grpc.Errorf(codes.NotFound, \"Unknown field specified: %s\",\n\t\t\tfield)\n\t}\n\n\tencodedProto, err = proto.Marshal(member)\n\tif err != nil {\n\t\treturn grpc.Errorf(codes.Internal,\n\t\t\t\"Error parsing stored membership data: %s\", err.Error())\n\t}\n\n\t// Write data columns and pb_data back.\n\tbatch = m.sess.NewBatch(gocql.LoggedBatch).WithContext(ctx)\n\tbatch.SetConsistency(gocql.Quorum)\n\tbatch.Query(\n\t\t\"UPDATE members SET \"+field+\" = ?, pb_data = ? WHERE key = ?\",\n\t\tvalue, encodedProto, append([]byte(memberPrefix), []byte(id)...))\n\tbatch.Query(\n\t\t\"UPDATE member_agreements SET pb_data = ? WHERE key = ?\",\n\t\tencodedProto, append([]byte(memberPrefix), []byte(id)...))\n\terr = m.sess.ExecuteBatch(batch)\n\tif err != nil {\n\t\treturn grpc.Errorf(codes.Internal,\n\t\t\t\"Error writing back membership data: %s\", err.Error())\n\t}\n\n\treturn nil\n}", "func (_Mapping *MappingTransactorSession) SetBytesBool(value [32]byte, setBool bool) (*types.Transaction, error) {\n\treturn _Mapping.Contract.SetBytesBool(&_Mapping.TransactOpts, value, setBool)\n}", "func (key Key) SetBool(bp *bool) error {\n\tstr := string(key)\n\tval, ok := os.LookupEnv(str)\n\tif !ok {\n\t\treturn fmt.Errorf(\"env.Key.SetBool: missing environment variable %s\", key)\n\t}\n\tasBool, err := strconv.ParseBool(val)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"env.Key.SetInt: strconv.ParseBool: %v\", err)\n\t}\n\t*bp = asBool\n\treturn nil\n}", "func BoolP(short rune, long string, value bool, description string) *bool {\n\tvar v bool\n\tBoolVarP(&v, short, long, value, description)\n\treturn &v\n}", "func (stream *Stream) WriteBool(b bool) {\n\tif b {\n\t\tstream.writeFourBytes('t', 'r', 'u', 'e')\n\t} else {\n\t\tstream.writeFiveBytes('f', 'a', 'l', 's', 'e')\n\t}\n}", "func (bs *byteSliceBitSet) Set(index int) {\n\tif index < 0 {\n\t\treturn\n\t}\n\t// Check capacity\n\tbs.checkAndIncreaseCapacity(index)\n\t// Locate byte and bit\n\tbyteIndex, bitIndex := bs.locateBit(index)\n\t// Set value\n\tbs.bytes[byteIndex] = bs.bytes[byteIndex] | (1 << byte(bitIndex))\n\t// Increase word in use counter\n\tbs.wordInUse += 1\n}", "func (state *State) IsBool(index int) bool { return state.TypeAt(index) == BoolType }", "func RegisterBoolean(key string, def bool, description string) onion.Bool {\n\tsetDescription(key, description)\n\treturn o.RegisterBool(key, def)\n}", "func (am AttributeMap) UpdateBool(k string, v bool) {\n\tif av, existing := am.Get(k); existing {\n\t\tav.SetBoolVal(v)\n\t}\n}", "func (am AttributeMap) UpdateBool(k string, v bool) {\n\tif av, existing := am.Get(k); existing {\n\t\tav.SetBoolVal(v)\n\t}\n}", "func UpdateBoolean(database *gorm.DB) func(*gin.Context) {\n\tvar boolObj models.BooleanTemp\n\treturn func(c *gin.Context) {\n\t\tif AuthCheck(c) {\n\t\t\treturn\n\t\t}\n\t\tID := c.Param(\"id\")\n\t\tif err := c.ShouldBindJSON(&boolObj); err != nil {\n\t\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\t\treturn\n\t\t}\n\t\tdb.UpdateBoolean(database, ID, boolObj)\n\t\tboolObj := db.ReadBoolean(database, ID)\n\t\tc.JSON(http.StatusOK, gin.H{\"id\": boolObj.Id, \"key\": boolObj.Key, \"value\": boolObj.Value})\n\t}\n}", "func Bool(v *Value, def bool) bool {\n\tb, err := v.Bool()\n\tif err != nil {\n\t\treturn def\n\t}\n\treturn b\n}", "func (client PrimitiveClient) PutBool(complexBody BooleanWrapper) (result autorest.Response, err error) {\n req, err := client.PutBoolPreparer(complexBody)\n if err != nil {\n return result, autorest.NewErrorWithError(err, \"complexgroup.PrimitiveClient\", \"PutBool\", nil , \"Failure preparing request\")\n }\n\n resp, err := client.PutBoolSender(req)\n if err != nil {\n result.Response = resp\n return result, autorest.NewErrorWithError(err, \"complexgroup.PrimitiveClient\", \"PutBool\", resp, \"Failure sending request\")\n }\n\n result, err = client.PutBoolResponder(resp)\n if err != nil {\n err = autorest.NewErrorWithError(err, \"complexgroup.PrimitiveClient\", \"PutBool\", resp, \"Failure responding to request\")\n }\n\n return\n}", "func (d *DSP) SetParameterFloat(index int, value float64) error {\n\tres := C.FMOD_DSP_SetParameterFloat(d.cptr, C.int(index), C.float(value))\n\treturn errs[res]\n}", "func Boolean(param interface{}) bool {\n\tvar v bool\n\tif param != nil {\n\t\tv = param.(bool)\n\t}\n\treturn v\n}", "func (f *Form) Bool(param string, defaultValue bool) bool {\n\tvals, ok := f.values[param]\n\tif !ok {\n\t\treturn defaultValue\n\t}\n\tparamVal, err := strconv.ParseBool(vals[0])\n\tif err != nil {\n\t\tf.err = err\n\t\treturn defaultValue\n\t}\n\treturn paramVal\n}", "func (w *Writer) WriteBool(b bool) {\n\tif b {\n\t\tw.cache |= 1 << (w.available - 1)\n\t}\n\n\tw.available--\n\n\tif w.available == 0 {\n\t\t// WriteByte never returns error\n\t\t_ = w.out.WriteByte(w.cache)\n\t\tw.cache = 0\n\t\tw.available = 8\n\t}\n}", "func (e *Encoder) Bool(v bool) (int, error) {\n\tif v {\n\t\treturn e.Byte(0x1)\n\t}\n\treturn e.Byte(0x0)\n}", "func (ab *ABool) Set(b bool) {\n\tvar val int32\n\tif b {\n\t\tval = 1\n\t}\n\tatomic.StoreInt32(&ab.flag, val)\n}", "func (b *BoolValue) Set(s string) error {\n\tv, err := strconv.ParseBool(s)\n\t*b = BoolValue(v)\n\treturn err\n}", "func (m Measurement) AddBool(name string, value bool) Measurement {\n\tm.fieldSet[name] = value\n\treturn m\n}", "func Bool(v bool) (p *bool) { return &v }", "func Bool(name string, val bool) Field {\n\treturn Field(zap.Bool(name, val))\n}", "func (self *HttpContext) DefineBoolParam(name, invalidErrorCode string, paramType HttpParamType, required bool) {\n\tself.Params[name] = &HttpParam{ Name: name, InvalidErrorCode: invalidErrorCode, DataType: HttpBoolParam, Required: required, Type: paramType, Valid: true }\n}", "func BoolSet(flg *flag.FlagSet, name string, value string, usage string, aliases ...string) *Value {\n\treturn newBool(flg.Var, name, value, usage, aliases...)\n}", "func (q *quartileIndex) Set(at int, val bool) {\n\tcur := q.bits.Get(at)\n\tif cur && val {\n\t\treturn\n\t}\n\tif !cur && !val {\n\t\treturn\n\t}\n\tq.bits.Set(at, val)\n\tvar delta int\n\tif val {\n\t\tdelta = 1\n\t} else {\n\t\tdelta = -1\n\t}\n\tfor i, o := range q.offsets {\n\t\tif at < o {\n\t\t\tq.counts[i] += delta\n\t\t}\n\t}\n}", "func (g *Pin) SetValue(val bool){\n\tif g.mode == INPUT || g.value == val {\n\t\treturn\n\t}\n\tg.value = val\n\tvar setTo string\n\tif g.value {\n\t\tif g.activeLow {\n\t\t\tsetTo = \"0\"\n\t\t} else {\n\t\t\tsetTo = \"1\"\n\t\t}\n\t} else {\n\t\tif g.activeLow {\n\t\t\tsetTo = \"1\"\n\t\t} else {\n\t\t\tsetTo = \"0\"\n\t\t}\n\t}\n\n\tattempts := 0\n\tfor success:=false; success != true; {\n\t\tfile,err := os.OpenFile(g.path+VALUE_FILE_NAME,os.O_WRONLY,os.ModeExclusive)\n\t\tdefer file.Close()\n\t\tattempts++\n\t\tif err != nil {\n\t\t\tif attempts > FILE_ACCESS_BOUND {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t} else {\n\t\t\tfile.WriteString(setTo)\n\t\t\tsuccess = true\n\t\t}\n\t}\n\treturn\n}", "func (w *Writer) Bool(b bool) error {\n\tif b {\n\t\treturn w.Bit(1)\n\t}\n\treturn w.Bit(0)\n}", "func sanitizeBoolField(s Sanitizer, structValue reflect.Value, idx int) error {\n\tfieldValue := structValue.Field(idx)\n\n\ttags := s.fieldTags(structValue.Type().Field(idx).Tag)\n\n\tif fieldValue.Kind() == reflect.Ptr && !fieldValue.IsNil() {\n\t\tfieldValue = fieldValue.Elem()\n\t}\n\n\tisSlice := fieldValue.Kind() == reflect.Slice\n\n\tvar fields []reflect.Value\n\tif !isSlice {\n\t\tfields = []reflect.Value{fieldValue}\n\t} else {\n\t\tfor i := 0; i < fieldValue.Len(); i++ {\n\t\t\tfields = append(fields, fieldValue.Index(i))\n\t\t}\n\t}\n\n\tfor _, field := range fields {\n\t\tisPtr := field.Kind() == reflect.Ptr\n\n\t\t// Only handle \"def\". No min or max etc.\n\t\tif isPtr && field.IsNil() {\n\t\t\tif _, ok := tags[\"def\"]; ok {\n\t\t\t\tdefBool, err := strconv.ParseBool(tags[\"def\"])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"unable to parse default bool value: %+v\", err)\n\t\t\t\t}\n\n\t\t\t\tfield.Set(reflect.ValueOf(&defBool))\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (f BooleanField) SetBool(val bool) FieldAssignment {\n\treturn FieldAssignment{\n\t\tField: f,\n\t\tValue: val,\n\t}\n}", "func (node *Configuration) SetShort(parameter uint8, value uint16) error {\n\treturn node.zwSendDataRequest(CommandClassConfiguration,\n\t\t[]uint8{configurationSet, parameter, 2, uint8((value >> 8) & (0xff)),\n\t\t\tuint8(value & 0xff)})\n}", "func BoolIdxDesc(list []bool, indices []int, element bool) (int, bool) {\n\tif len(indices) > 0 {\n\t\tvalueIndex := indices[0]\n\t\tif list[valueIndex] {\n\t\t\tif element {\n\t\t\t\treturn 0, true\n\t\t\t}\n\t\t\treturn 1, len(indices) >= 2\n\t\t}\n\t\treturn 0, !element\n\t}\n\treturn 0, false\n}", "func (self *Tween) SetIsPausedA(member bool) {\n self.Object.Set(\"isPaused\", member)\n}", "func (bw *BufWriter) Bool(val bool) {\n\tif bw.Error != nil {\n\t\treturn\n\t}\n\tif val {\n\t\t_, bw.Error = bw.writer.WriteString(\"true\")\n\t\treturn\n\t}\n\t_, bw.Error = bw.writer.WriteString(\"false\")\n}", "func (p Parameters) GetBool(key string) (val bool) {\n\tif p != nil {\n\t\tval, _ = p[key].(bool)\n\t}\n\treturn\n}", "func (form *FormData) Bool(key string, target *bool, defaultValue bool) *FormData {\n\treturn form.mustValue(key, target, defaultValue)\n}" ]
[ "0.7692853", "0.60610425", "0.6013715", "0.5884806", "0.58234805", "0.57855713", "0.56893903", "0.56847155", "0.56807125", "0.5648212", "0.56343883", "0.560381", "0.55438143", "0.5524273", "0.5446539", "0.54162705", "0.53735465", "0.53634995", "0.5360937", "0.5355041", "0.53504694", "0.5343481", "0.53265953", "0.5326419", "0.52919245", "0.52837616", "0.5277212", "0.5262225", "0.52465165", "0.5238153", "0.5219175", "0.52133626", "0.5213222", "0.5210809", "0.51934785", "0.51871735", "0.51831895", "0.5171257", "0.51653755", "0.51602757", "0.515491", "0.5148728", "0.51360005", "0.5130126", "0.5102363", "0.51022404", "0.50932324", "0.509138", "0.50882864", "0.5088072", "0.50806063", "0.5058422", "0.5051192", "0.5049375", "0.5049236", "0.50457656", "0.50431764", "0.5037436", "0.5026731", "0.5014397", "0.50026554", "0.5000559", "0.4999707", "0.49843216", "0.49825248", "0.49803454", "0.49800658", "0.4959036", "0.4950452", "0.4937397", "0.49304974", "0.49140027", "0.49138063", "0.49138063", "0.49124014", "0.49028513", "0.48997554", "0.4897884", "0.4896426", "0.48934484", "0.48924363", "0.48780257", "0.48699158", "0.48647898", "0.48631266", "0.4861025", "0.4842924", "0.48410195", "0.48372328", "0.48336026", "0.48265895", "0.48235098", "0.48162314", "0.4815522", "0.48134747", "0.48110902", "0.478468", "0.47832292", "0.47828725", "0.4775969" ]
0.7395472
1
NOTE: Not implement yet Sets a DSP unit's binary data parameter by index. To find out the parameter names and range, see the see also field. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error { //FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (c *SquareChannel) SetValue(address uint16, data uint8) {\n\tswitch address {\n\t// Sweep period, negate, shift\n\tcase 0xFF10:\n\t\tc.SweepPeriodData = (data >> 4) & 0x7\n\t\tc.SweepNegate = (data & 0x8) == 0x8\n\t\tc.SweepShift = data & 0x7\n\t\tbreak\n\t// Duty, Length load (64-L)\n\tcase 0xFF11:\n\t\tfallthrough\n\tcase 0xFF16:\n\t\tc.DutyCounter = (data >> 6) & 0x3\n\t\tc.LengthData = data & 0x3F\n\t\tbreak\n\t// Starting volume, Envelope add mode, period\n\tcase 0xFF12:\n\t\tfallthrough\n\tcase 0xFF17:\n\t\t// DAC\n\t\tc.DACEnabled = (data & 0xF8) != 0\n\t\tc.VolumeData = (data >> 4) & 0xF\n\t\tc.envelopeAddMode = (data & 0x8) == 0x8\n\t\tc.envelopePeriodData = (data & 0x7)\n\t\tc.Volume = c.VolumeData\n\t\tbreak\n\t// Frequency LSB\n\tcase 0xFF13:\n\t\tfallthrough\n\tcase 0xFF18:\n\t\tc.FrequencyData = (c.FrequencyData & 0x700) | uint16(data)\n\t\tbreak\n\t// Trigger, Length enable, Frequency MSB\n\tcase 0xFF14:\n\t\tfallthrough\n\tcase 0xFF19:\n\t\tc.FrequencyData = (c.FrequencyData & 0xFF) | (uint16(data)&0x7)<<8\n\t\tc.LengthEnabled = (data & 0x40) == 0x40\n\t\tc.Trigger = (data & 0x80) == 0x80\n\t\tif c.Trigger {\n\t\t\tc.executeTrigger()\n\t\t}\n\t\tbreak\n\t}\n}", "func (b *fixedResolutionValues) SetValueAt(n int, v float64) {\n\tb.values[n] = v\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterInt(index, value int) error {\n\tres := C.FMOD_DSP_SetParameterInt(d.cptr, C.int(index), C.int(value))\n\treturn errs[res]\n}", "func (def *Definition) SetValueWithIndex(name string, index []uint32, x interface{}) error {\n\ttyp, err := def.SearchType(name)\n\tif err != nil {\n\t\tCentral.Log.Debugf(\"Search type error: %v\", err)\n\t\treturn err\n\t}\n\tif len(index) == 2 && typ.Type() != FieldTypeMultiplefield && index[1] > 0 {\n\t\treturn NewGenericError(62)\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Set value %s with index=%#v value=%v\", name, index, x)\n\t}\n\tvar val IAdaValue\n\tif !typ.HasFlagSet(FlagOptionPE) {\n\t\tCentral.Log.Debugf(\"Search name ....%s\", name)\n\t\tval = def.Search(name)\n\t\tif val == nil {\n\t\t\treturn NewGenericError(63, name)\n\t\t}\n\t} else {\n\t\tCentral.Log.Debugf(\"Search indexed period group ....%s %d\", name, index)\n\t\tval, err = def.SearchByIndex(name, index, true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif val == nil {\n\t\t\treturn NewGenericError(127, name)\n\t\t}\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Found value to add to %s[%d,%d] type=%v %T %T index=%#v\", val.Type().Name(),\n\t\t\tval.PeriodIndex(), val.MultipleIndex(), val.Type().Type().name(), val, val.Type(), index)\n\t}\n\tswitch val.Type().Type() {\n\tcase FieldTypeMultiplefield:\n\t\tsv := val.(*StructureValue)\n\t\tst := sv.Type().(*StructureType)\n\t\t//sv.Type().\n\t\t//\tsv.Elements = append(sv.Elements, subValue)\n\t\t// if len(sv.Elements) == 0 {\n\t\t// \te := &structureElement{}\n\t\t// \tCentral.Log.Debugf(\"Add empty element to %s\",sv.Type().Name())\n\t\t// \tsv.Elements = append(sv.Elements, e)\n\t\t// }\n\t\t// if len(sv.Elements[0].Values) >= int(index[0]) {\n\t\t// \tCentral.Log.Debugf(\"Adapt %#v\", st.SubTypes)\n\t\t// \tsubValue := sv.Elements[0].Values[int(index[0]-1)]\n\t\t// \terr = subValue.SetValue(x)\n\t\t// } else {\n\t\tsubValue, serr := st.SubTypes[0].Value()\n\t\tif serr != nil {\n\t\t\treturn serr\n\t\t}\n\t\terr = subValue.SetValue(x)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpeIndex := uint32(0)\n\t\tcurIndex := 0\n\t\tif typ.HasFlagSet(FlagOptionPE) {\n\t\t\tif len(index) > 0 {\n\t\t\t\tpeIndex = index[curIndex]\n\t\t\t\tcurIndex++\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tmuIndex := uint32(0)\n\t\tif typ.Type() == FieldTypeMultiplefield || typ.HasFlagSet(FlagOptionMUGhost) {\n\t\t\tif len(index) > curIndex {\n\t\t\t\tmuIndex = index[curIndex]\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tCentral.Log.Debugf(\"Set indexes to PE=%d MU=%d current=%d\", peIndex, muIndex, curIndex)\n\t\terr = sv.addValue(subValue, peIndex, muIndex)\n\t\t// subValue.setMultipleIndex(index[0])\n\t\t// sv.Elements[0].Values = append(sv.Elements[0].Values, subValue)\n\t\t// }\n\t\tif Central.IsDebugLevel() {\n\t\t\tCentral.Log.Debugf(\"Add Multiple field, elements=%d\", len(sv.Elements))\n\t\t}\n\tdefault:\n\t\terr = val.SetValue(x)\n\t}\n\treturn err\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func Set(data []uintptr, bitIdx int) {\n\t// Unsigned division by a power-of-2 constant compiles to a right-shift,\n\t// while signed does not due to negative nastiness.\n\tdata[uint(bitIdx)/BitsPerWord] |= 1 << (uint(bitIdx) % BitsPerWord)\n}", "func (gdt *Array) Set(idx Int, value Variant) {\n\targ0 := gdt.getBase()\n\targ1 := idx.getBase()\n\targ2 := value.getBase()\n\n\tC.go_godot_array_set(GDNative.api, arg0, arg1, arg2)\n}", "func (d *DSP) SetParameterFloat(index int, value float64) error {\n\tres := C.FMOD_DSP_SetParameterFloat(d.cptr, C.int(index), C.float(value))\n\treturn errs[res]\n}", "func (s *f64) SetSample(i int, value float64) {\n\ts.buffer[i] = float64(value)\n}", "func (d *DSP) SetParameterBool(index int, value bool) error {\n\tres := C.FMOD_DSP_SetParameterBool(d.cptr, C.int(index), getBool(value))\n\treturn errs[res]\n}", "func (bs *byteSliceBitSet) Set(index int) {\n\tif index < 0 {\n\t\treturn\n\t}\n\t// Check capacity\n\tbs.checkAndIncreaseCapacity(index)\n\t// Locate byte and bit\n\tbyteIndex, bitIndex := bs.locateBit(index)\n\t// Set value\n\tbs.bytes[byteIndex] = bs.bytes[byteIndex] | (1 << byte(bitIndex))\n\t// Increase word in use counter\n\tbs.wordInUse += 1\n}", "func (v Vector) Set(n int, data float64) {\n\tv.data[n] = data\n}", "func (ba *FilterBitArray) Set(i uint) {\n\t// Location of i in the array index is floor(i/byte_size) + 1. If it exceeds the\n\t// current byte array, we'll make a new one large enough to include the\n\t// specified bit-index\n\tif i >= ba.Capacity() {\n\t\tba.expand(i/byteSize + 1)\n\t}\n\t(*ba)[i/byteSize] |= 1 << (i % byteSize)\n}", "func (this *NamedParameterQuery) SetValue(parameterName string, parameterValue interface{}) {\n\n\tfor _, position := range this.positions[parameterName] {\n\t\tthis.parameters[position] = parameterValue\n\t}\n}", "func (uni *Uniform1fv) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (cmd *ControlModuleVoltage) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 1000\n\n\treturn nil\n}", "func (na *NArray) SetValue(v float32) *NArray {\n\n\tfor i := range na.Data {\n\t\tna.Data[i] = v\n\t}\n\treturn na\n}", "func setData(d *data, s string, x int) {\n\tswitch s {\n\tcase \"g\":\n\t\td.g = x\t\n\tcase \"m\":\n\t\td.m = x\n\tcase \"a\":\n\t\td.a = x\n\t}\n}", "func (o *Sensorefficiency) SetValue(v string) {\n\to.Value = v\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (l *Libvirt) DomainSetNumaParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(254, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (w *Wire) SetValue(value WireValue) {\n\tw.ovnum &^= valueMask\n\tw.ovnum |= (uint32(value) << valueShift) & valueMask\n}", "func (cmd *VehicleSpeed) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (node *Configuration) SetShort(parameter uint8, value uint16) error {\n\treturn node.zwSendDataRequest(CommandClassConfiguration,\n\t\t[]uint8{configurationSet, parameter, 2, uint8((value >> 8) & (0xff)),\n\t\t\tuint8(value & 0xff)})\n}", "func (na *NArray) Set(v float32, indices ...int) {\n\n\tna.Data[na.Index(indices...)] = v\n}", "func (uni *Uniform4fv) Set(idx int, v0, v1, v2, v3 float32) {\n\n\tpos := idx * 4\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n\tuni.v[pos+3] = v3\n}", "func (s *Uint16Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Uint16Value, err = cast.ToUint16E(v)\n\treturn err\n}", "func (cmd *OBDStandards) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (debugging *debuggingOpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tdebugging.recordEntry(\"TexParameteri\", target, pname, param)\n\tdebugging.gl.TexParameteri(target, pname, param)\n\tdebugging.recordExit(\"TexParameteri\")\n}", "func (h *handle) MPSSETxShort(w byte, wbits, rbits int, ew, er gpio.Edge, lsbf bool) (byte, error) {\n\top := byte(dataBit)\n\tif lsbf {\n\t\top |= dataLSBF\n\t}\n\tl := wbits\n\tif wbits != 0 {\n\t\tif wbits > 8 {\n\t\t\treturn 0, errors.New(\"ftdi: write buffer too long; max 8\")\n\t\t}\n\t\top |= dataOut\n\t\tif ew == gpio.FallingEdge {\n\t\t\top |= dataOutFall\n\t\t}\n\t}\n\tif rbits != 0 {\n\t\tif rbits > 8 {\n\t\t\treturn 0, errors.New(\"ftdi: read buffer too long; max 8\")\n\t\t}\n\t\top |= dataIn\n\t\tif er == gpio.FallingEdge {\n\t\t\top |= dataInFall\n\t\t}\n\t\tif l != 0 && rbits != l {\n\t\t\treturn 0, errors.New(\"ftdi: mismatched buffer lengths\")\n\t\t}\n\t\tl = rbits\n\t}\n\tb := [3]byte{op, byte(l - 1)}\n\tcmd := b[:2]\n\tif wbits != 0 {\n\t\tcmd = append(cmd, w)\n\t}\n\tif rbits != 0 {\n\t\tcmd = append(cmd, flush)\n\t}\n\tif _, err := h.Write(cmd); err != nil {\n\t\treturn 0, err\n\t}\n\tif rbits != 0 {\n\t\tctx, cancel := context200ms()\n\t\tdefer cancel()\n\t\t_, err := h.ReadAll(ctx, b[:1])\n\t\treturn b[0], err\n\t}\n\treturn 0, nil\n}", "func (part *PartSupported) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpart.Value = uint32(payload)\n\n\treturn nil\n}", "func (i IndexBlock) Set(blockNum byte, block uint16) {\n\ti[blockNum] = byte(block)\n\ti[256+int(blockNum)] = byte(block >> 8)\n}", "func (p *program) loadParameterValues(i *instruction) {\n for j := 0; j < i.getValuesCount(); j++ {\n switch i.params[j].mode {\n case 0:\n i.params[j].value = p.memory[i.params[j].value]\n case 2:\n i.params[j].value = p.memory[p.relativeBase+ int(i.params[j].value)]\n }\n }\n\n if i.doesStoreOutputInMemory() {\n if i.params[i.getValuesCount()].mode == 2 {\n i.params[i.getValuesCount()].value = int64(p.relativeBase) + i.params[i.getValuesCount()].value\n }\n }\n}", "func (r *R1_eg) setBit(idx1 int, value int) {\n\tr.Values[idx1] = value\n}", "func (me *THMACOutputLengthType) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (l *Libvirt) DomainSetMemoryParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetMemoryParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(197, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (b *AddonInstallationBuilder) Parameters(value *AddonInstallationParametersBuilder) *AddonInstallationBuilder {\n\tb.parameters = value\n\tif value != nil {\n\t\tb.bitmap_ |= 1024\n\t} else {\n\t\tb.bitmap_ &^= 1024\n\t}\n\treturn b\n}", "func (t Texture3D) SetParameter(paramName uint32, param int32) {\n\tt.Bind()\n\tgl.TexParameteri(gl.TEXTURE_3D, paramName, param)\n\tt.Unbind()\n}", "func (cmd *FuelPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload) * 3\n\n\treturn nil\n}", "func (builder *BitVectorBuilderData) Set(i uint64, val bool) {\n\tbuilder.vec.set(i, val)\n}", "func (uni *Uniform3fv) Set(idx int, v0, v1, v2 float32) {\n\n\tpos := idx * 3\n\tuni.v[pos] = v0\n\tuni.v[pos+1] = v1\n\tuni.v[pos+2] = v2\n}", "func (g *GPIOControllerPCF8574T) Set(index int, on bool) {\n\tif index < 0 || index > pinCount {\n\t\tfmt.Printf(\"Input out of range for gpio: %d\", index)\n\t\treturn\n\t}\n\n\tg.mutex.Lock()\n\tdefer g.mutex.Unlock()\n\tif on {\n\t\tg.valuePinMask |= (1 << index)\n\t} else {\n\t\tg.valuePinMask &= ((1 << index) ^ 0xff)\n\t}\n\tg.sync()\n}", "func (cmd *TransmissionActualGear) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\t// A & B are not used in the calculation\n\tcmd.Value = float32(payload>>16) / 1000\n\n\treturn nil\n}", "func (cmd *Odometer) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt32()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 10\n\n\treturn nil\n}", "func (cmd *AbsoluteBarometricPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = int(payload)\n\n\treturn nil\n}", "func (bitmap *bitmap) set(index int, bit int) {\n\tif index >= bitmap.Size {\n\t\tpanic(\"index out of range\")\n\t}\n\n\tdiv, mod := index/8, index%8\n\tshift := byte(1 << uint(7-mod))\n\n\tbitmap.data[div] &= ^shift\n\tif bit > 0 {\n\t\tbitmap.data[div] |= shift\n\t}\n}", "func (instance *Instance) SetUint(fieldName string, value uint) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (x *fastReflection_DenomUnit) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {\n\tswitch fd.FullName() {\n\tcase \"cosmos.bank.v1beta1.DenomUnit.denom\":\n\t\tx.Denom = value.Interface().(string)\n\tcase \"cosmos.bank.v1beta1.DenomUnit.exponent\":\n\t\tx.Exponent = uint32(value.Uint())\n\tcase \"cosmos.bank.v1beta1.DenomUnit.aliases\":\n\t\tlv := value.List()\n\t\tclv := lv.(*_DenomUnit_3_list)\n\t\tx.Aliases = *clv.list\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.DenomUnit\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.DenomUnit does not contain field %s\", fd.FullName()))\n\t}\n}", "func (spriteBatch *SpriteBatch) Set(index int, args ...float32) error {\n\treturn spriteBatch.addv(spriteBatch.texture.getVerticies(), generateModelMatFromArgs(args), index)\n}", "func (p *Param) SetValue(value float64) error {\n\tvar ferr C.FMOD_RESULT\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_SetValue(p.param, C.float(value))\n\t})\n\treturn base.ResultToError(ferr)\n}", "func (o *EquipmentBaseSensor) SetValue(v string) {\n\to.Value = &v\n}", "func (z *Int) SetBit(x *Int, i int, b uint) *Int {}", "func (p *swPwm) Set(period time.Duration, duty int) error {\n\tif duty < 0 || duty > 100 {\n\t\treturn os.ErrInvalid\n\t}\n\tp.c <- pwmMsg{period, duty, nil}\n\treturn nil\n}", "func (d *DynamicArr) Set(index int, value interface{}) error {\n\tif index < 0 {\n\t\treturn errors.New(\"Index has to be greater than or equal to zero\")\n\t}\n\n\tfor index > d.capacity {\n\t\td.growSize()\n\t\td.length = d.capacity\n\t}\n\n\td.array[index] = value\n\td.length++\n\treturn nil\n}", "func (s *Trainer) SetParameters(p []float64) {\n\tif len(p) != s.NumParameters() {\n\t\tpanic(\"sink: parameter size mismatch\")\n\t}\n\trm := s.featureWeights.RawMatrix()\n\tcopy(rm.Data, p)\n}", "func (wv *Spectrum) Set(v float32) {\n\tfor k := 0; k < 4; k++ {\n\t\twv.C[k] = v\n\t}\n\n}", "func (cmd *IntakeManifoldPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload)\n\n\treturn nil\n}", "func (instance *Instance) SetByte(fieldName string, value byte) error {\n\tfieldNameCStr := C.CString(fieldName)\n\tdefer C.free(unsafe.Pointer(fieldNameCStr))\n\n\tretcode := int(C.RTI_Connector_set_number_into_samples(unsafe.Pointer(instance.output.connector.native), instance.output.nameCStr, fieldNameCStr, C.double(value)))\n\treturn checkRetcode(retcode)\n}", "func (l *Libvirt) DomainSetBlkioParameters(Dom Domain, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetBlkioParametersArgs {\n\t\tDom: Dom,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(205, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func SetBCD(vx uint16) { // FX33\n\tval := V[vx]\n\n\tMemory[VI] = byte(val / 100 % 10)\n\tMemory[VI+1] = byte(val / 10 % 10)\n\tMemory[VI+2] = byte(val % 10)\n\n\tPC += 2\n}", "func ParamUnit(name, description string) *float64 {\n\tf := &unitFlag{}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func (device *ServoBrick) SetPulseWidth(servoNum uint8, min uint16, max uint16) (err error) {\n\tvar buf bytes.Buffer\n\tbinary.Write(&buf, binary.LittleEndian, servoNum)\n\tbinary.Write(&buf, binary.LittleEndian, min)\n\tbinary.Write(&buf, binary.LittleEndian, max)\n\n\tresultBytes, err := device.device.Set(uint8(FunctionSetPulseWidth), buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 8 {\n\t\t\treturn fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 8)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tbytes.NewBuffer(resultBytes[8:])\n\n\t}\n\n\treturn nil\n}", "func (w *wasmPluginImpl) SetMemLimit(mem int) {}", "func (a *AVP) SetValue(dict *Dictionary, cdr Coder) (err error) {\n\tif a.Value != nil { // already set\n\t\treturn\n\t}\n\tif a.Number == VendorSpecificNumber { // Special handling of VSA values\n\t\tvsa, _ := NewVSAFromAVP(a)\n\t\tif err := vsa.SetValue(dict, cdr); err != nil {\n\t\t\treturn err\n\t\t}\n\t\ta.Name = VendorSpecificName\n\t\ta.Type = StringValue\n\t\ta.Value = vsa\n\t\treturn nil\n\t}\n\tda := dict.AttributeWithNumber(a.Number, NoVendor)\n\tif da == nil {\n\t\treturn fmt.Errorf(\"no dictionary data for avp: %+v\", a)\n\t}\n\tval, strVal, err := cdr.Decode(da.AttributeType, a.RawValue)\n\tif err != nil {\n\t\tif err != ErrUnsupportedAttributeType {\n\t\t\treturn err\n\t\t}\n\t\ta.Name = ErrUnsupportedAttributeType.Error()\n\t\terr = nil\n\t} else {\n\t\ta.Name = da.AttributeName\n\t}\n\ta.Type = da.AttributeType\n\ta.Value = val\n\ta.StringValue = strVal\n\tif a.Type == IntegerValue { // Attempty aliasing string value with the one from enum\n\t\tif dv := dict.ValueWithNumber(a.Name, uint8(a.Value.(uint32)), NoVendor); dv != nil {\n\t\t\ta.StringValue = dv.ValueName\n\t\t}\n\t}\n\treturn\n}", "func (l *Libvirt) DomainSetInterfaceParameters(Dom Domain, Device string, Params []TypedParam, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := DomainSetInterfaceParametersArgs {\n\t\tDom: Dom,\n\t\tDevice: Device,\n\t\tParams: Params,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(256, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (p *ProcStat) setN(data int) {\n\tif data&BIT_7 == BIT_7 {\n\t\tp.n = 1\n\t} else {\n\t\tp.n = 0\n\t}\n}", "func (s *AnalyticsBinKey) SetValue(v int64) *AnalyticsBinKey {\n\ts.Value = &v\n\treturn s\n}", "func SetConfigParameterForQBlock(session *libcoap.Session, customerId int) {\n // Get session config\n sessionConfig, err := models.GetCurrentSignalSessionConfiguration(customerId)\n if err != nil {\n log.Error(\"Failed to get current session config\")\n }\n // Get mitigationIds with status is 2\n mids, err := models.GetMitigationIdsByCustomer(customerId)\n if err != nil {\n log.Error(\"Failed to Get mitigation ids\")\n return\n }\n if sessionConfig != nil && sessionConfig.SessionId > 0 {\n maxPayLoad := sessionConfig.MaxPayloadIdle\n nonMaxRetransmit := sessionConfig.NonMaxRetransmitIdle\n nonTimeout := sessionConfig.NonTimeoutIdle\n nonReceiveTimeout := sessionConfig.NonReceiveTimeoutIdle\n if len(mids) > 0 {\n maxPayLoad = sessionConfig.MaxPayload\n nonMaxRetransmit = sessionConfig.NonMaxRetransmit\n nonTimeout = sessionConfig.NonTimeout\n nonReceiveTimeout = sessionConfig.NonReceiveTimeout\n }\n session.SetMaxPayLoads(maxPayLoad)\n session.SetNonMaxRetransmit(nonMaxRetransmit)\n session.SetNonTimeout(decimal.NewFromFloat(nonTimeout).Round((2)))\n session.SetNonReceiveTimeout(decimal.NewFromFloat(nonReceiveTimeout).Round((2)))\n }\n}", "func WB(address uint16, value uint8) {}", "func (spwm SoftPwm) Write(value int) error {\n\tif value < 0 || value > spwm.rang {\n\t\treturn fmt.Errorf(\"Please provide PWM range between 0 and %d\", spwm.rang)\n\t}\n\tC.softPwmWrite(C.int(spwm.pin), C.int(value))\n\treturn nil\n}", "func (d *Data) Set(name string, version uint, value []byte) (*Data, error) {\n\tfor i, b := range value {\n\t\tif b == 0 {\n\t\t\treturn nil, fmt.Errorf(\"invalid null byte in twig value at index %d\", i)\n\t\t}\n\t}\n\td.Values[Key{Name: name, Version: version}] = value\n\treturn d, nil\n}", "func (cmd *EngineRPM) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 4\n\n\treturn nil\n}", "func (d *Detector) SetSampleRate(x int) error {\n\terrno := C.fvad_set_sample_rate(d.fvad, C.int(x))\n\tif errno != 0 {\n\t\treturn fmt.Errorf(\"invalid sample rate: %v\", x)\n\t}\n\treturn nil\n}", "func (s *Int16Setting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.Int16Value, err = cast.ToInt16E(v)\n\treturn err\n}", "func (native *OpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tgl.TexParameteri(target, pname, param)\n}", "func (t *Texture) Set(x uint16, y uint16, value rgb565.Rgb565Color) {\n\tt.pixels[y*t.width+x] = value\n}", "func PCMPEQB(mx, x operand.Op) { ctx.PCMPEQB(mx, x) }", "func (ms HistogramBucketExemplar) SetValue(v float64) {\n\t(*ms.orig).Value = v\n}", "func (s *UintSetting) SetValue(v interface{}) error {\n\tvar err error\n\t*s.UintValue, err = cast.ToUintE(v)\n\treturn err\n}", "func (ms SummaryDataPointValueAtQuantile) SetValue(v float64) {\n\tms.orig.Value = v\n}", "func (q *quartileIndex) Set(at int, val bool) {\n\tcur := q.bits.Get(at)\n\tif cur && val {\n\t\treturn\n\t}\n\tif !cur && !val {\n\t\treturn\n\t}\n\tq.bits.Set(at, val)\n\tvar delta int\n\tif val {\n\t\tdelta = 1\n\t} else {\n\t\tdelta = -1\n\t}\n\tfor i, o := range q.offsets {\n\t\tif at < o {\n\t\t\tq.counts[i] += delta\n\t\t}\n\t}\n}", "func (b *Binding) Set(buf uint32) {\n\tgl.BindBufferBase(gl.SHADER_STORAGE_BUFFER, b.uint32, buf)\n}", "func (s *Parameter) SetValue(v string) *Parameter {\n\ts.Value = &v\n\treturn s\n}", "func (va *VertexArray) SetIndexData(data []uint32) {\n\t// Index Buffer Object\n\tgl.GenBuffers(1, &va.ibo) // generates the buffer (or multiple)\n\tgl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, va.ibo) // tells OpenGL what kind of buffer this is\n\n\t// BufferData assigns data to the buffer.\n\tgl.BufferData(gl.ELEMENT_ARRAY_BUFFER, len(data)*4, gl.Ptr(data), gl.STATIC_DRAW)\n\n\tva.vertices = len(data)\n}", "func (r *ClusterUpdateRequest) Parameter(name string, value interface{}) *ClusterUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func SetParameter(param Parameters) {\n\tif param.ReverifyInterval > 0 {\n\t\treverifyInterval = param.ReverifyInterval\n\t} else {\n\t\treverifyInterval = DefaultReverifyInterval\n\t}\n\tif param.QueryInterval > 0 {\n\t\tqueryInterval = param.QueryInterval\n\t} else {\n\t\tqueryInterval = DefaultQueryInterval\n\t}\n\tif param.MaxManaged > 0 {\n\t\tmaxManaged = param.MaxManaged\n\t} else {\n\t\tmaxManaged = DefaultMaxManaged\n\t}\n\tif param.MaxReplacements > 0 {\n\t\tmaxReplacements = param.MaxReplacements\n\t} else {\n\t\tmaxReplacements = DefaultMaxReplacements\n\t}\n}", "func (uni *UniformMatrix3f) Set(pos int, v float32) {\n\n\tuni.v[pos] = v\n}", "func (cmd *MafAirFlowRate) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsUInt16()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = float32(payload) / 100\n\n\treturn nil\n}", "func (r *ManagedServiceUpdateRequest) Parameter(name string, value interface{}) *ManagedServiceUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (o StakingPriceRecordAssetList) SetValue(asset string, value float64) {\n\t// This only keeps 8 decimal places of precision\n\to[asset] = uint64(math.Round(value * 1e8))\n}", "func (r *ClusterHibernateRequest) Parameter(name string, value interface{}) *ClusterHibernateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (d *Dense) Set(i, j int, v float64) {\n\tidx := i*d.columns + j\n\td.data[idx] = v\n}", "func (ba *FilterBitArray) ValueAt(i uint) byte {\n\tif i < ba.Capacity() {\n\t\treturn (*ba)[i/byteSize] & (1 << (i % byteSize))\n\t}\n\treturn 0\n}", "func (m *Measurement) SetValue(value string) {\n\tm.Values[\"value\"] = value\n}" ]
[ "0.6344773", "0.6249034", "0.6028529", "0.5725853", "0.5420507", "0.54057163", "0.52792674", "0.52589864", "0.5167751", "0.5121044", "0.5097041", "0.50767267", "0.50513506", "0.50232834", "0.5014348", "0.5014157", "0.49709666", "0.494074", "0.49014142", "0.4868088", "0.48605397", "0.4840457", "0.4827272", "0.4820961", "0.48116982", "0.48029757", "0.47847775", "0.47835118", "0.47682664", "0.47280464", "0.47279105", "0.47278124", "0.469104", "0.46859264", "0.46734124", "0.46712297", "0.46655974", "0.46411097", "0.46408126", "0.46353137", "0.4628037", "0.462803", "0.46243805", "0.46166575", "0.46140432", "0.46107423", "0.45968604", "0.45955348", "0.45915306", "0.45901108", "0.4585204", "0.45849106", "0.45841268", "0.4579733", "0.45754611", "0.45722967", "0.456855", "0.45673165", "0.45633367", "0.4560559", "0.45449913", "0.45391223", "0.45311055", "0.4530937", "0.45252168", "0.45251375", "0.44935238", "0.4489567", "0.44835228", "0.44797534", "0.44758445", "0.44535345", "0.44473478", "0.4445553", "0.44333422", "0.4430818", "0.44269884", "0.44214043", "0.441814", "0.44113216", "0.44105428", "0.44090593", "0.4405511", "0.4392011", "0.4389194", "0.43874782", "0.4385293", "0.437393", "0.43732253", "0.43702194", "0.43687674", "0.43494824", "0.43456408", "0.4342731", "0.43417922", "0.43414247", "0.43406612", "0.43309924", "0.43260857", "0.43259713" ]
0.6611978
0
NOTE: Not implement yet Retrieves a DSP unit's floating point parameter by index. To find out the parameter names and range, see the see also field. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (this *parameter) Float() float64 {\n\tif this.Values == nil {\n\t\treturn 0\n\t} else {\n\t\treturn reflekt.AsFloat(this.Values[0])\n\t}\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (p FloatFormalParam) GetValue() string {\n\treturn p.Value\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n C.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func (d *DSP) SetParameterFloat(index int, value float64) error {\n\tres := C.FMOD_DSP_SetParameterFloat(d.cptr, C.int(index), C.float(value))\n\treturn errs[res]\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tC.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tC.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func GetUniformfv(program uint32, location int32, params *float32) {\n\tsyscall.Syscall(gpGetUniformfv, 3, uintptr(program), uintptr(location), uintptr(unsafe.Pointer(params)))\n}", "func (p Properties) GetFloat(name string) float64 {\n\tfor _, property := range p {\n\t\tif property.Name == name && property.Type == \"float\" {\n\t\t\tv, err := strconv.ParseFloat(property.Value, 64)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn v\n\t\t}\n\t}\n\treturn 0\n}", "func ParamUnit(name, description string) *float64 {\n\tf := &unitFlag{}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func (blood *bloodGeneral) Get(name string) (value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.FieldByName(name)\n\tif field.IsValid() && field.Kind() == reflect.Float64 {\n\t\tvalue = field.Float()\n\t} else {\n\t\tpanic(\"Cannot find \" + name + \" in BloodGeneral struct\")\n\t}\n\n\treturn\n}", "func (uni *Uniform1fv) Get(pos int, v float32) float32 {\n\n\treturn uni.v[pos]\n}", "func (p *Param) GetValue() (float64, error) {\n\tvar ferr C.FMOD_RESULT\n\tvar value C.float\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_GetValue(p.param, &value)\n\t})\n\treturn float64(value), base.ResultToError(ferr)\n}", "func (items Float64Slice) Value(index int) interface{} { return items[index] }", "func (uni *Uniform4fv) Get(idx int) (v0, v1, v2, v3 float32) {\n\n\tpos := idx * 4\n\treturn uni.v[pos], uni.v[pos+1], uni.v[pos+2], uni.v[pos+3]\n}", "func (c Controller) GetFloat(key string, def ...float64) float64 {\n\tif v := string(c.QueryArgs().Peek(key)); v != \"\" {\n\t\ttmp, _ := strconv.ParseFloat(v, 64)\n\t\treturn tmp\n\t}\n\tif len(def) > 0 {\n\t\treturn def[0]\n\t}\n\treturn 0\n}", "func GetUniformfv(program uint32, location int32, params *float32) {\n C.glowGetUniformfv(gpGetUniformfv, (C.GLuint)(program), (C.GLint)(location), (*C.GLfloat)(unsafe.Pointer(params)))\n}", "func (af *filtBase) checkFloatParam(p, low, high float64, name string) (float64, error) {\n\tif low <= p && p <= high {\n\t\treturn p, nil\n\t} else {\n\t\terr := fmt.Errorf(\"parameter %v is not in range <%v, %v>\", name, low, high)\n\t\treturn 0, err\n\t}\n}", "func (this *parameter) Floats() []float64 {\n\tif this.Values == nil {\n\t\treturn nil\n\t} else {\n\t\tres := make([]float64, this.Count())\n\t\tfor i, v := range this.Values {\n\t\t\tres[i] = reflekt.AsFloat(v)\n\t\t}\n\t\treturn res\n\t}\n}", "func (obj VECTOR_TYPE) ValueAt(i int) float64 {\n if i < 0 || i >= obj.Dim() {\n panic(\"index out of bounds\")\n }\n if v, ok := obj.values[i]; ok {\n return v.GetValue()\n } else {\n return 0.0\n }\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (p FloatFormalParam) GetName() string {\n\tif p.IsPointer {\n\t\treturn \"*\" + p.Name\n\t}\n\treturn p.Name\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func parseFloatParameterRange(input string) (*FloatParameterRange, error) {\n\tvar start, end float64\n\n\tvar err error\n\tif strings.Index(input, \"-\") >= 0 {\n\t\tarray := strings.Split(input, \"-\")\n\t\tif len(array) != 2 {\n\t\t\terr = errors.New(\"Failed to split the string type\")\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif start, err = strconv.ParseFloat(array[0], 64); err != nil {\n\t\t\t// negative values must be dropped here\n\t\t\treturn nil, err\n\t\t}\n\t\tif end, err = strconv.ParseFloat(array[1], 64); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tif start, err = strconv.ParseFloat(input, 64); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tend = start\n\t}\n\n\tif start > end {\n\t\terr = errors.New(\"The 'max-config-values' attributes MUST be greater or equal to their counterpart in 'min-config-values' attributes.\")\n\t\treturn nil, err\n\t}\n\n\treturn &FloatParameterRange{\n\t\tstart: start,\n\t\tend: end,\n\t}, nil\n}", "func ParamUnitD(name, description string, defaultValue float64) *float64 {\n\tf := &unitFlag{\n\t\tset: true,\n\t\tvalue: defaultValue,\n\t}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func (uni *Uniform3fv) Get(idx int) (v0, v1, v2 float32) {\n\n\tpos := idx * 3\n\treturn uni.v[pos], uni.v[pos+1], uni.v[pos+2]\n}", "func (d Datapoints) ValueAt(n int) float64 { return d[n].Value }", "func (pm *FloatParameterRange) Start() interface{} {\n\treturn pm.start\n}", "func (data *Data) Float(s ...string) float64 {\n\treturn data.Interface(s...).(float64)\n}", "func (item Item) GetFloat(name string) float64 {\n\tf, _ := strconv.ParseFloat(fmt.Sprintf(\"%v\", item[name]), 64)\n\treturn f\n}", "func GetFloatv(dst []float32, pname Enum) {\n\tgl.GetFloatv(uint32(pname), &dst[0])\n}", "func (pr *prepareResult) parameterField(idx int) *p.ParameterField {\n\treturn pr.parameterFields[idx]\n}", "func (v *Vector) Get(i int) float64 {\n\tswitch i {\n\tcase 0:\n\t\treturn v.X\n\tcase 1:\n\t\treturn v.Y\n\tcase 2:\n\t\treturn v.Z\n\t}\n\treturn 0.0\n}", "func (s *System) Parameters() []float32 {\n\treturn s.parametersVector\n}", "func Float(name string, value float, usage string) *float {\n\tp := new(float);\n\tFloatVar(p, name, value, usage);\n\treturn p;\n}", "func GetParam(d []*commands.Data, name string) *commands.Data {\n\tfor _, element := range d {\n\t\tif strings.Compare(element.Name, name) == 0 {\n\t\t\treturn element\n\t\t}\n\t}\n\treturn nil\n}", "func FloatP(short rune, long string, value float64, description string) *float64 {\n\tvar v float64\n\tFloatVarP(&v, short, long, value, description)\n\treturn &v\n}", "func ParamSpecFloat_(name string, nick string, blurb string, minimum float32, maximum float32, defaultValue float32, flags ParamFlags) *ParamSpec {\n\tc_name := C.CString(name)\n\tdefer C.free(unsafe.Pointer(c_name))\n\n\tc_nick := C.CString(nick)\n\tdefer C.free(unsafe.Pointer(c_nick))\n\n\tc_blurb := C.CString(blurb)\n\tdefer C.free(unsafe.Pointer(c_blurb))\n\n\tc_minimum := (C.gfloat)(minimum)\n\n\tc_maximum := (C.gfloat)(maximum)\n\n\tc_default_value := (C.gfloat)(defaultValue)\n\n\tc_flags := (C.GParamFlags)(flags)\n\n\tretC := C.g_param_spec_float(c_name, c_nick, c_blurb, c_minimum, c_maximum, c_default_value, c_flags)\n\tretGo := ParamSpecNewFromC(unsafe.Pointer(retC))\n\n\treturn retGo\n}", "func (c *Config) GetF(name string, defvals ...float64) float64 {\n\tif c == nil || c.mx == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn 0.0\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\tc.mx.RLock()\n\tval := c.data[strings.ToLower(name)]\n\tc.mx.RUnlock()\n\n\tif val == \"\" {\n\t\tif len(defvals) == 0 {\n\t\t\treturn 0.0\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\tvalFl, err := strconv.ParseFloat(val, 64)\n\n\tif err != nil {\n\t\treturn 0.0\n\t}\n\n\treturn valFl\n}", "func (c *Controller) GetFloat(key string, def ...float64) (float64, error) {\n\tstrv := c.Ctx.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\treturn strconv.ParseFloat(strv, 64)\n}", "func FloatVarP(pv *float64, short rune, long string, value float64, description string) {\n\tif err := parseShortAndLongFlag(short, long); err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionFloat{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func Float(param interface{}) float64 {\n\tvar v float64\n\tif param != nil {\n\t\tswitch param.(type) {\n\t\tcase int64:\n\t\t\tv = float64(param.(int64))\n\t\tdefault:\n\t\t\tv = param.(float64)\n\t\t}\n\t}\n\treturn v\n}", "func (f *Flags) Float(spec string, p *float64, name, usage string) {\n\tf.addOption(spec, name, usage, func(name, value string) error {\n\t\tf, err := strconv.ParseFloat(value, 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid %s argument '%s'\", name, value)\n\t\t}\n\t\t*p = f\n\t\treturn nil\n\t})\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func (m Any) GetSliceOfFloat(name string) []float64 {\n\treturn convert.SliceOfFloat(m[name])\n}", "func (ctx *Context) ParamByIndex(index int) string {\n\treturn ctx.PathParams.ByIndex(index)\n}", "func (env *Environment) GetFloat(var_name string) float64 {\n\tev := reflect.ValueOf(env).Elem()\n\treturn ev.FieldByName(var_name).Float()\n}", "func GetF(name string, defvals ...float64) float64 {\n\tif global == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn 0.0\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\treturn global.GetF(name, defvals...)\n}", "func (_DelegateProfile *DelegateProfileCallerSession) GetFieldByIndex(_idx *big.Int) (struct {\n\tName string\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByIndex(&_DelegateProfile.CallOpts, _idx)\n}", "func (af *filtBase) GetParams() (int, float64, []float64) {\n\treturn af.n, af.mu, af.w.RawRowView(0)\n}", "func GetUniformfv(program uint32, location int32, params *float32) {\n\tC.glowGetUniformfv(gpGetUniformfv, (C.GLuint)(program), (C.GLint)(location), (*C.GLfloat)(unsafe.Pointer(params)))\n}", "func GetUniformfv(program uint32, location int32, params *float32) {\n\tC.glowGetUniformfv(gpGetUniformfv, (C.GLuint)(program), (C.GLint)(location), (*C.GLfloat)(unsafe.Pointer(params)))\n}", "func (s *f64) Sample(i int) float64 {\n\treturn float64(s.buffer[i])\n}", "func (fn *formulaFuncs) stdevp(name string, argsList *list.List) formulaArg {\n\tif argsList.Len() < 1 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf(\"%s requires at least 1 argument\", name))\n\t}\n\tfnName := \"VARP\"\n\tif name == \"STDEVPA\" {\n\t\tfnName = \"VARPA\"\n\t}\n\tvarp := fn.vars(fnName, argsList)\n\tif varp.Type != ArgNumber {\n\t\treturn varp\n\t}\n\treturn newNumberFormulaArg(math.Sqrt(varp.Number))\n}", "func (_DelegateProfile *DelegateProfileSession) GetFieldByIndex(_idx *big.Int) (struct {\n\tName string\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByIndex(&_DelegateProfile.CallOpts, _idx)\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func (ms Float64Slice) At(i int) float64 {\n\treturn (*ms.getOrig())[i]\n}", "func (c *Configuration) GetFloat(name string) (float64, error) {\n\tv, ok := c.data[name].(float64)\n\tif !ok {\n\t\treturn 0, errors.New(fmt.Sprintf(\"no existe el campo %s o no se puede convertir en float64\", name))\n\t}\n\n\treturn v, nil\n}", "func (l *Layer) Parameters() []*autofunc.Variable {\n\treturn []*autofunc.Variable{l.Biases, l.Scales}\n}", "func (options *Options) Param(pos int) interface{} {\n\tif len(options.params) > pos {\n\t\treturn options.params[pos]\n\t}\n\n\treturn nil\n}", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (c *Validator) GetFloat(key string, def ...float64) (float64, error) {\n\tstrv := c.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\treturn strconv.ParseFloat(strv, 64)\n}", "func (obj *SparseRealVector) ValueAt(i int) float64 {\n if i < 0 || i >= obj.Dim() {\n panic(\"index out of bounds\")\n }\n if v, ok := obj.values[i]; ok {\n return v.GetValue()\n } else {\n return 0.0\n }\n}", "func (p *Param) GetRange() (min, max float64, err error) {\n\tvar ferr C.FMOD_RESULT\n\tvar cmin, cmax C.float\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_GetRange(p.param, &cmin, &cmax)\n\t})\n\tmin = float64(cmin)\n\tmax = float64(cmax)\n\terr = base.ResultToError(ferr)\n\treturn\n}", "func (p Point) At(idx int) float64 {\n\treturn p[idx]\n}", "func (vm *VirtualMachine) getValueForElement(e quads.Element) interface{} {\n\tif strings.Contains(e.ID(), \"ptr_\") {\n\t\tmemblock := vm.getMemBlockForAddr(e.GetAddr())\n\t\tptrAddr, ok := memblock.Get(e.GetAddr()).(float64)\n\t\tif !ok {\n\t\t\tlog.Fatalf(\"Error: (getValueForElement) couldn't cast index to float64\")\n\t\t}\n\n\t\tauxElement := quads.NewElement(int(ptrAddr), e.ID(), e.Type(), \"\")\n\t\tmemblock = vm.getMemBlockForElement(auxElement)\n\t\trealValue := memblock.Get(int(ptrAddr))\n\t\treturn realValue\n\t}\n\tmemblock := vm.getMemBlockForElement(e)\n\treturn memblock.Get(e.GetAddr())\n}", "func (s *Smplen) Float() float64 {\n\treturn s.f\n}", "func (x *fastReflection_DenomUnit) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {\n\tswitch descriptor.FullName() {\n\tcase \"cosmos.bank.v1beta1.DenomUnit.denom\":\n\t\tvalue := x.Denom\n\t\treturn protoreflect.ValueOfString(value)\n\tcase \"cosmos.bank.v1beta1.DenomUnit.exponent\":\n\t\tvalue := x.Exponent\n\t\treturn protoreflect.ValueOfUint32(value)\n\tcase \"cosmos.bank.v1beta1.DenomUnit.aliases\":\n\t\tif len(x.Aliases) == 0 {\n\t\t\treturn protoreflect.ValueOfList(&_DenomUnit_3_list{})\n\t\t}\n\t\tlistValue := &_DenomUnit_3_list{list: &x.Aliases}\n\t\treturn protoreflect.ValueOfList(listValue)\n\tdefault:\n\t\tif descriptor.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.DenomUnit\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.DenomUnit does not contain field %s\", descriptor.FullName()))\n\t}\n}", "func VPI(index int32) Device {\n return Device{KDLVPI, index}\n}", "func Float(flag string, value float64, description string) *float64 {\n\tvar v float64\n\tFloatVar(&v, flag, value, description)\n\treturn &v\n}", "func extractAmavisParameterFloat(content string) float64{\n patterns := []string{`(?P<result>\\d+)\\*1024;$`,\n `(?P<result>\\d\\.\\d+);$`,\n `(?P<result>\\d+);$`,\n }\n result := []byte{}\n for i := 0; (i<len(patterns) && string(result) == \"\"); i++ {\n pattern := regexp.MustCompile(patterns[i])\n if pattern.MatchString(content) {\n template := \"$result\"\n for _, submatches := range pattern.FindAllStringSubmatchIndex(content, -1) {\n // Apply the captured submatches to the template and append the output\n // to the result.\n result = pattern.ExpandString(result, template, content, submatches)\n }\n }\n }\n resultFloat, _ := strconv.ParseFloat(string(result), 64)\n return resultFloat\n}", "func GetUniformfv(dst []float32, src Uniform, p Program) {\n\tgl.GetUniformfv(p.Value, src.Value, &dst[0])\n}", "func GetUniformfv(program Uint, location Int, params []Float) {\n\tcprogram, _ := (C.GLuint)(program), cgoAllocsUnknown\n\tclocation, _ := (C.GLint)(location), cgoAllocsUnknown\n\tcparams, _ := (*C.GLfloat)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&params)).Data)), cgoAllocsUnknown\n\tC.glGetUniformfv(cprogram, clocation, cparams)\n}", "func (p FloatFormalParam) Print() string {\n\t// TODO we will want more custom formatting based on the type here\n\treturn \"std::cout << \\\"\" + p.Name + \" \\\" << \" + p.Reference() + \" << std::endl;\"\n}", "func GetFloatv(pname GLenum, params []float32) {\n\tif len(params) == 0 {\n\t\tpanic(\"Invalid params length\")\n\t}\n\tC.glGetFloatv(C.GLenum(pname), (*C.GLfloat)(&params[0]))\n}", "func (v Vector) Get(n int) float64 {\n\treturn v.data[n]\n}", "func (s *INISection) GetFloat(key string, alt float64) float64 {\n\tv, ok := s.Fields[key]\n\tif !ok {\n\t\treturn alt\n\t}\n\n\treturn v.floatV\n}", "func (n *Norm) Parameters() []*autofunc.Variable {\n\tres := make([]*autofunc.Variable, len(n.Weights)+len(n.Mags))\n\tcopy(res, n.Weights)\n\tcopy(res[len(n.Weights):], n.Mags)\n\n\tnormRes, rv := n.newNormRResult(autofunc.RVector{})\n\tnet := n.Creator.Create(normRes.NormPool)\n\tparams := net.Parameters()\n\tfor _, param := range params {\n\t\tif _, ok := rv[param]; !ok {\n\t\t\tres = append(res, param)\n\t\t}\n\t}\n\n\treturn res\n}", "func (_DelegateProfile *DelegateProfileCaller) GetFieldByIndex(opts *bind.CallOpts, _idx *big.Int) (struct {\n\tName string\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\tret := new(struct {\n\t\tName string\n\t\tVerifier common.Address\n\t\tDeprecated bool\n\t})\n\tout := ret\n\terr := _DelegateProfile.contract.Call(opts, out, \"getFieldByIndex\", _idx)\n\treturn *ret, err\n}", "func SDAccel(index int32) Device {\n return Device{KDLSDAccel, index}\n}", "func (c *Command) GetFloat(key string, def ...float64) (float64, error) {\n\tv := c.Query(key)\n\n\tif v != nil && len(v.CommandValue) > 0 {\n\t\treturn strconv.ParseFloat(v.CommandValue, 64)\n\t} else if len(def) > 0 {\n\t\treturn def[0], nil\n\t} else if v.DefaultValue != nil {\n\t\tswitch v.DefaultValue.(type) {\n\t\tcase int:\n\t\t\treturn float64(v.DefaultValue.(int)), nil\n\t\tcase float64:\n\t\t\treturn v.DefaultValue.(float64), nil\n\t\tdefault:\n\t\t\treturn 0.0, nil\n\t\t}\n\t}\n\n\treturn 0.0, nil\n}", "func (c Config) GetParameter(name string) (Parameter, bool) {\n\tfor i, v := range c.Parameters {\n\t\tif v.Name == name {\n\t\t\treturn c.Parameters[i], true\n\t\t}\n\t}\n\treturn Parameter{}, false\n}", "func (r Qword) GetF() float64 {\n\treturn *(*float64)(unsafe.Pointer(&r))\n}", "func (s *Smpval) Float() float64 {\n\treturn s.f\n}", "func (seq Sequence) ValueAt(period int, e expr.Expr) (val float64, found bool) {\n\tif e.IsConstant() {\n\t\tval, found, _ = e.Get(nil)\n\t\treturn\n\t}\n\tif len(seq) == 0 {\n\t\treturn 0, false\n\t}\n\tif period < 0 {\n\t\treturn 0, false\n\t}\n\treturn seq.ValueAtOffset(period*e.EncodedWidth(), e)\n}", "func FloatVar(pv *float64, flag string, value float64, description string) {\n\tshort, long, err := parseSingleFlag(flag)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionFloat{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (c *Constructor[_]) Float(name string, value float64, help string) *float64 {\n\tp := new(float64)\n\tc.FloatVar(p, name, value, help)\n\treturn p\n}", "func GetParameters(maxSize uint, fpProb float64) (m uint, k uint) {\n m = uint(-1 * (float64(maxSize) * math.Log(fpProb)) / math.Pow(math.Log(2), 2))\n k = uint((float64(m) / float64(maxSize)) * math.Log(2))\n return\n}", "func (p FloatFormalParam) Declaration() string {\n\t// This is a declaration for formal params (we need the * for pointer)\n\treturn p.Type + \" \" + p.Reference()\n}", "func (uni *Uniform4fv) GetPos(pos int) float32 {\n\n\treturn uni.v[pos]\n}", "func ReportFloat(ns, name string) VarFloat {\n\tvarName := ns + \".\" + name\n\tvarLock.Lock()\n\tdefer varLock.Unlock()\n\n\tif v := expvar.Get(varName); v != nil {\n\t\treturn v.(*expvar.Float)\n\t}\n\treturn expvar.NewFloat(varName)\n}", "func GetRenderbufferParameteri(target, pname Enum) int {\n\tlog.Println(\"GetRenderbufferParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar result int32\n\tgl.GetRenderbufferParameteriv(uint32(target), uint32(pname), &result)\n\treturn int(result)\n}", "func (i Info) FreeFrac(k string) float64 {\n\treturn float64(i[k+\"Free\"]) / float64(i[k+\"Total\"])\n}", "func (fn *formulaFuncs) PDURATION(argsList *list.List) formulaArg {\n\tif argsList.Len() != 3 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"PDURATION requires 3 arguments\")\n\t}\n\trate := argsList.Front().Value.(formulaArg).ToNumber()\n\tif rate.Type != ArgNumber {\n\t\treturn rate\n\t}\n\tpv := argsList.Front().Next().Value.(formulaArg).ToNumber()\n\tif pv.Type != ArgNumber {\n\t\treturn pv\n\t}\n\tfv := argsList.Back().Value.(formulaArg).ToNumber()\n\tif fv.Type != ArgNumber {\n\t\treturn fv\n\t}\n\tif rate.Number <= 0 || pv.Number <= 0 || fv.Number <= 0 {\n\t\treturn newErrorFormulaArg(formulaErrorNUM, formulaErrorNUM)\n\t}\n\treturn newNumberFormulaArg((math.Log(fv.Number) - math.Log(pv.Number)) / math.Log(1+rate.Number))\n}", "func (a *Args) Float(arg rune) float64 {\n\tvar val float64\n\tif argMarshaler, ok := a.marhalers[arg]; ok {\n\t\tval = argMarshaler.get().(float64)\n\t}\n\treturn val\n}", "func readDeviceParameters(groupDir string, filenames []string, params DeviceParameters) error {\n\tvar errors *multierror.Error\n\tcontents, err := readFirstFile(groupDir, filenames)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, line := range strings.Split(contents, \"\\n\") {\n\t\t// Device weight files may have \"default NNN\" line at the beginning. Skip it.\n\t\tif line == \"\" || strings.HasPrefix(line, \"default \") {\n\t\t\tcontinue\n\t\t}\n\t\t// Expect syntax MAJOR:MINOR VALUE\n\t\tdevVal := strings.Split(line, \" \")\n\t\tif len(devVal) != 2 {\n\t\t\terrors = multierror.Append(errors, fmt.Errorf(\"invalid line %q, single space expected\", line))\n\t\t\tcontinue\n\t\t}\n\t\tmajMin := strings.Split(devVal[0], \":\")\n\t\tif len(majMin) != 2 {\n\t\t\terrors = multierror.Append(errors, fmt.Errorf(\"invalid line %q, single colon expected before space\", line))\n\t\t\tcontinue\n\t\t}\n\t\tmajor, majErr := strconv.ParseInt(majMin[0], 10, 64)\n\t\tminor, minErr := strconv.ParseInt(majMin[1], 10, 64)\n\t\tvalue, valErr := strconv.ParseInt(devVal[1], 10, 64)\n\t\tif majErr != nil || minErr != nil || valErr != nil {\n\t\t\terrors = multierror.Append(errors, fmt.Errorf(\"invalid number when parsing \\\"major:minor value\\\" from \\\"%s:%s %s\\\"\", majMin[0], majMin[1], devVal[1]))\n\t\t\tcontinue\n\t\t}\n\t\tparams.Append(major, minor, value)\n\t}\n\treturn errors.ErrorOrNil()\n}" ]
[ "0.6544512", "0.6089265", "0.5905936", "0.5897812", "0.5773538", "0.57044613", "0.56934804", "0.5658616", "0.5386246", "0.53801095", "0.53801095", "0.51362926", "0.5113154", "0.5106956", "0.503388", "0.5023903", "0.5014192", "0.4998702", "0.49777007", "0.49754697", "0.49165106", "0.4899918", "0.48515987", "0.48371428", "0.48333287", "0.48188934", "0.4804386", "0.47994414", "0.47987175", "0.4796837", "0.4792597", "0.4791634", "0.4784234", "0.47615343", "0.47293475", "0.47222608", "0.47024146", "0.46969247", "0.46965668", "0.46919608", "0.46823195", "0.4682148", "0.46651995", "0.46632233", "0.46614808", "0.46341014", "0.46338397", "0.46324033", "0.46182063", "0.46134564", "0.46094042", "0.46053898", "0.4603754", "0.45993242", "0.45841375", "0.45841375", "0.45818987", "0.45736644", "0.4549324", "0.45480072", "0.45471188", "0.45415285", "0.45258895", "0.4521466", "0.4513859", "0.4503956", "0.44917443", "0.44873977", "0.44840294", "0.44818714", "0.44752365", "0.446354", "0.44548762", "0.4439114", "0.44373202", "0.44363156", "0.44329265", "0.44243917", "0.44204995", "0.44157267", "0.44156694", "0.44086984", "0.4403159", "0.44014007", "0.43986747", "0.43982247", "0.43896246", "0.43779734", "0.4375207", "0.4371772", "0.43627313", "0.43600732", "0.4359666", "0.43569767", "0.43534255", "0.43532553", "0.4344169", "0.43430096", "0.4340777", "0.43320203" ]
0.73844755
0
NOTE: Not implement yet Retrieves a DSP unit's integer parameter by index. To find out the parameter names and range, see the see also field. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func GetRenderbufferParameteri(target, pname Enum) int {\n\tlog.Println(\"GetRenderbufferParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar result int32\n\tgl.GetRenderbufferParameteriv(uint32(target), uint32(pname), &result)\n\treturn int(result)\n}", "func (f *linkFrame) GetParamInt(k string) (i int64, err error) {\n v, ok := f.param[k]\n if ok {\n switch v.(type) {\n case int64:\n i = v.(int64)\n break\n default:\n err = errors.New(\"param value \"+k+\" not int\")\n }\n } else {\n err = errors.New(\"params don't have \"+k)\n }\n return\n}", "func QueryParameterInt(c *gin.Context, name string) int64 {\n\tvalueArray := c.Request.URL.Query()[name]\n\tif valueArray == nil {\n\t\treturn 0\n\t}\n\n\tvalue, err := strconv.ParseInt(valueArray[0], 10, 64)\n\tif err != nil {\n\t\tc.JSON(axdb.RestStatusInvalid, map[string]string{})\n\t\treturn 0\n\t}\n\treturn value\n}", "func (self *PhysicsP2) Mpxi(v int) int{\n return self.Object.Call(\"mpxi\", v).Int()\n}", "func (d *DSP) SetParameterInt(index, value int) error {\n\tres := C.FMOD_DSP_SetParameterInt(d.cptr, C.int(index), C.int(value))\n\treturn errs[res]\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func getParam(memory []int, ip int, rb int, mode ParamMode) int {\n\tswitch mode {\n\tcase POSITION:\n\t\treturn memory[memory[ip]]\n\tcase IMMEDIATE:\n\t\treturn memory[ip]\n\tcase RELATIVE:\n\t\treturn memory[rb+memory[ip]]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unknown parameter mode: %d\", mode))\n\t}\n\treturn 0\n}", "func (self *PhysicsP2) Pxmi(v int) int{\n return self.Object.Call(\"pxmi\", v).Int()\n}", "func (p *Program) getParameter(param uint32) int {\n\tvar v int32\n\tgl.GetProgramiv(uint32(p.glHandle), param, &v)\n\treturn int(v)\n}", "func (v *Posit16x2) Get(i int) Posit16 { return v.impl[i] }", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (this *parameter) Int() int {\n\tif this.Values == nil {\n\t\treturn 0\n\t} else {\n\t\treturn reflekt.AsInt(this.Values[0])\n\t}\n}", "func (self *PhysicsP2) PxmiI(args ...interface{}) int{\n return self.Object.Call(\"pxmi\", args).Int()\n}", "func GetBufferParameteri(target, pname Enum) int {\n\tvar params int32\n\tgl.GetBufferParameteriv(uint32(target), uint32(pname), &params)\n\treturn int(params)\n}", "func (f FramesInt) Get(channels, n int) int {\n\tpanic(\"not implemented\")\n}", "func (ps *PrimeStore) GetByIndex(nth uint64) (n uint64) {\n\tdefer Tracer(NewTrace(\"GetByIndex\"))\n\n\tn = 0\n\tif nth < ps.base || nth >= (ps.base+ps.count) {\n\t\tlog.Print(\"out of range.\", nth, \" \", ps)\n\t\treturn\n\t}\n\n\tn = ps.index[nth-ps.base]\n\treturn\n}", "func (options *Options) Param(pos int) interface{} {\n\tif len(options.params) > pos {\n\t\treturn options.params[pos]\n\t}\n\n\treturn nil\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (self *PhysicsP2) MpxiI(args ...interface{}) int{\n return self.Object.Call(\"mpxi\", args).Int()\n}", "func (x IntSlice) Get(i int) interface{} {return x[i]}", "func (s Stereotype) IntP() *uint {\n\tmyInt := uint(s)\n\treturn &myInt\n}", "func (self *SinglePad) Index() int{\n return self.Object.Get(\"index\").Int()\n}", "func ProgramParameteri(program uint32, pname uint32, value int32) {\n\tsyscall.Syscall(gpProgramParameteri, 3, uintptr(program), uintptr(pname), uintptr(value))\n}", "func (p Configuration) GetInt(name string) (value int, err error) {\n\tvar v float64\n\tv, err = p.GetFloat64(name)\n\tif err != nil {\n\t\treturn value, err\n\t}\n\tvalue = int(v)\n\treturn value, nil\n}", "func ParameterValue(opcodes map[int64]int64, ptr int64, parameter int64, relativeBase int64) int64 {\n\tj := int64(10)\n\tfor i := int64(0); i < parameter; i++ {\n\t\tj *= 10\n\t}\n\tparameterMode := (opcodes[ptr] / j) % 10\n\n\tswitch parameterMode {\n\tcase 0:\n\t\t// Position mode (return value at the position of parameter)\n\t\t// return GetMemory(opcodes, GetMemory(opcodes, ptr+parameter))\n\t\treturn opcodes[opcodes[ptr+parameter]]\n\tcase 1:\n\t\t// Immediate mode (return value of parameter)\n\t\t// return GetMemory(opcodes, ptr+parameter)\n\t\treturn opcodes[ptr+parameter]\n\tcase 2:\n\t\t// Relative mode\n\t\t// return GetMemory(opcodes, GetMemory(opcodes, ptr+parameter)+relativeBase)\n\t\treturn opcodes[opcodes[ptr+parameter]+relativeBase]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unexpected parameter mode %d for opcode %d at position %d\", parameterMode, opcodes[ptr], ptr))\n\t}\n}", "func GetI(name string, defvals ...int) int {\n\tif global == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn 0\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\treturn global.GetI(name, defvals...)\n}", "func (ctx *Context) ParamByIndex(index int) string {\n\treturn ctx.PathParams.ByIndex(index)\n}", "func (this *Section) GetInt(key string, args ... int) (int, error) {\n\tvalue, ok := this.Params[key]\n\tif ok {\n\t\tretVal, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\treturn retVal, nil\n\t}\n\tif len(args) > 0 {\n\t\treturn args[0], nil\n\t}\n\treturn 0, fmt.Errorf(\"The param named %s does not exist.\", key)\n}", "func (ly *CINLayer) UnitVarIdx(varNm string) (int, error) {\n\tvidx, err := ly.Layer.UnitVarIdx(varNm)\n\tif err == nil {\n\t\treturn vidx, err\n\t}\n\tif varNm != \"ACh\" {\n\t\treturn -1, fmt.Errorf(\"pcore.CINLayer: variable named: %s not found\", varNm)\n\t}\n\tnn := ly.Layer.UnitVarNum()\n\treturn nn, nil\n}", "func (af *filtBase) checkIntParam(p, low, high int, name string) (int, error) {\n\tif low <= p && p <= high {\n\t\treturn p, nil\n\t} else {\n\t\terr := fmt.Errorf(\"parameter %v is not in range <%v, %v>\", name, low, high)\n\t\treturn 0, err\n\t}\n}", "func ProgramParameteri(program uint32, pname uint32, value int32) {\n\tC.glowProgramParameteri(gpProgramParameteri, (C.GLuint)(program), (C.GLenum)(pname), (C.GLint)(value))\n}", "func ProgramParameteri(program uint32, pname uint32, value int32) {\n\tC.glowProgramParameteri(gpProgramParameteri, (C.GLuint)(program), (C.GLenum)(pname), (C.GLint)(value))\n}", "func (self *PhysicsP2) MpxI(args ...interface{}) int{\n return self.Object.Call(\"mpx\", args).Int()\n}", "func (ly *Layer) UnitVarIdx(varNm string) (int, error) {\n\tvidx, err := ly.AlphaMaxLayer.UnitVarIdx(varNm)\n\tif err == nil {\n\t\treturn vidx, err\n\t}\n\tif varNm != \"DA\" {\n\t\treturn -1, fmt.Errorf(\"pcore.Layer: variable named: %s not found\", varNm)\n\t}\n\tnn := ly.AlphaMaxLayer.UnitVarNum()\n\treturn nn, nil\n}", "func (c *Context) ParamInt(name string) int {\n\ti, _ := strconv.Atoi(c.Param(name))\n\treturn i\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (debugging *debuggingOpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tdebugging.recordEntry(\"TexParameteri\", target, pname, param)\n\tdebugging.gl.TexParameteri(target, pname, param)\n\tdebugging.recordExit(\"TexParameteri\")\n}", "func getParamInt(c *gin.Context, paramName string) (int64, error) {\n\tp := c.Param(paramName)\n\n\tv, err := strconv.ParseInt(p, 10, 0)\n\tif err != nil {\n\t\treturn 0, ErrNotFound\n\t}\n\n\treturn v, nil\n}", "func (native *OpenGL) GetProgramParameter(program uint32, param uint32) int32 {\n\tresult := int32(0)\n\tgl.GetProgramiv(program, param, &result)\n\treturn result\n}", "func (p Params) GetInt(key string) int {\n\t// TODO: all numbers.\n\tv, _ := p[key].(float64)\n\treturn int(v)\n}", "func (p Properties) GetInt(name string) int {\n\tfor _, property := range p {\n\t\tif property.Name == name && property.Type == \"int\" {\n\t\t\tv, err := strconv.Atoi(property.Value)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn v\n\t\t}\n\t}\n\treturn 0\n}", "func (l *Libvirt) DomainGetInterfaceParameters(Dom Domain, Device string, Nparams int32, Flags DomainModificationImpact) (rParams []TypedParam, rNparams int32, err error) {\n\tvar buf []byte\n\n\targs := DomainGetInterfaceParametersArgs {\n\t\tDom: Dom,\n\t\tDevice: Device,\n\t\tNparams: Nparams,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(257, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Params: []TypedParam\n\t_, err = dec.Decode(&rParams)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Nparams: int32\n\t_, err = dec.Decode(&rNparams)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (c Config) GetParameter(name string) (Parameter, bool) {\n\tfor i, v := range c.Parameters {\n\t\tif v.Name == name {\n\t\t\treturn c.Parameters[i], true\n\t\t}\n\t}\n\treturn Parameter{}, false\n}", "func (self *PhysicsP2) PxmI(args ...interface{}) int{\n return self.Object.Call(\"pxm\", args).Int()\n}", "func (self *PhysicsP2) Pxm(v int) int{\n return self.Object.Call(\"pxm\", v).Int()\n}", "func (p *program) getAddrIndex(n int) int {\n\tparameter := p.mem[p.pc+n]\n\tmode := p.instructionMode(n)\n\n\tif mode == 0 {\n\t\treturn parameter\n\t} else if mode == 2 {\n\t\treturn p.base + parameter\n\t} else {\n\t\tpanic(\"unsupported immediate mode for writing\")\n\t}\n}", "func (obj *GenericMeasure) GetInfo(ctx context.Context) (*NxInfo, error) {\n\tresult := &struct {\n\t\tInfo *NxInfo `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (config *Config) GetInt(key string) int {\n\treturn int(config.getRawParam(key).(float64))\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func GetInteger(pname Enum) int {\n\tvar data int32\n\tgl.GetIntegerv(uint32(pname), &data)\n\treturn int(data)\n}", "func (args Arguments) Int(index int) int {\n\tvar s int\n\tvar ok bool\n\tif s, ok = args.Get(index).(int); !ok {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Int(%d) failed because object wasn't correct type: %v\", index, args.Get(index)))\n\t}\n\treturn s\n}", "func (l *Libvirt) DomainGetNumaParameters(Dom Domain, Nparams int32, Flags uint32) (rParams []TypedParam, rNparams int32, err error) {\n\tvar buf []byte\n\n\targs := DomainGetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tNparams: Nparams,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(255, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Params: []TypedParam\n\t_, err = dec.Decode(&rParams)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Nparams: int32\n\t_, err = dec.Decode(&rNparams)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (native *OpenGL) TexParameteri(target uint32, pname uint32, param int32) {\n\tgl.TexParameteri(target, pname, param)\n}", "func (node *Configuration) GetInt(parameter uint8) (uint32, error) {\n\tvar value []uint8\n\tvar err error\n\n\tif value, err = node.getValue(parameter, 4); err != nil {\n\t\treturn 0, err\n\t}\n\treturn binary.BigEndian.Uint32(value), nil\n}", "func (self *AdminBaseController) GetUint(key string, def ...uint) (uint, error) {\n\tstrv := self.Ctx.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\tval, err := strconv.ParseInt(strv, 10, 64)\n\treturn uint(val), err\n}", "func (pr *prepareResult) parameterField(idx int) *p.ParameterField {\n\treturn pr.parameterFields[idx]\n}", "func TexParameteri(target, pname Enum, param int) {\n\tgl.TexParameteri(uint32(target), uint32(pname), int32(param))\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func (d *DSP) NumParameters() (int, error) {\n\tvar numparams C.int\n\tres := C.FMOD_DSP_GetNumParameters(d.cptr, &numparams)\n\treturn int(numparams), errs[res]\n}", "func (modes Modes) Param(position int) Mode {\n\tdigit := digitAt(int(modes), position)\n\treturn Mode(digit)\n}", "func IntP(short rune, long string, value int, description string) *int {\n\tvar v int\n\tIntVarP(&v, short, long, value, description)\n\treturn &v\n}", "func (self *Graphics) GetChildIndexI(args ...interface{}) int{\n return self.Object.Call(\"getChildIndex\", args).Int()\n}", "func (a QueryArg) GetPort(port int) uint16 {\n\tif a.ImpliedPort {\n\t\treturn uint16(port)\n\t}\n\treturn a.Port\n}", "func (c *Command) GetInt(name string) (int, error) {\n\tvalue := c.Flagset.Lookup(name).Value.String()\n\tif value == \"\" {\n\t\treturn 0, ErrParameterNotFound\n\t}\n\treturn strconv.Atoi(value)\n}", "func (p *GetField) Index() int { return p.fieldIndex }", "func (c *Configuration) GetInt(name string) (int, error) {\n\tv, ok := c.data[name].(float64)\n\tif !ok {\n\t\treturn 0, errors.New(fmt.Sprintf(\"no existe el campo %s o no se puede convertir en int\", name))\n\t}\n\n\treturn int(v), nil\n}", "func (r *vpr) GetInt(s string) int {\n\tret, _ := r.Get(s).(int)\n\n\treturn ret\n}", "func (sh *StatsHandler) readInt(intString string, min, max, defaultValue int) (int, error) {\n\tif intString == \"\" {\n\t\treturn defaultValue, nil\n\t}\n\tvalue, err := strconv.Atoi(intString)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif value < min || value > max {\n\t\treturn 0, gimlet.ErrorResponse{\n\t\t\tMessage: fmt.Sprintf(\"integer value %d must be between %d and %d\", value, min, max),\n\t\t\tStatusCode: http.StatusBadRequest,\n\t\t}\n\t}\n\treturn value, nil\n}", "func (v variable) At(index int) interface{} {\n\tm, ok := v.store.Get(v.Name)\n\tif !ok {\n\t\treturn nil\n\t}\n\tif intArray, ok := m.([]interface{}); ok {\n\t\tif index < 1 || index > len(intArray) {\n\t\t\treturn nil\n\t\t}\n\t\treturn intArray[index-1]\n\t}\n\tif indexable, ok := m.(core.Indexable); ok {\n\t\treturn indexable.At(index)\n\t}\n\tif sequenceable, ok := m.(core.Sequenceable); ok {\n\t\treturn core.BuildSequence(sequenceable.S().At(index))\n\t}\n\treturn nil\n}", "func (e TPMFmt1Error) Parameter() (bool, int) {\n\tif e.subject != parameterRelated {\n\t\treturn false, 0\n\t}\n\treturn true, e.index\n}", "func (t *itlTrack) GetInt(name string) int {\n\tswitch name {\n\tcase \"ID\": // NB: This should really be read as a string\n\t\treturn t.TrackID\n\tcase \"DiscNumber\":\n\t\treturn t.DiscNumber\n\tcase \"DiscCount\":\n\t\treturn t.DiscCount\n\tcase \"TrackNumber\":\n\t\treturn t.TrackNumber\n\tcase \"TrackCount\":\n\t\treturn t.TrackCount\n\tcase \"Year\":\n\t\treturn t.Year\n\tcase \"TotalTime\":\n\t\treturn t.TotalTime\n\tcase \"BitRate\":\n\t\treturn t.BitRate\n\t}\n\n\ttt := reflect.TypeOf(t)\n\tft, ok := tt.FieldByName(name)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"invalid field '%v'\", name))\n\t}\n\tif ft.Type.Kind() != reflect.Int {\n\t\tpanic(fmt.Sprintf(\"field '%v' is not an int\", name))\n\t}\n\n\tv := reflect.ValueOf(t)\n\tf := v.FieldByName(name)\n\treturn int(f.Int())\n}", "func (ly *MatrixLayer) UnitVarIdx(varNm string) (int, error) {\n\tvidx, err := ly.Layer.UnitVarIdx(varNm)\n\tif err == nil {\n\t\treturn vidx, err\n\t}\n\tif !(varNm == \"DALrn\" || varNm == \"ACh\") {\n\t\treturn -1, fmt.Errorf(\"pcore.NeuronVars: variable named: %s not found\", varNm)\n\t}\n\tnn := len(leabra.NeuronVars)\n\t// nn = DA\n\tif varNm == \"DALrn\" {\n\t\treturn nn + 1, nil\n\t}\n\treturn nn + 2, nil\n}", "func (p IntArray) Index(n int) int {\n\tfor i, v := range p {\n\t\tif v == n {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "func GetLimitFromParameter(param interface{}, min, def uint64) (uint64, error) {\n\tlimit := def\n\n\tswitch v := param.(type) {\n\tcase string:\n\t\tvar err error\n\t\tif limit, err = strconv.ParseUint(v, 0, 64); err != nil {\n\t\t\treturn limit, fmt.Errorf(\"parameter must be an integer, '%v' invalid\", param)\n\t\t}\n\tcase uint64:\n\t\tlimit = v\n\tcase int, int32, int64:\n\t\tval := reflect.ValueOf(v).Convert(reflect.TypeOf(param)).Int()\n\t\t// if param is negative casting to uint64 will wrap around and\n\t\t// give you the hugest thread limit ever. Let's be sensible, here\n\t\tif val > 0 {\n\t\t\tlimit = uint64(val)\n\t\t} else {\n\t\t\tlimit = min\n\t\t}\n\tcase uint, uint32:\n\t\tlimit = reflect.ValueOf(v).Convert(reflect.TypeOf(param)).Uint()\n\tcase nil:\n\t\t// use the default\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"invalid value '%#v'\", param)\n\t}\n\n\tif limit < min {\n\t\treturn min, nil\n\t}\n\n\treturn limit, nil\n}", "func (c *Context) ParamUint(name string) uint {\n\ti, _ := strconv.ParseUint(c.Param(name), 10, 0)\n\treturn uint(i)\n}", "func FramebufferParameteri(target uint32, pname uint32, param int32) {\n C.glowFramebufferParameteri(gpFramebufferParameteri, (C.GLenum)(target), (C.GLenum)(pname), (C.GLint)(param))\n}", "func (gl *WebGL) TexParameteri(target GLEnum, param GLEnum, value int) {\n\tgl.context.Call(\"texParameteri\", target, param, value)\n}", "func (ly *ModLayer) UnitValByIdx(vidx NeuronVars, idx int) float32 {\n\tswitch vidx {\n\tcase DA:\n\t\treturn ly.DA\n\tcase DALrn:\n\t\treturn ly.DA\n\tcase ACh:\n\t\treturn ly.ACh\n\tcase SE:\n\t\treturn ly.SE\n\t}\n\treturn 0\n}", "func (debugging *debuggingOpenGL) GetProgramParameter(program uint32, param uint32) int32 {\n\tdebugging.recordEntry(\"GetProgramParameter\", program, param)\n\tresult := debugging.gl.GetProgramParameter(program, param)\n\tdebugging.recordExit(\"GetProgramParameter\", result)\n\treturn result\n}", "func (s System) Dimension(i int) float64 {\n\tswitch i {\n\tcase 0:\n\t\treturn float64(s.Coords.X)\n\tcase 1:\n\t\treturn float64(s.Coords.Y)\n\tdefault:\n\t\treturn float64(s.Coords.Z)\n\t}\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (o *VisualScriptPropertySet) GetIndex() gdnative.String {\n\t//log.Println(\"Calling VisualScriptPropertySet.GetIndex()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"VisualScriptPropertySet\", \"get_index\")\n\n\t// Call the parent method.\n\t// String\n\tretPtr := gdnative.NewEmptyString()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewStringFromPointer(retPtr)\n\treturn ret\n}", "func (c *Cmd) Int(p IntParam) *int {\n\tinto := new(int)\n\tvalue := values.NewInt(into, p.value())\n\n\tswitch x := p.(type) {\n\tcase IntOpt:\n\t\tc.mkOpt(container.Container{Name: x.Name, Desc: x.Desc, EnvVar: x.EnvVar, HideValue: x.HideValue, Value: value, ValueSetByUser: x.SetByUser})\n\tcase IntArg:\n\t\tc.mkArg(container.Container{Name: x.Name, Desc: x.Desc, EnvVar: x.EnvVar, HideValue: x.HideValue, Value: value, ValueSetByUser: x.SetByUser})\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unhandled param %v\", p))\n\t}\n\n\treturn into\n}", "func (ly *CINLayer) UnitVarNum() int {\n\treturn ly.Layer.UnitVarNum() + 1\n}", "func (self *PhysicsP2) Mpx(v int) int{\n return self.Object.Call(\"mpx\", v).Int()\n}", "func (c *Controller) GetInt(key string, def ...int) (int, error) {\n\tstrv := c.Ctx.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\treturn strconv.Atoi(strv)\n}", "func (item Item) GetInt(name string) int64 {\n\ti, _ := strconv.ParseInt(fmt.Sprintf(\"%v\", item[name]), 10, 64)\n\treturn i\n}", "func VPI(index int32) Device {\n return Device{KDLVPI, index}\n}", "func (c *Config) GetI(name string, defvals ...int) int {\n\tif len(defvals) != 0 {\n\t\treturn int(c.GetI64(name, int64(defvals[0])))\n\t}\n\n\treturn int(c.GetI64(name))\n}", "func GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {\n\tlog.Println(\"GetFramebufferAttachmentParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar param int32\n\tgl.GetFramebufferAttachmentParameteriv(uint32(target), uint32(attachment), uint32(pname), &param)\n\treturn int(param)\n}", "func (m NumSeriesDistribution) Get(index int) *NumSeries {\n\tif index > -1 {\n\t\tif s, ok := m[index]; ok {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn nil\n}", "func GetInt(section, option string) int {\n\treturn cfg.GetInt(section, option)\n}", "func (v Posit16x2) Int() []int16 {\n\tout := make([]int16, 2)\n\tfor i, posit := range v.impl {\n\t\tout[i] = posit.Int()\n\t}\n\treturn out\n}", "func GetParam(d []*commands.Data, name string) *commands.Data {\n\tfor _, element := range d {\n\t\tif strings.Compare(element.Name, name) == 0 {\n\t\t\treturn element\n\t\t}\n\t}\n\treturn nil\n}", "func getParameterDefault(c *gin.Context, name string, defaultValue int) int {\n\tval, err := strconv.Atoi(c.Request.URL.Query().Get(name))\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn defaultValue\n\t}\n\treturn val\n}", "func (node *Configuration) GetShort(parameter uint8) (uint16, error) {\n\tvar value []uint8\n\tvar err error\n\n\tif value, err = node.getValue(parameter, 2); err != nil {\n\t\treturn 0, err\n\t}\n\treturn binary.BigEndian.Uint16(value), nil\n}", "func (f *Flags) Int(spec string, p *int, name, usage string) {\n\tf.addOption(spec, name, usage, func(name, value string) error {\n\t\ti, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid %s argument '%s'\", name, value)\n\t\t}\n\t\t*p = i\n\t\treturn nil\n\t})\n}" ]
[ "0.6683479", "0.60687375", "0.5905783", "0.57343125", "0.56214726", "0.5300076", "0.52585703", "0.52482766", "0.5227167", "0.52154946", "0.51989967", "0.5133527", "0.51179343", "0.5113958", "0.50895095", "0.5055208", "0.502526", "0.50174165", "0.4969394", "0.49634928", "0.49543986", "0.4942501", "0.49259833", "0.49083996", "0.48723024", "0.48414585", "0.48342592", "0.4795369", "0.47866574", "0.47773126", "0.47675708", "0.47533727", "0.4749446", "0.47334394", "0.47334394", "0.47276887", "0.4720015", "0.46962106", "0.46798033", "0.46738353", "0.46670553", "0.46568653", "0.46490738", "0.46449697", "0.46444297", "0.4642985", "0.4642772", "0.46351606", "0.46343532", "0.46341503", "0.4633987", "0.46301937", "0.462875", "0.461995", "0.46072355", "0.46014458", "0.46008077", "0.45929965", "0.459141", "0.45876247", "0.45741278", "0.4564199", "0.45621002", "0.4558117", "0.45567062", "0.45518285", "0.45373258", "0.4536731", "0.45316085", "0.45270482", "0.4526825", "0.45212275", "0.45176744", "0.4514141", "0.45085156", "0.45079112", "0.449792", "0.44913828", "0.4486057", "0.44843993", "0.44842884", "0.44808936", "0.4479199", "0.447269", "0.4469576", "0.4468291", "0.4464393", "0.44589698", "0.44576323", "0.44504756", "0.44406703", "0.44395006", "0.44376191", "0.4426208", "0.44224262", "0.44222715", "0.4421841", "0.44180563", "0.4404596", "0.44023225" ]
0.7570433
0
NOTE: Not implement yet Retrieves a DSP unit's boolean parameter by index. To find out the parameter names and range, see the see also field. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) SetParameterBool(index int, value bool) error {\n\tres := C.FMOD_DSP_SetParameterBool(d.cptr, C.int(index), getBool(value))\n\treturn errs[res]\n}", "func (p Parameters) GetBool(key string) (val bool) {\n\tif p != nil {\n\t\tval, _ = p[key].(bool)\n\t}\n\treturn\n}", "func (this *parameter) Bool() bool {\n\tif this.Values == nil {\n\t\treturn false\n\t} else {\n\t\treturn reflekt.AsBool(this.Values[0])\n\t}\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func QueryParamBool(request *http.Request, name string) (bool, IResponse) {\n\tvalueStr := request.URL.Query().Get(name)\n\tvalue, err := strconv.ParseBool(valueStr)\n\tif err != nil {\n\t\treturn false, BadRequest(request, \"Invalid query param %s (value: '%s'): %s\", name, valueStr, err)\n\t}\n\n\treturn value, nil\n}", "func (f *Form) Bool(param string, defaultValue bool) bool {\n\tvals, ok := f.values[param]\n\tif !ok {\n\t\treturn defaultValue\n\t}\n\tparamVal, err := strconv.ParseBool(vals[0])\n\tif err != nil {\n\t\tf.err = err\n\t\treturn defaultValue\n\t}\n\treturn paramVal\n}", "func (args Arguments) Bool(index int) bool {\n\tvar s bool\n\tvar ok bool\n\tif s, ok = args.Get(index).(bool); !ok {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Bool(%d) failed because object wasn't correct type: %v\", index, args.Get(index)))\n\t}\n\treturn s\n}", "func (m *DeviceHealthScriptBooleanParameter) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.DeviceHealthScriptParameter.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteBoolValue(\"defaultValue\", m.GetDefaultValue())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (c *Context) ParamBool(name string) bool {\n\tb, _ := strconv.ParseBool(c.Param(name))\n\treturn b\n}", "func (c Controller) GetBool(key string, def ...bool) bool {\n\tif v := string(c.QueryArgs().Peek(key)); v != \"\" {\n\t\ttmp, _ := strconv.ParseBool(v)\n\t\treturn tmp\n\t}\n\tif len(def) > 0 {\n\t\treturn def[0]\n\t}\n\treturn false\n}", "func (c Config) GetParameter(name string) (Parameter, bool) {\n\tfor i, v := range c.Parameters {\n\t\tif v.Name == name {\n\t\t\treturn c.Parameters[i], true\n\t\t}\n\t}\n\treturn Parameter{}, false\n}", "func GetBool(name string) bool {\n\t//params, err := url.ParseQuery(r.URL.RawQuery)\n\t//if err != nil {\n\t//\treturn false\n\t//}\n\n\t//value, ok := params[name]\n\t//if !ok {\n\t//\treturn false\n\t//}\n\n\tstrValue := strings.Join([]string{\"\", \"\"}, \"\")\n\tif strValue == \"\" {\n\t\treturn true\n\t}\n\n\tboolValue, err := strconv.ParseBool(strValue)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn boolValue\n}", "func (this *Section) GetBool(key string, args ... bool) (bool, error) {\n\tvalue, ok := this.Params[key]\n\tif ok {\n\t\tif strings.EqualFold(\"on\", value) || strings.EqualFold(\"true\", value) {\n\t\t\treturn true, nil\n\t\t}\n\t\treturn false, nil\n\t}\n\tif len(args) > 0 {\n\t\treturn args[0], nil\n\t}\n\treturn false, fmt.Errorf(\"The param named %s does not exist.\", key)\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func Boolean(param interface{}) bool {\n\tvar v bool\n\tif param != nil {\n\t\tv = param.(bool)\n\t}\n\treturn v\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (o FunctionInputResponseOutput) IsConfigurationParameter() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v FunctionInputResponse) *bool { return v.IsConfigurationParameter }).(pulumi.BoolPtrOutput)\n}", "func URLParamBool(request *http.Request, name string) (bool, IResponse) {\n\tvalueStr := chi.URLParam(request, name)\n\tvalue, err := strconv.ParseBool(valueStr)\n\tif err != nil {\n\t\treturn false, BadRequest(request, \"Invalid url param %s (value: '%s'): %s\", name, valueStr, err)\n\t}\n\n\treturn value, nil\n}", "func BoolP(short rune, long string, value bool, description string) *bool {\n\tvar v bool\n\tBoolVarP(&v, short, long, value, description)\n\treturn &v\n}", "func (context *Context) ParamsBool(key string) bool {\n\treturn context.params.ValueBool(key)\n}", "func (s *StressFlag) Bool(name string, def bool, usage string) *bool {\n\tv := def\n\n\tswitch name {\n\tcase \"top\":\n\t\tv = true\n\t}\n\n\treturn &v\n}", "func (ctx *serverRequestContextImpl) GetBoolQueryParm(name string) (bool, error) {\n\tvar err error\n\n\tvalue := false\n\tparam := ctx.req.URL.Query().Get(name)\n\tif param != \"\" {\n\t\tvalue, err = strconv.ParseBool(strings.ToLower(param))\n\t\tif err != nil {\n\t\t\treturn false, caerrors.NewHTTPErr(400, caerrors.ErrUpdateConfigRemoveAff, \"Failed to correctly parse value of '%s' query parameter: %s\", name, err)\n\t\t}\n\t}\n\n\treturn value, nil\n}", "func (result ContractFunctionResult) GetBool(index uint64) bool {\n\treturn result.GetUint32(index) == 1\n}", "func (p Properties) GetBool(name string) bool {\n\tfor _, property := range p {\n\t\tif property.Name == name && property.Type == \"boolean\" {\n\t\t\treturn property.Value == \"true\"\n\t\t}\n\t}\n\treturn p.GetString(name) == \"true\"\n}", "func (c *Controller) GetBool(key string, def ...bool) (bool, error) {\n\tstrv := c.Ctx.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\treturn strconv.ParseBool(strv)\n}", "func QueryBoolParam(r *http.Request, param string, defaultValue bool) bool {\n\tvalue := r.URL.Query().Get(param)\n\tif value == \"\" {\n\t\treturn defaultValue\n\t}\n\n\tval, err := strconv.ParseBool(value)\n\n\tif err != nil {\n\t\treturn defaultValue\n\t}\n\n\treturn val\n}", "func (e TPMFmt1Error) Parameter() (bool, int) {\n\tif e.subject != parameterRelated {\n\t\treturn false, 0\n\t}\n\treturn true, e.index\n}", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (node *Configuration) GetBool(parameter uint8) (bool, error) {\n\tvar value []uint8\n\tvar err error\n\n\tif value, err = node.getValue(parameter, 1); err != nil {\n\t\treturn false, err\n\t}\n\treturn value[0] != 0, nil\n}", "func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {\n\tswitch descriptor.FullName() {\n\tcase \"cosmos.bank.v1beta1.Params.send_enabled\":\n\t\tif len(x.SendEnabled) == 0 {\n\t\t\treturn protoreflect.ValueOfList(&_Params_1_list{})\n\t\t}\n\t\tlistValue := &_Params_1_list{list: &x.SendEnabled}\n\t\treturn protoreflect.ValueOfList(listValue)\n\tcase \"cosmos.bank.v1beta1.Params.default_send_enabled\":\n\t\tvalue := x.DefaultSendEnabled\n\t\treturn protoreflect.ValueOfBool(value)\n\tdefault:\n\t\tif descriptor.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.Params\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.Params does not contain field %s\", descriptor.FullName()))\n\t}\n}", "func (o FunctionInputTypeOutput) IsConfigurationParameter() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v FunctionInputType) *bool { return v.IsConfigurationParameter }).(pulumi.BoolPtrOutput)\n}", "func GetBooleanv(dst []bool, pname Enum) {\n\tgl.GetBooleanv(uint32(pname), &dst[0])\n}", "func NewDeviceHealthScriptBooleanParameter()(*DeviceHealthScriptBooleanParameter) {\n m := &DeviceHealthScriptBooleanParameter{\n DeviceHealthScriptParameter: *NewDeviceHealthScriptParameter(),\n }\n odataTypeValue := \"#microsoft.graph.deviceHealthScriptBooleanParameter\"\n m.SetOdataType(&odataTypeValue)\n return m\n}", "func (o *AddOn) GetParameters() (value *AddOnParameterList, ok bool) {\n\tok = o != nil && o.bitmap_&8192 != 0\n\tif ok {\n\t\tvalue = o.parameters\n\t}\n\treturn\n}", "func GetBooleanv(pname GLenum, params []bool) {\n\tif len(params) == 0 {\n\t\tpanic(\"Invalid params length\")\n\t}\n\tC.glGetBooleanv(C.GLenum(pname), (*C.GLboolean)(unsafe.Pointer(&params[0])))\n}", "func GetBool(fixControlMap map[uint64]string, key uint64) (value bool, exists bool) {\n\tif fixControlMap == nil {\n\t\treturn false, false\n\t}\n\trawValue, ok := fixControlMap[key]\n\tif !ok {\n\t\treturn false, false\n\t}\n\t// The same as TiDBOptOn in sessionctx/variable.\n\tvalue = strings.EqualFold(rawValue, \"ON\") || rawValue == \"1\"\n\treturn value, true\n}", "func GetBoolean(vars map[string]string, key string, def bool) bool {\n\tval, ok := vars[key]\n\tif ok {\n\t\tif b, err := strconv.ParseBool(val); err == nil {\n\t\t\treturn b\n\t\t} else {\n\t\t\tlog.Printf(\"failed to convert config[%v]=%v to boolean: %v\", key, val, err)\n\t\t}\n\t}\n\treturn def\n}", "func ToBool(v interface{}, def bool) bool {\r\n\tif b, ok := v.(bool); ok {\r\n\t\treturn b\r\n\t}\r\n\tif i, ok := v.(int); ok {\r\n\t\treturn i > 0\r\n\t}\r\n\tif i, ok := v.(float64); ok {\r\n\t\treturn i > 0\r\n\t}\r\n\tif i, ok := v.(float32); ok {\r\n\t\treturn i > 0\r\n\t}\r\n\tif ss, ok := v.([]string); ok {\r\n\t\tv = ss[0]\r\n\t}\r\n\tif s, ok := v.(string); ok {\r\n\t\tif s == \"on\" {\r\n\t\t\treturn true\r\n\t\t}\r\n\t\tif s == \"off\" || s == \"\" {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\tif b, err := strconv.ParseBool(s); err == nil {\r\n\t\t\treturn b\r\n\t\t}\r\n\t}\r\n\r\n\treturn def\r\n\r\n}", "func (s *Session) GetBool(key interface{}, def ...bool) bool {\n\tif v := s.Get(key); v != nil {\n\t\treturn v.(bool)\n\t}\n\tif len(def) > 0 {\n\t\treturn def[0]\n\t}\n\treturn false\n}", "func (c *Command) GetBool(key string, def ...bool) (bool, error) {\n\tv := c.Query(key)\n\n\tif v != nil && len(v.CommandValue) > 0 {\n\t\treturn strconv.ParseBool(v.CommandValue)\n\t} else if len(def) > 0 {\n\t\treturn def[0], nil\n\t} else if v.DefaultValue != nil {\n\t\treturn v.DefaultValue.(bool), nil\n\t}\n\n\treturn false, nil\n}", "func (self *Graphics) InCamera() bool{\n return self.Object.Get(\"inCamera\").Bool()\n}", "func (BooleanLiteral) paramValueNode() {}", "func getBoolParamFromURL(r *http.Request, key string) (bool, error) {\n\tval, err := hchi.GetStringFromURL(r, key)\n\tif err != nil {\n\t\treturn false, errors.Wrapf(err, \"loading %s from URL\", key)\n\t}\n\n\tif val == \"true\" {\n\t\treturn true, nil\n\t}\n\tif val == \"false\" || val == \"\" {\n\t\treturn false, nil\n\t}\n\n\treturn false, problem.MakeInvalidFieldProblem(key, errors.New(\"invalid bool value\"))\n}", "func (g *GPIOControllerPCF8574T) Get(index int) bool {\n\n\tif index < 0 || index > pinCount {\n\t\tfmt.Printf(\"Input out of range for gpio: %d\", index)\n\t\treturn false\n\t}\n\n\tg.mutex.Lock()\n\tdefer g.mutex.Unlock()\n\n\tif !g.isInput(index) {\n\t\treturn g.isOn(index)\n\t}\n\n\tlog.Fatal(\"Input not implemented\")\n\n\treturn false\n}", "func BoolIdx(list []bool, indices []int, element bool) (int, bool) {\n\tif len(indices) > 0 {\n\t\tvalueIndex := indices[0]\n\t\tif !list[valueIndex] {\n\t\t\tif !element {\n\t\t\t\treturn 0, true\n\t\t\t}\n\t\t\treturn 1, len(indices) >= 2\n\t\t}\n\t\treturn 0, element\n\t}\n\treturn 0, false\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (a *Argument) Bool() bool {\n\treturn a.state.CheckBool(a.number)\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func ParamSpecBoolean_(name string, nick string, blurb string, defaultValue bool, flags ParamFlags) *ParamSpec {\n\tc_name := C.CString(name)\n\tdefer C.free(unsafe.Pointer(c_name))\n\n\tc_nick := C.CString(nick)\n\tdefer C.free(unsafe.Pointer(c_nick))\n\n\tc_blurb := C.CString(blurb)\n\tdefer C.free(unsafe.Pointer(c_blurb))\n\n\tc_default_value :=\n\t\tboolToGboolean(defaultValue)\n\n\tc_flags := (C.GParamFlags)(flags)\n\n\tretC := C.g_param_spec_boolean(c_name, c_nick, c_blurb, c_default_value, c_flags)\n\tretGo := ParamSpecNewFromC(unsafe.Pointer(retC))\n\n\treturn retGo\n}", "func (self *PhysicsP2) Time() bool{\n return self.Object.Get(\"time\").Bool()\n}", "func Bool(v bool) (p *bool) { return &v }", "func BoolVarP(pv *bool, short rune, long string, value bool, description string) {\n\tif err := parseShortAndLongFlag(short, long); err != nil {\n\t\tpanic(err)\n\t}\n\t*pv = value\n\tflags = append(flags, &optionBool{\n\t\tdescription: description,\n\t\tlong: long,\n\t\tshort: short,\n\t\tpv: pv,\n\t\tdef: value,\n\t})\n}", "func (o *MetricDefaultAggregation) GetParameterOk() (*float64, bool) {\n\tif o == nil || o.Parameter == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Parameter, true\n}", "func FormatBoolean(name string) string {\n\treturn \"strconv.FormatBool(\" + name + \")\"\n}", "func (c *Cmd) Bool(p BoolParam) *bool {\n\tinto := new(bool)\n\tvalue := values.NewBool(into, p.value())\n\n\tswitch x := p.(type) {\n\tcase BoolOpt:\n\t\tc.mkOpt(container.Container{Name: x.Name, Desc: x.Desc, EnvVar: x.EnvVar, HideValue: x.HideValue, Value: value, ValueSetByUser: x.SetByUser})\n\tcase BoolArg:\n\t\tc.mkArg(container.Container{Name: x.Name, Desc: x.Desc, EnvVar: x.EnvVar, HideValue: x.HideValue, Value: value, ValueSetByUser: x.SetByUser})\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unhandled param %v\", p))\n\t}\n\n\treturn into\n}", "func (self *HttpContext) DefineBoolParam(name, invalidErrorCode string, paramType HttpParamType, required bool) {\n\tself.Params[name] = &HttpParam{ Name: name, InvalidErrorCode: invalidErrorCode, DataType: HttpBoolParam, Required: required, Type: paramType, Valid: true }\n}", "func (item Item) GetBool(name string) bool {\n\n\tif item[name] == nil {\n\t\treturn false\n\t}\n\n\tswitch item[name].(type) {\n\tdefault:\n\t\tb := strings.ToLower(fmt.Sprintf(\"%v\", item[name]))\n\t\tif b == \"\" || b == \"0\" || b == \"false\" {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func (m *DeviceHealthScriptBooleanParameter) GetDefaultValue()(*bool) {\n val, err := m.GetBackingStore().Get(\"defaultValue\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (c *Command) GetBool(name string) (bool, error) {\n\tvalue := c.Flagset.Lookup(name).Value.String()\n\tif value == \"\" {\n\t\treturn false, ErrParameterNotFound\n\t}\n\treturn strconv.ParseBool(value)\n}", "func (c *Context) QueryBool(name string) bool {\n\tb, _ := strconv.ParseBool(c.Query(name))\n\treturn b\n}", "func (s *Smpval) Bool() bool {\n\treturn s.b\n}", "func (b *BoolMatrixLinear) GetBool(i, j int) bool {\n\tif i > b.heigh || j > b.width {\n\t\treturn false\n\t}\n\n\treturn b.matrix[i*b.width+j]\n}", "func (td TupleDesc) GetBool(i int, tup Tuple) (v bool, ok bool) {\n\ttd.expectEncoding(i, Int8Enc)\n\tb := td.GetField(i, tup)\n\tif b != nil {\n\t\tv, ok = readBool(b), true\n\t}\n\treturn\n}", "func asSupportedParameter(param string) (string, bool) {\n\tlower := strings.ToLower(param)\n\treturn lower, lowerCaseParameters[lower]\n}", "func (c *Validator) GetBool(key string, def ...bool) (bool, error) {\n\tstrv := c.Input.Query(key)\n\tif len(strv) == 0 && len(def) > 0 {\n\t\treturn def[0], nil\n\t}\n\treturn strconv.ParseBool(strv)\n}", "func (v *Value) BoolAt(i int) (bool, error) {\n\tif v.kind != kindArray {\n\t\treturn false, errors.New(\"JSON value is not an array\")\n\t}\n\tif i >= len(v.arrayContent) {\n\t\treturn false, errors.New(\"Index is out of bounds of array\")\n\t}\n\tvalue, err := v.arrayContent[i].Bool()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn value, nil\n}", "func (d *DataGenerator) getBool() bool {\n\treturn rand.Intn(100) < 50\n}", "func (self *Graphics) FixedToCamera() bool{\n return self.Object.Get(\"fixedToCamera\").Bool()\n}", "func (p Parameter) viewParameter(viewrule bool) {\n\tfmt.Println(\"Parameter-----\")\n\tfmt.Println(\"Delay:\", p.Delay, \"Arity:\", p.Arity)\n\n\tfmt.Print(\"Transcript=\")\n\tfmt.Print(p.Transcript.Arr)\n\tfmt.Println(\"\")\n\n\tif viewrule {\n\t\tfmt.Println(\"Ruleset={\")\n\t\tfor b1 := 1; b1 <= 132; b1++ {\n\t\t\tr2s, ok := p.Rule.rule[strconv.Itoa(b1)]\n\t\t\tif ok {\n\t\t\t\tsort.Strings(r2s)\n\t\t\t\tfor _, r2 := range r2s {\n\t\t\t\t\tb2, ok2 := strconv.Atoi(r2)\n\t\t\t\t\tif ok2 == nil && b1 <= b2 {\n\t\t\t\t\t\tfmt.Println(\"(\" + strconv.Itoa(b1) + \",\" + strconv.Itoa(b2) + \"),\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"}----end\")\n\t\t/*\n\t\t\tfmt.Println(\"Ruleset={\")\n\t\t\tfor b1, v := range p.Rule.rule {\n\t\t\t\tfor _, b2 := range v {\n\t\t\t\t\tfmt.Println(\" -(\", b1, b2, \")\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Println(\"}----end\")\n\t\t*/\n\t}\n}", "func (m *BoolMatrix) Get(x, y int64) bool {\n\treturn m.bs.Get(m.index(x, y))\n}", "func (c *Configuration) GetBool(name string) (bool, error) {\n\tv, ok := c.data[name].(bool)\n\tif !ok {\n\t\treturn false, errors.New(fmt.Sprintf(\"no existe el campo %s o no se puede convertir en bool\", name))\n\t}\n\n\treturn v, nil\n}", "func (a *Args) Boolean(arg rune) bool {\n\tvar val bool\n\tif argumentMarshaler, ok := a.marhalers[arg]; ok {\n\t\tval = argumentMarshaler.get().(bool)\n\t}\n\treturn val\n}", "func (pb *Bar) GetBool(key interface{}) bool {\n\tif v, ok := pb.Get(key).(bool); ok {\n\t\treturn v\n\t}\n\treturn false\n}", "func (nvp *NameValues) Bool(name string) (bool, bool) {\n\tvalue, _ := nvp.String(name)\n\treturn (value == \"true\" || value == \"yes\" || value == \"1\" || value == \"-1\" || value == \"on\"), true\n}", "func (node *Configuration) GetShort(parameter uint8) (uint16, error) {\n\tvar value []uint8\n\tvar err error\n\n\tif value, err = node.getValue(parameter, 2); err != nil {\n\t\treturn 0, err\n\t}\n\treturn binary.BigEndian.Uint16(value), nil\n}", "func BoolIdxDesc(list []bool, indices []int, element bool) (int, bool) {\n\tif len(indices) > 0 {\n\t\tvalueIndex := indices[0]\n\t\tif list[valueIndex] {\n\t\t\tif element {\n\t\t\t\treturn 0, true\n\t\t\t}\n\t\t\treturn 1, len(indices) >= 2\n\t\t}\n\t\treturn 0, !element\n\t}\n\treturn 0, false\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 (device *IndustrialDigitalIn4V2Bricklet) GetValue() (value [4]bool, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetValue), buf.Bytes())\n\tif err != nil {\n\t\treturn value, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 9 {\n\t\t\treturn value, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 9)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn value, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tcopy(value[:], ByteSliceToBoolSlice(resultBuf.Next(1)))\n\n\t}\n\n\treturn value, nil\n}", "func (f *Flagger) Bool(name, shorthand string, value bool, usage string) {\n\tf.cmd.Flags().BoolP(name, shorthand, value, usage)\n\tf.cfg.BindPFlag(name, f.cmd.Flags().Lookup(name))\n}", "func (self *PhysicsP2) SleepMode() int{\n return self.Object.Get(\"sleepMode\").Int()\n}", "func (s *Smplen) Bool() bool {\n\treturn s.b\n}", "func (c *Command) AddBoolParameter(parameter *Parameter, value *bool, defaultValue bool) *Parameter {\n\tc.addParameter(parameter)\n\tfor _, alias := range parameter.Aliases() {\n\t\tc.Flagset.BoolVar(value, alias, defaultValue, parameter.Use)\n\t}\n\n\treturn parameter\n}", "func Bool(name string, value bool, usage string) *bool {\n\tp := new(bool);\n\tBoolVar(p, name, value, usage);\n\treturn p;\n}", "func Bool(bp *bool) bool {\n\tif bp == nil {\n\t\treturn false\n\t}\n\treturn *bp\n}", "func (r Record) Bool(key string) bool {\n\tif r.dropped {\n\t\tlog.Fatalf(\"Int called on dropped record\")\n\t}\n\n\tval, ok := r.values[key]\n\tif !ok {\n\t\treturn false\n\t}\n\n\tswitch val := val.(type) {\n\tcase nil:\n\t\treturn false\n\tcase string:\n\t\treturn val == \"true\"\n\tcase int64:\n\t\treturn val != 0\n\tcase float64:\n\t\treturn val != 0.0\n\tcase bool:\n\t\treturn val\n\t}\n\n\treturn false\n}", "func (self *PhysicsP2) ApplyDamping() bool{\n return self.Object.Get(\"applyDamping\").Bool()\n}", "func (v Boolean) Bool() bool {\n\treturn v.v\n}", "func Bool(name string, defs ...bool) bool {\n\tvar def bool\n\tfor _, d := range defs {\n\t\tdef = d\n\t\tbreak\n\t}\n\tswitch v := strings.ToLower(Raw(name)); {\n\tcase v == \"true\":\n\t\treturn true\n\tcase v == \"false\":\n\t\treturn false\n\tdefault:\n\t\treturn def\n\t}\n}", "func (req *ServerHTTPRequest) GetQueryBool(key string) (bool, bool) {\n\tsuccess := req.parseQueryValues()\n\tif !success {\n\t\treturn false, false\n\t}\n\n\tvalue := req.queryValues.Get(key)\n\tif value == \"true\" {\n\t\treturn true, true\n\t} else if value == \"false\" {\n\t\treturn false, true\n\t}\n\n\terr := &strconv.NumError{\n\t\tFunc: \"ParseBool\",\n\t\tNum: value,\n\t\tErr: strconv.ErrSyntax,\n\t}\n\n\treq.LogAndSendQueryError(err, \"bool\", key, value)\n\treturn false, false\n}", "func GetB(name string, defvals ...bool) bool {\n\tif global == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn false\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\treturn global.GetB(name, defvals...)\n}", "func (c *Config) GetB(name string, defvals ...bool) bool {\n\tif c == nil || c.mx == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn false\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\tc.mx.RLock()\n\tval := c.data[strings.ToLower(name)]\n\tc.mx.RUnlock()\n\n\tif val == \"\" {\n\t\tif len(defvals) == 0 {\n\t\t\treturn false\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\tswitch val {\n\tcase \"\", \"0\", \"false\", \"no\":\n\t\treturn false\n\tdefault:\n\t\treturn true\n\t}\n}", "func (v *VarSet) Bool(name string) (bool, error) {\n\tval, ok := v.load(name)\n\tif !ok {\n\t\treturn false, nil\n\t}\n\trv, err := strconv.ParseBool(val)\n\tif err != nil {\n\t\treturn false, &varNotParsableError{name: name}\n\t}\n\treturn rv, nil\n}", "func getBoolValue(val *bool) bool {\n\tif val == nil {\n\t\treturn false\n\t}\n\n\treturn *val\n}", "func (m *Value) Bool() bool { return m.BoolMock() }", "func (o *AddOn) Parameters() *AddOnParameterList {\n\tif o != nil && o.bitmap_&8192 != 0 {\n\t\treturn o.parameters\n\t}\n\treturn nil\n}", "func (self *PhysicsP2) ApplyGravity() bool{\n return self.Object.Get(\"applyGravity\").Bool()\n}", "func GetBoolean(data []byte, keys ...string) (val bool, offset int, err error) {\n\tv, t, offset, e := Get(data, keys...)\n\n\tif e != nil {\n\t\treturn false, offset, e\n\t}\n\n\tif t != Boolean {\n\t\treturn false, offset, fmt.Errorf(\"Value is not a boolean: %s\", string(v))\n\t}\n\n\tif v[0] == 't' {\n\t\tval = true\n\t} else {\n\t\tval = false\n\t}\n\n\treturn\n}", "func (kv KeyValueStore) GetBoolDef(key string) bool {\n\tval, _ := kv.Get(key)\n\treturn stringToBool(val)\n}", "func Bool(name string, value string, usage string, aliases ...string) *Value {\n\treturn newBool(flag.Var, name, value, usage, aliases...)\n}", "func (self *Graphics) Debug() bool{\n return self.Object.Get(\"debug\").Bool()\n}" ]
[ "0.59388584", "0.59239125", "0.5891305", "0.56941694", "0.53808606", "0.53508043", "0.53500885", "0.53307074", "0.5278743", "0.5264969", "0.52161", "0.5175539", "0.5129567", "0.5119758", "0.51162565", "0.5091159", "0.5084478", "0.50487745", "0.50438625", "0.50364995", "0.5017633", "0.5011838", "0.50116414", "0.50088453", "0.49645975", "0.49597278", "0.49409476", "0.49217096", "0.4899577", "0.4885604", "0.48787498", "0.48718736", "0.48609358", "0.48600894", "0.4853499", "0.484377", "0.48362294", "0.48288217", "0.4811667", "0.48000902", "0.47805128", "0.47770688", "0.4760806", "0.47536734", "0.47465166", "0.47412163", "0.47328645", "0.47325096", "0.47273296", "0.47207895", "0.47144672", "0.4705865", "0.4696051", "0.46942636", "0.4681872", "0.46805763", "0.46740714", "0.46724802", "0.4672045", "0.46694762", "0.46643987", "0.46641618", "0.46633005", "0.46603972", "0.46601674", "0.46551734", "0.46492144", "0.46467918", "0.46457052", "0.464386", "0.46306446", "0.4627773", "0.4625905", "0.46232784", "0.46178472", "0.46125743", "0.46052143", "0.45944196", "0.45940223", "0.45936275", "0.45915377", "0.4591171", "0.4575148", "0.4573691", "0.45733088", "0.4571049", "0.45679423", "0.4559359", "0.45561105", "0.4555144", "0.4552819", "0.454624", "0.45448363", "0.45356718", "0.4533292", "0.4532516", "0.45319486", "0.45270383", "0.4525266", "0.45250925" ]
0.77068895
0
NOTE: Not implement yet Retrieves a DSP unit's data block parameter by index. To find out the parameter names and range, see the see also field. The parameter properties (such as min/max values) can be retrieved with "DSP.ParameterInfo".
func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func GetParam(d []*commands.Data, name string) *commands.Data {\n\tfor _, element := range d {\n\t\tif strings.Compare(element.Name, name) == 0 {\n\t\t\treturn element\n\t\t}\n\t}\n\treturn nil\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tsyscall.Syscall(gpGetMultisamplefv, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(val)))\n}", "func (c *common) Parameters() sbcon.Parameters { return c.params }", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (p *Program) getParameter(param uint32) int {\n\tvar v int32\n\tgl.GetProgramiv(uint32(p.glHandle), param, &v)\n\treturn int(v)\n}", "func (r *BlockSeqFunc) Parameters() []*autofunc.Variable {\n\tif l, ok := r.Block.(sgd.Learner); ok {\n\t\treturn l.Parameters()\n\t} else {\n\t\treturn nil\n\t}\n}", "func (options *Options) Param(pos int) interface{} {\n\tif len(options.params) > pos {\n\t\treturn options.params[pos]\n\t}\n\n\treturn nil\n}", "func (l *Libvirt) DomainGetBlkioParameters(Dom Domain, Nparams int32, Flags uint32) (rParams []TypedParam, rNparams int32, err error) {\n\tvar buf []byte\n\n\targs := DomainGetBlkioParametersArgs {\n\t\tDom: Dom,\n\t\tNparams: Nparams,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(206, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Params: []TypedParam\n\t_, err = dec.Decode(&rParams)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Nparams: int32\n\t_, err = dec.Decode(&rNparams)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (c Config) GetParameter(name string) (Parameter, bool) {\n\tfor i, v := range c.Parameters {\n\t\tif v.Name == name {\n\t\t\treturn c.Parameters[i], true\n\t\t}\n\t}\n\treturn Parameter{}, false\n}", "func ParameterFor(source Source, name string, description string) Parameter {\n\treturn Parameter{\n\t\tSource: source,\n\t\tName: name,\n\t\tDescription: description,\n\t}\n}", "func (l *Layer) Parameters() []*autofunc.Variable {\n\treturn []*autofunc.Variable{l.Biases, l.Scales}\n}", "func (af *filtBase) GetParams() (int, float64, []float64) {\n\treturn af.n, af.mu, af.w.RawRowView(0)\n}", "func (tr *CapacityProvider) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (parser *Parser) parameter() (*Declaration, error) {\n\tparser.trace(\"PARAMETER\")\n\tdefer parser.untrace()\n\tdataTypeTok, err, found := parser.match(fxsymbols.DataType)\n\tif err != nil {\n\t\t// return ErrSyntax\n\t\treturn nil, err\n\t}\n\tif !found {\n\t\treturn nil, ErrNoMatch\n\t}\n\tdataIdTok, _, found := parser.match(fxsymbols.Id)\n\tif !found {\n\t\treturn nil, parser.Errorf(ErrNoId)\n\t}\n\tif parser.symbEnvs.GetSymb(dataIdTok.Lex) != nil {\n\t\treturn nil, fxsymbols.ErrVarExists\n\t}\n\tparser.symbEnvs.PutVar(dataIdTok)\n\treturn NewDeclaration(dataIdTok.Lex, fxlex.DataTypeConst(dataTypeTok.Val)), nil\n}", "func (pr *prepareResult) parameterField(idx int) *p.ParameterField {\n\treturn pr.parameterFields[idx]\n}", "func (visual *Visual) FindParameter(id uuid.UUID) (*Group, *parameters.Parameter) {\n\tvisual.mux.Lock()\n\tdefer visual.mux.Unlock()\n\n\t// iterate over shows, visuals and groups\n\tfor _, group := range visual.Groups() {\n\t\tfor _, parameter := range group.Effect.Parameters() {\n\t\t\tif parameter.ID == id {\n\t\t\t\treturn group, parameter\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func (d *DSP) Input(index int) (DSP, DspConnection, error) {\n\tvar input DSP\n\tvar inputconnection DspConnection\n\tres := C.FMOD_DSP_GetInput(d.cptr, C.int(index), &input.cptr, &inputconnection.cptr)\n\treturn input, inputconnection, errs[res]\n}", "func (scs *SubCommandStruct) ParameterUsage() ([]*cli.Parameter, string) {\n\tif scs.ParameterSetter != nil {\n\t\treturn scs.ParameterSetter.ParameterUsage()\n\t}\n\treturn nil, \"\"\n}", "func (device *SilentStepperBrick) GetAllData() (currentVelocity uint16, currentPosition int32, remainingSteps int32, stackVoltage uint16, externalVoltage uint16, currentConsumption uint16, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetAllData), buf.Bytes())\n\tif err != nil {\n\t\treturn currentVelocity, currentPosition, remainingSteps, stackVoltage, externalVoltage, currentConsumption, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 24 {\n\t\t\treturn currentVelocity, currentPosition, remainingSteps, stackVoltage, externalVoltage, currentConsumption, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 24)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn currentVelocity, currentPosition, remainingSteps, stackVoltage, externalVoltage, currentConsumption, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &currentVelocity)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &currentPosition)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &remainingSteps)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &stackVoltage)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &externalVoltage)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &currentConsumption)\n\n\t}\n\n\treturn currentVelocity, currentPosition, remainingSteps, stackVoltage, externalVoltage, currentConsumption, nil\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n C.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func (*Parameters_Parameter) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_r5_core_resources_parameters_proto_rawDescGZIP(), []int{0, 0}\n}", "func (ps *PrimeStore) GetByIndex(nth uint64) (n uint64) {\n\tdefer Tracer(NewTrace(\"GetByIndex\"))\n\n\tn = 0\n\tif nth < ps.base || nth >= (ps.base+ps.count) {\n\t\tlog.Print(\"out of range.\", nth, \" \", ps)\n\t\treturn\n\t}\n\n\tn = ps.index[nth-ps.base]\n\treturn\n}", "func getParam(memory []int, ip int, rb int, mode ParamMode) int {\n\tswitch mode {\n\tcase POSITION:\n\t\treturn memory[memory[ip]]\n\tcase IMMEDIATE:\n\t\treturn memory[ip]\n\tcase RELATIVE:\n\t\treturn memory[rb+memory[ip]]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unknown parameter mode: %d\", mode))\n\t}\n\treturn 0\n}", "func (a *AddMixer) Parameters() []*anydiff.Var {\n\tvar res []*anydiff.Var\n\tfor _, v := range []Layer{a.In1, a.In2, a.Out} {\n\t\tif p, ok := v.(Parameterizer); ok {\n\t\t\tres = append(res, p.Parameters()...)\n\t\t}\n\t}\n\treturn res\n}", "func ParameterValue(opcodes map[int64]int64, ptr int64, parameter int64, relativeBase int64) int64 {\n\tj := int64(10)\n\tfor i := int64(0); i < parameter; i++ {\n\t\tj *= 10\n\t}\n\tparameterMode := (opcodes[ptr] / j) % 10\n\n\tswitch parameterMode {\n\tcase 0:\n\t\t// Position mode (return value at the position of parameter)\n\t\t// return GetMemory(opcodes, GetMemory(opcodes, ptr+parameter))\n\t\treturn opcodes[opcodes[ptr+parameter]]\n\tcase 1:\n\t\t// Immediate mode (return value of parameter)\n\t\t// return GetMemory(opcodes, ptr+parameter)\n\t\treturn opcodes[ptr+parameter]\n\tcase 2:\n\t\t// Relative mode\n\t\t// return GetMemory(opcodes, GetMemory(opcodes, ptr+parameter)+relativeBase)\n\t\treturn opcodes[opcodes[ptr+parameter]+relativeBase]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unexpected parameter mode %d for opcode %d at position %d\", parameterMode, opcodes[ptr], ptr))\n\t}\n}", "func (ctx *Context) ParamByIndex(index int) string {\n\treturn ctx.PathParams.ByIndex(index)\n}", "func (s *System) Parameters() []float32 {\n\treturn s.parametersVector\n}", "func GetBlkioParameters(group string) (BlockIOParameters, error) {\n\tvar errors *multierror.Error\n\tblockIO := NewBlockIOParameters()\n\n\terrors = multierror.Append(errors, readWeight(group, blkioWeightFiles, &blockIO.Weight))\n\terrors = multierror.Append(errors, readDeviceParameters(group, blkioWeightDeviceFiles, &blockIO.WeightDevice))\n\terrors = multierror.Append(errors, readDeviceParameters(group, blkioThrottleReadBpsFiles, &blockIO.ThrottleReadBpsDevice))\n\terrors = multierror.Append(errors, readDeviceParameters(group, blkioThrottleWriteBpsFiles, &blockIO.ThrottleWriteBpsDevice))\n\terrors = multierror.Append(errors, readDeviceParameters(group, blkioThrottleReadIOPSFiles, &blockIO.ThrottleReadIOPSDevice))\n\terrors = multierror.Append(errors, readDeviceParameters(group, blkioThrottleWriteIOPSFiles, &blockIO.ThrottleWriteIOPSDevice))\n\treturn blockIO, errors.ErrorOrNil()\n}", "func (tr *Cluster) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o BackendCredentialsAuthorizationPtrOutput) Parameter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BackendCredentialsAuthorization) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameter\n\t}).(pulumi.StringPtrOutput)\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (r *ClusterUpdateRequest) Parameter(name string, value interface{}) *ClusterUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func getBlock(file *os.File, pr int64, bm int64) dataBlock {\n\tblock := dataBlock{}\n\tsize := int64(binary.Size(block))\n\tindex := pr + bm*size\n\tfile.Seek(index, 0)\n\t//Se obtiene la data del archivo binarios\n\tdata := readNextBytes(file, size)\n\tbuffer := bytes.NewBuffer(data)\n\t//Se asigna al mbr declarado para leer la informacion de ese disco\n\terr := binary.Read(buffer, binary.BigEndian, &block)\n\tif err != nil {\n\t\tlog.Fatal(\"binary.Read failed\", err)\n\t}\n\treturn block\n}", "func (r *ClusterPollRequest) Parameter(name string, value interface{}) *ClusterPollRequest {\n\tr.request.Parameter(name, value)\n\treturn r\n}", "func (r *ManagedServicePollRequest) Parameter(name string, value interface{}) *ManagedServicePollRequest {\n\tr.request.Parameter(name, value)\n\treturn r\n}", "func (in *RecordSetGroup) GetParameters() map[string]string {\n\tparams := map[string]string{}\n\tcfnencoder.MarshalTypes(params, in.Spec, \"Parameter\")\n\treturn params\n}", "func (tr *Table) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func ParamUnit(name, description string) *float64 {\n\tf := &unitFlag{}\n\tflag.Var(f, name, description)\n\tparamNames = append(paramNames, name)\n\treturn &f.value\n}", "func (s *Stack) GetParameter(key string) *cfn.Parameter {\n\tfor i := 0; i < len(s.Parameters); i++ {\n\t\tif *s.Parameters[i].ParameterKey == key {\n\t\t\treturn s.Parameters[i]\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o BackendCredentialsAuthorizationOutput) Parameter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BackendCredentialsAuthorization) *string { return v.Parameter }).(pulumi.StringPtrOutput)\n}", "func (i IndexBlock) Get(blockNum byte) uint16 {\n\treturn uint16(i[blockNum]) + uint16(i[256+int(blockNum)])<<8\n}", "func (r *ManagedServiceUpdateRequest) Parameter(name string, value interface{}) *ManagedServiceUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (r *MachinePoolsListRequest) Parameter(name string, value interface{}) *MachinePoolsListRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (e TPMFmt1Error) Parameter() (bool, int) {\n\tif e.subject != parameterRelated {\n\t\treturn false, 0\n\t}\n\treturn true, e.index\n}", "func (tr *CassandraKeySpace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o *AddOn) Parameters() *AddOnParameterList {\n\tif o != nil && o.bitmap_&8192 != 0 {\n\t\treturn o.parameters\n\t}\n\treturn nil\n}", "func (c *Client) GetStorageAt(addr Address, index Quantity, block string) (*DataResponse, error) {\n\trequest := c.newRequest(EthGetStorageAt)\n\n\trequest.Params = []interface{}{\n\t\taddr,\n\t\tindex,\n\t\tblock,\n\t}\n\tresponse := &DataResponse{}\n\n\treturn response, c.send(request, response)\n}", "func (*Parameters_Parameter_ValueX) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_r5_core_resources_parameters_proto_rawDescGZIP(), []int{0, 0, 0}\n}", "func (o BuildSpecPtrOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v *BuildSpec) []BuildSpecParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(BuildSpecParametersArrayOutput)\n}", "func GetRenderbufferParameteri(target, pname Enum) int {\n\tlog.Println(\"GetRenderbufferParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar result int32\n\tgl.GetRenderbufferParameteriv(uint32(target), uint32(pname), &result)\n\treturn int(result)\n}", "func (r *Document) Parameters() pulumi.ArrayOutput {\n\treturn (pulumi.ArrayOutput)(r.s.State[\"parameters\"])\n}", "func (tr *Account) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *CassandraTable) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *MongoDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *TaskDefinition) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (_DelegateProfile *DelegateProfileCallerSession) GetFieldByIndex(_idx *big.Int) (struct {\n\tName string\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByIndex(&_DelegateProfile.CallOpts, _idx)\n}", "func QueryParameterFor(name string, description string) Parameter {\n\treturn ParameterFor(Query, name, description)\n}", "func (o SettingsSectionDescriptionOutput) Parameters() SettingsParameterDescriptionArrayOutput {\n\treturn o.ApplyT(func(v SettingsSectionDescription) []SettingsParameterDescription { return v.Parameters }).(SettingsParameterDescriptionArrayOutput)\n}", "func (r *ClusterHibernateRequest) Parameter(name string, value interface{}) *ClusterHibernateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (tr *NotebookWorkspace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (s *SsmService) GetParameterValue(ctx context.Context, param *string, withDecryption bool) *string {\n\tlog.Printf(\"Get Parameter Value of %s from SSM\\n\", *param)\n\n\tinput := &ssm.GetParameterInput{\n\t\tName: param,\n\t\tWithDecryption: withDecryption,\n\t}\n\n\toutput, err := s.client.GetParameter(ctx, input)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error getting Parameter Value of %s from SSM - %s\", *param, err.Error())\n\t\treturn nil\n\t}\n\treturn output.Parameter.Value\n}", "func (tr *SQLDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *Service) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o BuildSpecOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v BuildSpec) []BuildSpecParameters { return v.Parameters }).(BuildSpecParametersArrayOutput)\n}", "func (p ParamData) Name() string {\n\treturn p.Var.Name\n}", "func (*ParameterInformation_Offset) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{121, 0}\n}", "func (config *Config) getRawParam(key string) interface{} {\n\tenvironment := os.Getenv(\"TEAM254_ENV\")\n\tif environment == \"\" {\n\t\tenvironment = \"dev\"\n\t}\n\n\t// Look in the environment-specific configs first.\n\tif _, ok := config.params[environment]; ok {\n\t\tvalue := config.params[environment][key]\n\t\tif value != nil {\n\t\t\treturn value\n\t\t}\n\t}\n\n\t// Look in the global configs.\n\tif _, ok := config.params[\"global\"]; ok {\n\t\tvalue := config.params[\"global\"][key]\n\t\tif value != nil {\n\t\t\treturn value\n\t\t}\n\t}\n\n\tlog.Fatalf(\"Error: No value found for config key '%s'.\", key)\n\treturn nil\n}", "func (f *Frame) Sample() (*Sample, int) {\n\tf.active.mu.Lock()\n\tdefer f.active.mu.Unlock()\n\treturn f.data, f.samples\n}", "func (w *Wav) GetData() (interface{}, error) {\n\tbytePerSample := int(w.BitsPerSample / 8)\n\tsampleParser, err := GetSampleParser(w.BitsPerSample, w.WaveFormat)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif w.NumChannels == 1 {\n\t\tsample := parseMonoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\tif w.NumChannels == 2 {\n\t\tsample := parseStereoSample(w.Data, bytePerSample, sampleParser)\n\t\tbound, err := GetBound(w.BitsPerSample, w.WaveFormat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsample.Bound = bound\n\t\treturn sample, nil\n\t}\n\n\treturn nil, errors.New(\"failed to sampled data from wav file\")\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tC.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func GetMultisamplefv(pname uint32, index uint32, val *float32) {\n\tC.glowGetMultisamplefv(gpGetMultisamplefv, (C.GLenum)(pname), (C.GLuint)(index), (*C.GLfloat)(unsafe.Pointer(val)))\n}", "func (n *Norm) Parameters() []*autofunc.Variable {\n\tres := make([]*autofunc.Variable, len(n.Weights)+len(n.Mags))\n\tcopy(res, n.Weights)\n\tcopy(res[len(n.Weights):], n.Mags)\n\n\tnormRes, rv := n.newNormRResult(autofunc.RVector{})\n\tnet := n.Creator.Create(normRes.NormPool)\n\tparams := net.Parameters()\n\tfor _, param := range params {\n\t\tif _, ok := rv[param]; !ok {\n\t\t\tres = append(res, param)\n\t\t}\n\t}\n\n\treturn res\n}", "func (tr *MongoCollection) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (p *Parameter) Name() string {\n\treturn p.name\n}", "func (x *fastReflection_DenomUnit) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {\n\tswitch descriptor.FullName() {\n\tcase \"cosmos.bank.v1beta1.DenomUnit.denom\":\n\t\tvalue := x.Denom\n\t\treturn protoreflect.ValueOfString(value)\n\tcase \"cosmos.bank.v1beta1.DenomUnit.exponent\":\n\t\tvalue := x.Exponent\n\t\treturn protoreflect.ValueOfUint32(value)\n\tcase \"cosmos.bank.v1beta1.DenomUnit.aliases\":\n\t\tif len(x.Aliases) == 0 {\n\t\t\treturn protoreflect.ValueOfList(&_DenomUnit_3_list{})\n\t\t}\n\t\tlistValue := &_DenomUnit_3_list{list: &x.Aliases}\n\t\treturn protoreflect.ValueOfList(listValue)\n\tdefault:\n\t\tif descriptor.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.bank.v1beta1.DenomUnit\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.bank.v1beta1.DenomUnit does not contain field %s\", descriptor.FullName()))\n\t}\n}", "func (*Parameters) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_r5_core_resources_parameters_proto_rawDescGZIP(), []int{0}\n}", "func (r *ClusterGetRequest) Parameter(name string, value interface{}) *ClusterGetRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (p *Param) GetRange() (min, max float64, err error) {\n\tvar ferr C.FMOD_RESULT\n\tvar cmin, cmax C.float\n\tbase.Thread(func() {\n\t\tferr = C.FMOD_EventParameter_GetRange(p.param, &cmin, &cmax)\n\t})\n\tmin = float64(cmin)\n\tmax = float64(cmax)\n\terr = base.ResultToError(ferr)\n\treturn\n}", "func ShowParameterInPipeline(projectKey, pipelineName string) ([]Parameter, error) {\n\tpath := fmt.Sprintf(\"/project/%s/pipeline/%s/parameter\", projectKey, pipelineName)\n\tdata, _, err := Request(\"GET\", path, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar params []Parameter\n\tif err := json.Unmarshal(data, &params); err != nil {\n\t\treturn nil, err\n\t}\n\treturn params, nil\n}", "func (o *Block) GetConfiguration(ctx context.Context) (configuration []struct {\n\tV0 string\n\tV1 map[string]dbus.Variant\n}, err error) {\n\terr = o.object.CallWithContext(ctx, \"org.freedesktop.DBus.Properties.Get\", 0, InterfaceBlock, \"Configuration\").Store(&configuration)\n\treturn\n}", "func (_DelegateProfile *DelegateProfileSession) GetFieldByIndex(_idx *big.Int) (struct {\n\tName string\n\tVerifier common.Address\n\tDeprecated bool\n}, error) {\n\treturn _DelegateProfile.Contract.GetFieldByIndex(&_DelegateProfile.CallOpts, _idx)\n}", "func SetConfigParameterForQBlock(session *libcoap.Session, customerId int) {\n // Get session config\n sessionConfig, err := models.GetCurrentSignalSessionConfiguration(customerId)\n if err != nil {\n log.Error(\"Failed to get current session config\")\n }\n // Get mitigationIds with status is 2\n mids, err := models.GetMitigationIdsByCustomer(customerId)\n if err != nil {\n log.Error(\"Failed to Get mitigation ids\")\n return\n }\n if sessionConfig != nil && sessionConfig.SessionId > 0 {\n maxPayLoad := sessionConfig.MaxPayloadIdle\n nonMaxRetransmit := sessionConfig.NonMaxRetransmitIdle\n nonTimeout := sessionConfig.NonTimeoutIdle\n nonReceiveTimeout := sessionConfig.NonReceiveTimeoutIdle\n if len(mids) > 0 {\n maxPayLoad = sessionConfig.MaxPayload\n nonMaxRetransmit = sessionConfig.NonMaxRetransmit\n nonTimeout = sessionConfig.NonTimeout\n nonReceiveTimeout = sessionConfig.NonReceiveTimeout\n }\n session.SetMaxPayLoads(maxPayLoad)\n session.SetNonMaxRetransmit(nonMaxRetransmit)\n session.SetNonTimeout(decimal.NewFromFloat(nonTimeout).Round((2)))\n session.SetNonReceiveTimeout(decimal.NewFromFloat(nonReceiveTimeout).Round((2)))\n }\n}", "func (o *MetricDefaultAggregation) GetParameter() float64 {\n\tif o == nil || o.Parameter == nil {\n\t\tvar ret float64\n\t\treturn ret\n\t}\n\treturn *o.Parameter\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (d Datapoints) ValueAt(n int) float64 { return d[n].Value }", "func GetCUEParameterValue(cueStr string) (cue.Value, error) {\n\tr := cue.Runtime{}\n\ttemplate, err := r.Compile(\"\", cueStr+velacue.BaseTemplate)\n\tif err != nil {\n\t\treturn cue.Value{}, err\n\t}\n\ttempStruct, err := template.Value().Struct()\n\tif err != nil {\n\t\treturn cue.Value{}, err\n\t}\n\t// find the parameter definition\n\tvar paraDef cue.FieldInfo\n\tvar found bool\n\tfor i := 0; i < tempStruct.Len(); i++ {\n\t\tparaDef = tempStruct.Field(i)\n\t\tif paraDef.Name == velacue.ParameterTag {\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !found {\n\t\treturn cue.Value{}, errors.New(\"parameter not exist\")\n\t}\n\targuments := paraDef.Value\n\n\treturn arguments, nil\n}", "func (l *Libvirt) DomainBlockPeek(Dom Domain, Path string, Offset uint64, Size uint32, Flags uint32) (rBuffer []byte, err error) {\n\tvar buf []byte\n\n\targs := DomainBlockPeekArgs {\n\t\tDom: Dom,\n\t\tPath: Path,\n\t\tOffset: Offset,\n\t\tSize: Size,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(103, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Buffer: []byte\n\t_, err = dec.Decode(&rBuffer)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func getParameter(request *http.Request, parameterName string) string {\n\tquery := request.URL.Query()\n\treturn query[parameterName][0]\n}", "func (uni *Uniform4fv) Get(idx int) (v0, v1, v2, v3 float32) {\n\n\tpos := idx * 4\n\treturn uni.v[pos], uni.v[pos+1], uni.v[pos+2], uni.v[pos+3]\n}", "func (d *Dataset) Block(i int) *Block {\n\tif len(d.blocks) == 0 {\n\t\t//load blocks so errors can be populated in dataset\n\t\td.loadBlocks()\n\t}\n\n\tif i <= len(d.blocks)-1 {\n\t\treturn d.blocks[i]\n\t}\n\n\treturn nil\n}", "func (*ParameterInformation) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{121}\n}", "func (r *ManagedServiceGetRequest) Parameter(name string, value interface{}) *ManagedServiceGetRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (out *Out) Read(i int) float64 {\n\treturn out.frame[i]\n}", "func (tr *GremlinDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (node *Configuration) getValue(parameter uint8, size uint8) ([]uint8, error) {\n\t// Check size\n\tif size != 1 && size != 2 && size != 4 {\n\t\treturn nil, fmt.Errorf(\"Bad request size: %d\", size)\n\t}\n\n\tfilter := func(response *ApplicationCommandData) bool {\n\t\treturn len(response.Command.Data) > 1 && response.Command.Data[0] == parameter\n\t}\n\n\t// Issue request\n\tvar response *ApplicationCommandData\n\tvar err error\n\tif response, err = node.zwSendDataWaitForResponse(\n\t\tCommandClassConfiguration, []uint8{configurationGet, parameter},\n\t\tconfigurationReport, filter); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Check response\n\tdata := response.Command.Data\n\tif len(data) != 2+int(size) {\n\t\treturn nil, fmt.Errorf(\"Unexpected data length: %d != %d, value might not exist\",\n\t\t\tlen(data), 2+size)\n\t}\n\n\tif data[1] != size {\n\t\t// Validate size\n\t\treturn nil, fmt.Errorf(\"Bad size: 0x%02x != 0x%02x\", data[1], size)\n\t}\n\n\t// Return data\n\treturn data[2 : 2+size], nil\n}" ]
[ "0.6603123", "0.6373271", "0.56036365", "0.52326775", "0.50494623", "0.502724", "0.49873933", "0.49083984", "0.4878963", "0.4816053", "0.47980267", "0.4796334", "0.47890034", "0.477631", "0.47721228", "0.47642902", "0.47169486", "0.47114068", "0.4669271", "0.46572283", "0.4595355", "0.4584278", "0.45841622", "0.45812708", "0.45783958", "0.45692366", "0.45679232", "0.4553216", "0.45522293", "0.45462775", "0.4542179", "0.45331734", "0.45321095", "0.4523858", "0.45226812", "0.45137668", "0.45111695", "0.44619536", "0.44593096", "0.4448288", "0.4446897", "0.44359365", "0.44073373", "0.44029558", "0.44028366", "0.44015682", "0.44002384", "0.43971813", "0.43953088", "0.4388408", "0.4388051", "0.43807444", "0.43627256", "0.43476728", "0.43379113", "0.433425", "0.43331465", "0.43318483", "0.43278867", "0.43175876", "0.43120706", "0.43103066", "0.43096748", "0.43074447", "0.43050328", "0.43009418", "0.42966503", "0.42938003", "0.42919746", "0.4287388", "0.4285913", "0.42710254", "0.42697397", "0.42656142", "0.42643332", "0.42643332", "0.4264154", "0.4263004", "0.42629287", "0.4255584", "0.42529824", "0.4252561", "0.42513475", "0.42460477", "0.42460045", "0.42395484", "0.4219407", "0.42188665", "0.42171776", "0.42130396", "0.42122728", "0.42052254", "0.42049655", "0.42006314", "0.419525", "0.41952044", "0.41834933", "0.4182047", "0.4179079", "0.4169181" ]
0.65771335
1
Retrieves the number of parameters a DSP unit has to control its behaviour. Use this to enumerate all parameters of a DSP unit with "DSP.ParameterInfo".
func (d *DSP) NumParameters() (int, error) { var numparams C.int res := C.FMOD_DSP_GetNumParameters(d.cptr, &numparams) return int(numparams), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Trainer) NumParameters() int {\n\treturn s.outputDim * s.nFeatures\n}", "func (p Pareto) NumParameters() int {\n\treturn 2\n}", "func (a AlphaStable) NumParameters() int {\n\treturn 4\n}", "func (Binomial) NumParameters() int {\n\treturn 2\n}", "func (f F) NumParameters() int {\n\treturn 2\n}", "func (this *parameter) Count() int {\n\treturn len(this.Values)\n}", "func (p *Parameters) Len() int {\n\treturn len(p.names)\n}", "func (c ChiSquared) NumParameters() int {\n\treturn 1\n}", "func (StudentsT) NumParameters() int {\n\treturn 3\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (Exponential) NumParameters() int {\n\treturn 1\n}", "func (o *AddOn) GetParameters() (value *AddOnParameterList, ok bool) {\n\tok = o != nil && o.bitmap_&8192 != 0\n\tif ok {\n\t\tvalue = o.parameters\n\t}\n\treturn\n}", "func (s *System) Parameters() []float32 {\n\treturn s.parametersVector\n}", "func (tr *CapacityProvider) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (self params) Count() int { return len(self) }", "func countParameterType(b bindingInterface, i interface{}) (ret int) {\n\tt := reflect.TypeOf(i)\n\tret = 0\n\ta := parameterTypeArray(b, true)\n\tfor _, v := range a {\n\t\tif v == t {\n\t\t\tret++\n\t\t}\n\t}\n\treturn\n}", "func (l *Layer) Parameters() []*autofunc.Variable {\n\treturn []*autofunc.Variable{l.Biases, l.Scales}\n}", "func (o *AddOn) Parameters() *AddOnParameterList {\n\tif o != nil && o.bitmap_&8192 != 0 {\n\t\treturn o.parameters\n\t}\n\treturn nil\n}", "func (s *Statement) Parameters() int {\n\treturn int(C.sqlite3_bind_parameter_count(s.cptr))\n}", "func (af *filtBase) GetParams() (int, float64, []float64) {\n\treturn af.n, af.mu, af.w.RawRowView(0)\n}", "func (tr *Service) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (a *AddMixer) Parameters() []*anydiff.Var {\n\tvar res []*anydiff.Var\n\tfor _, v := range []Layer{a.In1, a.In2, a.Out} {\n\t\tif p, ok := v.(Parameterizer); ok {\n\t\t\tres = append(res, p.Parameters()...)\n\t\t}\n\t}\n\treturn res\n}", "func (l *Libvirt) DomainGetNumaParameters(Dom Domain, Nparams int32, Flags uint32) (rParams []TypedParam, rNparams int32, err error) {\n\tvar buf []byte\n\n\targs := DomainGetNumaParametersArgs {\n\t\tDom: Dom,\n\t\tNparams: Nparams,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(255, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Params: []TypedParam\n\t_, err = dec.Decode(&rParams)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Nparams: int32\n\t_, err = dec.Decode(&rNparams)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (b *BackShift) numParams() int {\n\treturn len(b._offsets)\n}", "func (o BuildSpecOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v BuildSpec) []BuildSpecParameters { return v.Parameters }).(BuildSpecParametersArrayOutput)\n}", "func (dist Beta) NumParams() int {\n\treturn 2\n}", "func (input *BeegoInput) ParamsLen() int {\n\treturn len(input.pnames)\n}", "func (tr *Account) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *CassandraKeySpace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o BuildSpecPtrOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v *BuildSpec) []BuildSpecParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(BuildSpecParametersArrayOutput)\n}", "func (GumbelRight) NumParameters() int {\n\treturn 2\n}", "func (r *Document) Parameters() pulumi.ArrayOutput {\n\treturn (pulumi.ArrayOutput)(r.s.State[\"parameters\"])\n}", "func (tr *Cluster) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o ApplicationSpecSourceKsonnetOutput) Parameters() ApplicationSpecSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationSpecSourceKsonnet) []ApplicationSpecSourceKsonnetParameters { return v.Parameters }).(ApplicationSpecSourceKsonnetParametersArrayOutput)\n}", "func (o BuildRunStatusBuildSpecPtrOutput) Parameters() BuildRunStatusBuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v *BuildRunStatusBuildSpec) []BuildRunStatusBuildSpecParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(BuildRunStatusBuildSpecParametersArrayOutput)\n}", "func (tr *MongoCollection) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (in *RecordSetGroup) GetParameters() map[string]string {\n\tparams := map[string]string{}\n\tcfnencoder.MarshalTypes(params, in.Spec, \"Parameter\")\n\treturn params\n}", "func (s APIParams) Len() int {\n\treturn len(s)\n}", "func (o SystemParameterRuleOutput) Parameters() SystemParameterArrayOutput {\n\treturn o.ApplyT(func(v SystemParameterRule) []SystemParameter { return v.Parameters }).(SystemParameterArrayOutput)\n}", "func (o ApplicationSpecSourceKsonnetPtrOutput) Parameters() ApplicationSpecSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecSourceKsonnet) []ApplicationSpecSourceKsonnetParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationSpecSourceKsonnetParametersArrayOutput)\n}", "func (tr *Table) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *NotebookWorkspace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func GetRenderbufferParameteri(target, pname Enum) int {\n\tlog.Println(\"GetRenderbufferParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar result int32\n\tgl.GetRenderbufferParameteriv(uint32(target), uint32(pname), &result)\n\treturn int(result)\n}", "func (o BuildRunStatusBuildSpecOutput) Parameters() BuildRunStatusBuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v BuildRunStatusBuildSpec) []BuildRunStatusBuildSpecParameters { return v.Parameters }).(BuildRunStatusBuildSpecParametersArrayOutput)\n}", "func (o *ParameterContextDTO) HasParameters() bool {\n\tif o != nil && o.Parameters != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (tr *TaskDefinition) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (s *BaseEvent) ScriptParamSize() (int,error) {\n return len(s.execArray),nil\n}", "func (params *Params) NumAttributes() int {\n\treturn len(params.H)\n}", "func (o ApplicationStatusHistorySourceKsonnetPtrOutput) Parameters() ApplicationStatusHistorySourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusHistorySourceKsonnet) []ApplicationStatusHistorySourceKsonnetParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationStatusHistorySourceKsonnetParametersArrayOutput)\n}", "func (tr *MongoDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *CassandraTable) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o ApplicationStatusSyncComparedToSourceKsonnetPtrOutput) Parameters() ApplicationStatusSyncComparedToSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusSyncComparedToSourceKsonnet) []ApplicationStatusSyncComparedToSourceKsonnetParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationStatusSyncComparedToSourceKsonnetParametersArrayOutput)\n}", "func (o ApplicationStatusSyncComparedToSourceKsonnetOutput) Parameters() ApplicationStatusSyncComparedToSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationStatusSyncComparedToSourceKsonnet) []ApplicationStatusSyncComparedToSourceKsonnetParameters {\n\t\treturn v.Parameters\n\t}).(ApplicationStatusSyncComparedToSourceKsonnetParametersArrayOutput)\n}", "func (m *Pump) NumChannelsParam(numChannels int) func() {\n\treturn func() {\n\t\tm.NumChannels = numChannels\n\t}\n}", "func (c *common) Parameters() sbcon.Parameters { return c.params }", "func (o ResponsePlanActionSsmAutomationOutput) Parameters() ResponsePlanActionSsmAutomationParameterArrayOutput {\n\treturn o.ApplyT(func(v ResponsePlanActionSsmAutomation) []ResponsePlanActionSsmAutomationParameter {\n\t\treturn v.Parameters\n\t}).(ResponsePlanActionSsmAutomationParameterArrayOutput)\n}", "func (d *DSP) NumInputs() (int, error) {\n\tvar numinputs C.int\n\tres := C.FMOD_DSP_GetNumInputs(d.cptr, &numinputs)\n\treturn int(numinputs), errs[res]\n}", "func (o SettingsSectionDescriptionOutput) Parameters() SettingsParameterDescriptionArrayOutput {\n\treturn o.ApplyT(func(v SettingsSectionDescription) []SettingsParameterDescription { return v.Parameters }).(SettingsParameterDescriptionArrayOutput)\n}", "func (o EntitlementOutput) Parameters() GoogleCloudChannelV1ParameterResponseArrayOutput {\n\treturn o.ApplyT(func(v *Entitlement) GoogleCloudChannelV1ParameterResponseArrayOutput { return v.Parameters }).(GoogleCloudChannelV1ParameterResponseArrayOutput)\n}", "func (o ApplicationStatusHistorySourceKsonnetOutput) Parameters() ApplicationStatusHistorySourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationStatusHistorySourceKsonnet) []ApplicationStatusHistorySourceKsonnetParameters {\n\t\treturn v.Parameters\n\t}).(ApplicationStatusHistorySourceKsonnetParametersArrayOutput)\n}", "func (o SystemParameterRuleResponseOutput) Parameters() SystemParameterResponseArrayOutput {\n\treturn o.ApplyT(func(v SystemParameterRuleResponse) []SystemParameterResponse { return v.Parameters }).(SystemParameterResponseArrayOutput)\n}", "func (pr *prepareResult) numField() int { return len(pr.parameterFields) }", "func (pr *prepareResult) numField() int { return len(pr.parameterFields) }", "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (tr *GremlinGraph) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o SettingsSectionDescriptionResponseOutput) Parameters() SettingsParameterDescriptionResponseArrayOutput {\n\treturn o.ApplyT(func(v SettingsSectionDescriptionResponse) []SettingsParameterDescriptionResponse { return v.Parameters }).(SettingsParameterDescriptionResponseArrayOutput)\n}", "func (tr *SQLContainer) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (c *Constructor) Parameters() []reflect.Type {\n\tif c == nil {\n\t\treturn nil\n\t}\n\ttypes := make([]reflect.Type, len(c.inTypes))\n\tcopy(types, c.inTypes)\n\treturn types\n}", "func (n *Norm) Parameters() []*autofunc.Variable {\n\tres := make([]*autofunc.Variable, len(n.Weights)+len(n.Mags))\n\tcopy(res, n.Weights)\n\tcopy(res[len(n.Weights):], n.Mags)\n\n\tnormRes, rv := n.newNormRResult(autofunc.RVector{})\n\tnet := n.Creator.Create(normRes.NormPool)\n\tparams := net.Parameters()\n\tfor _, param := range params {\n\t\tif _, ok := rv[param]; !ok {\n\t\t\tres = append(res, param)\n\t\t}\n\t}\n\n\treturn res\n}", "func (o *ParameterContextDTO) GetParametersOk() (*[]ParameterEntity, bool) {\n\tif o == nil || o.Parameters == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Parameters, true\n}", "func (tr *SQLDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o ApplicationOperationSyncSourceKsonnetPtrOutput) Parameters() ApplicationOperationSyncSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationOperationSyncSourceKsonnet) []ApplicationOperationSyncSourceKsonnetParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationOperationSyncSourceKsonnetParametersArrayOutput)\n}", "func (m *Request) NumArguments() int {\n\treturn len(m.Inputs)\n}", "func (o ApplicationStatusSyncComparedToSourceHelmPtrOutput) Parameters() ApplicationStatusSyncComparedToSourceHelmParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusSyncComparedToSourceHelm) []ApplicationStatusSyncComparedToSourceHelmParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationStatusSyncComparedToSourceHelmParametersArrayOutput)\n}", "func (s *BackendService) Parameters() ([]*cloudformation.Parameter, error) {\n\treturn append(s.svc.Parameters(), []*cloudformation.Parameter{\n\t\t{\n\t\t\tParameterKey: aws.String(BackendServiceContainerPortParamKey),\n\t\t\tParameterValue: aws.String(strconv.FormatUint(uint64(aws.Uint16Value(s.manifest.BackendServiceConfig.Image.Port)), 10)),\n\t\t},\n\t}...), nil\n}", "func (tr *SQLTrigger) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o GetResponsePlanActionSsmAutomationOutput) Parameters() GetResponsePlanActionSsmAutomationParameterArrayOutput {\n\treturn o.ApplyT(func(v GetResponsePlanActionSsmAutomation) []GetResponsePlanActionSsmAutomationParameter {\n\t\treturn v.Parameters\n\t}).(GetResponsePlanActionSsmAutomationParameterArrayOutput)\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (o *PhoneSearchOptions) getParameters() (params map[string]string, err error) {\n\t// create an empty map of options\n\tparams = make(map[string]string)\n\n\t// reflect over the properties in o, adding parameters to the global map\n\tval := reflect.ValueOf(o).Elem()\n\tfor i := 0; i < val.NumField(); i++ {\n\t\tif !val.Field(i).IsNil() {\n\t\t\to := val.Field(i).Interface().(OptionProvider)\n\t\t\tfieldParams, err := o.getParameters()\n\t\t\tif err != nil {\n\t\t\t\treturn params, err\n\t\t\t}\n\t\t\tfor k, v := range fieldParams {\n\t\t\t\tparams[k] = v\n\t\t\t}\n\t\t}\n\t}\n\treturn params, nil\n}", "func (tr *GremlinDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (params *headerParams) Length() int {\n\treturn len(params.params)\n}", "func (tr *SQLStoredProcedure) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o ApplicationOperationSyncSourceKsonnetOutput) Parameters() ApplicationOperationSyncSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationOperationSyncSourceKsonnet) []ApplicationOperationSyncSourceKsonnetParameters {\n\t\treturn v.Parameters\n\t}).(ApplicationOperationSyncSourceKsonnetParametersArrayOutput)\n}", "func (o ApplicationStatusOperationStateOperationSyncSourceKsonnetPtrOutput) Parameters() ApplicationStatusOperationStateOperationSyncSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationStatusOperationStateOperationSyncSourceKsonnet) []ApplicationStatusOperationStateOperationSyncSourceKsonnetParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationStatusOperationStateOperationSyncSourceKsonnetParametersArrayOutput)\n}", "func (tr *SQLFunction) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o ApplicationStatusOperationStateOperationSyncSourceKsonnetOutput) Parameters() ApplicationStatusOperationStateOperationSyncSourceKsonnetParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationStatusOperationStateOperationSyncSourceKsonnet) []ApplicationStatusOperationStateOperationSyncSourceKsonnetParameters {\n\t\treturn v.Parameters\n\t}).(ApplicationStatusOperationStateOperationSyncSourceKsonnetParametersArrayOutput)\n}", "func getParameters(c *cli.Context) error {\n\tif !isSystemRunning() {\n\t\treturn nil\n\t}\n\t_, _, _, controllers := getIPAddresses()\n\n\tparams := sendCommandToControllers(controllers, \"GetParams\", \"\")\n\tfmt.Println(params)\n\n\treturn nil\n}", "func (r *BlockSeqFunc) Parameters() []*autofunc.Variable {\n\tif l, ok := r.Block.(sgd.Learner); ok {\n\t\treturn l.Parameters()\n\t} else {\n\t\treturn nil\n\t}\n}", "func (dev *PMX) OutputCount() int {\n\treturn len(dev.Channels)\n}", "func GetSupportedParameters() []string {\n\treturn util.GetSortedKeys(supportedParameterDescriptions)\n}", "func (p *PointerCallback) ArgCount() int {\n\treturn p.paramCount\n}", "func (o *ParameterContextDTO) GetParameters() []ParameterEntity {\n\tif o == nil || o.Parameters == nil {\n\t\tvar ret []ParameterEntity\n\t\treturn ret\n\t}\n\treturn *o.Parameters\n}", "func (scs *SubCommandStruct) ParameterUsage() ([]*cli.Parameter, string) {\n\tif scs.ParameterSetter != nil {\n\t\treturn scs.ParameterSetter.ParameterUsage()\n\t}\n\treturn nil, \"\"\n}", "func (v *parameter) MaxItems() int {\n\tif !v.HasMaxItems() {\n\t\treturn 0\n\t}\n\treturn *v.maxItems\n}", "func (opts *ListOpts) Len() int {\n return len((*opts.values))\n}", "func (o ApiOperationRequestPtrOutput) QueryParameters() ApiOperationRequestQueryParameterArrayOutput {\n\treturn o.ApplyT(func(v *ApiOperationRequest) []ApiOperationRequestQueryParameter {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.QueryParameters\n\t}).(ApiOperationRequestQueryParameterArrayOutput)\n}", "func (o ApplicationStatusSyncComparedToSourceHelmOutput) Parameters() ApplicationStatusSyncComparedToSourceHelmParametersArrayOutput {\n\treturn o.ApplyT(func(v ApplicationStatusSyncComparedToSourceHelm) []ApplicationStatusSyncComparedToSourceHelmParameters {\n\t\treturn v.Parameters\n\t}).(ApplicationStatusSyncComparedToSourceHelmParametersArrayOutput)\n}", "func (o ApplicationSpecSourceHelmPtrOutput) Parameters() ApplicationSpecSourceHelmParametersArrayOutput {\n\treturn o.ApplyT(func(v *ApplicationSpecSourceHelm) []ApplicationSpecSourceHelmParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(ApplicationSpecSourceHelmParametersArrayOutput)\n}", "func (a *Affine) Parameters() []*anydiff.Var {\n\treturn []*anydiff.Var{a.Scalers, a.Biases}\n}" ]
[ "0.6459628", "0.63830197", "0.6268999", "0.62101907", "0.6169887", "0.6065322", "0.59820825", "0.5900332", "0.58650327", "0.5860217", "0.5820561", "0.5777419", "0.5672821", "0.5621701", "0.56176215", "0.55777013", "0.55626154", "0.5529533", "0.5521496", "0.541845", "0.54066426", "0.5403008", "0.5397055", "0.5380819", "0.5372595", "0.5371934", "0.5351401", "0.53145844", "0.5303937", "0.5301385", "0.5296125", "0.52939194", "0.52760947", "0.5268385", "0.52331215", "0.52325505", "0.52302605", "0.52271205", "0.52228343", "0.5218286", "0.5209178", "0.5207614", "0.5199384", "0.5185632", "0.51690876", "0.5162774", "0.5156102", "0.5134246", "0.512943", "0.5105573", "0.50914645", "0.5083753", "0.50800884", "0.5076396", "0.5062873", "0.503945", "0.5035036", "0.5029282", "0.50251895", "0.50164205", "0.50123626", "0.49945945", "0.4990798", "0.4990798", "0.4990226", "0.49758878", "0.49618953", "0.4955107", "0.4940744", "0.49337277", "0.49190494", "0.49142697", "0.48978072", "0.48956957", "0.48919815", "0.48815912", "0.48737207", "0.4873027", "0.48707953", "0.4869546", "0.4863731", "0.48579776", "0.48574764", "0.4843388", "0.48189795", "0.4814491", "0.48097593", "0.4802471", "0.4797296", "0.47901872", "0.47793618", "0.4777761", "0.4777279", "0.47712803", "0.47612715", "0.47594243", "0.4757861", "0.47553393", "0.4739648", "0.47347832" ]
0.69617003
0
NOTE: Not implement yet Retrieve information about a specified parameter within the DSP unit. Use "DSP.NumParameters" to find out the number of parameters for this DSP unit.
func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error { //FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (c *common) Parameters() sbcon.Parameters { return c.params }", "func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);\n\treturn ErrNoImpl\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (p *Program) getParameter(param uint32) int {\n\tvar v int32\n\tgl.GetProgramiv(uint32(p.glHandle), param, &v)\n\treturn int(v)\n}", "func (p *Param) GetInfo() error {\n\treturn errors.New(\"Param.GetInfo() has not been implemented yet.\")\n}", "func (xmlmc *XmlmcInstStruct) GetParam() string {\n\n\treturn \"<params>\" + xmlmc.paramsxml + \"</params>\"\n}", "func (l *Layer) Parameters() []*autofunc.Variable {\n\treturn []*autofunc.Variable{l.Biases, l.Scales}\n}", "func (c Config) GetParameter(name string) (Parameter, bool) {\n\tfor i, v := range c.Parameters {\n\t\tif v.Name == name {\n\t\t\treturn c.Parameters[i], true\n\t\t}\n\t}\n\treturn Parameter{}, false\n}", "func (in *RecordSetGroup) GetParameters() map[string]string {\n\tparams := map[string]string{}\n\tcfnencoder.MarshalTypes(params, in.Spec, \"Parameter\")\n\treturn params\n}", "func (scs *SubCommandStruct) ParameterUsage() ([]*cli.Parameter, string) {\n\tif scs.ParameterSetter != nil {\n\t\treturn scs.ParameterSetter.ParameterUsage()\n\t}\n\treturn nil, \"\"\n}", "func (e TPMFmt1Error) Parameter() (bool, int) {\n\tif e.subject != parameterRelated {\n\t\treturn false, 0\n\t}\n\treturn true, e.index\n}", "func (o BackendCredentialsAuthorizationPtrOutput) Parameter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BackendCredentialsAuthorization) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameter\n\t}).(pulumi.StringPtrOutput)\n}", "func (o BackendCredentialsAuthorizationOutput) Parameter() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v BackendCredentialsAuthorization) *string { return v.Parameter }).(pulumi.StringPtrOutput)\n}", "func (d *DSP) ParameterFloat(index C.int, value *C.float, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterFloat(FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func GetParam(d []*commands.Data, name string) *commands.Data {\n\tfor _, element := range d {\n\t\tif strings.Compare(element.Name, name) == 0 {\n\t\t\treturn element\n\t\t}\n\t}\n\treturn nil\n}", "func (s *System) Parameters() []float32 {\n\treturn s.parametersVector\n}", "func (tr *CapacityProvider) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (d *DSP) NumParameters() (int, error) {\n\tvar numparams C.int\n\tres := C.FMOD_DSP_GetNumParameters(d.cptr, &numparams)\n\treturn int(numparams), errs[res]\n}", "func (e *ArgsError) Parameter() string {\n\treturn e.errorParameter\n}", "func GetRenderbufferParameteri(target, pname Enum) int {\n\tlog.Println(\"GetRenderbufferParameteri: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)\")\n\tvar result int32\n\tgl.GetRenderbufferParameteriv(uint32(target), uint32(pname), &result)\n\treturn int(result)\n}", "func (o *AddOn) Parameters() *AddOnParameterList {\n\tif o != nil && o.bitmap_&8192 != 0 {\n\t\treturn o.parameters\n\t}\n\treturn nil\n}", "func (tr *Service) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *Cluster) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (p *Parameter) Name() string {\n\treturn p.name\n}", "func (o *AddOn) GetParameters() (value *AddOnParameterList, ok bool) {\n\tok = o != nil && o.bitmap_&8192 != 0\n\tif ok {\n\t\tvalue = o.parameters\n\t}\n\treturn\n}", "func (tr *SQLDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (s *Stack) GetParameter(key string) *cfn.Parameter {\n\tfor i := 0; i < len(s.Parameters); i++ {\n\t\tif *s.Parameters[i].ParameterKey == key {\n\t\t\treturn s.Parameters[i]\n\t\t}\n\t}\n\n\treturn nil\n}", "func (tr *Account) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (af *filtBase) GetParams() (int, float64, []float64) {\n\treturn af.n, af.mu, af.w.RawRowView(0)\n}", "func getParameter(request *http.Request, parameterName string) string {\n\tquery := request.URL.Query()\n\treturn query[parameterName][0]\n}", "func getParam(memory []int, ip int, rb int, mode ParamMode) int {\n\tswitch mode {\n\tcase POSITION:\n\t\treturn memory[memory[ip]]\n\tcase IMMEDIATE:\n\t\treturn memory[ip]\n\tcase RELATIVE:\n\t\treturn memory[rb+memory[ip]]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unknown parameter mode: %d\", mode))\n\t}\n\treturn 0\n}", "func (tr *MongoDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *CassandraKeySpace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (handler Handler) GetParameter(r *http.Request, key string) string {\n\treturn r.URL.Query().Get(key)\n}", "func (tr *GremlinDatabase) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *Table) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (options *Options) Param(pos int) interface{} {\n\tif len(options.params) > pos {\n\t\treturn options.params[pos]\n\t}\n\n\treturn nil\n}", "func (tr *MongoCollection) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *GremlinGraph) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (a *AddMixer) Parameters() []*anydiff.Var {\n\tvar res []*anydiff.Var\n\tfor _, v := range []Layer{a.In1, a.In2, a.Out} {\n\t\tif p, ok := v.(Parameterizer); ok {\n\t\t\tres = append(res, p.Parameters()...)\n\t\t}\n\t}\n\treturn res\n}", "func (parser *Parser) parameter() (*Declaration, error) {\n\tparser.trace(\"PARAMETER\")\n\tdefer parser.untrace()\n\tdataTypeTok, err, found := parser.match(fxsymbols.DataType)\n\tif err != nil {\n\t\t// return ErrSyntax\n\t\treturn nil, err\n\t}\n\tif !found {\n\t\treturn nil, ErrNoMatch\n\t}\n\tdataIdTok, _, found := parser.match(fxsymbols.Id)\n\tif !found {\n\t\treturn nil, parser.Errorf(ErrNoId)\n\t}\n\tif parser.symbEnvs.GetSymb(dataIdTok.Lex) != nil {\n\t\treturn nil, fxsymbols.ErrVarExists\n\t}\n\tparser.symbEnvs.PutVar(dataIdTok)\n\treturn NewDeclaration(dataIdTok.Lex, fxlex.DataTypeConst(dataTypeTok.Val)), nil\n}", "func (*Parameters_Parameter) Descriptor() ([]byte, []int) {\n\treturn file_proto_google_fhir_proto_r5_core_resources_parameters_proto_rawDescGZIP(), []int{0, 0}\n}", "func (debugging *debuggingOpenGL) GetProgramParameter(program uint32, param uint32) int32 {\n\tdebugging.recordEntry(\"GetProgramParameter\", program, param)\n\tresult := debugging.gl.GetProgramParameter(program, param)\n\tdebugging.recordExit(\"GetProgramParameter\", result)\n\treturn result\n}", "func (c *Context) Param(name string) string {\n\tfor i, n := range c.pnames {\n\t\tif n == name {\n\t\t\treturn c.pvalues[i]\n\t\t}\n\t}\n\treturn \"\"\n}", "func (r *Document) Parameters() pulumi.ArrayOutput {\n\treturn (pulumi.ArrayOutput)(r.s.State[\"parameters\"])\n}", "func GetParameter(options *GetParameterOptions) (string, error) {\n\tout, err := options.Client.GetParameter(context.TODO(), &ssm.GetParameterInput{\n\t\tName: &options.Name,\n\t\tWithDecryption: options.Decrypt,\n\t})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// return val, nil\n\treturn strings.TrimSuffix(*out.Parameter.Value, \"\\n\"), nil\n}", "func (visual *Visual) FindParameter(id uuid.UUID) (*Group, *parameters.Parameter) {\n\tvisual.mux.Lock()\n\tdefer visual.mux.Unlock()\n\n\t// iterate over shows, visuals and groups\n\tfor _, group := range visual.Groups() {\n\t\tfor _, parameter := range group.Effect.Parameters() {\n\t\t\tif parameter.ID == id {\n\t\t\t\treturn group, parameter\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, nil\n}", "func (pr *prepareResult) parameterField(idx int) *p.ParameterField {\n\treturn pr.parameterFields[idx]\n}", "func (param *LoadParams) Info() string {\n\treturn fmt.Sprintf(\"current loader[qps=%d, durations=%v,timeout=%v]\", param.QPS, param.Duration, param.Timeout)\n}", "func (z RequestData) Param() interface{} {\n\treturn z.p\n}", "func (tr *TaskDefinition) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (c *C) Param(name string) string {\n\treturn c.params.ByName(name)\n}", "func (native *OpenGL) GetProgramParameter(program uint32, param uint32) int32 {\n\tresult := int32(0)\n\tgl.GetProgramiv(program, param, &result)\n\treturn result\n}", "func (tr *SQLContainer) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (s *Instruction) Param() *Param {\n\tif len(s.Params) > 0 {\n\t\treturn s.Params[0]\n\t}\n\treturn nil\n}", "func (*SignatureHelpClientCapabilities_SignatureInformation_ParameterInformation) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{114, 0, 0}\n}", "func (obj *GenericMeasure) GetInfo(ctx context.Context) (*NxInfo, error) {\n\tresult := &struct {\n\t\tInfo *NxInfo `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (tr *SQLFunction) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (key Key) GetParam(param KeyParamID) (res []byte, err error) {\n\tvar slen C.DWORD\n\tif C.CryptGetKeyParam(key.hKey, C.DWORD(param), nil, &slen, 0) == 0 {\n\t\terr = getErr(\"Error getting param's value length for key\")\n\t\treturn\n\t}\n\n\tbuf := make([]byte, slen)\n\tif C.CryptGetKeyParam(key.hKey, C.DWORD(param), (*C.BYTE)(unsafe.Pointer(&buf[0])), &slen, 0) == 0 {\n\t\terr = getErr(\"Error getting param for key\")\n\t\treturn\n\t}\n\n\tres = buf[0:int(slen)]\n\treturn\n}", "func (r *ManagedServiceUpdateRequest) Parameter(name string, value interface{}) *ManagedServiceUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func getParameters(c *cli.Context) error {\n\tif !isSystemRunning() {\n\t\treturn nil\n\t}\n\t_, _, _, controllers := getIPAddresses()\n\n\tparams := sendCommandToControllers(controllers, \"GetParams\", \"\")\n\tfmt.Println(params)\n\n\treturn nil\n}", "func (p Parameter) Name() string {\n\treturn string(p)\n}", "func (tr *NotebookWorkspace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (r *ManagedServiceGetRequest) Parameter(name string, value interface{}) *ManagedServiceGetRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (o BuildSpecOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v BuildSpec) []BuildSpecParameters { return v.Parameters }).(BuildSpecParametersArrayOutput)\n}", "func (rc *Ctx) Param(name string) (string, error) {\n\tif rc.routeParams != nil {\n\t\trouteValue := rc.routeParams.Get(name)\n\t\tif len(routeValue) > 0 {\n\t\t\treturn routeValue, nil\n\t\t}\n\t}\n\tif rc.request != nil {\n\t\tif rc.request.URL != nil {\n\t\t\tqueryValue := rc.request.URL.Query().Get(name)\n\t\t\tif len(queryValue) > 0 {\n\t\t\t\treturn queryValue, nil\n\t\t\t}\n\t\t}\n\t\tif rc.request.Header != nil {\n\t\t\theaderValue := rc.request.Header.Get(name)\n\t\t\tif len(headerValue) > 0 {\n\t\t\t\treturn headerValue, nil\n\t\t\t}\n\t\t}\n\n\t\tformValue := rc.request.FormValue(name)\n\t\tif len(formValue) > 0 {\n\t\t\treturn formValue, nil\n\t\t}\n\n\t\tcookie, cookieErr := rc.request.Cookie(name)\n\t\tif cookieErr == nil && len(cookie.Value) != 0 {\n\t\t\treturn cookie.Value, nil\n\t\t}\n\t}\n\n\treturn \"\", newParameterMissingError(name)\n}", "func (config AudioConfig) params() (map[string]string, error) {\n\tparams, _ := config.BaseFile.params()\n\n\tif config.Duration != 0 {\n\t\tparams[\"duration\"] = strconv.Itoa(config.Duration)\n\t}\n\n\tif config.Performer != \"\" {\n\t\tparams[\"performer\"] = config.Performer\n\t}\n\tif config.Title != \"\" {\n\t\tparams[\"title\"] = config.Title\n\t}\n\tif config.Caption != \"\" {\n\t\tparams[\"caption\"] = config.Caption\n\t\tif config.ParseMode != \"\" {\n\t\t\tparams[\"parse_mode\"] = config.ParseMode\n\t\t}\n\t}\n\n\treturn params, nil\n}", "func (this *Device) Info() IDeviceInfo {\n return this.info\n}", "func GetParam(www http.ResponseWriter, req *http.Request, name string, dflt string) (rv string) {\n\tfound := false\n\tvalue := dflt\n\n\tmethod := req.Method\n\tif dbFlag[\"GetVal\"] {\n\t\tfmt.Printf(\"GetVar name=%s req.Method %s AT:%s\\n\", name, method, godebug.LF())\n\t}\n\tif method == \"POST\" || method == \"PUT\" {\n\t\tif str := req.PostFormValue(name); str != \"\" {\n\t\t\tvalue = str\n\t\t\tfound = true\n\t\t}\n\t} else if method == \"GET\" || method == \"DELETE\" {\n\t\tif dbFlag[\"GetVal\"] {\n\t\t\tfmt.Printf(\"AT:%s\\n\", godebug.LF())\n\t\t}\n\t\tqq := req.URL.Query()\n\t\tstrArr, ok := qq[name]\n\t\tif dbFlag[\"GetVal\"] {\n\t\t\tfmt.Printf(\"AT:%s strArr = %s ok = %v\\n\", godebug.LF(), godebug.SVar(strArr), ok)\n\t\t}\n\t\tif ok {\n\t\t\tif dbFlag[\"GetVal\"] {\n\t\t\t\tfmt.Printf(\"AT:%s\\n\", godebug.LF())\n\t\t\t}\n\t\t\tif len(strArr) > 0 {\n\t\t\t\tif dbFlag[\"GetVal\"] {\n\t\t\t\t\tfmt.Printf(\"AT:%s\\n\", godebug.LF())\n\t\t\t\t}\n\t\t\t\tvalue = strArr[0]\n\t\t\t\tfound = true\n\t\t\t} else {\n\t\t\t\tif dbFlag[\"GetVal\"] {\n\t\t\t\t\tfmt.Printf(\"AT:%s\\n\", godebug.LF())\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Multiple values for [%s]\\n\", name)\n\t\t\t\tfound = false\n\t\t\t}\n\t\t}\n\t}\n\tif found {\n\t\trv = value\n\t}\n\treturn\n}", "func (f *linkFrame) GetParamStr(k string) (str []byte, err error) {\n v, ok := f.param[k]\n if ok {\n // we got it\n var s []byte\n switch v.(type) {\n case []byte:\n s = v.([]byte)\n str = make([]byte, len(s))\n copy(str, s)\n break\n default:\n err = errors.New(\"param value \"+k+\" not bytes\")\n }\n } else {\n err = errors.New(\"params don't have \"+k)\n }\n return\n}", "func (tr *CassandraTable) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o BuildSpecPtrOutput) Parameters() BuildSpecParametersArrayOutput {\n\treturn o.ApplyT(func(v *BuildSpec) []BuildSpecParameters {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Parameters\n\t}).(BuildSpecParametersArrayOutput)\n}", "func (c *Ctx) Param(name string) string {\n\n\tfor _, entry := range c.params {\n\t\tif entry.Key == name {\n\t\t\treturn entry.Value\n\t\t}\n\t}\n\n\treturn blank\n}", "func (c *Context)Param(key string) string{\n\tvalue, _ := c.Params[key]\n\treturn value\n}", "func (config VoiceConfig) params() (map[string]string, error) {\n\tparams, _ := config.BaseFile.params()\n\n\tif config.Duration != 0 {\n\t\tparams[\"duration\"] = strconv.Itoa(config.Duration)\n\t}\n\tif config.Caption != \"\" {\n\t\tparams[\"caption\"] = config.Caption\n\t\tif config.ParseMode != \"\" {\n\t\t\tparams[\"parse_mode\"] = config.ParseMode\n\t\t}\n\t}\n\n\treturn params, nil\n}", "func (paramMgr *paramManager) GetParam(name string) (string, error) {\n\tssmAPI := paramMgr.ssmAPI\n\n\tlog.Debug(\"Getting param '%s'\", name)\n\n\tinput := &ssm.GetParametersInput{\n\t\tNames: []*string{aws.String(name)},\n\t\tWithDecryption: aws.Bool(true),\n\t}\n\n\toutput, err := ssmAPI.GetParameters(input)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(output.Parameters) != 1 {\n\t\treturn \"\", nil\n\t}\n\n\treturn aws.StringValue(output.Parameters[0].Value), nil\n}", "func (config VideoNoteConfig) params() (map[string]string, error) {\n\tparams, _ := config.BaseFile.params()\n\n\tif config.Length != 0 {\n\t\tparams[\"length\"] = strconv.Itoa(config.Length)\n\t}\n\tif config.Duration != 0 {\n\t\tparams[\"duration\"] = strconv.Itoa(config.Duration)\n\t}\n\n\treturn params, nil\n}", "func (rc *RemoteConfig) GetParam(key string, def string) string {\n\tparam, ok := rc.Params[key]\n\tif !ok {\n\t\treturn def\n\t}\n\treturn param\n}", "func (o *InlineObject4) GetParam() string {\n\tif o == nil || o.Param == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Param\n}", "func (p *MetricProvider) GetParam() event.MetricTemplate {\n\treturn p.template\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func (tr *SQLStoredProcedure) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (tr *SQLTrigger) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func (o *MetricDefaultAggregation) GetParameter() float64 {\n\tif o == nil || o.Parameter == nil {\n\t\tvar ret float64\n\t\treturn ret\n\t}\n\treturn *o.Parameter\n}", "func (n *Norm) Parameters() []*autofunc.Variable {\n\tres := make([]*autofunc.Variable, len(n.Weights)+len(n.Mags))\n\tcopy(res, n.Weights)\n\tcopy(res[len(n.Weights):], n.Mags)\n\n\tnormRes, rv := n.newNormRResult(autofunc.RVector{})\n\tnet := n.Creator.Create(normRes.NormPool)\n\tparams := net.Parameters()\n\tfor _, param := range params {\n\t\tif _, ok := rv[param]; !ok {\n\t\t\tres = append(res, param)\n\t\t}\n\t}\n\n\treturn res\n}", "func (p Parameter) viewParameter(viewrule bool) {\n\tfmt.Println(\"Parameter-----\")\n\tfmt.Println(\"Delay:\", p.Delay, \"Arity:\", p.Arity)\n\n\tfmt.Print(\"Transcript=\")\n\tfmt.Print(p.Transcript.Arr)\n\tfmt.Println(\"\")\n\n\tif viewrule {\n\t\tfmt.Println(\"Ruleset={\")\n\t\tfor b1 := 1; b1 <= 132; b1++ {\n\t\t\tr2s, ok := p.Rule.rule[strconv.Itoa(b1)]\n\t\t\tif ok {\n\t\t\t\tsort.Strings(r2s)\n\t\t\t\tfor _, r2 := range r2s {\n\t\t\t\t\tb2, ok2 := strconv.Atoi(r2)\n\t\t\t\t\tif ok2 == nil && b1 <= b2 {\n\t\t\t\t\t\tfmt.Println(\"(\" + strconv.Itoa(b1) + \",\" + strconv.Itoa(b2) + \"),\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfmt.Println(\"}----end\")\n\t\t/*\n\t\t\tfmt.Println(\"Ruleset={\")\n\t\t\tfor b1, v := range p.Rule.rule {\n\t\t\t\tfor _, b2 := range v {\n\t\t\t\t\tfmt.Println(\" -(\", b1, b2, \")\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tfmt.Println(\"}----end\")\n\t\t*/\n\t}\n}", "func (r *ClusterUpdateRequest) Parameter(name string, value interface{}) *ClusterUpdateRequest {\n\thelpers.AddValue(&r.query, name, value)\n\treturn r\n}", "func (o SystemParameterOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v SystemParameter) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (m *Immutable) Parameters() map[string]string {\n\treturn m.contained.Parameters()\n}", "func (c *Context) Param(name string) string {\n\treturn c.Params.Get(name)\n}", "func (area *Circle) Param() string {\n\treturn fmt.Sprintf(\"%.6f:%.6f:%.6f\", area.Lat(), area.Lng(), area.Radius)\n}", "func Param(ctx context.Context, name string) string {\n\treturn Params(ctx).ByName(name)\n}", "func (r *Request) GetParam(name string) string {\n if r.Params == nil || len(r.Params) == 0 {\n return \"\"\n }\n params, ok := r.Params[name]\n if !ok || len(params) == 0 {\n return \"\"\n }\n return params[0]\n}", "func (debugging *debuggingOpenGL) GetShaderParameter(shader uint32, param uint32) int32 {\n\tdebugging.recordEntry(\"GetShaderParameter\", shader, param)\n\tresult := debugging.gl.GetShaderParameter(shader, param)\n\tdebugging.recordExit(\"GetShaderParameter\", result)\n\treturn result\n}", "func (o SettingsSectionDescriptionOutput) Parameters() SettingsParameterDescriptionArrayOutput {\n\treturn o.ApplyT(func(v SettingsSectionDescription) []SettingsParameterDescription { return v.Parameters }).(SettingsParameterDescriptionArrayOutput)\n}", "func GetParameters(ctx *gin.Context) (time.Time, time.Time, string, error) {\n\tvar errorMsg = \"\"\n\n\tartist := ctx.Query(\"artist\")\n\n\tfrom, err := time.Parse(Parse_Layout, ctx.Query(\"from\"))\n\tif err != nil && errorMsg == \"\" {\n\t\terrorMsg = \"Invalid or missing 'From' parameter\"\n\t}\n\n\tuntil, err := time.Parse(Parse_Layout, ctx.Query(\"until\"))\n\tif err != nil && errorMsg == \"\" {\n\t\terrorMsg = \"Invalid or missing 'Until' parameter\"\n\t}\n\n\tif from.After(until) && errorMsg == \"\" {\n\t\terrorMsg = \"'from' is greater than 'until'\"\n\t}\n\tif errorMsg != \"\" {\n\t\treturn from, until, artist, errors.New(errorMsg)\n\t} else {\n\t\treturn from, until, artist, nil\n\t}\n\n}", "func getParameterString(parameters map[string]string) string {\n\tvar str string\n\tfor key, value := range parameters {\n\t\tif str != \"\" {\n\t\t\tstr += \",\"\n\t\t}\n\t\tstr += key + \"=\" + value\n\t}\n\n\treturn str\n}" ]
[ "0.6727691", "0.6196759", "0.5887389", "0.58802027", "0.57353175", "0.5718226", "0.5701319", "0.57007605", "0.56526715", "0.5644817", "0.5642984", "0.56409687", "0.5614138", "0.5611334", "0.56032884", "0.55377084", "0.5532125", "0.5519996", "0.55129033", "0.55052924", "0.550265", "0.5485546", "0.5467156", "0.5459958", "0.54572725", "0.53959846", "0.5374939", "0.5358329", "0.5340314", "0.53376573", "0.5329829", "0.53240174", "0.5311347", "0.52825725", "0.5281063", "0.5272446", "0.52598196", "0.52555215", "0.52488154", "0.52441835", "0.52388704", "0.52336043", "0.52315134", "0.5220584", "0.5218754", "0.52147627", "0.5195975", "0.5193972", "0.51906765", "0.51749516", "0.5166215", "0.5163033", "0.51564", "0.51556265", "0.51500136", "0.5149788", "0.5143572", "0.5129754", "0.5122174", "0.5119689", "0.5099075", "0.50964415", "0.50869143", "0.50789315", "0.5067239", "0.505267", "0.50517565", "0.50468177", "0.5031398", "0.5027538", "0.5022322", "0.50136393", "0.500165", "0.4998353", "0.49883956", "0.4978837", "0.4970896", "0.49707213", "0.49690878", "0.49624348", "0.49605387", "0.4957051", "0.49565703", "0.4954309", "0.49471042", "0.49465176", "0.49443078", "0.49434423", "0.492443", "0.4919517", "0.49158007", "0.49128816", "0.49095228", "0.49077994", "0.49058616", "0.4898639", "0.4898441", "0.48946422", "0.48922026", "0.48912275" ]
0.75489753
0
NOTE: Not implement yet Retrieve the index of the first data parameter of a particular data type. The return code can therefore be used to check whether the DSP supports specific functionality through data parameters of certain types without the need to pass in 'index'.
func (d *DSP) DataParameterIndex(datatype C.int, index *C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) ParameterData(index C.int, data **interface{}, length *C.uint, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterData(FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (*System_Cpu_Index_Union_Uint32) Is_System_Cpu_Index_Union() {}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func FindIndex(data, callback interface{}, args ...int) (int, error) {\n\tvar err error\n\n\tresult := func(err *error) int {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn -1\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn -1\n\t\t}\n\n\t\tcallbackValue, callbackType := inspectFunc(err, callback)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tcallbackTypeNumIn := validateFuncInputForSliceLoop(err, callbackType, dataValue)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tvalidateFuncOutputOneVarBool(err, callbackType, true)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn -1\n\t\t}\n\n\t\tstartIndex := 0\n\t\tif len(args) > 0 {\n\t\t\tstartIndex = args[0]\n\t\t}\n\n\t\tresult := -1\n\n\t\tforEachSliceStoppable(dataValue, dataValueLen, func(each reflect.Value, i int) bool {\n\t\t\tif i < startIndex {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tres := callFuncSliceLoop(callbackValue, each, i, callbackTypeNumIn)\n\t\t\tif res[0].Bool() {\n\t\t\t\tresult = i\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\treturn true\n\t\t})\n\n\t\treturn result\n\t}(&err)\n\n\treturn result, err\n}", "func (d *DSP) ParameterInt(index C.int, value *C.int, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInt(FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (c Config) IsDataTypeSupported() bool {\n\tsupported := false\n\tfor _, v := range []string{\"int\", \"float\", \"bool\"} {\n\t\tif v == c.Val {\n\t\t\tsupported = true\n\t\t\tbreak\n\t\t}\n\t}\n\treturn supported\n}", "func (*OpenconfigSystem_System_Cpus_Cpu_State_Index_Union_Uint32) Is_OpenconfigSystem_System_Cpus_Cpu_State_Index_Union() {}", "func (*System_Cpu_Index_Union_E_OpenconfigSystem_Cpu_Index) Is_System_Cpu_Index_Union() {}", "func (e TPMFmt1Error) Parameter() (bool, int) {\n\tif e.subject != parameterRelated {\n\t\treturn false, 0\n\t}\n\treturn true, e.index\n}", "func (a aid) dataType() uint32 { return uint32(a & math.MaxUint32) }", "func getNumber(api *StackAPI, index int, numType interface{}) bool {\n\tif !api.IsNumber(index) {\n\t\tapi.ArgTypeError(index, ValueTNumber)\n\t\treturn false\n\t}\n\n\tif num, ok := numType.(*int); ok {\n\t\t*num = int(api.GetNumber(index))\n\t\treturn true\n\t}\n\tpanic(\"assert\")\n}", "func (*OpenconfigSystem_System_Cpus_Cpu_State_Index_Union_E_OpenconfigSystem_System_Cpus_Cpu_State_Index) Is_OpenconfigSystem_System_Cpus_Cpu_State_Index_Union() {}", "func (sl *Slice) IndexByType(t reflect.Type, embeds bool, startIdx int) (int, bool) {\n\tif embeds {\n\t\treturn sl.IndexByFunc(startIdx, func(ch Ki) bool { return ch.TypeEmbeds(t) })\n\t}\n\treturn sl.IndexByFunc(startIdx, func(ch Ki) bool { return ch.Type() == t })\n}", "func countParameterType(b bindingInterface, i interface{}) (ret int) {\n\tt := reflect.TypeOf(i)\n\tret = 0\n\ta := parameterTypeArray(b, true)\n\tfor _, v := range a {\n\t\tif v == t {\n\t\t\tret++\n\t\t}\n\t}\n\treturn\n}", "func (part *PartSupported) Index() byte {\n\treturn part.index\n}", "func TestSupportedType1(t *testing.T) {\n\tfor _, typeDef := range []string{\"string\", \"integer\", \"float\", \"boolean\", \"array\", \"object\"} {\n\t\tif !supportedType(typeDef) {\n\t\t\tt.Errorf(\"Supported Type '%s' Returned As Unsupported\", typeDef)\n\t\t}\n\t}\n}", "func IndexOf(data interface{}, search interface{}, args ...int) (int, error) {\n\tvar err error\n\n\tresult := func(err *error) int {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn -1\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn -1\n\t\t}\n\n\t\tstartIndex := 0\n\t\tif len(args) > 0 {\n\t\t\tstartIndex = args[0]\n\t\t}\n\n\t\tif startIndex >= dataValueLen {\n\t\t\treturn -1\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn -1\n\t\t}\n\n\t\tresult := -1\n\n\t\tforEachSliceStoppable(dataValue, dataValueLen, func(each reflect.Value, i int) bool {\n\t\t\tif startIndex > -1 {\n\t\t\t\tif startIndex > 0 && i < startIndex {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\n\t\t\t\tif each.Interface() == search && result == -1 {\n\t\t\t\t\tresult = i\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif i > (startIndex*-1)-1 {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\n\t\t\t\tiFromRight := dataValueLen - i - 1\n\t\t\t\teachFromRight := dataValue.Index(iFromRight)\n\n\t\t\t\tif eachFromRight.Interface() == search {\n\t\t\t\t\tresult = iFromRight\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true\n\t\t})\n\n\t\treturn result\n\t}(&err)\n\n\treturn result, err\n}", "func (args *SPH_UDF_ARGS) arg_type(idx int) SPH_UDF_TYPE {\n\treturn *args.typeptr(idx)\n}", "func (*InstPtrToInt) isValue() {}", "func (f *FieldSet) DataType(idx int) DataType {\n\treturn f.fields[idx].typeCode().dataType()\n}", "func asSupportedParameter(param string) (string, bool) {\n\tlower := strings.ToLower(param)\n\treturn lower, lowerCaseParameters[lower]\n}", "func (*Functions) IndexOf(array interface{}, value interface{}) int {\n\ta := reflect.ValueOf(array)\n\tfor i, c := 0, a.Len(); i < c; i++ {\n\t\tif a.Index(i).Interface() == value {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "func (args *SPH_UDF_ARGS) typeptr(idx int) *SPH_UDF_TYPE {\n\treturn (*SPH_UDF_TYPE)(unsafe.Pointer(uintptr(unsafe.Pointer(args.arg_types)) +\n\t\tunsafe.Sizeof(*args.arg_types)*uintptr(idx)))\n}", "func isIndexTypeSupportedByStrategy(indexType PropertyIndexType, strategy string) bool {\n\tswitch indexType {\n\tcase IndexTypePropLength,\n\t\tIndexTypePropNull,\n\t\tIndexTypePropValue:\n\t\treturn lsmkv.IsExpectedStrategy(strategy, lsmkv.StrategySetCollection, lsmkv.StrategyRoaringSet)\n\tcase IndexTypePropSearchableValue:\n\t\treturn lsmkv.IsExpectedStrategy(strategy, lsmkv.StrategyMapCollection)\n\t}\n\treturn false\n}", "func (self *SinglePad) Index() int{\n return self.Object.Get(\"index\").Int()\n}", "func GetSubroutineIndex(program uint32, shadertype uint32, name *int8) uint32 {\n ret := C.glowGetSubroutineIndex(gpGetSubroutineIndex, (C.GLuint)(program), (C.GLenum)(shadertype), (*C.GLchar)(unsafe.Pointer(name)))\n return (uint32)(ret)\n}", "func (d *DSP) SetParameterData(index C.int, data *interface{}, length C.uint) error {\n\t//FMOD_RESULT F_API FMOD_DSP_SetParameterData(FMOD_DSP *dsp, int index, void *data, unsigned int length);\n\treturn ErrNoImpl\n}", "func GetSubroutineIndex(program uint32, shadertype uint32, name *uint8) uint32 {\n\tret, _, _ := syscall.Syscall(gpGetSubroutineIndex, 3, uintptr(program), uintptr(shadertype), uintptr(unsafe.Pointer(name)))\n\treturn (uint32)(ret)\n}", "func (def *Definition) SetValueWithIndex(name string, index []uint32, x interface{}) error {\n\ttyp, err := def.SearchType(name)\n\tif err != nil {\n\t\tCentral.Log.Debugf(\"Search type error: %v\", err)\n\t\treturn err\n\t}\n\tif len(index) == 2 && typ.Type() != FieldTypeMultiplefield && index[1] > 0 {\n\t\treturn NewGenericError(62)\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Set value %s with index=%#v value=%v\", name, index, x)\n\t}\n\tvar val IAdaValue\n\tif !typ.HasFlagSet(FlagOptionPE) {\n\t\tCentral.Log.Debugf(\"Search name ....%s\", name)\n\t\tval = def.Search(name)\n\t\tif val == nil {\n\t\t\treturn NewGenericError(63, name)\n\t\t}\n\t} else {\n\t\tCentral.Log.Debugf(\"Search indexed period group ....%s %d\", name, index)\n\t\tval, err = def.SearchByIndex(name, index, true)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif val == nil {\n\t\t\treturn NewGenericError(127, name)\n\t\t}\n\t}\n\tif Central.IsDebugLevel() {\n\t\tCentral.Log.Debugf(\"Found value to add to %s[%d,%d] type=%v %T %T index=%#v\", val.Type().Name(),\n\t\t\tval.PeriodIndex(), val.MultipleIndex(), val.Type().Type().name(), val, val.Type(), index)\n\t}\n\tswitch val.Type().Type() {\n\tcase FieldTypeMultiplefield:\n\t\tsv := val.(*StructureValue)\n\t\tst := sv.Type().(*StructureType)\n\t\t//sv.Type().\n\t\t//\tsv.Elements = append(sv.Elements, subValue)\n\t\t// if len(sv.Elements) == 0 {\n\t\t// \te := &structureElement{}\n\t\t// \tCentral.Log.Debugf(\"Add empty element to %s\",sv.Type().Name())\n\t\t// \tsv.Elements = append(sv.Elements, e)\n\t\t// }\n\t\t// if len(sv.Elements[0].Values) >= int(index[0]) {\n\t\t// \tCentral.Log.Debugf(\"Adapt %#v\", st.SubTypes)\n\t\t// \tsubValue := sv.Elements[0].Values[int(index[0]-1)]\n\t\t// \terr = subValue.SetValue(x)\n\t\t// } else {\n\t\tsubValue, serr := st.SubTypes[0].Value()\n\t\tif serr != nil {\n\t\t\treturn serr\n\t\t}\n\t\terr = subValue.SetValue(x)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpeIndex := uint32(0)\n\t\tcurIndex := 0\n\t\tif typ.HasFlagSet(FlagOptionPE) {\n\t\t\tif len(index) > 0 {\n\t\t\t\tpeIndex = index[curIndex]\n\t\t\t\tcurIndex++\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tmuIndex := uint32(0)\n\t\tif typ.Type() == FieldTypeMultiplefield || typ.HasFlagSet(FlagOptionMUGhost) {\n\t\t\tif len(index) > curIndex {\n\t\t\t\tmuIndex = index[curIndex]\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"XXX\")\n\t\t\t}\n\t\t}\n\t\tCentral.Log.Debugf(\"Set indexes to PE=%d MU=%d current=%d\", peIndex, muIndex, curIndex)\n\t\terr = sv.addValue(subValue, peIndex, muIndex)\n\t\t// subValue.setMultipleIndex(index[0])\n\t\t// sv.Elements[0].Values = append(sv.Elements[0].Values, subValue)\n\t\t// }\n\t\tif Central.IsDebugLevel() {\n\t\t\tCentral.Log.Debugf(\"Add Multiple field, elements=%d\", len(sv.Elements))\n\t\t}\n\tdefault:\n\t\terr = val.SetValue(x)\n\t}\n\treturn err\n}", "func LastIndexOf(data interface{}, search interface{}, args ...int) (int, error) {\n\tvar err error\n\n\tresult := func(err *error) int {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn -1\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn -1\n\t\t}\n\n\t\tstartIndex := dataValueLen - 1\n\t\tif len(args) > 0 {\n\t\t\tstartIndex = args[0]\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn -1\n\t\t}\n\n\t\tresult := -1\n\n\t\tforEachSliceStoppable(dataValue, dataValueLen, func(each reflect.Value, i int) bool {\n\t\t\tif startIndex > -1 {\n\t\t\t\tiFromRight := startIndex - i\n\t\t\t\tif iFromRight > (dataValueLen-1) || iFromRight < 0 {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\n\t\t\t\teachFromRight := dataValue.Index(iFromRight)\n\t\t\t\tif eachFromRight.Interface() == search && result == -1 {\n\t\t\t\t\tresult = iFromRight\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tiFromRight := dataValueLen + startIndex - i\n\t\t\t\tif iFromRight > (dataValueLen-1) || iFromRight < 0 {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\n\t\t\t\teachFromRight := dataValue.Index(iFromRight)\n\t\t\t\tif eachFromRight.Interface() == search && result == -1 {\n\t\t\t\t\tresult = iFromRight\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true\n\t\t})\n\n\t\treturn result\n\t}(&err)\n\n\treturn result, err\n}", "func (a *ArrayObject) index(t *thread, args []Object, sourceLine int) Object {\n\tif len(args) != 1 {\n\t\treturn t.vm.initErrorObject(errors.ArgumentError, sourceLine, \"Expect 1 arguments. got=%d\", len(args))\n\t}\n\n\ti := args[0]\n\tindex, ok := i.(*IntegerObject)\n\n\tif !ok {\n\t\treturn t.vm.initErrorObject(errors.TypeError, sourceLine, errors.WrongArgumentTypeFormat, classes.IntegerClass, args[0].Class().Name)\n\t}\n\n\tnormalizedIndex := a.normalizeIndex(index)\n\n\tif normalizedIndex == -1 {\n\t\treturn NULL\n\t}\n\n\treturn a.Elements[normalizedIndex]\n}", "func isBasicType(v interface{}) bool {\n\t_, isBasicType := schema.DataTypeFromString[toString(v)]\n\treturn isBasicType\n}", "func DataType(){\n\tBool()\n\tFloat()\n\tComplex()\n\tStdInput()\n}", "func (qr *queryResult) ColumnTypeLength(idx int) (int64, bool) { return qr.fields[idx].TypeLength() }", "func (qr *queryResult) ColumnTypeLength(idx int) (int64, bool) { return qr.fields[idx].TypeLength() }", "func (k *K) Index(i int) interface{} {\n\tif k.Type < K0 || k.Type > XT {\n\t\treturn nil\n\t}\n\tif k.Len() == 0 {\n\t\t// need to return null of that type\n\t\tif k.Type == K0 {\n\t\t\treturn &K{K0, NONE, make([]*K, 0)}\n\t\t}\n\t\treturn nil\n\n\t}\n\tif k.Type >= K0 && k.Type <= KT {\n\t\treturn reflect.ValueOf(k.Data).Index(i).Interface()\n\t}\n\t// case for table\n\t// need to return dict with header\n\tif k.Type != XT {\n\t\treturn nil\n\t}\n\tvar t = k.Data.(Table)\n\treturn &K{XD, NONE, t.Index(i)}\n}", "func (this *Tuple) Index(item interface{}, start int) int {\n\tfor i := start; i < this.Len(); i++ {\n\t\tif TupleElemEq(this.Get(i), item) {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "func (args Arguments) Int(index int) int {\n\tvar s int\n\tvar ok bool\n\tif s, ok = args.Get(index).(int); !ok {\n\t\tpanic(fmt.Sprintf(\"assert: arguments: Int(%d) failed because object wasn't correct type: %v\", index, args.Get(index)))\n\t}\n\treturn s\n}", "func isTypeParam(_ *ast.Field, _ []*ast.FuncDecl, _ []*ast.FuncLit) bool {\n\treturn false\n}", "func (tf *TickFile) checkDataType() error {\n\tif tf.dataType.Kind() == reflect.Struct {\n\t\tn := tf.dataType.NumField()\n\t\tvar fields []reflect.StructField\n\t\tfor i := 0; i < n; i++ {\n\t\t\tif tf.dataType.Field(i).Name != \"_\" {\n\t\t\t\tfields = append(fields, tf.dataType.Field(i))\n\t\t\t}\n\t\t}\n\t\tif len(fields) != len(tf.itemSection.Fields) {\n\t\t\treturn fmt.Errorf(\"given type has %d fields, was expecting %d\", len(fields), len(tf.itemSection.Fields))\n\t\t}\n\t\tfor i := 0; i < len(fields); i++ {\n\t\t\tdataField := fields[i]\n\t\t\tfileField := tf.itemSection.Fields[i]\n\t\t\tif dataField.Type.Kind() != fieldTypeToKind[fileField.Type] {\n\t\t\t\treturn fmt.Errorf(\"was not expecting %w\", dataField.Type)\n\t\t\t}\n\t\t\tif dataField.Offset != uintptr(fileField.Offset) {\n\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\"got different offsets for field %d: %d %d\",\n\t\t\t\t\ti,\n\t\t\t\t\tdataField.Offset,\n\t\t\t\t\tfileField.Offset)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif len(tf.itemSection.Fields) != 1 {\n\t\t\treturn fmt.Errorf(\"got a basic type, was expecting a struct\")\n\t\t}\n\t\tif tf.dataType.Name() != tf.itemSection.Fields[0].Name {\n\t\t\treturn fmt.Errorf(\"got different name, was expecting %s got %s\",\n\t\t\t\ttf.itemSection.Fields[0].Name,\n\t\t\t\ttf.dataType.Name())\n\t\t}\n\t\tif tf.dataType.Kind() != fieldTypeToKind[tf.itemSection.Fields[0].Type] {\n\t\t\treturn fmt.Errorf(\"got different type, was expecting %s, got %s\",\n\t\t\t\tfieldTypeToKind[tf.itemSection.Fields[0].Type].String(),\n\t\t\t\ttf.dataType.Kind().String())\n\t\t}\n\t}\n\n\treturn nil\n}", "func (t *IntDataType) Type() interface{} {\n\treturn 0\n}", "func (d *DSP) ParameterBool(index C.int, value *C.FMOD_BOOL, valuestr *C.char, valuestrlen C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterBool(FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);\n\treturn ErrNoImpl\n}", "func (dec *Decoder) Index() int {\n\treturn dec.arrayIndex\n}", "func (*InstIntToPtr) isValue() {}", "func (el *Elements) Index(name string) (int, bool) {\n\tfor n, e := range *el {\n\t\tif e.Name == name {\n\t\t\treturn n, true\n\t\t}\n\t}\n\treturn 0, false\n}", "func (d *Driver) checkIdx(i int) error {\n\tif i <= 0 || i > d.Drivers {\n\t\treturn fmt.Errorf(\"max72xx: bad index, %d\", i)\n\t}\n\treturn nil\n}", "func interpretInt16Type(originalValue interface{}) (func(value interface{}) (int16, bool), error) {\n\tswitch value := originalValue.(type) {\n\tcase int16:\n\t\treturn func(value interface{}) (int16, bool) {\n\t\t\t// Have to recompute value of ok even if match to ensure that subsequent values matches same type\n\t\t\tv, ok := value.(int16)\n\t\t\treturn v, ok\n\t\t}, nil\n\tcase int8:\n\t\treturn func(value interface{}) (int16, bool) {\n\t\t\tv, ok := value.(int8)\n\t\t\treturn int16(v), ok\n\t\t}, nil\n\tdefault:\n\t\treturn nil, NewErrInvalidColumnType(value, int16(0))\n\t}\n}", "func Idx(e, slice interface{}) int {\n\tv := rValueOf(slice)\n\tL, I := v.Len(), -1\n\tfor i := 0; i < L; i++ {\n\t\tif v.Index(i).Interface() == e {\n\t\t\tI = i\n\t\t\tbreak\n\t\t}\n\t}\n\treturn I\n}", "func (this *Array) isIndexOutOfRange(index uint) bool{\n\tif index >= uint(cap(this.data)){\n\t\treturn true\n\t}\n\treturn false\n}", "func (this *DefMethod) GetParamSchema(indx int) *MethParam {\n\tfor _, v := range this.Paras {\n\t\tif v.Indx == indx {\n\t\t\treturn &v\n\t\t}\n\t}\n\treturn nil\n}", "func (p *PKGBUILD) GetIndex(i int) (info *atom.Info, isBlank bool, ok bool) {\n\tif ok = i >= 0 && i < len(p.atoms); !ok {\n\t\treturn\n\t}\n\tvar isNamed bool\n\tif info, isNamed = p.info.GetByIndex(i); !isNamed {\n\t\tisBlank = p.atoms[i].GetType() == atom.Blank\n\t}\n\treturn\n}", "func (h *Header) index(key string) (int, bool) {\n\tfor i := 0; i < len(h.slice); i += 2 {\n\t\tif h.slice[i] == key {\n\t\t\treturn i, true\n\t\t}\n\t}\n\treturn -1, false\n}", "func (a Slice[T]) Index(element T) int {\n\tfor i, o := range a {\n\t\tif o == element {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "func (p *GetField) Index() int { return p.fieldIndex }", "func IndexPointer(xtype uint32, stride int32, pointer unsafe.Pointer) {\n\tsyscall.Syscall(gpIndexPointer, 3, uintptr(xtype), uintptr(stride), uintptr(pointer))\n}", "func (*Interface_Subinterface_Vlan_VlanId_Union_Uint16) Is_Interface_Subinterface_Vlan_VlanId_Union() {\n}", "func (me TdtypeType) IsInteger() bool { return me.String() == \"integer\" }", "func (*Component_Type_Union_E_OpenconfigPlatformTypes_OPENCONFIG_HARDWARE_COMPONENT) Is_Component_Type_Union() {\n}", "func GetSubroutineIndex(program uint32, shadertype uint32, name *uint8) uint32 {\n\tret := C.glowGetSubroutineIndex(gpGetSubroutineIndex, (C.GLuint)(program), (C.GLenum)(shadertype), (*C.GLchar)(unsafe.Pointer(name)))\n\treturn (uint32)(ret)\n}", "func GetSubroutineIndex(program uint32, shadertype uint32, name *uint8) uint32 {\n\tret := C.glowGetSubroutineIndex(gpGetSubroutineIndex, (C.GLuint)(program), (C.GLenum)(shadertype), (*C.GLchar)(unsafe.Pointer(name)))\n\treturn (uint32)(ret)\n}", "func (*InstFPExt) isValue() {}", "func First(data interface{}) (interface{}, error) {\n\tvar err error\n\n\tresult := func(err *error) interface{} {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn nil\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn nil\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn dataValue.Index(0).Interface()\n\t}(&err)\n\n\treturn result, err\n}", "func (word ControlWord) Parameter() uint32 {\n\treturn (uint32(word) >> 0) & ControlWordParamLimit\n}", "func (bA *CompactBitArray) GetIndex(i int) bool {\n\tif bA == nil {\n\t\treturn false\n\t}\n\tif i < 0 || i >= bA.Count() {\n\t\treturn false\n\t}\n\n\treturn bA.Elems[i>>3]&(1<<uint8(7-(i%8))) > 0\n}", "func IndexPointer(xtype uint32, stride int32, pointer unsafe.Pointer) {\n C.glowIndexPointer(gpIndexPointer, (C.GLenum)(xtype), (C.GLsizei)(stride), pointer)\n}", "func (o *KeyValueOrdered) Index(name Key) (int, bool) {\n\tval, ok := o.m[name]\n\treturn val, ok\n}", "func (tf *TeaFile) checkDataType() error {\n\tn := tf.dataType.NumField()\n\tvar fields []reflect.StructField\n\tfor i := 0; i < n; i++ {\n\t\tif tf.dataType.Field(i).Name != \"_\" {\n\t\t\tfields = append(fields, tf.dataType.Field(i))\n\t\t}\n\t}\n\tif len(fields) != len(tf.itemSection.Fields) {\n\t\treturn fmt.Errorf(\"given type has %d fields, was expecting %d\", n, len(tf.itemSection.Fields))\n\t}\n\tfor i := 0; i < len(fields); i++ {\n\t\tdataField := fields[i]\n\t\tfileField := tf.itemSection.Fields[i]\n\t\tif dataField.Type.Kind() != fieldTypeToKind[fileField.Type] {\n\t\t\treturn fmt.Errorf(\"was not expecting %v\", dataField.Type)\n\t\t}\n\t\tif dataField.Offset != uintptr(fileField.Offset) {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"got different offsets for field %d: %d %d\",\n\t\t\t\ti,\n\t\t\t\tdataField.Offset,\n\t\t\t\tfileField.Offset)\n\t\t}\n\t}\n\treturn nil\n}", "func (p *program) getAddrIndex(n int) int {\n\tparameter := p.mem[p.pc+n]\n\tmode := p.instructionMode(n)\n\n\tif mode == 0 {\n\t\treturn parameter\n\t} else if mode == 2 {\n\t\treturn p.base + parameter\n\t} else {\n\t\tpanic(\"unsupported immediate mode for writing\")\n\t}\n}", "func (ob *ObservableArray) IndexOf(data interface{}) int {\n\treturn ob.o.Call(\"indexOf\", data).Int()\n}", "func Contains(array interface{}, val interface{}) (index int) {\n index = -1\n switch reflect.TypeOf(array).Kind() {\n case reflect.Slice: {\n s := reflect.ValueOf(array)\n for i := 0; i < s.Len(); i++ {\n if reflect.DeepEqual(val, s.Index(i).Interface()) {\n index = i\n return\n }\n }\n }\n }\n return\n}", "func (*InstZExt) isValue() {}", "func GenerateValidIndex(datatypeName string) string {\n\tswitch datatypeName {\n\tcase field.TypeString:\n\t\treturn \"strconv.Itoa(0)\"\n\tcase field.TypeUint, field.TypeInt:\n\t\treturn \"0\"\n\tcase field.TypeBool:\n\t\treturn valueFalse\n\tcase field.TypeCustom:\n\t\treturn valueNull\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown type %s\", datatypeName))\n\t}\n}", "func getTestValue(isUpdate bool, dataType string) interface{} {\n\n\tswitch dataType {\n\tcase \"string\":\n\t\tif isUpdate {\n\t\t\treturn \"string_update\"\n\t\t}\n\t\treturn \"string_value\"\n\n\tcase \"float32\":\n\t\tif isUpdate {\n\t\t\treturn cFl32Upd\n\t\t}\n\t\treturn cFl32Crt\n\tcase \"float64\":\n\t\tif isUpdate {\n\t\t\treturn cFl64Upd\n\t\t}\n\t\treturn cFl64Crt\n\tcase \"int\":\n\t\tif isUpdate {\n\t\t\treturn cIUpd\n\t\t}\n\t\treturn cICrt\n\tcase \"int8\":\n\t\tif isUpdate {\n\t\t\treturn cI8Upd\n\t\t}\n\t\treturn cI8Crt\n\tcase \"int16\":\n\t\tif isUpdate {\n\t\t\treturn cI16Upd\n\t\t}\n\t\treturn cI16Crt\n\tcase \"int32\":\n\t\tif isUpdate {\n\t\t\treturn cI32Upd\n\t\t}\n\t\treturn cI32Crt\n\tcase \"int64\":\n\t\tif isUpdate {\n\t\t\treturn cI64Upd\n\t\t}\n\t\treturn cI64Crt\n\tcase \"uint\":\n\t\tif isUpdate {\n\t\t\treturn cUUpd\n\t\t}\n\t\treturn cUCrt\n\tcase \"uint8\":\n\t\tif isUpdate {\n\t\t\treturn cU8Upd\n\t\t}\n\t\treturn cU8Crt\n\tcase \"uint16\":\n\t\tif isUpdate {\n\t\t\treturn cU16Upd\n\t\t}\n\t\treturn cU16Crt\n\tcase \"uint32\":\n\t\tif isUpdate {\n\t\t\treturn cU32Upd\n\t\t}\n\t\treturn cU32Crt\n\tcase \"uint64\":\n\t\tif isUpdate {\n\t\t\treturn cU64Upd\n\t\t}\n\t\treturn cU64Crt\n\tcase \"bool\":\n\t\tif isUpdate {\n\t\t\treturn cBoolUpd\n\t\t}\n\t\treturn cBoolCrt\n\tdefault:\n\t\tlog.Printf(\"unknown data-type %s in test generation - please add support manually\", dataType)\n\t\tos.Exit(-1)\n\t}\n\treturn nil\n}", "func (t *Types) Get(index uint64) (Type, bool) {\n\tif index < t.Count() {\n\t\treturn *t.entries[index], true\n\t}\n\treturn Type{}, false\n}", "func (*Component_Type_Union_E_OpenconfigPlatformTypes_OPENCONFIG_SOFTWARE_COMPONENT) Is_Component_Type_Union() {\n}", "func (wtq *WorkerTypeQuery) FirstIDX(ctx context.Context) int {\n\tid, err := wtq.FirstID(ctx)\n\tif err != nil && !IsNotFound(err) {\n\t\tpanic(err)\n\t}\n\treturn id\n}", "func (*NamedTypeDummy) isType() {}", "func getIndex(k uint64, p, pPrime uint) uint64 {\n\tif k&1 == 1 {\n\t\tindex := extractShift(k, 7, p+6) // erratum from paper, start index is 7, not 6\n\t\treturn index\n\t} else {\n\t\tindex := extractShift(k, 1, p) // erratum from paper, end index is p, not p+1\n\t\treturn index\n\t}\n}", "func indexValueOf(args []string, flag string) (int, int, error) {\n for i := 0; i < len(args); i ++ {\n s := args[i]\n\n if len(s) == 0 || s[0] != '-' || len(s) == 1 {\n continue\n }\n\n num_minuses := 1\n if s[1] == '-' {\n num_minuses++\n if len(s) == 2 { // \"--\" terminates the flags\n i ++\n break\n }\n }\n\n name := s[num_minuses:]\n if len(name) == 0 || name[0] == '-' || name[0] == '=' {\n continue\n }\n\n // it's a flag. does it have an argument?\n has_value := false\n var j int\n for j = 1; j < len(name); j ++ { // equals cannot be first\n if name[j] == '=' {\n has_value = true\n name = name[0:j]\n break\n }\n }\n\n if name == flag {\n if !has_value {\n if i + 1 < len(args) {\n // value is the current arg\n has_value = true\n return i + 1, 0, nil\n }\n\n return -1, -1, fmt.Errorf(\"flag needs an argument: -%s\", name)\n }\n\n return i, num_minuses + j + 1, nil\n }\n }\n\n return -1, -1, fmt.Errorf(\"not found\")\n}", "func (self *Graphics) GetChildIndexI(args ...interface{}) int{\n return self.Object.Call(\"getChildIndex\", args).Int()\n}", "func IndexOfSingleToken(token string) (val byte, ok bool) {\n\tval, ok = mdSingleByteTokenIndex[token]\n\treturn\n}", "func TestGetColumnType(t *testing.T) {\r\n\ttests := []struct {\r\n\t\ttyp reflect.Type\r\n\t\ttag reflect.StructTag\r\n\t\twantType string\r\n\t\twantErr bool\r\n\t}{\r\n\t\t{\r\n\t\t\treflect.TypeOf(new(int)),\r\n\t\t\t``,\r\n\t\t\t\"\",\r\n\t\t\ttrue,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf([]int{}),\r\n\t\t\t``,\r\n\t\t\t\"\",\r\n\t\t\ttrue,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(map[int]int{}),\r\n\t\t\t``,\r\n\t\t\t\"\",\r\n\t\t\ttrue,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(true),\r\n\t\t\t``,\r\n\t\t\t\"BOOL\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(int(0)),\r\n\t\t\t``,\r\n\t\t\t\"INT4\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(int16(0)),\r\n\t\t\t``,\r\n\t\t\t\"INT2\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(int32(0)),\r\n\t\t\t``,\r\n\t\t\t\"INT4\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(int64(0)),\r\n\t\t\t``,\r\n\t\t\t\"INT8\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(float32(0)),\r\n\t\t\t``,\r\n\t\t\t\"FLOAT4\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(float64(0)),\r\n\t\t\t``,\r\n\t\t\t\"FLOAT8\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(\"\"),\r\n\t\t\t``,\r\n\t\t\t\"TEXT\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf([]byte{}),\r\n\t\t\t``,\r\n\t\t\t\"BYTEA\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(time.Time{}),\r\n\t\t\t``,\r\n\t\t\t\"TIMESTAMP\",\r\n\t\t\tfalse,\r\n\t\t}, {\r\n\t\t\treflect.TypeOf(time.Time{}),\r\n\t\t\t`typ:\"FAKENEWS\"`,\r\n\t\t\t\"FAKENEWS\",\r\n\t\t\tfalse,\r\n\t\t},\r\n\t}\r\n\tfor i, test := range tests {\r\n\t\tfield := reflect.StructField{Type: test.typ, Tag: test.tag}\r\n\t\thaveType, haveErr := getColumnType(field)\r\n\t\tif (haveErr != nil) != test.wantErr {\r\n\t\t\tt.Errorf(\"TestGetColumnType()[%d] = %v, want error %t.\", i, haveErr, test.wantErr)\r\n\t\t}\r\n\t\tif haveType != test.wantType {\r\n\t\t\tt.Errorf(\"TestGetColumnType()[%d] = %q, want type %q.\", i, haveType, test.wantType)\r\n\t\t}\r\n\t}\r\n}", "func (*InstBitCast) isValue() {}", "func (f *linkFrame) GetParamInt(k string) (i int64, err error) {\n v, ok := f.param[k]\n if ok {\n switch v.(type) {\n case int64:\n i = v.(int64)\n break\n default:\n err = errors.New(\"param value \"+k+\" not int\")\n }\n } else {\n err = errors.New(\"params don't have \"+k)\n }\n return\n}", "func (*InstSExt) isValue() {}", "func DataTypeBits(dataType DataType) int {\n\treturn int(0x0000FFFF & dataType)\n}", "func (*InstFPToSI) isValue() {}", "func (i *DeserializerV1) ReadAt(p []byte, begin int) ([]interface{}, int, error) {\n\tvar ans []interface{}\n\tvar j = begin\n\tvar err error\n\n\tfor ; j < len(p); j++ {\n\t\tch := p[j]\n\t\tswitch ch {\n\t\tdefault:\n\t\tcase 'c':\n\t\tcase 'r':\n\t\tcase 'f':\n\t\t\tvar args []interface{}\n\t\t\targs, j, err = i.ReadAt(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\treturn nil, j, fmt.Errorf(\"Call Service Error, Exception: %s, Message: %s\", args[1].(string), args[3].(string))\n\t\tcase 'z':\n\t\t\treturn ans, j, nil\n\t\tcase 'T':\n\t\t\tans = append(ans, true)\n\t\tcase 'F':\n\t\t\tans = append(ans, false)\n\t\tcase 'N':\n\t\t\tans = append(ans, nil)\n\t\tcase 'B':\n\t\t\t// B b16 b8 byte-value\n\t\t\tvar val []byte\n\t\t\tval, j, err = i.ReadBytesAt(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'S':\n\t\t\t// S b16 b8 string-value\n\t\t\tvar val string\n\t\t\tval, j, err = i.ReadStringAt(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'I':\n\t\t\t// I b32 b24 b16 b8\n\t\t\tvar val int32\n\t\t\tval, j, err = i.ReadInt32At(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'L':\n\t\t\t// L b64 b56 b48 b40 b32 b24 b16 b8\n\t\t\tvar val int64\n\t\t\tval, j, err = i.ReadInt64At(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'D':\n\t\t\t// D b64 b56 b48 b40 b32 b24 b16 b8\n\t\t\tvar val float64\n\t\t\tval, j, err = i.ReadFloat64At(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'd':\n\t\t\t// d b64 b56 b48 b40 b32 b24 b16 b8\n\t\t\tvar val time.Time\n\t\t\tval, j, err = i.ReadDateAt(p, j+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, j, err\n\t\t\t}\n\t\t\tans = append(ans, val)\n\t\tcase 'M':\n\t\t\tif p[j+1] == 't' {\n\t\t\t\tj++\n\t\t\t\tvar pkg string\n\t\t\t\tvar m = make(map[interface{}]interface{})\n\t\t\t\tpkg, j, err = i.ReadStringAt(p, j+1)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, j, err\n\t\t\t\t}\n\n\t\t\t\t// parse 'Mt' arguments\n\t\t\t\tm, j, err = i.ReadMapAt(p, j+1)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, j, err\n\t\t\t\t}\n\n\t\t\t\tif len(pkg) > 0 {\n\t\t\t\t\tobj, err := i.BuildObject(pkg, m)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tans = append(ans, nil)\n\t\t\t\t\t}\n\t\t\t\t\tans = append(ans, obj)\n\t\t\t\t} else {\n\t\t\t\t\tans = append(ans, m)\n\t\t\t\t}\n\t\t\t}\n\t\tcase 'V':\n\t\t\tif p[j+1] == 't' {\n\t\t\t\tj++\n\t\t\t\tvar arr []interface{}\n\n\t\t\t\tarr, j, err = i.ReadArrayAt(p, j+1)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, j, err\n\t\t\t\t}\n\n\t\t\t\tans = append(ans, arr)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ans, j, nil\n}", "func extractParameterType(astType ast.Expr) (*parameterType, error) {\n\tcurExpr := astType\n\tvar pt parameterType\n\tif starExpr, ok := astType.(*ast.StarExpr); ok {\n\t\tpt.IsPointer = true\n\t\tcurExpr = starExpr.X\n\t}\n\tlayers := make([]*parameterTypeLayer, 0)\n\tvar curLayer *parameterTypeLayer\n\tfor {\n\t\tswitch t := curExpr.(type) {\n\t\tcase *ast.Ident:\n\t\t\tbase := parameterTypeBase{\n\t\t\t\tCoreType: t.Name,\n\t\t\t}\n\t\t\tif curLayer != nil {\n\t\t\t\tif curLayer.ArrayConfig == nil {\n\t\t\t\t\tbase.IndirectionLevel = curLayer.IndirectionLevel\n\t\t\t\t} else {\n\t\t\t\t\tlayers = append(layers, curLayer)\n\t\t\t\t}\n\t\t\t}\n\t\t\tpt.Layers = layers\n\t\t\tpt.Base = base\n\t\t\treturn &pt, nil\n\t\tcase *ast.StarExpr:\n\t\t\tif curLayer == nil {\n\t\t\t\tcurLayer = &parameterTypeLayer{}\n\t\t\t}\n\t\t\tcurLayer.IndirectionLevel++\n\t\t\tcurExpr = t.X\n\t\tcase *ast.ArrayType:\n\t\t\tif curLayer == nil {\n\t\t\t\tcurLayer = &parameterTypeLayer{}\n\t\t\t}\n\t\t\tcurLayer.ArrayConfig = &arrayConfig{\n\t\t\t\tIsSlice: true,\n\t\t\t}\n\t\t\tif t.Len != nil {\n\t\t\t\tswitch tLen := t.Len.(type) {\n\t\t\t\tcase *ast.BasicLit:\n\t\t\t\t\tval, err := strconv.Atoi(tLen.Value)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"failed to cast array value %s to int: %v\", tLen.Value, err)\n\t\t\t\t\t}\n\t\t\t\t\tcurLayer.ArrayConfig.IsSlice = false\n\t\t\t\t\tcurLayer.ArrayConfig.Length = val\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, fmt.Errorf(\"parameter's array length expression %v is of an unknown type\", t.Len)\n\t\t\t\t}\n\t\t\t}\n\t\t\tlayers = append(layers, curLayer)\n\t\t\tcurLayer = nil\n\t\t\tcurExpr = t.Elt\n\t\tdefault:\n\t\t\t// TODO: return a better error\n\t\t\treturn nil, fmt.Errorf(\"expected an array, a pointer or a basic type, got: %v\", astType)\n\t\t}\n\t}\n}", "func (m *_S7ParameterModeTransition) GetParameterType() uint8 {\n\treturn 0x01\n}", "func (s Slice) Interface(i int) (v interface{}, ok bool) {\n\tif len(s) <= i {\n\t\treturn nil, false\n\t}\n\n\treturn s[i], true\n}", "func isPyCompatFunc(sig *types.Signature) (ret types.Type, haserr, hasfun bool, err error) {\n\tres := sig.Results()\n\n\tswitch res.Len() {\n\tcase 2:\n\t\tif !isErrorType(res.At(1).Type()) {\n\t\t\terr = fmt.Errorf(\"gopy: second result value must be of type error: %s\", sig.String())\n\t\t\treturn\n\t\t}\n\t\thaserr = true\n\t\tret = res.At(0).Type()\n\tcase 1:\n\t\tif isErrorType(res.At(0).Type()) {\n\t\t\thaserr = true\n\t\t\tret = nil\n\t\t} else {\n\t\t\tret = res.At(0).Type()\n\t\t}\n\tcase 0:\n\t\tret = nil\n\tdefault:\n\t\terr = fmt.Errorf(\"gopy: too many results to return: %s\", sig.String())\n\t\treturn\n\t}\n\n\tif ret != nil {\n\t\tif err = isPyCompatType(ret); err != nil {\n\t\t\treturn\n\t\t}\n\t\tif _, isSig := ret.Underlying().(*types.Signature); isSig {\n\t\t\terr = fmt.Errorf(\"gopy: return type is signature\")\n\t\t\treturn\n\t\t}\n\t\tif ret.Underlying().String() == \"interface{}\" {\n\t\t\terr = fmt.Errorf(\"gopy: return type is interface{}\")\n\t\t\treturn\n\t\t}\n\t}\n\n\targs := sig.Params()\n\tnargs := args.Len()\n\tfor i := 0; i < nargs; i++ {\n\t\targ := args.At(i)\n\t\targt := arg.Type()\n\t\tif err = isPyCompatType(argt); err != nil {\n\t\t\treturn\n\t\t}\n\t\tif _, isSig := argt.Underlying().(*types.Signature); isSig {\n\t\t\tif !hasfun {\n\t\t\t\thasfun = true\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"gopy: only one function signature arg allowed: %s\", sig.String())\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func parseVersionTypeData(d interface{}) (string, int, error) {\n\tr := []rune(strings.TrimSpace(fmt.Sprintf(\"%v\", d)))\n\tif len(r) <= 0 {\n\t\treturn \"\", 0, fmt.Errorf(\"unable to extract version from: %v\", d)\n\t}\n\treturn string(r), int(r[0]) - '0', nil\n}", "func Nth(data interface{}, i int) (interface{}, error) {\n\tvar err error\n\n\tresult := func(err *error) interface{} {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn nil\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn nil\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tif i < 0 {\n\t\t\ti = dataValueLen + i\n\t\t}\n\n\t\tif i < dataValueLen {\n\t\t\treturn dataValue.Index(i).Interface()\n\t\t}\n\n\t\treturn nil\n\t}(&err)\n\n\treturn result, err\n}", "func FindLastIndex(data, callback interface{}, args ...int) (int, error) {\n\tvar err error\n\n\tresult := func(err *error) int {\n\t\tdefer catch(err)\n\n\t\tif !isNonNilData(err, \"data\", data) {\n\t\t\treturn -1\n\t\t}\n\n\t\tdataValue, _, _, dataValueLen := inspectData(data)\n\n\t\tif !isSlice(err, \"data\", dataValue) {\n\t\t\treturn -1\n\t\t}\n\n\t\tcallbackValue, callbackType := inspectFunc(err, callback)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tcallbackTypeNumIn := validateFuncInputForSliceLoop(err, callbackType, dataValue)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tvalidateFuncOutputOneVarBool(err, callbackType, true)\n\t\tif *err != nil {\n\t\t\treturn -1\n\t\t}\n\n\t\tif dataValueLen == 0 {\n\t\t\treturn -1\n\t\t}\n\n\t\tendIndex := dataValueLen\n\t\tif len(args) > 0 {\n\t\t\tendIndex = args[0]\n\t\t}\n\n\t\tresult := -1\n\n\t\tforEachSliceStoppable(dataValue, dataValueLen, func(each reflect.Value, i int) bool {\n\t\t\tif i > endIndex {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tres := callFuncSliceLoop(callbackValue, each, i, callbackTypeNumIn)\n\t\t\tif res[0].Bool() {\n\t\t\t\tresult = i\n\t\t\t}\n\n\t\t\treturn true\n\t\t})\n\n\t\tif result < 0 {\n\t\t\treturn result\n\t\t}\n\n\t\treturn result\n\t}(&err)\n\n\treturn result, err\n}", "func (_Storage *StorageCallerSession) PermissionIndexOf(kind uint8, addr common.Address) (*big.Int, error) {\n\treturn _Storage.Contract.PermissionIndexOf(&_Storage.CallOpts, kind, addr)\n}", "func Index(key string, list []string) (int, bool) {\n\tfor i, item := range list {\n\t\tif item == key {\n\t\t\treturn i, true\n\t\t}\n\t}\n\n\t// any index is ok to return\n\treturn 0, false\n}", "func (p IntArray) Index(n int) int {\n\tfor i, v := range p {\n\t\tif v == n {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}", "func (a ValueArray) TryGet(index int) (Value, bool) {\n\tif index < 0 || index >= len(a.data) {\n\t\treturn Null(), false\n\t}\n\treturn a.data[index], true\n}", "func (buf *ListBuffer) legalIndex(idx BufferIndex) (inRange, initialized bool) {\n\tinRange = idx >= 0 && idx < BufferIndex(len(buf.Buffer))\n\tif inRange {\n\t\tinitialized = buf.Buffer[idx].Item.Type != Uninitialized\n\t} else {\n\t\tinitialized = true\n\t}\n\treturn inRange, initialized\n}" ]
[ "0.61002547", "0.56935805", "0.56436086", "0.5518017", "0.53062433", "0.5280237", "0.5259598", "0.52571326", "0.5215286", "0.51848507", "0.51287943", "0.5111558", "0.51069194", "0.5055307", "0.50197893", "0.50162286", "0.5011006", "0.49753526", "0.49401036", "0.49217778", "0.4864874", "0.48599446", "0.4835507", "0.4835287", "0.48242512", "0.47935605", "0.47885194", "0.47694752", "0.47568157", "0.47512585", "0.474513", "0.47391748", "0.4730264", "0.47240716", "0.47240716", "0.4705812", "0.4701982", "0.4675412", "0.46666142", "0.4662102", "0.4657004", "0.46517974", "0.46413916", "0.46286556", "0.46175316", "0.46150544", "0.4614987", "0.46117958", "0.4598697", "0.459667", "0.45834628", "0.457379", "0.4572965", "0.4570985", "0.4567371", "0.4556126", "0.45531553", "0.45496246", "0.45482373", "0.45482373", "0.45385277", "0.4520627", "0.45181426", "0.4515695", "0.4513282", "0.4511194", "0.4510498", "0.4505127", "0.45043254", "0.44985965", "0.4476938", "0.44762552", "0.44731492", "0.44696206", "0.44679558", "0.44632155", "0.44590104", "0.44545498", "0.44509017", "0.44473046", "0.44450352", "0.44420093", "0.44414723", "0.4429269", "0.4429058", "0.44258747", "0.44253042", "0.4424195", "0.44218", "0.44154263", "0.44107386", "0.44081783", "0.44072857", "0.44024906", "0.43988204", "0.43986517", "0.439531", "0.43897024", "0.43868428", "0.43847188" ]
0.639183
0
NOTE: Not implement yet Display or hide a DSP unit configuration dialog box inside the target window. Dialog boxes are used by DSP plugins that prefer to use a graphical user interface to modify their parameters rather than using the other method of enumerating the parameters and using "DSP.SetParameterFloat" / "DSP.SetParameterInt" / "DSP.SetParameterBool" / "DSP.SetParameterData". These are usually VST plugins. FMOD Studio plugins do not have configuration dialog boxes. To find out what size window to create to store the configuration screen, use "DSP.Info" where you can get the width and height.
func (d *DSP) ShowConfigDialog(hwnd *interface{}, show C.FMOD_BOOL) error { //FMOD_RESULT F_API FMOD_DSP_ShowConfigDialog (FMOD_DSP *dsp, void *hwnd, FMOD_BOOL show); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func windowsShowSettingsUI(_ *cagent.Cagent, _ bool) {\n\n}", "func (syn *Synth) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Synth\")\n\tgi.SetAppAbout(`This demonstrates synthesizing a sound (phone or word)`)\n\n\twin := gi.NewMainWindow(\"one\", \"Auditory ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\tsyn.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMax()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(syn)\n\n\ttview := gi.AddNewTabView(split, \"tv\")\n\n\tplt := tview.AddNewTab(eplot.KiT_Plot2D, \"wave\").(*eplot.Plot2D)\n\tsyn.WavePlot = syn.ConfigWavePlot(plt, syn.SignalData)\n\n\t// tbar.AddAction(gi.ActOpts{Label: \"Update Wave\", Icon: \"new\"}, win.This(),\n\t// \tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t// \t\tsyn.GetWaveData()\n\t// \t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Synthesize\", Icon: \"new\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tsyn.Synthesize()\n\t\t})\n\n\tsplit.SetSplitsList([]float32{.3, .7})\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func ConfigShow() error {\n\n\tfmt.Printf(\"\\nCurrently saved values:\\n\")\n\n\tif Config.Secure {\n\t\tfmt.Printf(\" -https\\n\")\n\t} else {\n\t\tfmt.Printf(\" -http\\n\")\n\t}\n\n\tif Config.Hub != \"\" && Config.Hub != notehub.DefaultAPIService {\n\t\tfmt.Printf(\" -hub %s\\n\", Config.Hub)\n\t}\n\tif Config.App != \"\" {\n\t\tfmt.Printf(\" -app %s\\n\", Config.App)\n\t}\n\tif Config.Product != \"\" {\n\t\tfmt.Printf(\" -product %s\\n\", Config.Product)\n\t}\n\tif Config.Device != \"\" {\n\t\tfmt.Printf(\" -device %s\\n\", Config.Device)\n\t}\n\tif Config.Root != \"\" {\n\t\tfmt.Printf(\" -root %s\\n\", Config.Root)\n\t}\n\tif Config.Cert != \"\" {\n\t\tfmt.Printf(\" -cert %s\\n\", Config.Cert)\n\t}\n\tif Config.Key != \"\" {\n\t\tfmt.Printf(\" -key %s\\n\", Config.Key)\n\t}\n\tif Config.Interface != \"\" {\n\t\tfmt.Printf(\" -interface %s\\n\", Config.Interface)\n\t\tif Config.Port == \"\" {\n\t\t\tfmt.Printf(\" -port -\\n\")\n\t\t\tfmt.Printf(\" -portconfig -\\n\")\n\t\t} else {\n\t\t\tfmt.Printf(\" -port %s\\n\", Config.Port)\n\t\t\tfmt.Printf(\" -portconfig %d\\n\", Config.PortConfig)\n\t\t}\n\t}\n\n\treturn nil\n\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\t// tv := gi.AddNewTabView(split, \"tv\")\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Reset\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.Reset()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Load Params\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.LoadParams()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Wavs\", Icon: \"new\", Tooltip: \"Generate the .wav files\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Split Wavs\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.SplitWavs()\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func (ap *App) ConfigGui() *gi.Window {\n\tgi.SetAppName(\"Gabor View\")\n\tgi.SetAppAbout(\"Application/Utility to allow viewing of gabor convolution with sound\")\n\n\tap.GUI.Win = gi.NewMainWindow(\"gb\", \"Gabor View\", 1600, 1200)\n\tap.GUI.ViewPort = ap.GUI.Win.Viewport\n\tap.GUI.ViewPort.UpdateStart()\n\n\tmfr := ap.GUI.Win.SetMainFrame()\n\n\tap.GUI.ToolBar = gi.AddNewToolBar(mfr, \"tbar\")\n\tap.GUI.ToolBar.SetStretchMaxWidth()\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Init\", Icon: \"update\",\n\t\tTooltip: \"Initialize everything including network weights, and start over. Also applies current params.\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\tap.Init()\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Open Sound Files\",\n\t\tIcon: \"file-open\",\n\t\tTooltip: \"Opens a file dialog for selecting a single sound file or a directory of sound files (only .wav files work at this time)\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\texts := \".wav\"\n\t\t\tgiv.FileViewDialog(ap.GUI.ViewPort, ap.OpenPath, exts, giv.DlgOpts{Title: \"Open .wav Sound File\", Prompt: \"Open a .wav file, or directory of .wav files, for sound processing.\"}, nil,\n\t\t\t\tap.GUI.Win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\t\t\tif sig == int64(gi.DialogAccepted) {\n\t\t\t\t\t\tdlg, _ := send.Embed(gi.KiT_Dialog).(*gi.Dialog)\n\t\t\t\t\t\tfn := giv.FileViewDialogValue(dlg)\n\t\t\t\t\t\tinfo, err := os.Stat(fn)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tfmt.Println(\"error stating %s\", fn)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif info.IsDir() {\n\t\t\t\t\t\t\t// Could do fully recursive by passing path var to LoadTranscription but I\n\t\t\t\t\t\t\t// tried it and it didn't return from TIMIT/TRAIN/DR1 even after 10 minutes\n\t\t\t\t\t\t\t// This way it does one level directory only and is fast\n\t\t\t\t\t\t\tfilepath.Walk(fn, func(path string, info os.FileInfo, err error) error {\n\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\tlog.Fatalf(err.Error())\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif info.IsDir() == false {\n\t\t\t\t\t\t\t\t\t//fmt.Printf(\"File Name: %s\\n\", info.Name())\n\t\t\t\t\t\t\t\t\tfp := filepath.Join(fn, info.Name())\n\t\t\t\t\t\t\t\t\tap.LoadTranscription(fp)\n\t\t\t\t\t\t\t\t}\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} else {\n\t\t\t\t\t\t\tap.LoadTranscription(fn)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tap.ConfigTableView(ap.SndsTable.View)\n\t\t\t\t\t\tap.GUI.IsRunning = true\n\t\t\t\t\t\tap.GUI.ToolBar.UpdateActions()\n\t\t\t\t\t\tap.GUI.Win.UpdateSig()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Unload Sounds\",\n\t\tIcon: \"file-close\",\n\t\tTooltip: \"Clears the table of sounds and closes the open sound files\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.SndsTable.Table.SetNumRows(0)\n\t\t\tap.SndsTable.View.UpdateTable()\n\t\t\tap.GUI.IsRunning = false\n\t\t\tap.GUI.ToolBar.UpdateActions()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Process 1\", Icon: \"play\",\n\t\tTooltip: \"Process the segment of audio from SegmentStart to SegmentEnd applying the gabor filters to the Mel tensor\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\terr := ap.ProcessSetup(&ap.WParams1, &ap.CurSnd1)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams1, &ap.PParams1, &ap.GParams1)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams1, &ap.GParams1)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Process 2\", Icon: \"play\",\n\t\tTooltip: \"Process the segment of audio from SegmentStart to SegmentEnd applying the gabor filters to the Mel tensor\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\terr := ap.ProcessSetup(&ap.WParams2, &ap.CurSnd2)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams2, &ap.PParams2, &ap.GParams2)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams2, &ap.GParams2)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Next 1\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Process the next segment of audio\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\t// setup the next segment of sound\n\t\t\tif ap.WParams1.TimeMode == false { // default\n\t\t\t\tap.SndsTable.View.ResetSelectedIdxs()\n\t\t\t\tif ap.Row == ap.SndsTable.View.DispRows-1 {\n\t\t\t\t\tap.Row = 0\n\t\t\t\t} else {\n\t\t\t\t\tap.Row += 1\n\t\t\t\t}\n\t\t\t\tap.SndsTable.View.SelectedIdx = ap.Row\n\t\t\t\tap.SndsTable.View.SelectIdx(ap.Row)\n\t\t\t} else {\n\t\t\t\td := ap.WParams1.SegmentEnd - ap.WParams1.SegmentStart\n\t\t\t\tap.WParams1.SegmentStart += d\n\t\t\t\tap.WParams1.SegmentEnd += d\n\t\t\t}\n\t\t\terr := ap.ProcessSetup(&ap.WParams1, &ap.CurSnd1)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams1, &ap.PParams1, &ap.GParams1)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams1, &ap.GParams1)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Next 2\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Process the next segment of audio\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\t// setup the next segment of sound\n\t\t\tif ap.WParams2.TimeMode == false { // default\n\t\t\t\tap.SndsTable.View.ResetSelectedIdxs()\n\t\t\t\tif ap.Row == ap.SndsTable.View.DispRows-1 {\n\t\t\t\t\tap.Row = 0\n\t\t\t\t} else {\n\t\t\t\t\tap.Row += 1\n\t\t\t\t}\n\t\t\t\tap.SndsTable.View.SelectedIdx = ap.Row\n\t\t\t\tap.SndsTable.View.SelectIdx(ap.Row)\n\t\t\t} else {\n\t\t\t\td := ap.WParams2.SegmentEnd - ap.WParams2.SegmentStart\n\t\t\t\tap.WParams2.SegmentStart += d\n\t\t\t\tap.WParams2.SegmentEnd += d\n\t\t\t}\n\t\t\terr := ap.ProcessSetup(&ap.WParams2, &ap.CurSnd2)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams2, &ap.PParams2, &ap.GParams2)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams2, &ap.GParams2)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Update Gabors\", Icon: \"update\",\n\t\tTooltip: \"Call this to see the result of changing the Gabor specifications\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\tap.UpdateGabors(&ap.GParams1)\n\t\t\tap.UpdateGabors(&ap.GParams2)\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Save 1\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Save the mel and result grids\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.SnapShot1()\n\t\t},\n\t})\n\n\t//ap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Copy 1 -> 2\", Icon: \"copy\",\n\t//\tTooltip: \"Copy all set 1 params (window, process, gabor) to set 2\",\n\t//\tActive: egui.ActiveAlways,\n\t//\tFunc: func() {\n\t//\t\tap.CopyOne()\n\t//\t\tap.GUI.UpdateWindow()\n\t//\t},\n\t//})\n\t//\n\t//ap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Copy 2 -> 1\", Icon: \"copy\",\n\t//\tTooltip: \"Copy all set 2 params (window, process, gabor) to set 1\",\n\t//\tActive: egui.ActiveAlways,\n\t//\tFunc: func() {\n\t//\t\tap.CopyTwo()\n\t//\t\tap.GUI.UpdateWindow()\n\t//\t},\n\t//})\n\n\tap.GUI.ToolBar.AddSeparator(\"filt\")\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Filter sounds...\", Icon: \"search\",\n\t\tTooltip: \"filter the table of sounds for sounds containing string...\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tgiv.CallMethod(ap, \"FilterSounds\", ap.GUI.ViewPort)\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Unilter sounds...\", Icon: \"reset\",\n\t\tTooltip: \"clear sounds table filter\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.UnfilterSounds()\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"View\", Icon: \"file-open\",\n\t\tTooltip: \"opens spectrogram view of selected sound in external application 'Audacity' - edit code to use a different application\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.View()\n\t\t\t//giv.CallMethod(ap, \"ViewSpectrogram\", ap.GUI.ViewPort)\n\t\t},\n\t})\n\n\tsplit1 := gi.AddNewSplitView(mfr, \"split1\")\n\tsplit1.Dim = 0\n\tsplit1.SetStretchMax()\n\n\tsplit := gi.AddNewSplitView(split1, \"split\")\n\tsplit.Dim = 1\n\tsplit.SetStretchMax()\n\n\ttv1 := gi.AddNewTabView(split1, \"tv1\")\n\tap.SndsTable.View = tv1.AddNewTab(etview.KiT_TableView, \"Sounds\").(*etview.TableView)\n\tap.ConfigTableView(ap.SndsTable.View)\n\tap.SndsTable.View.SetTable(ap.SndsTable.Table, nil)\n\n\tsplit1.SetSplits(.75, .25)\n\n\tap.GUI.StructView = giv.AddNewStructView(split, \"app\")\n\tap.GUI.StructView.SetStruct(ap)\n\n\tspecs := giv.AddNewTableView(split, \"specs1\")\n\tspecs.Viewport = ap.GUI.ViewPort\n\tspecs.SetSlice(&ap.GParams1.GaborSpecs)\n\n\tspecs = giv.AddNewTableView(split, \"specs2\")\n\tspecs.Viewport = ap.GUI.ViewPort\n\tspecs.SetSlice(&ap.GParams2.GaborSpecs)\n\n\ttv := gi.AddNewTabView(split, \"tv\")\n\n\ttg := tv.AddNewTab(etview.KiT_TensorGrid, \"Gabors\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams1.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.GParams1.GaborSet.Filters)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Power\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams1.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.PParams1.LogPowerSegment)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Mel\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MelFBankSegment)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Result\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams1.GborOutput)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"MFCC\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCSegment)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Deltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"DeltaDeltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCDeltaDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttv2 := gi.AddNewTabView(split, \"tv2\")\n\tsplit.SetSplits(.3, .15, .15, .2, .2)\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Gabors\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams2.GaborSet.Filters)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Power\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams2.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.PParams2.LogPowerSegment)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Mel\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MelFBankSegment)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Result\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams2.GborOutput)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"MFCC\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCSegment)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Deltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"DeltaDeltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCDeltaDeltas)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\tap.StatLabel = gi.AddNewLabel(mfr, \"status\", \"Status...\")\n\tap.StatLabel.SetStretchMaxWidth()\n\tap.StatLabel.Redrawable = true\n\n\tap.GUI.FinalizeGUI(false)\n\treturn ap.GUI.Win\n}", "func (ws *WindowSurface) Configure() {\n\tws.txtSimStatus = NewText(ws.nFont, ws.renderer)\n\terr := ws.txtSimStatus.SetText(\"Sim Status: \", sdl.Color{R: 0, G: 0, B: 255, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtFPSLabel = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtFPSLabel.SetText(\"FPS: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtMousePos = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtMousePos.SetText(\"Mouse: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtLoopLabel = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtLoopLabel.SetText(\"Loop: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.dynaTxt = NewDynaText(ws.nFont, ws.renderer, sdl.Color{R: 255, G: 255, B: 255, A: 255})\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\t// tv := gi.AddNewTabView(split, \"tv\")\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen cat string\", Icon: \"new\", Tooltip: \"Generate a new initial random seed to get different results. By default, Init re-establishes the same initial seed every time.\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.CatNoRepeat(gn.syls1)\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func (c *FwGeneral) Show() (Config, error) {\n c.con.LogQuery(\"(show) general settings\")\n return c.details(c.con.Show)\n}", "func ShowPreferencesDialog(parent gtk.IWindow, onMpdReconnect, onQueueColumnsChanged, onPlayerSettingChanged func()) {\n\t// Create the dialog\n\td := &PrefsDialog{\n\t\tonQueueColumnsChanged: onQueueColumnsChanged,\n\t\tonPlayerSettingChanged: onPlayerSettingChanged,\n\t}\n\n\t// Load the dialog layout and map the widgets\n\tbuilder, err := NewBuilder(prefsGlade)\n\tif err == nil {\n\t\terr = builder.BindWidgets(d)\n\t}\n\n\t// Check for errors\n\tif errCheck(err, \"ShowPreferencesDialog(): failed to initialise dialog\") {\n\t\tutil.ErrorDialog(parent, fmt.Sprint(glib.Local(\"Failed to load UI widgets\"), err))\n\t\treturn\n\t}\n\tdefer d.PreferencesDialog.Destroy()\n\n\t// Set the dialog up\n\td.PreferencesDialog.SetTransientFor(parent)\n\n\t// Remove the 2-pixel \"aura\" around the notebook\n\tif box, err := d.PreferencesDialog.GetContentArea(); err == nil {\n\t\tbox.SetBorderWidth(0)\n\t}\n\n\t// Map the handlers to callback functions\n\tbuilder.ConnectSignals(map[string]interface{}{\n\t\t\"on_PreferencesDialog_map\": d.onMap,\n\t\t\"on_Setting_change\": d.onSettingChange,\n\t\t\"on_MpdReconnect\": onMpdReconnect,\n\t\t\"on_ColumnMoveUpToolButton_clicked\": d.onColumnMoveUp,\n\t\t\"on_ColumnMoveDownToolButton_clicked\": d.onColumnMoveDown,\n\t})\n\n\t// Run the dialog\n\td.PreferencesDialog.Run()\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen TriSyllable Strings\", Icon: \"new\", Tooltip: \"Generate all combinations of tri syllabic strings from the sets of syllables for each position\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenTriSyllables()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Write TriSyls Strings\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.WriteTriSyllables()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Shuffle CVs\", Icon: \"new\", Tooltip: \"Shuffle the syllables and add this shuffle to the list of shuffles\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.ShuffleCVs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Write Shuffled CVs\", Icon: \"new\", Tooltip: \"WriteShuffles writes an individual file for each of the shuffled CV lists generated\\n// and also writes a file called \\\"ls\\\" that is a list of the files written!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.WriteShuffles()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Speech\", Icon: \"new\", Tooltip: \"Calls GnuSpeech on content of files\\n// and also writes a file called \\\"ls\\\" that is a list of the files written!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenSpeech(gn.ShufflesIn, gn.ShufflesOut)\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Rename Individual CVs\", Icon: \"new\", Tooltip: \"Must run this after splitting shuffle files into individual CVs before concatenating!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.Rename()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Whole Word Wavs\", Icon: \"new\", Tooltip: \"Generates wav files of 3 CVs where the second and third are fully predictable based on first CV\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenWholeWordWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Part Word Wavs\", Icon: \"new\", Tooltip: \"Generates wav files of 3 CVs, the second CV is of a set (so partially predictable), the third CV is predictable based on second\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenPartWordWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Wav sequence from tri wavs\", Icon: \"new\", Tooltip: \"Write wav file that is the concatenation of wav files of tri CVs\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.SequenceFromTriCVs()\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func NewWindow() *Window {\n\tfile := ui.NewFileWithName(\":/widget.ui\")\n\tloader := ui.NewUiLoader()\n\twidget := loader.Load(file)\n\n\t// Init main window\n\twindow := ui.NewMainWindow()\n\twindow.SetCentralWidget(widget)\n\twindow.SetWindowTitle(\"DFSS Demonstrator v\" + dfss.Version)\n\n\tw := &Window{\n\t\tQMainWindow: window,\n\t\tscene: &Scene{},\n\t}\n\tw.InstallEventFilter(w)\n\n\t// Load dynamic elements from driver\n\tw.logField = ui.NewTextEditFromDriver(widget.FindChild(\"logField\"))\n\tw.graphics = ui.NewGraphicsViewFromDriver(widget.FindChild(\"graphicsView\"))\n\tw.progress = ui.NewLabelFromDriver(widget.FindChild(\"progressLabel\"))\n\n\tw.playButton = ui.NewPushButtonFromDriver(widget.FindChild(\"playButton\"))\n\tw.stopButton = ui.NewPushButtonFromDriver(widget.FindChild(\"stopButton\"))\n\tw.replayButton = ui.NewPushButtonFromDriver(widget.FindChild(\"replayButton\"))\n\n\tw.quantumField = ui.NewSpinBoxFromDriver(widget.FindChild(\"quantumField\"))\n\tw.speedSlider = ui.NewSliderFromDriver(widget.FindChild(\"speedSlider\"))\n\n\t// Load pixmaps\n\tw.pixmaps = map[string]*ui.QPixmap{\n\t\t\"ttp\": ui.NewPixmapWithFilenameFormatFlags(\":/images/server_key.png\", \"\", ui.Qt_AutoColor),\n\t\t\"platform\": ui.NewPixmapWithFilenameFormatFlags(\":/images/server_connect.png\", \"\", ui.Qt_AutoColor),\n\t}\n\n\t// Load icons\n\tw.addIcons()\n\n\t// Add actions\n\tw.addActions()\n\tw.initScene()\n\tw.initTimer()\n\n\tw.StatusBar().ShowMessage(\"Ready\")\n\tw.PrintQuantumInformation()\n\treturn w\n}", "func Show(app fyne.App) {\n c := newCalculator()\n c.loadUI(app)\n}", "func (s *sdlWindow) Size() (w, h int) {\n\tr := s.Bounds()\n\treturn r.Max.X, r.Max.Y\n}", "func createComponentWindow(sX, sY, sW, sH float32) *gui.Window {\n\t// create a window for operating on the component file\n\tcomponentWindow := uiman.NewWindow(\"Component\", sX, sY, sW, sH, func(wnd *gui.Window) {\n\t\tloadComponent, _ := wnd.Button(\"componentFileLoadButton\", \"Load\")\n\t\tsaveComponent, _ := wnd.Button(\"componentFileSaveButton\", \"Save\")\n\t\twnd.Editbox(\"componentFileEditbox\", &flagComponentFile)\n\t\tif saveComponent {\n\t\t\terr := doSaveComponent(&theComponent, flagComponentFile)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Failed to save the component.\\n%v\\n\", err)\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"Saved the component file: %s\\n\", flagComponentFile)\n\t\t\t}\n\t\t}\n\n\t\tif loadComponent {\n\t\t\t// remove all existing mesh windows\n\t\t\tcloseAllMeshWindows()\n\t\t\t// load the component file again and create mesh windows / renderables\n\t\t\tdoLoadComponentFile(flagComponentFile)\n\t\t}\n\n\t\twnd.Separator()\n\t\twnd.RequestItemWidthMin(textWidth)\n\t\twnd.Text(\"Name\")\n\t\twnd.Editbox(\"componentNameEditbox\", &theComponent.Name)\n\n\t\t// do the user interface for mesh windows\n\t\twnd.Separator()\n\t\twnd.RequestItemWidthMin(textWidth)\n\t\twnd.Text(\"Meshes:\")\n\t\taddMesh, _ := wnd.Button(\"componentFileAddMeshButton\", \"Add Mesh\")\n\t\tif addMesh {\n\t\t\tdoAddMesh()\n\t\t}\n\n\t\tmeshesThatSurvive := theComponent.Meshes[:0]\n\t\tfor compMeshIndex, compMesh := range theComponent.Meshes {\n\t\t\twnd.StartRow()\n\t\t\twnd.RequestItemWidthMin(textWidth)\n\t\t\twnd.Text(fmt.Sprintf(\"%s\", compMesh.Name))\n\t\t\tshowMeshWnd, _ := wnd.Button(fmt.Sprintf(\"buttonShowMesh%d\", compMeshIndex), \"Show\")\n\t\t\thideMeshWnd, _ := wnd.Button(fmt.Sprintf(\"buttonHideMesh%d\", compMeshIndex), \"Hide\")\n\t\t\tdeleteMesh, _ := wnd.Button(fmt.Sprintf(\"buttonDeleteMesh%d\", compMeshIndex), \"Delete\")\n\t\t\tif showMeshWnd {\n\t\t\t\tdoShowMeshWindow(compMesh)\n\t\t\t}\n\t\t\tif hideMeshWnd || deleteMesh {\n\t\t\t\tdoHideMeshWindow(compMesh)\n\t\t\t}\n\t\t\tif !deleteMesh {\n\t\t\t\tmeshesThatSurvive = append(meshesThatSurvive, compMesh)\n\t\t\t} else {\n\t\t\t\tdoDeleteMesh(compMesh.Name)\n\t\t\t}\n\n\t\t}\n\t\t// FIXME: not Destroying renderables for meshes that don't survive\n\t\ttheComponent.Meshes = meshesThatSurvive\n\n\t\t// do the user interface for colliders\n\t\twnd.Separator()\n\t\twnd.RequestItemWidthMin(textWidth)\n\t\twnd.Text(\"Colliders: \")\n\t\taddNewCollider, _ := wnd.Button(\"buttonAddCollider\", \"Add Collider\")\n\t\tif addNewCollider {\n\t\t\tdoAddCollider(&theComponent)\n\t\t}\n\n\t\tcollidersThatSurvive := theComponent.Collisions[:0]\n\t\tvisibleCollidersThatSurvive := visibleColliders[:0]\n\t\tfor colliderIndex, collider := range theComponent.Collisions {\n\t\t\twnd.StartRow()\n\t\t\twnd.RequestItemWidthMin(textWidth)\n\t\t\twnd.Text(fmt.Sprintf(\"Collider %d:\", colliderIndex))\n\n\t\t\tdelCollider, _ := wnd.Button(fmt.Sprintf(\"buttonDeleteCollider%d\", colliderIndex), \"X\")\n\t\t\tprevColliderType, _ := wnd.Button(fmt.Sprintf(\"buttonPrevColliderType%d\", colliderIndex), \"<\")\n\t\t\tnextColliderType, _ := wnd.Button(fmt.Sprintf(\"buttonNextColliderType%d\", colliderIndex), \">\")\n\n\t\t\tif !delCollider {\n\t\t\t\tcollidersThatSurvive = append(collidersThatSurvive, collider)\n\n\t\t\t\tif prevColliderType {\n\t\t\t\t\tdoPrevColliderType(collider)\n\t\t\t\t}\n\t\t\t\tif nextColliderType {\n\t\t\t\t\tdoNextColliderType(collider)\n\t\t\t\t}\n\n\t\t\t\tswitch collider.Type {\n\t\t\t\tcase component.ColliderTypeAABB:\n\t\t\t\t\twnd.Text(\"Axis Aligned Bounding Box\")\n\t\t\t\t\twnd.StartRow()\n\t\t\t\t\twnd.Space(textWidth)\n\t\t\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\t\t\twnd.Text(\"Min\")\n\t\t\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"ColliderMin\", colliderIndex, 0.01, &collider.Min)\n\n\t\t\t\t\twnd.StartRow()\n\t\t\t\t\twnd.Space(textWidth)\n\t\t\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\t\t\twnd.Text(\"Max\")\n\t\t\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"ColliderMax\", colliderIndex, 0.01, &collider.Max)\n\n\t\t\t\tcase component.ColliderTypeSphere:\n\t\t\t\t\twnd.Text(\"Sphere\")\n\t\t\t\t\twnd.StartRow()\n\t\t\t\t\twnd.Space(textWidth)\n\t\t\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\t\t\twnd.Text(\"Offset\")\n\t\t\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"ColliderOffset\", colliderIndex, 0.01, &collider.Offset)\n\n\t\t\t\t\twnd.StartRow()\n\t\t\t\t\twnd.Space(textWidth)\n\t\t\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\t\t\twnd.Text(\"Radius\")\n\t\t\t\t\twnd.DragSliderFloat(fmt.Sprintf(\"ColliderRadius%d\", colliderIndex), 0.01, &collider.Radius)\n\t\t\t\tdefault:\n\t\t\t\t\twnd.Text(fmt.Sprintf(\"Unknown collider (%d)!\", collider.Type))\n\t\t\t\t}\n\n\t\t\t\t// see if we need to update the renderable if it exists already\n\t\t\t\tvisibleColliders = doUpdateVisibleCollider(visibleColliders, collider, colliderIndex)\n\t\t\t\tvisibleCollidersThatSurvive = append(visibleCollidersThatSurvive, visibleColliders[colliderIndex])\n\t\t\t}\n\t\t}\n\t\ttheComponent.Collisions = collidersThatSurvive\n\t\tvisibleColliders = visibleCollidersThatSurvive\n\n\t\twnd.Separator()\n\t\twnd.RequestItemWidthMin(textWidth)\n\t\twnd.Text(\"Child Components:\")\n\t\taddChildComponent, _ := wnd.Button(\"addChildComponent\", \"Add Child\")\n\t\tif addChildComponent {\n\t\t\tdoAddChildReference(&theComponent)\n\t\t}\n\n\t\tchildRefsThatSurvive := theComponent.ChildReferences[:0]\n\t\tfor childRefIndex, childRef := range theComponent.ChildReferences {\n\t\t\twnd.StartRow()\n\t\t\twnd.RequestItemWidthMin(textWidth)\n\t\t\twnd.Text(\"File:\")\n\t\t\tremoveReference, _ := wnd.Button(fmt.Sprintf(\"childRefRemove%d\", childRefIndex), \"X\")\n\t\t\tloadChildReference, _ := wnd.Button(fmt.Sprintf(\"childRefLoad%d\", childRefIndex), \"L\")\n\t\t\twnd.Editbox(fmt.Sprintf(\"childRefFileEditbox%d\", childRefIndex), &childRef.File)\n\n\t\t\twnd.StartRow()\n\t\t\twnd.Space(textWidth)\n\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\twnd.Text(\"Offset\")\n\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"childRefLocation\", childRefIndex, 0.01, &childRef.Location)\n\n\t\t\twnd.StartRow()\n\t\t\twnd.Space(textWidth)\n\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\twnd.Text(\"Scale\")\n\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"childRefScale\", childRefIndex, 0.01, &childRef.Scale)\n\n\t\t\twnd.StartRow()\n\t\t\twnd.Space(textWidth)\n\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\twnd.Text(\"Rot Axis\")\n\t\t\tguiAddDragSliderVec3(wnd, width4Col, \"childRefRotAxis\", childRefIndex, 0.01, &childRef.RotationAxis)\n\n\t\t\twnd.StartRow()\n\t\t\twnd.Space(textWidth)\n\t\t\twnd.RequestItemWidthMin(width4Col)\n\t\t\twnd.Text(\"Rot Deg\")\n\t\t\twnd.DragSliderFloat(fmt.Sprintf(\"childRefRotDeg%d\", childRefIndex), 0.1, &childRef.RotationDegrees)\n\n\t\t\tif !removeReference {\n\t\t\t\tchildRefsThatSurvive = append(childRefsThatSurvive, childRef)\n\t\t\t}\n\t\t\tif loadChildReference {\n\t\t\t\tvar err error\n\t\t\t\tchildComponents, err = doLoadChildComponent(childComponents, childRef)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Printf(\"Failed to load child component.\\n%v\\n\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttheComponent.ChildReferences = childRefsThatSurvive\n\n\t\t// remove any visible child components that no longer have a reference\n\t\tchildComponents = removeStaleChildComponents(childComponents, &theComponent, childRefFilenames)\n\t})\n\treturn componentWindow\n}", "func newSettings() *settings {\n\ts := new(settings)\n\ts.windowSettings = &graphics.WindowSettings{}\n\ts.windowSettings.SetResolution(800, 600)\n\treturn s\n}", "func (w *WindowWidget) Size(width, height float32) *WindowWidget {\n\tw.width, w.height = width, height\n\treturn w\n}", "func (app *appImpl) setSysWindow(opts *oswin.NewWindowOptions, winPtr uintptr) error {\n\tapp.mu.Lock()\n\tdefer app.mu.Unlock()\n\n\tvar sf vk.Surface\n\t// we have to remake the surface, system, and drawer every time someone reopens the window\n\t// because the operating system changes the underlying window\n\tlog.Println(\"in NewWindow\", app.gpu.Instance, winPtr, &sf)\n\tret := vk.CreateWindowSurface(app.gpu.Instance, winPtr, nil, &sf)\n\tif err := vk.Error(ret); err != nil {\n\t\tlog.Println(\"oswin/driver/mobile new window: vulkan error:\", err)\n\t\treturn err\n\t}\n\tapp.Surface = vgpu.NewSurface(app.gpu, sf)\n\n\tlog.Printf(\"format: %s\\n\", app.Surface.Format.String())\n\n\tapp.System = app.gpu.NewGraphicsSystem(app.name, &app.Surface.Device)\n\tapp.System.ConfigRender(&app.Surface.Format, vgpu.UndefType)\n\tapp.Surface.SetRender(&app.System.Render)\n\t// app.window.System.Mem.Vars.NDescs = vgpu.MaxTexturesPerSet\n\tapp.System.Config()\n\n\tapp.Draw = vdraw.Drawer{\n\t\tSys: *app.System,\n\t\tYIsDown: true,\n\t}\n\t// app.window.Draw.ConfigSys()\n\tapp.Draw.ConfigSurface(app.Surface, vgpu.MaxTexturesPerSet)\n\n\tapp.winptr = winPtr\n\tlog.Println(\"set window pointer to\", app.winptr)\n\tlog.Println(\"total number of windows:\", len(app.windows))\n\n\treturn nil\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func SetCosoleWinsize(pid, w, h int) {\n\twhandle, err := GetWindowHandleByPID(pid, true)\n\tif err != nil {\n\t\tlog.Printf(\"SetWinsize: %v\", err)\n\t\treturn\n\t}\n\t// read default font size from registry\n\tconsole_reg_key, err := registry.OpenKey(registry.CURRENT_USER, \"Console\", registry.QUERY_VALUE)\n\tif err != nil {\n\t\tlog.Printf(\"SetCosoleWinsize: %v\", err)\n\t\treturn\n\t}\n\tdefer console_reg_key.Close()\n\tfont_size_val, _, err := console_reg_key.GetIntegerValue(\"FontSize\")\n\tif err != nil {\n\t\tlog.Printf(\"SetConsoleWinSize: query fontsize: %v\", err)\n\t\treturn\n\t}\n\tfont_size := int(font_size_val >> 16) // font height in pixels, width = h/2\n\tlog.Printf(\"Default font size of console host is %d (0x%x), parsed from 0x%x\",\n\t\tfont_size, font_size, font_size_val)\n\t// what size in pixels we need\n\tw_px := w * font_size / 2\n\th_px := h * font_size\n\n\tif ConsoleExtraHeight == 0 && ConsoleExtraWidth == 0 {\n\t\t// Get default window size\n\t\tnow_size, _, err := console_reg_key.GetIntegerValue(\"WindowSize\")\n\t\tif err != nil {\n\t\t\tlog.Printf(\"window size: %v\", err)\n\t\t\treturn\n\t\t}\n\t\t// in chars\n\t\tdefault_width := int(now_size & 0xffff)\n\t\tdefault_height := int(now_size >> 16)\n\t\t// in pixels\n\t\tdefault_w_px := default_width * font_size / 2\n\t\tdefault_h_px := default_height * font_size\n\t\tlog.Printf(\"Default window (client rectangle, excluding frames) is %dx%d (chars) or %dx%d (pixels)\",\n\t\t\tdefault_width, default_height,\n\t\t\tdefault_w_px, default_h_px)\n\t\t// window size in pixels, including title bar and frame\n\t\tnow_rect := w32.GetWindowRect(whandle)\n\t\tnow_w_px := int(now_rect.Width())\n\t\tnow_h_px := int(now_rect.Height())\n\t\tif now_h_px <= 0 || now_w_px <= 0 {\n\t\t\tlog.Printf(\"Now window (normal rectangle) size is %dx%d, aborting\", now_w_px, now_h_px)\n\t\t\treturn\n\t\t}\n\t\tlog.Printf(\"Current window (normal rectangle, including frames) is %dx%d (pixels)\",\n\t\t\tnow_w_px, now_h_px)\n\t\t// calculate extra width and height\n\t\tConsoleExtraHeight = now_h_px - default_h_px\n\t\tConsoleExtraWidth = now_w_px - default_w_px\n\t\tif ConsoleExtraWidth <= 0 || ConsoleExtraHeight <= 0 {\n\t\t\tlog.Printf(\"Extra width %d pixels, extra height %d pixels, aborting\", ConsoleExtraWidth, ConsoleExtraHeight)\n\t\t\treturn\n\t\t}\n\t\tlog.Printf(\"Frame (excluding window content) is %d(w), %d(h) (pixels)\",\n\t\t\tConsoleExtraWidth, ConsoleExtraHeight)\n\n\t}\n\tw_px = w_px + ConsoleExtraWidth\n\th_px = h_px + ConsoleExtraHeight\n\n\t// set window size in pixels\n\tif w32.SetWindowPos(whandle, whandle, 0, 0, w_px, h_px, w32.SWP_NOMOVE|w32.SWP_NOZORDER) {\n\t\tlog.Printf(\"Window (0x%x) of %d is being resized to %dx%d (chars) or %dx%d (pixels)\",\n\t\t\twhandle, pid, w, h, w_px, h_px)\n\t}\n\n\t// check window size\n\tnow_rect := w32.GetWindowRect(whandle)\n\tnow_w_px := int(now_rect.Width())\n\tnow_h_px := int(now_rect.Height())\n\tif now_w_px != w_px || now_h_px != h_px {\n\t\tlog.Printf(\"Resizing failed, actual window size is now %dx%d pixels\", now_w_px, now_h_px)\n\t}\n}", "func newWindow(width, height int) (wdeWindow wde.Window, err error) {\n\tw := &sdlWindow{}\n\twdeWindow = w\n\tsdlWrap.Size <- &geom.Coord{float64(width), float64(height)}\n\tw.Surface = <-sdlWrap.Surface\n\tw.events = make(chan interface{}, 16)\n\tgo w.poolSdl()\n\n\tif w.Surface == nil {\n\t\terr = sdlError(sdl.GetError())\n\t\treturn\n\t}\n\n\treturn\n}", "func (w *Window) Size() (width, height float64) {\n\tvar out struct {\n\t\tWidth float64\n\t\tHeigth float64\n\t}\n\n\tif err := driver.macRPC.Call(\"windows.Size\", &out, struct {\n\t\tID string\n\t}{\n\t\tID: w.ID().String(),\n\t}); err != nil {\n\t\tpanic(err)\n\t}\n\treturn out.Width, out.Heigth\n}", "func (w *Window) Setup(c WindowConfig) (err error) {\n\tw.This = ElementI(w)\n\tw.SetupChannels()\n\tw.RenderFunc = c.RenderFunc\n\tw.Style.Parse(WindowElementStyle)\n\tw.Style.Parse(c.Style)\n\tw.Context = c.Context\n\tw.Value = c.Value\n\tw.BatchChannel = make(chan []BatchMessage, 5000)\n\tw.SetDirty(true)\n\tw.SDLWindow, err = sdl.CreateWindow(\n\t\tc.Value,\n\t\tint32(w.Style.X.Value),\n\t\tint32(w.Style.Y.Value),\n\t\tint32(w.Style.W.Value),\n\t\tint32(w.Style.H.Value),\n\t\tsdl.WINDOW_SHOWN|sdl.WINDOW_RESIZABLE,\n\t)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Create our Renderer\n\tw.Context.Renderer, err = sdl.CreateRenderer(w.SDLWindow, -1, sdl.RENDERER_ACCELERATED)\n\tw.Context.Renderer.SetDrawBlendMode(sdl.BLENDMODE_BLEND)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw.CalculateStyle()\n\t// Trigger a resize so we can create a Texture\n\t//wid, err := w.SDLWindow.GetID()\n\t//w.Resize(wid, w.w, w.h)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func UI(redraw func()) *tview.Form {\n\tredrawParent = redraw\n\tcommand = settings.Get(settings.SetConfig, settings.KeyOmxplayerCommand).(string)\n\n\tuiForm = tview.NewForm().\n\t\tAddInputField(\"omxmplayer command\", command, 40, nil, handleCommandChange).\n\t\tAddButton(\"Save\", handlePressSave).\n\t\tAddButton(\"Cancel\", handlePressCancel)\n\n\tuiForm.SetFieldBackgroundColor(tcell.ColorGold).SetFieldTextColor(tcell.ColorBlack)\n\tuiForm.SetBorder(true).SetTitle(\"Settings\")\n\n\treturn uiForm\n}", "func (w *Window) Show() {\n\tw.Draw()\n}", "func onWindowResize(w *glfw.Window, width int, height int) {\n\t// uiman.AdviseResolution(int32(width), int32(height))\n\t// renderer.ChangeResolution(int32(width), int32(height))\n}", "func (x *Rest) ConfigurationShow(w http.ResponseWriter, r *http.Request,\n\tparams httprouter.Params) {\n\tdefer panicCatcher(w)\n\n\trequest := msg.New(r, params)\n\trequest.Section = msg.SectionConfiguration\n\trequest.Action = msg.ActionShow\n\trequest.Configuration.ID = strings.ToLower(params.ByName(`ID`))\n\n\tif _, err := uuid.FromString(request.Configuration.ID); err != nil {\n\t\tx.replyBadRequest(&w, &request, err)\n\t\treturn\n\t}\n\n\tif !x.isAuthorized(&request) {\n\t\tx.replyForbidden(&w, &request, nil)\n\t\treturn\n\t}\n\n\thandler := x.handlerMap.Get(`configuration_r`)\n\thandler.Intake() <- request\n\tresult := <-request.Reply\n\tx.respond(&w, &result)\n}", "func DialogBox(\n\thInstance HINSTANCE,\n\tTemplateName string,\n\thWndParent HWND,\n\tlpDialogFunc DLGPROC,\n) INT_PTR {\n\tvar ret, _, _ = userDialogBoxParamW.Call(\n\t\tuintptr(hInstance),\n\t\tUintptrFromString(&TemplateName),\n\t\tuintptr(hWndParent),\n\t\tuintptr(lpDialogFunc),\n\t\t0,\n\t)\n\treturn INT_PTR(ret)\n}", "func (w *Window) Size() (width, height float32) {\n\treturn w.width, w.height\n}", "func setupWindow(title string) *gtk.Window {\n\twin, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)\n\tif err != nil {\n\t\tlog.Fatal(\"Unable to create window:\", err)\n\t}\n\n\twin.SetTitle(title)\n\twin.Connect(\"destroy\", func() {\n\t\tgtk.MainQuit()\n\t})\n\twin.SetPosition(gtk.WIN_POS_CENTER)\n\twidth, height := 600, 300\n\twin.SetDefaultSize(width, height)\n\n\tbox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)\n\tbtn, _ := gtk.ButtonNew()\n\tbtn.Connect(\"clicked\", ButtonClicked)\n\tbtn.SetLabel(\"Stop timeout\")\n\n\tbox.Add(btn)\n\twin.Add(box)\n\n\treturn win\n}", "func (sd *SettingsDialog) OpenSettingsDialog() {\n\tif !sd.isDisplayInited {\n\t\tsd.__init_display()\n\t}\n\tsd.populateFields()\n\tsd.Open()\n}", "func debugPrintWinSize() {\n\twindow := getWinSize()\n\tfmt.Printf(\"col: %v\\nrow: %v\\nx: %v\\ny: %v\\n\", window.col, window.row, window.unusedX, window.unusedY)\n}", "func displayDetails(dev *device.SDRDevice) {\n\n\tfmt.Printf(\"-------------------\\n\")\n\tfmt.Printf(\"Device Information\\n\")\n\tfmt.Printf(\"-------------------\\n\")\n\n\t// Function from identification API\n\tfmt.Printf(\"Identification / DriverKey: %v\\n\", dev.GetDriverKey())\n\tfmt.Printf(\"Identification / HardwareKey: %v\\n\", dev.GetHardwareKey())\n\n\thardwareInfo := dev.GetHardwareInfo()\n\tif len(hardwareInfo) > 0 {\n\t\tfor k, v := range hardwareInfo {\n\t\t\tfmt.Printf(\"Identification / HardwareInfo: {%v:%v}\\n\", k, v)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Identification / HardwareInfo: [none]\\n\")\n\t}\n\n\t//\n\t// GPIO\n\t//\n\tbanks := dev.ListGPIOBanks()\n\tif len(banks) > 0 {\n\t\tfor i, bank := range banks {\n\t\t\tfmt.Printf(\"GPIO / Bank #%d: %v\\n\", i, bank)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"GPIO / Banks: [none]\\n\")\n\t}\n\n\t//\n\t// Settings\n\t//\n\tsettings := dev.GetSettingInfo()\n\tif len(settings) > 0 {\n\t\tfor i, setting := range settings {\n\t\t\tfmt.Printf(\"Settings / Setting #%d: %v\\n\", i, setting.ToString())\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Settings: [none]\\n\")\n\t}\n\n\t//\n\t// UARTs\n\t//\n\tuarts := dev.ListUARTs()\n\tif len(settings) > 0 {\n\t\tfor i, uart := range uarts {\n\t\t\tfmt.Printf(\"UARTs #%d: / UART: %v\\n\", i, uart)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"UARTs: [none]\\n\")\n\t}\n\n\t//\n\t// Clocking\n\t//\n\tfmt.Printf(\"MasterClockRate: %v\\n\", dev.GetMasterClockRate())\n\tclockRanges := dev.GetMasterClockRates()\n\tif len(clockRanges) > 0 {\n\t\tfor i, clockRange := range clockRanges {\n\t\t\tfmt.Printf(\"MasterClockRate range #%d: %v\\n\", i, clockRange)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"MasterClockRate ranges: [none]\\n\")\n\t}\n\tclockSources := dev.ListClockSources()\n\tif len(clockSources) > 0 {\n\t\tfor i, clockSource := range clockSources {\n\t\t\tfmt.Printf(\"Clock source #%d: %v\\n\", i, clockSource)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Clock sources: [none]\\n\")\n\t}\n\n\t//\n\t// Register\n\t//\n\tregisters := dev.ListRegisterInterfaces()\n\tif len(registers) > 0 {\n\t\tfor i, register := range registers {\n\t\t\tfmt.Printf(\"Register #%d: %v\\n\", i, register)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Registers: [none]\\n\")\n\t}\n\n\t//\n\t// Device Sensor\n\t//\n\tsensors := dev.ListSensors()\n\tif len(sensors) > 0 {\n\t\tfor i, sensor := range sensors {\n\t\t\tfmt.Printf(\"Sensor #%d: %v\\n\", i, sensor)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Sensors: [none]\\n\")\n\t}\n\n\t//\n\t// TimeSource\n\t//\n\ttimeSources := dev.ListTimeSources()\n\tif len(timeSources) > 0 {\n\t\tfor i, timeSource := range timeSources {\n\t\t\tfmt.Printf(\"Time source #%d: %v\\n\", i, timeSource)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Time sources: [none]\\n\")\n\t}\n\thasHardwareTime := dev.HasHardwareTime(\"\")\n\tfmt.Printf(\"Time source / Has hardware time: %v\\n\", hasHardwareTime)\n\tif hasHardwareTime {\n\t\tfmt.Printf(\"Time source / Hardware time: %v\\n\", dev.GetHardwareTime(\"\"))\n\t}\n\n\tdisplayDirectionDetails(dev, device.DirectionTX)\n\tdisplayDirectionDetails(dev, device.DirectionRX)\n}", "func (gui *GUI) resize(w *glfw.Window, width int, height int) {\n\n\tif width == gui.width && height == gui.height {\n\t\t//return\n\t}\n\n\tgui.logger.Debugf(\"Initiating GUI resize to %dx%d\", width, height)\n\n\tgui.width = width\n\tgui.height = height\n\n\tgui.logger.Debugf(\"Updating font resolution...\")\n\tif gui.font != nil {\n\t\tgui.font.UpdateResolution((width), (height))\n\t}\n\n\tgui.logger.Debugf(\"Setting renderer area...\")\n\tgui.renderer.SetArea(0, 0, gui.width, gui.height)\n\n\tgui.logger.Debugf(\"Calculating size in cols/rows...\")\n\tcols, rows := gui.renderer.GetTermSize()\n\n\tgui.logger.Debugf(\"Resizing internal terminal...\")\n\tif err := gui.terminal.SetSize(cols, rows); err != nil {\n\t\tgui.logger.Errorf(\"Failed to resize terminal to %d cols, %d rows: %s\", cols, rows, err)\n\t}\n\n\tgui.logger.Debugf(\"Setting viewport size...\")\n\tgl.Viewport(0, 0, int32(gui.width), int32(gui.height))\n\n\tgui.logger.Debugf(\"Resize complete!\")\n\n}", "func (this *Window) Display() {\n\tglobalMutex.Lock()\n\tC.sfWindow_display(this.cptr)\n\tglobalMutex.Unlock()\n}", "func configureFunc(m sparta.Widget, e interface{}) bool {\n\tev := e.(sparta.ConfigureEvent)\n\tfmt.Fprintf(os.Stdout, \"Ev:%s\\tMinX:%d\\tMinY:%d\\tMaxX:%d\\tMaxY:%d\\n\", sparta.Configure, ev.Rect.Min.X, ev.Rect.Min.Y, ev.Rect.Max.X, ev.Rect.Max.Y)\n\treturn false\n}", "func (w *Window) Size() (width, height int) {\n\tif w.closed {\n\t\treturn\n\t}\n\twidth, height = w.width, w.height\n\treturn\n}", "func (opt *MainOpt) UpdateOptions() {\n\n\topt.MainWinWidth, opt.MainWinHeight = mainObjects.MainWindow.GetSize()\n\topt.MainWinPosX, opt.MainWinPosY = mainObjects.MainWindow.GetPosition()\n\n\topt.Reminder = mainObjects.CheckbuttonAddReminder.GetActive()\n\topt.Md4 = mainObjects.CheckbuttonMd4.GetActive()\n\topt.Md5 = mainObjects.CheckbuttonMd5.GetActive()\n\topt.Sha1 = mainObjects.CheckbuttonSha1.GetActive()\n\topt.Sha256 = mainObjects.CheckbuttonSha256.GetActive()\n\topt.Sha384 = mainObjects.CheckbuttonSha384.GetActive()\n\topt.Sha512 = mainObjects.CheckbuttonSha512.GetActive()\n\topt.Sha3_256 = mainObjects.CheckbuttonSha3_256.GetActive()\n\topt.Sha3_384 = mainObjects.CheckbuttonSha3_384.GetActive()\n\topt.Sha3_512 = mainObjects.CheckbuttonSha3_512.GetActive()\n\topt.Blake2b256 = mainObjects.CheckbuttonBlake2b256.GetActive()\n\topt.Blake2b384 = mainObjects.CheckbuttonBlake2b384.GetActive()\n\topt.Blake2b512 = mainObjects.CheckbuttonBlake2b512.GetActive()\n\topt.ShowFilename = mainObjects.CheckbuttonShowFilename.GetActive()\n\topt.AppendDroppedFiles = mainObjects.CheckbuttonAppendFiles.GetActive()\n\topt.UseDecimal = mainObjects.CheckbuttonUseDecimal.GetActive()\n\topt.ConcurrentOp = mainObjects.CheckbuttonConcurrentOp.GetActive()\n\topt.RecursiveScan = mainObjects.CheckbuttonRecursiveScan.GetActive()\n\topt.MakeOutputFile = mainObjects.CheckbuttonCreateFile.GetActive()\n\n\topt.CurrentStackPage = mainObjects.Stack.GetVisibleChildName()\n\topt.SwitchStackPage = mainObjects.SwitchTreeView.GetActive()\n\topt.SwitchExpandState = mainObjects.SwitchExpand.GetActive()\n\n\topt.ShowSplash = mainObjects.CheckbuttonShowSplash.GetActive()\n}", "func (d *PrefsDialog) updateGeneralWidgets() {\n\tnetwork := d.MpdNetworkComboBox.GetActiveID()\n\tunix, tcp := network == \"unix\", network == \"tcp\"\n\td.MpdPathEntry.SetVisible(unix)\n\td.MpdPathLabel.SetVisible(unix)\n\td.MpdHostEntry.SetVisible(tcp)\n\td.MpdHostLabel.SetVisible(tcp)\n\td.MpdHostLabelRemark.SetVisible(tcp)\n\td.MpdPortSpinButton.SetVisible(tcp)\n\td.MpdPortLabel.SetVisible(tcp)\n}", "func (o *NewWindowOptions) Fixup() {\n\tsc := TheApp.Screen(0)\n\tscsz := sc.Geometry.Size() // window coords size\n\n\tif o.Size.X <= 0 {\n\t\to.StdPixels = false\n\t\to.Size.X = int(0.8 * float32(scsz.X) * sc.DevicePixelRatio)\n\t}\n\tif o.Size.Y <= 0 {\n\t\to.StdPixels = false\n\t\to.Size.Y = int(0.8 * float32(scsz.Y) * sc.DevicePixelRatio)\n\t}\n\n\to.Size, o.Pos = sc.ConstrainWinGeom(o.Size, o.Pos)\n\tif o.Pos.X == 0 && o.Pos.Y == 0 {\n\t\twsz := sc.WinSizeFmPix(o.Size)\n\t\tdialog, modal, _, _ := WindowFlagsToBool(o.Flags)\n\t\tnw := TheApp.NWindows()\n\t\tif nw > 0 {\n\t\t\tlastw := TheApp.Window(nw - 1)\n\t\t\tlsz := lastw.WinSize()\n\t\t\tlp := lastw.Position()\n\n\t\t\tnwbig := wsz.X > lsz.X || wsz.Y > lsz.Y\n\n\t\t\tif modal || dialog || !nwbig { // place centered on top of current\n\t\t\t\tctrx := lp.X + (lsz.X / 2)\n\t\t\t\tctry := lp.Y + (lsz.Y / 2)\n\t\t\t\to.Pos.X = ctrx - wsz.X/2\n\t\t\t\to.Pos.Y = ctry - wsz.Y/2\n\t\t\t} else { // cascade to right\n\t\t\t\to.Pos.X = lp.X + lsz.X // tile to right -- could depend on orientation\n\t\t\t\to.Pos.Y = lp.Y + 72 // and move down a bit\n\t\t\t}\n\t\t} else { // center in screen\n\t\t\to.Pos.X = scsz.X/2 - wsz.X/2\n\t\t\to.Pos.Y = scsz.Y/2 - wsz.Y/2\n\t\t}\n\t\to.Size, o.Pos = sc.ConstrainWinGeom(o.Size, o.Pos) // make sure ok\n\t}\n}", "func newGLWindow(opts *oswin.NewWindowOptions, sc *oswin.Screen) (*glfw.Window, error) {\n\t_, _, tool, fullscreen := oswin.WindowFlagsToBool(opts.Flags)\n\tglfw.DefaultWindowHints()\n\tglfw.WindowHint(glfw.Resizable, glfw.True)\n\tglfw.WindowHint(glfw.Visible, glfw.False) // needed to position\n\tglfw.WindowHint(glfw.Focused, glfw.True)\n\t// glfw.WindowHint(glfw.ScaleToMonitor, glfw.True)\n\tglfw.WindowHint(glfw.ContextVersionMajor, glosGlMajor)\n\tglfw.WindowHint(glfw.ContextVersionMinor, glosGlMinor)\n\tglfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)\n\tglfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)\n\tglfw.WindowHint(glfw.Samples, 0) // don't do multisampling for main window -- only in sub-render\n\tif glosDebug {\n\t\tglfw.WindowHint(glfw.OpenGLDebugContext, glfw.True)\n\t}\n\n\t// todo: glfw.Samples -- multisampling\n\tif fullscreen {\n\t\tglfw.WindowHint(glfw.Maximized, glfw.True)\n\t}\n\tif tool {\n\t\tglfw.WindowHint(glfw.Decorated, glfw.False)\n\t} else {\n\t\tglfw.WindowHint(glfw.Decorated, glfw.True)\n\t}\n\t// todo: glfw.Floating for always-on-top -- could set for modal\n\tsz := opts.Size // note: this is already in standard window size units!\n\twin, err := glfw.CreateWindow(sz.X, sz.Y, opts.GetTitle(), nil, theApp.shareWin)\n\tif err != nil {\n\t\treturn win, err\n\t}\n\twin.SetPos(opts.Pos.X, opts.Pos.Y)\n\treturn win, err\n}", "func (this *Window) SetSize(size Vector2u) {\n\tC.sfWindow_setSize(this.cptr, size.toC())\n}", "func getScreen(w, h int) screen.Screen {\n\tvar err error\n\trunSdl2 := flag.Bool(\"sdl2\", false, \"a string\")\n\trunDebug := flag.Bool(\"debug\", false, \"a string\")\n\tflag.Parse()\n\tvar scr screen.Screen\n\tif *runSdl2 {\n\t\tscr, err = screen.Sdl2{}.NewScreen(w, h)\n\t} else if *runDebug {\n\t\tscr, err = screen.DummyScreen{}.NewScreen(w, h)\n\t} else {\n\t\tscr, err = screen.Console{}.NewScreen(0, 0) // Console is auto-sized\n\t}\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tscr.SetKeyboardHandler(keyCodeToInput)\n\n\treturn scr\n}", "func SetConfigParameterForQBlock(session *libcoap.Session, customerId int) {\n // Get session config\n sessionConfig, err := models.GetCurrentSignalSessionConfiguration(customerId)\n if err != nil {\n log.Error(\"Failed to get current session config\")\n }\n // Get mitigationIds with status is 2\n mids, err := models.GetMitigationIdsByCustomer(customerId)\n if err != nil {\n log.Error(\"Failed to Get mitigation ids\")\n return\n }\n if sessionConfig != nil && sessionConfig.SessionId > 0 {\n maxPayLoad := sessionConfig.MaxPayloadIdle\n nonMaxRetransmit := sessionConfig.NonMaxRetransmitIdle\n nonTimeout := sessionConfig.NonTimeoutIdle\n nonReceiveTimeout := sessionConfig.NonReceiveTimeoutIdle\n if len(mids) > 0 {\n maxPayLoad = sessionConfig.MaxPayload\n nonMaxRetransmit = sessionConfig.NonMaxRetransmit\n nonTimeout = sessionConfig.NonTimeout\n nonReceiveTimeout = sessionConfig.NonReceiveTimeout\n }\n session.SetMaxPayLoads(maxPayLoad)\n session.SetNonMaxRetransmit(nonMaxRetransmit)\n session.SetNonTimeout(decimal.NewFromFloat(nonTimeout).Round((2)))\n session.SetNonReceiveTimeout(decimal.NewFromFloat(nonReceiveTimeout).Round((2)))\n }\n}", "func (s *User) SettingsUI(title string, editors []string) {\n\tapp := tview.NewApplication()\n\n\tform := tview.NewForm().\n\t\tAddCheckbox(\"Update on starting katbox\", s.AutoUpdate, nil).\n\t\tAddDropDown(\"Editor\", editors, 0, nil).\n\t\tAddInputField(\"(optional) Custom editor Path\", s.Editor, 30, nil, nil).\n\t\tAddInputField(\"Git clone path\", s.GitPath, 30, nil, nil).\n\t\tAddCheckbox(\"Open URLs in Browser\", s.OpenURL, nil).\n\t\tAddButton(\"Save Settings\", func() { app.Stop() })\n\n\tform.SetBorder(true).SetTitle(title).SetTitleAlign(tview.AlignLeft)\n\tif err := app.SetRoot(form, true).Run(); err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Retrieve values and update settings\n\n\t_, s.Editor = form.GetFormItemByLabel(\"Editor\").(*tview.DropDown).GetCurrentOption()\n\t// If a custom editor has been selected then set the value from the custom Editor field\n\tif s.Editor == \"Custom\" {\n\t\ts.CustomEditor = form.GetFormItemByLabel(\"Editor Path\").(*tview.InputField).GetText()\n\t}\n\n\t// TODO - do a OS/Editor lookup and set the path accordingly\n\n\ts.OpenURL = form.GetFormItemByLabel(\"Open URLs in Browser\").(*tview.Checkbox).IsChecked()\n}", "func WindowSize() (w, h int) {\n\treturn windowSize()\n}", "func (w *MainWindow) GetSize() (int, int) {\n\treturn w.glfwWindow.GetSize()\n}", "func onWindowResize(w *glfw.Window, width int, height int) {\n\tuiman.AdviseResolution(int32(width), int32(height))\n\trenderer.ChangeResolution(int32(width), int32(height))\n}", "func (win *Window) Display() {\n\tC.sfRenderWindow_display(win.win)\n}", "func (me XsdGoPkgHasAttr_Show) ShowDefault() TxsdShow { return TxsdShow(\"embed\") }", "func WindowSize(s int) ConfigFunc {\n\treturn func(c *Config) {\n\t\tc.WindowSize = s\n\t}\n}", "func (h *House) Update(win *pixelgl.Window, carrying string) {\n\tif !h.IsActive() {\n\t\treturn\n\t}\n\n\t// Draw box\n\timd := getBox()\n\timd.Draw(win)\n\n\t// Draw title\n\ttitle, scale := getText(-1, h.Title(), 1.4, titleV)\n\ttitle.Draw(win, scale)\n\n\tshiftV := pixel.V(0, 30)\n\thouseoptions := h.opts(carrying)\n\tfor j, opt := range houseoptions {\n\t\tv := menuV.Sub(shiftV.Scaled(float64(j + 1)))\n\t\toptTxt, scale := getText(j+1, opt.Text(), 1.1, v)\n\t\toptTxt.Draw(win, scale)\n\t}\n\n\t// Check if the user presses a number key to select an option\n\tdoOptions(win, houseoptions, carrying, h)\n}", "func wmDisplayResolutionP(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device) error {\n\tact, err := arc.NewActivity(a, wm.Pkg24, wm.ResizableLandscapeActivity)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer act.Close()\n\tif err := act.StartWithDefaultOptions(ctx, tconn); err != nil {\n\t\treturn err\n\t}\n\tdefer act.Stop(ctx, tconn)\n\n\tif err := wm.WaitUntilActivityIsReady(ctx, tconn, act, d); err != nil {\n\t\treturn err\n\t}\n\n\tdisp, err := display.GetPrimaryInfo(ctx, tconn)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toldBounds, err := act.WindowBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttesting.ContextLogf(ctx, \"Window bounds before changing display resolution: %+v\", oldBounds)\n\n\tbutton := d.Object(ui.PackageName(act.PackageName()),\n\t\tui.ClassName(\"android.widget.Button\"),\n\t\tui.ID(\"org.chromium.arc.testapp.windowmanager:id/button_show\"))\n\tif err := button.WaitForExists(ctx, 10*time.Second); err != nil {\n\t\treturn err\n\t}\n\tbuttonBoundsOld, err := button.GetBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttesting.ContextLogf(ctx, \"Button bounds before changing display resolution: %+v\", buttonBoundsOld)\n\tarray := disp.AvailableDisplayZoomFactors\n\ttesting.ContextLog(ctx, \"Available zoom factors: \", array)\n\tnewZoom := 0.\n\t// We are intersted in the first Zoom Factor different than 1.\n\tfor _, z := range array {\n\t\tif z != 1 {\n\t\t\tnewZoom = z\n\t\t\tbreak\n\t\t}\n\t}\n\tif newZoom == 0 {\n\t\treturn errors.Errorf(\"invalid AvailableDisplayZoomFactors: got %v; want array with at least one value different than '1'\", array)\n\t}\n\n\ttesting.ContextLog(ctx, \"Using display zoom factor = \", newZoom)\n\tif err := wm.ChangeDisplayZoomFactor(ctx, tconn, disp.ID, newZoom); err != nil {\n\t\treturn err\n\t}\n\t// Restore original zoom factor on exit.\n\tdefer wm.ChangeDisplayZoomFactor(ctx, tconn, disp.ID, disp.DisplayZoomFactor)\n\n\t// Polling until we get the expected value. But we don't PollBreak if we get an \"unexpected\" value, since\n\t// we might correctly get \"unexpected\" values from Android during the scale factor switch.\n\treturn testing.Poll(ctx, func(ctx context.Context) error {\n\t\t// New bounds should be: old bounds / newZoom.\n\t\t// Since the zoom factor could use numbers like 1.100000023841858, we take rounding-error into account.\n\t\t// But error shouldn't be more than 1 pixel.\n\t\tconst errorMargin = 1\n\t\tnewBounds, err := act.WindowBounds(ctx)\n\t\tif err != nil {\n\t\t\treturn testing.PollBreak(err)\n\t\t}\n\t\ttesting.ContextLogf(ctx, \"Window bounds after changing display resolution: %+v\", newBounds)\n\n\t\texpectedW := float64(oldBounds.Width) / newZoom\n\t\tif math.Abs(float64(newBounds.Width)-expectedW) > errorMargin {\n\t\t\treturn errors.Errorf(\"invalid width: got %d, want: %v +/- %d\", newBounds.Width, expectedW, errorMargin)\n\t\t}\n\t\texpectedH := float64(oldBounds.Height) / newZoom\n\t\tif math.Abs(float64(newBounds.Height)-expectedH) > errorMargin {\n\t\t\treturn errors.Errorf(\"invalid height: got %d, want: %v +/- %d\", newBounds.Height, expectedH, errorMargin)\n\t\t}\n\n\t\tbuttonBoundsNew, err := button.GetBounds(ctx)\n\t\tif err != nil {\n\t\t\treturn testing.PollBreak(err)\n\t\t}\n\t\ttesting.ContextLogf(ctx, \"Button bounds after changing display resolution: %+v\", buttonBoundsNew)\n\n\t\t// It might be possible that the layout changed, changing the buttons' position.\n\t\t// But the buttons' size in DPs, and not pixels, should be the same.\n\t\tif buttonBoundsOld.Width != buttonBoundsNew.Width {\n\t\t\treturn errors.Errorf(\"invalid button width: got %d, want %d\", buttonBoundsNew.Width, buttonBoundsOld.Width)\n\t\t}\n\t\tif buttonBoundsOld.Height != buttonBoundsNew.Height {\n\t\t\treturn errors.Errorf(\"invalid button height: got %d, want %d\", buttonBoundsNew.Height, buttonBoundsOld.Height)\n\t\t}\n\t\treturn nil\n\t}, &testing.PollOptions{Timeout: 10 * time.Second})\n}", "func (me XAttrShow) ShowDefault() TxsdShow { return TxsdShow(\"embed\") }", "func (game *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {\n return 640, 480\n}", "func (w *GlfwWindow) ScreenResolution(p interface{}) (width, height int) {\n\n\tmon := glfw.GetPrimaryMonitor()\n\tvmode := mon.GetVideoMode()\n\treturn vmode.Width, vmode.Height\n}", "func (w *Window) updateDimensions() {\n\tif w.windowLayout == nil {\n\t\treturn\n\t}\n\n\tw.window.SetFixedHeight(w.windowLayout.SizeHint().Height())\n}", "func doShowMeshWindow(compMesh *component.Mesh) {\n\tmeshWindow := uiman.GetWindow(fmt.Sprintf(\"%s%s\", compMeshWindowID, compMesh.Name))\n\tif meshWindow == nil {\n\t\tcreateMeshWindow(compMesh, meshWndX, meshWndY)\n\t}\n}", "func imgTopReleaseEvent() {\n\tAbout.Width = 400\n\tAbout.ImageOkButtonSize = 24\n\tAbout.Show()\n}", "func RunUI(cfg Config, inStatusCh chan inputStats, outputStatusChannel chan outputStats, cfgSource string) {\n\t// Let the goroutines initialize before starting GUI\n\ttime.Sleep(50 * time.Millisecond)\n\tif err := ui.Init(); err != nil {\n\t\tlog.Fatalf(\"failed to initialize termui: %v\", err)\n\t}\n\tdefer ui.Close()\n\n\ty := 0\n\theight := 5\n\twidth := 120\n\thalfWidth := width / 2\n\n\tp := widgets.NewParagraph()\n\tp.Title = applicationName()\n\tp.Text = fmt.Sprintf(\"PRESS q TO QUIT.\\nConfig from: %s\\n\", cfgSource)\n\n\tp.SetRect(0, y, width, height)\n\tp.TextStyle.Fg = ui.ColorWhite\n\tp.BorderStyle.Fg = ui.ColorCyan\n\n\ty += height\n\theight = 10\n\tinSrcHeight := height\n\tif cfg.RetransmitEnabled() {\n\t\tinSrcHeight = height * 2\n\n\t}\n\n\tinpSrcStatus := widgets.NewParagraph()\n\tinpSrcStatus.Title = \"GPS/GPS Compass in\"\n\tif cfg.InputEnabled() {\n\t\tinpSrcStatus.Text = \"Waiting for data\"\n\t} else {\n\t\tinpSrcStatus.Text = \"Input not enabled\"\n\t}\n\n\tinpSrcStatus.SetRect(0, y, halfWidth, y+inSrcHeight)\n\tinpSrcStatus.TextStyle.Fg = ui.ColorGreen\n\tinpSrcStatus.BorderStyle.Fg = ui.ColorCyan\n\n\tinpArrow := widgets.NewParagraph()\n\tinpArrow.Border = false\n\tinpArrow.Text = \"=>\"\n\tinpArrow.SetRect(halfWidth, y, halfWidth+5, y+height)\n\n\tinpDestStatus := widgets.NewParagraph()\n\tinpDestStatus.Title = \"GPS/GPS Compass out to UGPS\"\n\n\tinpDestStatus.SetRect(halfWidth+5, y, width, y+height)\n\tinpDestStatus.TextStyle.Fg = ui.ColorGreen\n\tinpDestStatus.BorderStyle.Fg = ui.ColorCyan\n\n\tinpRetransmitStatus := widgets.NewParagraph()\n\tif cfg.RetransmitEnabled() {\n\t\tinpRetransmitStatus.Title = \"Retransmit Input\"\n\n\t\tinpRetransmitStatus.SetRect(halfWidth+5, y+height, width, y+inSrcHeight)\n\t\tinpRetransmitStatus.TextStyle.Fg = ui.ColorGreen\n\t\tinpRetransmitStatus.BorderStyle.Fg = ui.ColorCyan\n\t}\n\n\t//y += height\n\ty += inSrcHeight\n\theight = 10\n\n\toutSrcStatus := widgets.NewParagraph()\n\toutSrcStatus.Title = \"Locator Position in from UGPS\"\n\toutSrcStatus.Text = \"Waiting for data\"\n\tif !cfg.OutputEnabled() {\n\t\toutSrcStatus.Text = \"Output not enabled\"\n\t}\n\toutSrcStatus.SetRect(0, y, halfWidth, y+height)\n\toutSrcStatus.TextStyle.Fg = ui.ColorGreen\n\toutSrcStatus.BorderStyle.Fg = ui.ColorCyan\n\n\toutArrow := widgets.NewParagraph()\n\toutArrow.Border = false\n\toutArrow.Text = \"=>\"\n\toutArrow.SetRect(halfWidth, y, halfWidth+5, y+height)\n\n\toutDestStatus := widgets.NewParagraph()\n\toutDestStatus.Title = \"Locator Position out to NMEA\"\n\toutDestStatus.Text = \"Waiting for data\"\n\tif !cfg.OutputEnabled() {\n\t\toutDestStatus.Text = \"Output not enabled\"\n\t}\n\toutDestStatus.SetRect(halfWidth+5, y, width, y+height)\n\toutDestStatus.TextStyle.Fg = ui.ColorGreen\n\toutDestStatus.BorderStyle.Fg = ui.ColorCyan\n\n\ty += height\n\theight = 15\n\n\tdbgText := widgets.NewList()\n\tdbgText.Title = \"Debug\"\n\tdbgText.Rows = dbgMsg\n\tdbgText.WrapText = true\n\tdbgText.SetRect(0, y, width, y+height)\n\tdbgText.BorderStyle.Fg = ui.ColorCyan\n\n\thideDebug := widgets.NewParagraph()\n\thideDebug.Text = \"\"\n\thideDebug.SetRect(0, y, width, y+height)\n\thideDebug.Border = false\n\n\tdraw := func() {\n\t\tui.Render(p, inpSrcStatus, inpArrow, inpDestStatus, outSrcStatus, outArrow, outDestStatus, inpRetransmitStatus)\n\t\tif debug {\n\t\t\tdbgText.Rows = dbgMsg\n\t\t\tui.Render(dbgText)\n\t\t} else {\n\t\t\tui.Render(hideDebug)\n\t\t}\n\t}\n\n\t// Initial draw before any events have occurred\n\tdraw()\n\n\tuiEvents := ui.PollEvents()\n\n\tfor {\n\t\tselect {\n\t\tcase inStats := <-inStatusCh:\n\t\t\tinpSrcStatus.TextStyle.Fg = ui.ColorGreen\n\t\t\tinpSrcStatus.Text = fmt.Sprintf(\"Source: %s\\n\\n\", cfg.Input.Device) +\n\t\t\t\t\"Supported NMEA sentences received:\\n\" +\n\t\t\t\tfmt.Sprintf(\" * Topside Position : %s\\n\", inStats.src.posDesc) +\n\t\t\t\tfmt.Sprintf(\" * Topside Heading : %s\\n\", inStats.src.headDesc) +\n\t\t\t\tfmt.Sprintf(\" * Parse error: %d\\n\\n\", inStats.src.unparsableCount) +\n\t\t\t\tinStats.src.errorMsg\n\t\t\tif inStats.src.errorMsg != \"\" {\n\t\t\t\tinpSrcStatus.TextStyle.Fg = ui.ColorRed\n\t\t\t}\n\t\t\tinpDestStatus.TextStyle.Fg = ui.ColorGreen\n\t\t\tinpDestStatus.Text = fmt.Sprintf(\"Destination: %s\\n\\n\", cfg.BaseURL) +\n\t\t\t\tfmt.Sprintf(\"Sent successfully to\\n Underwater GPS: %d\\n\\n\", inStats.dst.sendOk) +\n\t\t\t\tinStats.dst.errorMsg\n\t\t\tif inStats.dst.errorMsg != \"\" {\n\t\t\t\tinpDestStatus.TextStyle.Fg = ui.ColorRed\n\t\t\t}\n\n\t\t\tinpRetransmitStatus.Text = fmt.Sprintf(\"Destination: %s\\n\\n\", cfg.Input.Retransmit) +\n\t\t\t\tfmt.Sprintf(\"Count: %d\\n%s\", inStats.retransmit.count, inStats.retransmit.errorMsg)\n\t\t\tinpRetransmitStatus.TextStyle.Fg = ui.ColorGreen\n\t\t\tif inStats.retransmit.errorMsg != \"\" {\n\t\t\t\tinpRetransmitStatus.TextStyle.Fg = ui.ColorRed\n\t\t\t}\n\t\t\tdraw()\n\t\tcase outStats := <-outputStatusChannel:\n\t\t\toutSrcStatus.Text = fmt.Sprintf(\"Source: %s\\n\\n\", cfg.BaseURL) +\n\t\t\t\tfmt.Sprintf(\"Positions from Underwater GPS:\\n %d\\n\", outStats.src.getCount)\n\t\t\toutSrcStatus.TextStyle.Fg = ui.ColorGreen\n\n\t\t\tif outStats.src.errMsg != \"\" {\n\t\t\t\toutSrcStatus.TextStyle.Fg = ui.ColorRed\n\t\t\t\toutSrcStatus.Text += fmt.Sprintf(\"\\n\\n%v (%d)\", outStats.src.errMsg, outStats.src.getErr)\n\t\t\t}\n\n\t\t\toutDestStatus.Text = fmt.Sprintf(\"Destination: %s\\n\\n\", cfg.Output.Device) +\n\t\t\t\t\"Sent:\\n\" +\n\t\t\t\tfmt.Sprintf(\" * Locator/ROV Position : %s: %d\\n\", strings.ToUpper(cfg.Output.PositionSentence), outStats.dst.sendOk)\n\t\t\toutDestStatus.TextStyle.Fg = ui.ColorGreen\n\n\t\t\tif outStats.dst.errMsg != \"\" {\n\t\t\t\toutDestStatus.TextStyle.Fg = ui.ColorRed\n\t\t\t\toutDestStatus.Text += fmt.Sprintf(\"\\n\\n%s\", outStats.dst.errMsg)\n\t\t\t}\n\t\t\tdraw()\n\t\tcase e := <-uiEvents:\n\t\t\tswitch e.ID {\n\t\t\tcase \"q\", \"<C-c>\":\n\t\t\t\treturn\n\t\t\tcase \"d\":\n\t\t\t\tdbgMsg = nil\n\t\t\t\tdbgText.Rows = dbgMsg\n\t\t\t\tdebug = !debug\n\n\t\t\t\tdraw()\n\t\t\t}\n\t\t}\n\t}\n}", "func ShowConf(iface string) ([]byte, error) {\n\tcmd := exec.Command(\"wg\", \"showconf\", iface)\n\tvar stderr, stdout bytes.Buffer\n\tcmd.Stderr = &stderr\n\tcmd.Stdout = &stdout\n\tif err := cmd.Run(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read the WireGuard configuration: %s\", stderr.String())\n\t}\n\treturn stdout.Bytes(), nil\n}", "func (cfg *Config) Display() {\n fmt.Println(os.Args)\n fmt.Println(\"-------------------------------------\")\n}", "func fromdlgunitsX(du int, d *sizing) int {\n\treturn int(C.MulDiv(C.int(du), d.baseX, 4))\n}", "func (g *Gui) Size() (x, y int) {\n\treturn g.maxX, g.maxY\n}", "func (p *DiskPlugin) Config(key string, value string) error {\n\tif key == \"size\" {\n\t\tvar err error\n\t\tsize, err = strconv.ParseUint(value, 0, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsize_set = true\n\t\treturn nil\n\t} else {\n\t\treturn nbdkit.PluginError{Errmsg: \"unknown parameter\"}\n\t}\n}", "func (m *ScreenMode) Resolution() (width, height int) {\n\treturn m.width, m.height\n}", "func (d *PrefsDialog) onSettingChange() {\n\t// Ignore if the dialog is not initialised yet\n\tif !d.initialised {\n\t\treturn\n\t}\n\tlog.Debug(\"onSettingChange()\")\n\n\t// Collect settings\n\tcfg := config.GetConfig()\n\t// General page\n\tcfg.MpdNetwork = d.MpdNetworkComboBox.GetActiveID()\n\tcfg.MpdSocketPath = util.EntryText(d.MpdPathEntry, \"\")\n\tcfg.MpdHost = util.EntryText(d.MpdHostEntry, \"\")\n\tcfg.MpdPort = int(d.MpdPortAdjustment.GetValue())\n\tif s, err := d.MpdPasswordEntry.GetText(); !errCheck(err, \"MpdPasswordEntry.GetText() failed\") {\n\t\tcfg.MpdPassword = s\n\t}\n\tcfg.MpdAutoConnect = d.MpdAutoConnectCheckButton.GetActive()\n\tcfg.MpdAutoReconnect = d.MpdAutoReconnectCheckButton.GetActive()\n\td.updateGeneralWidgets()\n\n\t// Interface page\n\tif b := d.QueueToolbarCheckButton.GetActive(); b != cfg.QueueToolbar {\n\t\tcfg.QueueToolbar = b\n\t\td.schedulePlayerSettingChange()\n\t}\n\tcfg.TrackDefaultReplace = d.LibraryDefaultReplaceRadioButton.GetActive()\n\tcfg.PlaylistDefaultReplace = d.PlaylistsDefaultReplaceRadioButton.GetActive()\n\tcfg.StreamDefaultReplace = d.StreamsDefaultReplaceRadioButton.GetActive()\n\n\t// Automation page\n\tcfg.SwitchToOnQueueReplace = d.AutomationQueueReplaceSwitchToCheckButton.GetActive()\n\tcfg.PlayOnQueueReplace = d.AutomationQueueReplacePlayCheckButton.GetActive()\n\n\t// Player page\n\tif b := d.PlayerShowAlbumArtTracksCheckButton.GetActive(); b != cfg.PlayerAlbumArtTracks {\n\t\tcfg.PlayerAlbumArtTracks = b\n\t\td.schedulePlayerSettingChange()\n\t}\n\tif b := d.PlayerShowAlbumArtStreamsCheckButton.GetActive(); b != cfg.PlayerAlbumArtStreams {\n\t\tcfg.PlayerAlbumArtStreams = b\n\t\td.schedulePlayerSettingChange()\n\t}\n\tif i := int(d.PlayerAlbumArtSizeAdjustment.GetValue()); i != cfg.PlayerAlbumArtSize {\n\t\tcfg.PlayerAlbumArtSize = i\n\t\td.schedulePlayerSettingChange()\n\t}\n\tif s, err := util.GetTextBufferText(d.PlayerTitleTemplateTextBuffer); !errCheck(err, \"util.GetTextBufferText() failed\") {\n\t\tif s != cfg.PlayerTitleTemplate {\n\t\t\tcfg.PlayerTitleTemplate = s\n\t\t\td.schedulePlayerSettingChange()\n\t\t}\n\t}\n}", "func (p *Porter) ShowParameter(ctx context.Context, opts ParameterShowOptions) error {\n\tps, err := p.Parameters.GetParameterSet(ctx, opts.Namespace, opts.Name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tparamSet := NewDisplayParameterSet(ps)\n\n\tswitch opts.Format {\n\tcase printer.FormatJson:\n\t\treturn printer.PrintJson(p.Out, paramSet)\n\tcase printer.FormatYaml:\n\t\treturn printer.PrintYaml(p.Out, paramSet)\n\tcase printer.FormatPlaintext:\n\t\t// Set up human friendly time formatter\n\t\tnow := time.Now()\n\t\ttp := dtprinter.DateTimePrinter{\n\t\t\tNow: func() time.Time { return now },\n\t\t}\n\n\t\t// Here we use an instance of olekukonko/tablewriter as our table,\n\t\t// rather than using the printer pkg variant, as we wish to decorate\n\t\t// the table a bit differently from the default\n\t\tvar rows [][]string\n\n\t\t// Iterate through all ParameterStrategies and add to rows\n\t\tfor _, pset := range paramSet.Parameters {\n\t\t\trows = append(rows, []string{pset.Name, pset.Source.Hint, pset.Source.Strategy})\n\t\t}\n\n\t\t// Build and configure our tablewriter\n\t\ttable := tablewriter.NewWriter(p.Out)\n\t\ttable.SetCenterSeparator(\"\")\n\t\ttable.SetColumnSeparator(\"\")\n\t\ttable.SetAlignment(tablewriter.ALIGN_LEFT)\n\t\ttable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)\n\t\ttable.SetBorders(tablewriter.Border{Left: false, Right: false, Bottom: false, Top: true})\n\t\ttable.SetAutoFormatHeaders(false)\n\n\t\t// First, print the ParameterSet metadata\n\t\tfmt.Fprintf(p.Out, \"Name: %s\\n\", paramSet.Name)\n\t\tfmt.Fprintf(p.Out, \"Created: %s\\n\", tp.Format(paramSet.Status.Created))\n\t\tfmt.Fprintf(p.Out, \"Modified: %s\\n\\n\", tp.Format(paramSet.Status.Modified))\n\n\t\t// Print labels, if any\n\t\tif len(paramSet.Labels) > 0 {\n\t\t\tfmt.Fprintln(p.Out, \"Labels:\")\n\n\t\t\tfor k, v := range paramSet.Labels {\n\t\t\t\tfmt.Fprintf(p.Out, \" %s: %s\\n\", k, v)\n\t\t\t}\n\t\t\tfmt.Fprintln(p.Out)\n\t\t}\n\n\t\t// Now print the table\n\t\ttable.SetHeader([]string{\"Name\", \"Local Source\", \"Source Type\"})\n\t\tfor _, row := range rows {\n\t\t\ttable.Append(row)\n\t\t}\n\t\ttable.Render()\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid format: %s\", opts.Format)\n\t}\n}", "func newGLWindow(opts *oswin.NewWindowOptions) (*glfw.Window, error) {\n\t_, _, tool, fullscreen := oswin.WindowFlagsToBool(opts.Flags)\n\tglfw.DefaultWindowHints()\n\tglfw.WindowHint(glfw.Resizable, glfw.True)\n\tglfw.WindowHint(glfw.Visible, glfw.True) // needed to position\n\tglfw.WindowHint(glfw.Focused, glfw.True)\n\tglfw.WindowHint(glfw.ContextVersionMajor, 4) // 4.1 is max supported on macos\n\tglfw.WindowHint(glfw.ContextVersionMinor, 1)\n\tglfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)\n\tglfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)\n\tglfw.WindowHint(glfw.Samples, 0) // don't do multisampling for main window -- only in sub-render\n\tif glosDebug {\n\t\tglfw.WindowHint(glfw.OpenGLDebugContext, glfw.True)\n\t}\n\n\t// todo: glfw.Samples -- multisampling\n\tif fullscreen {\n\t\tglfw.WindowHint(glfw.Maximized, glfw.True)\n\t}\n\tif tool {\n\t\tglfw.WindowHint(glfw.Decorated, glfw.False)\n\t} else {\n\t\tglfw.WindowHint(glfw.Decorated, glfw.True)\n\t}\n\t// todo: glfw.Floating for always-on-top -- could set for modal\n\twin, err := glfw.CreateWindow(opts.Size.X, opts.Size.Y, opts.GetTitle(), nil, nil)\n\tif err != nil {\n\t\treturn win, err\n\t}\n\twin.SetPos(opts.Pos.X, opts.Pos.Y)\n\treturn win, err\n}", "func InputDialog(opt ...interface{}) string {\n b, _ := gtk.BuilderNewFromFile(\"glade/input-dialog.glade\")\n d := GetDialog(b, \"input_dialog\")\n entry := GetEntry(b, \"input_entry\")\n\n for i, v := range(opt) {\n if i % 2 == 0 {\n key := v.(string)\n switch key {\n case \"title\":\n d.SetTitle(opt[i+1].(string))\n case \"label\":\n l := GetLabel(b,\"input_label\")\n l.SetText(opt[i+1].(string))\n case \"password-mask\":\n entry.SetInvisibleChar(opt[i+1].(rune))\n entry.SetVisibility(false)\n case \"default\":\n entry.SetText(opt[i+1].(string))\n }\n }\n }\n\n output := \"\"\n entry.Connect(\"activate\", func (o *gtk.Entry) { d.Response(gtk.RESPONSE_OK) } )\n btok := GetButton(b, \"bt_ok\")\n btok.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_OK) } )\n\n btcancel := GetButton(b, \"bt_cancel\")\n btcancel.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_CANCEL) } )\n\n code := d.Run()\n if code == gtk.RESPONSE_OK {\n output, _ = entry.GetText()\n }\n\n d.Destroy()\n return output\n}", "func (this *Device) GetDisplaySize(display uint16) (uint32, uint32) {\n\treturn bcmGHostGetDisplaySize(display)\n}", "func (s *Screen) Size() Point { return Point{X: s.width, Y: len(s.current) / s.width} }", "func (v Vehicle) GuiSettings() (*GuiSettings, error) {\n\tstateRequest, err := fetchState(\"/gui_settings\", v.ID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn stateRequest.Response.GuiSettings, nil\n}", "func DialogInfo(body string) {\n\tif currentWindow == nil {\n\t\treturn\n\t}\n\n\t(*currentWindow).Dispatch(func() {\n\t\t(*currentWindow).Dialog(webview.DialogTypeAlert, webview.DialogFlagInfo,\n\t\t\t\"DTransfer\", body)\n\t})\n}", "func (c *Camera) SetSize(widht, height int) {\n\tc.windowWidth = widht\n\tc.windowHeight = height\n}", "func (elementConfiguration *ElementConfiguration) Show() (string, error) {\n\treturn util.ConvertToYAML(elementConfiguration)\n}", "func (u *Usage) Show() error {\n\th := u.handler\n\tdefer h.cleanup()\n\n\tif err := h.setup([]api.Script{api.Usage}, []api.Script{}); err != nil {\n\t\treturn err\n\t}\n\n\treturn h.execute(api.Usage)\n}", "func New(opts ...Option) *Config {\n\tcfg := &Config{\n\t\tWindowWidth: 800,\n\t\tWindowHeight: 600,\n\t\tSize: 5,\n\t\tSquareSize: 48,\n\t\tDotRadius: 16,\n\t\tColor: &sdl.Color{R: 168, G: 168, B: 168, A: 255},\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(cfg)\n\t}\n\n\treturn cfg\n}", "func CustomizeScreen(w fyne.Window) fyne.CanvasObject {\n\tc := conf.Get()\n\ttb := widget.NewTabContainer()\n\td, _ := ioutil.ReadFile(c.DynamicUIFile)\n\tvar info uiConf\n\terr := json.Unmarshal(d, &info)\n\tif err != nil {\n\t\t// fmt.Println(\"dReadUI:\", err)\n\t\ttb.Append(widget.NewTabItem(\"error\", widget.NewLabel(fmt.Sprint(err))))\n\t\ttb.SelectTabIndex(0)\n\t\treturn tb\n\t}\n\tfor _, it := range info.RunUI {\n\t\tif it.Hide {\n\t\t\tcontinue\n\t\t}\n\t\ttb.Append(widget.NewTabItem(\"R_\"+it.Name, newRunUI(w, it)))\n\t}\n\tfor _, it := range info.ViewUI {\n\t\tif it.Hide {\n\t\t\tcontinue\n\t\t}\n\t\ttb.Append(widget.NewTabItem(\"V_\"+it.Name, newReadUI(w, it)))\n\t}\n\ttb.SelectTabIndex(0)\n\treturn tb\n}", "func (c *Firewall) Show() (Config, error) {\n\tans := c.container()\n\terr := c.ns.Object(util.Show, c.pather(), \"\", ans)\n\treturn first(ans, err)\n}", "func (tbd *TermboxDriver) Size() (width int, height int) {\n\treturn tbd.width, tbd.height\n}", "func getMonitorRealSize(hMonitor win.HMONITOR) *win.RECT {\n\tinfo := _MONITORINFOEX{}\n\tinfo.CbSize = uint32(unsafe.Sizeof(info))\n\n\tret, _, _ := syscall.Syscall(funcGetMonitorInfo, 2, uintptr(hMonitor), uintptr(unsafe.Pointer(&info)), 0)\n\tif ret == 0 {\n\t\treturn nil\n\t}\n\n\tdevMode := _DEVMODE{}\n\tdevMode.DmSize = uint16(unsafe.Sizeof(devMode))\n\n\tif ret, _, _ := syscall.Syscall(funcEnumDisplaySettings, 3, uintptr(unsafe.Pointer(&info.DeviceName[0])), _ENUM_CURRENT_SETTINGS, uintptr(unsafe.Pointer(&devMode))); ret == 0 {\n\t\treturn nil\n\t}\n\n\treturn &win.RECT{\n\t\tLeft: devMode.DmPosition.X,\n\t\tRight: devMode.DmPosition.X + int32(devMode.DmPelsWidth),\n\t\tTop: devMode.DmPosition.Y,\n\t\tBottom: devMode.DmPosition.Y + int32(devMode.DmPelsHeight),\n\t}\n}", "func New(ctx context.Context, settings *DisplaySettings) *Display {\n\tebiten.SetWindowSize(settings.Width, settings.Height)\n\tebiten.SetWindowTitle(settings.Title)\n\n\t// hide cursor\n\tif settings.HideCursor {\n\t\tebiten.SetCursorMode(ebiten.CursorModeHidden)\n\t}\n\n\tdisplay := &Display{ctx: ctx, settings: settings, mouseEventRegistry: DefaultMouseEventRegistry}\n\treturn display\n}", "func (c *qemuCmd) WindowResize(fd, winchWidth, winchHeight int) error {\n\tcommand := api.InstanceExecControl{\n\t\tCommand: \"window-resize\",\n\t\tArgs: map[string]string{\n\t\t\t\"width\": strconv.Itoa(winchWidth),\n\t\t\t\"height\": strconv.Itoa(winchHeight),\n\t\t},\n\t}\n\n\t// Check handler hasn't finished.\n\tselect {\n\tcase <-c.dataDone:\n\t\treturn fmt.Errorf(\"no such process\") // Aligns with error retured from unix.Kill in lxc's Signal().\n\tdefault:\n\t}\n\n\tc.controlSendCh <- command\n\terr := <-c.controlResCh\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlogger.Debugf(`Forwarded window resize \"%dx%d\" to lxd-agent`, winchWidth, winchHeight)\n\treturn nil\n}", "func (this *Window) GetSize() Vector2u {\n\tsize := C.sfWindow_getSize(this.cptr)\n\treturn Vector2u{uint(size.x), uint(size.y)}\n}", "func (s *Service) Display(c context.Context, mid int64, plat int8, build int, buvid, channel, ip, ak, network, mobiApp,\n\tdevice, language, adExtra string, isTmp bool, now time.Time) (res []*show.Show) {\n\tres = s.showDisplay(c, mid, plat, build, buvid, channel, ip, ak, network, mobiApp, device, language, adExtra, isTmp, false, false, now)\n\treturn\n}", "func (n *mockAgent) winsizeProcess(c *Container, processID string, height, width uint32) error {\n\treturn nil\n}", "func (w *WindowWidget) CurrentSize() (width, height float32) {\n\tsize := w.getState().currentSize\n\treturn size.X, size.Y\n}", "func (c *Config) Resize(h, w int) error {\n\tselect {\n\tcase <-c.waitStart:\n\tcase <-time.After(time.Second):\n\t\treturn derr.ErrorCodeExecResize.WithArgs(c.ID)\n\t}\n\treturn c.ProcessConfig.Terminal.Resize(h, w)\n}", "func (w *Window) Resize(id uint32, width int32, height int32) (err error) {\n\twid, err := w.SDLWindow.GetID()\n\tif wid == id {\n\t\tw.Style.W.Set(float64(width))\n\t\tw.Style.H.Set(float64(height))\n\t\tw.CalculateStyle()\n\t}\n\treturn nil\n}", "func (nv *NetView) Config() {\n\tnv.Lay = gi.LayoutVert\n\tif nv.Params.UnitSize == 0 {\n\t\tnv.Defaults()\n\t}\n\tcmap, ok := colormap.AvailMaps[string(nv.Params.ColorMap)]\n\tif ok {\n\t\tnv.ColorMap = cmap\n\t} else {\n\t\tlog.Printf(\"NetView: %v ColorMap named: %v not found in colormap.AvailMaps\\n\", nv.Nm, nv.Params.ColorMap)\n\t}\n\tnv.SetProp(\"spacing\", gi.StdDialogVSpaceUnits)\n\tconfig := kit.TypeAndNameList{}\n\tconfig.Add(gi.KiT_ToolBar, \"tbar\")\n\tconfig.Add(gi.KiT_Layout, \"net\")\n\tconfig.Add(gi.KiT_Label, \"counters\")\n\tconfig.Add(gi.KiT_ToolBar, \"vbar\")\n\tmods, updt := nv.ConfigChildren(config)\n\tif !mods {\n\t\tupdt = nv.UpdateStart()\n\t}\n\n\tnlay := nv.NetLay()\n\tnlay.Lay = gi.LayoutHoriz\n\tnlay.SetProp(\"max-width\", -1)\n\tnlay.SetProp(\"max-height\", -1)\n\tnlay.SetProp(\"spacing\", gi.StdDialogVSpaceUnits)\n\n\tvncfg := kit.TypeAndNameList{}\n\tvncfg.Add(gi.KiT_Frame, \"vars\")\n\tvncfg.Add(gi3d.KiT_Scene, \"scene\")\n\tnlay.ConfigChildren(vncfg) // won't do update b/c of above updt\n\n\tnv.VarsConfig()\n\tnv.ViewConfig()\n\tnv.ToolbarConfig()\n\tnv.ViewbarConfig()\n\n\tctrs := nv.Counters()\n\tctrs.Redrawable = true\n\tctrs.SetText(\"Counters: \")\n\n\tnv.DataMu.Lock()\n\tnv.Data.Init(nv.Net, nv.Params.MaxRecs, nv.Params.NoSynData, nv.Net.MaxParallelData())\n\tnv.DataMu.Unlock()\n\tnv.ReconfigMeshes()\n\tnv.UpdateEnd(updt)\n}", "func GetSize(fd uintptr) (width, height int, err error) {\n\tinfo := new(consoleScreenBufferInfo)\n\tprocGetConsoleScreenBufferInfo.Call(fd, uintptr(unsafe.Pointer(info)))\n\treturn int(info.window.right - info.window.left), int(info.window.bottom - info.window.top), nil\n}", "func (gui *Gui) layout(g *gocui.Gui) error {\n\tg.Highlight = true\n\twidth, height := g.Size()\n\n\tinformation := gui.Config.GetVersion()\n\tif gui.g.Mouse {\n\t\tdonate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.SLocalize(\"Donate\"))\n\t\tinformation = donate + \" \" + information\n\t}\n\n\tminimumHeight := 9\n\tminimumWidth := 10\n\tif height < minimumHeight || width < minimumWidth {\n\t\tv, err := g.SetView(\"limit\", 0, 0, width-1, height-1, 0)\n\t\tif err != nil {\n\t\t\tif err.Error() != \"unknown view\" {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tv.Title = gui.Tr.SLocalize(\"NotEnoughSpace\")\n\t\t\tv.Wrap = true\n\t\t\t_, _ = g.SetViewOnTop(\"limit\")\n\t\t}\n\t\treturn nil\n\t}\n\n\tvHeights := gui.getViewHeights()\n\n\toptionsVersionBoundary := width - max(len(utils.Decolorise(information)), 1)\n\n\tappStatus := gui.statusManager.getStatusString()\n\tappStatusOptionsBoundary := 0\n\tif appStatus != \"\" {\n\t\tappStatusOptionsBoundary = len(appStatus) + 2\n\t}\n\n\t_, _ = g.SetViewOnBottom(\"limit\")\n\t_ = g.DeleteView(\"limit\")\n\n\ttextColor := theme.GocuiDefaultTextColor\n\n\tmain := \"main\"\n\tsecondary := \"secondary\"\n\n\tmainPanelLeft, mainPanelTop, mainPanelRight, mainPanelBottom, err := gui.getMainViewDimensions()\n\tif err != nil {\n\t\treturn err\n\t}\n\tleftSideWidth := mainPanelLeft - 1\n\n\tv, err := g.SetView(main, mainPanelLeft, mainPanelTop, mainPanelRight, mainPanelBottom, 0)\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tv.Wrap = true\n\t\tv.FgColor = textColor\n\t\tv.Autoscroll = true\n\t}\n\n\tfor _, commandView := range gui.State.CommandViewMap {\n\t\t_, _ = g.SetView(commandView.View.Name(), mainPanelLeft, mainPanelTop, mainPanelRight, mainPanelBottom, 0)\n\t}\n\n\thiddenViewOffset := 9999\n\n\tsecondaryView, err := g.SetView(secondary, mainPanelLeft, 0, width-1, mainPanelTop-1, 0)\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tsecondaryView.Wrap = true\n\t\tsecondaryView.FgColor = gocui.ColorWhite\n\t}\n\n\tif v, err := g.SetView(\"status\", 0, 0, leftSideWidth, vHeights[\"status\"]-1, gocui.BOTTOM|gocui.RIGHT); err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tv.Title = gui.Tr.SLocalize(\"StatusTitle\")\n\t\tv.FgColor = textColor\n\t}\n\n\tpackagesView, err := g.SetViewBeneath(\"packages\", \"status\", vHeights[\"packages\"])\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tpackagesView.Highlight = true\n\t\tpackagesView.Title = gui.Tr.SLocalize(\"PackagesTitle\")\n\t\tpackagesView.ContainsList = true\n\t}\n\n\tdepsView, err := g.SetViewBeneath(\"deps\", \"packages\", vHeights[\"deps\"])\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tdepsView.Title = gui.Tr.SLocalize(\"DepsTitle\")\n\t\tdepsView.FgColor = textColor\n\t\tdepsView.ContainsList = true\n\t}\n\n\tscriptsView, err := g.SetViewBeneath(\"scripts\", \"deps\", vHeights[\"scripts\"])\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tscriptsView.Title = gui.Tr.SLocalize(\"ScriptsTitle\")\n\t\tscriptsView.FgColor = textColor\n\t\tscriptsView.ContainsList = true\n\t}\n\n\ttarballsView, err := g.SetViewBeneath(\"tarballs\", \"scripts\", vHeights[\"tarballs\"])\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\ttarballsView.Title = gui.Tr.SLocalize(\"TarballsTitle\")\n\t\ttarballsView.FgColor = textColor\n\t\ttarballsView.ContainsList = true\n\t}\n\ttarballsView.Visible = gui.showTarballsView()\n\n\tif v, err := g.SetView(\"options\", appStatusOptionsBoundary-1, height-2, optionsVersionBoundary-1, height, 0); err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tv.Frame = false\n\t\tv.FgColor = theme.OptionsColor\n\t}\n\n\tsearchViewOffset := hiddenViewOffset\n\tif gui.State.Searching.isSearching {\n\t\tsearchViewOffset = 0\n\t}\n\n\t// this view takes up one character. Its only purpose is to show the slash when searching\n\tsearchPrefix := \"search: \"\n\tif searchPrefixView, err := g.SetView(\"searchPrefix\", appStatusOptionsBoundary-1+searchViewOffset, height-2+searchViewOffset, len(searchPrefix)+searchViewOffset, height+searchViewOffset, 0); err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\n\t\tsearchPrefixView.BgColor = gocui.ColorDefault\n\t\tsearchPrefixView.FgColor = gocui.ColorGreen\n\t\tsearchPrefixView.Frame = false\n\t\tgui.setViewContent(gui.g, searchPrefixView, searchPrefix)\n\t}\n\n\tif searchView, err := g.SetView(\"search\", appStatusOptionsBoundary-1+searchViewOffset+len(searchPrefix), height-2+searchViewOffset, optionsVersionBoundary+searchViewOffset, height+searchViewOffset, 0); err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\n\t\tsearchView.BgColor = gocui.ColorDefault\n\t\tsearchView.FgColor = gocui.ColorGreen\n\t\tsearchView.Frame = false\n\t\tsearchView.Editable = true\n\t}\n\n\tif appStatusView, err := g.SetView(\"appStatus\", -1, height-2, width, height, 0); err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tappStatusView.BgColor = gocui.ColorDefault\n\t\tappStatusView.FgColor = gocui.ColorCyan\n\t\tappStatusView.Frame = false\n\t\tif _, err := g.SetViewOnBottom(\"appStatus\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tinformationView, err := g.SetView(\"information\", optionsVersionBoundary-1, height-2, width, height, 0)\n\tif err != nil {\n\t\tif err.Error() != \"unknown view\" {\n\t\t\treturn err\n\t\t}\n\t\tinformationView.BgColor = gocui.ColorDefault\n\t\tinformationView.FgColor = gocui.ColorGreen\n\t\tinformationView.Frame = false\n\t\tgui.renderString(\"information\", information)\n\n\t\t// doing this here because it'll only happen once\n\t\tif err := gui.onInitialViewsCreation(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif gui.State.OldInformation != information {\n\t\tgui.setViewContent(g, informationView, information)\n\t\tgui.State.OldInformation = information\n\t}\n\n\tif gui.g.CurrentView() == nil {\n\t\tinitialView := gui.getPackagesView()\n\t\tif _, err := gui.g.SetCurrentView(initialView.Name()); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := gui.switchFocus(nil, initialView); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\ttype listViewState struct {\n\t\tselectedLine int\n\t\tlineCount int\n\t\tview *gocui.View\n\t\tcontext string\n\t\tlistView *listView\n\t}\n\n\tlistViewStates := []listViewState{\n\t\t{view: packagesView, context: \"\", selectedLine: gui.State.Panels.Packages.SelectedLine, lineCount: len(gui.State.Packages), listView: gui.packagesListView()},\n\t\t{view: depsView, context: \"\", selectedLine: gui.State.Panels.Deps.SelectedLine, lineCount: len(gui.State.Deps), listView: gui.depsListView()},\n\t\t{view: scriptsView, context: \"\", selectedLine: gui.State.Panels.Scripts.SelectedLine, lineCount: len(gui.getScripts()), listView: gui.scriptsListView()},\n\t\t{view: tarballsView, context: \"\", selectedLine: gui.State.Panels.Tarballs.SelectedLine, lineCount: len(gui.State.Tarballs), listView: gui.tarballsListView()},\n\t}\n\n\t// menu view might not exist so we check to be safe\n\tif menuView, err := gui.g.View(\"menu\"); err == nil {\n\t\tlistViewStates = append(listViewStates, listViewState{view: menuView, context: \"\", selectedLine: gui.State.Panels.Menu.SelectedLine, lineCount: gui.State.MenuItemCount, listView: gui.menuListView()})\n\t}\n\tfor _, listViewState := range listViewStates {\n\t\t// ignore views where the context doesn't match up with the selected line we're trying to focus\n\t\tif listViewState.context != \"\" && (listViewState.view.Context != listViewState.context) {\n\t\t\tcontinue\n\t\t}\n\t\t// check if the selected line is now out of view and if so refocus it\n\t\tlistViewState.view.FocusPoint(0, listViewState.selectedLine)\n\n\t\t// I doubt this is expensive though it's admittedly redundant after the first render\n\t\tlistViewState.view.SetOnSelectItem(gui.onSelectItemWrapper(listViewState.listView.onSearchSelect))\n\t}\n\n\tmainViewWidth, mainViewHeight := gui.getMainView().Size()\n\tif mainViewWidth != gui.State.PrevMainWidth || mainViewHeight != gui.State.PrevMainHeight {\n\t\tgui.State.PrevMainWidth = mainViewWidth\n\t\tgui.State.PrevMainHeight = mainViewHeight\n\t\tif err := gui.onResize(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// here is a good place log some stuff\n\t// if you download humanlog and do tail -f development.log | humanlog\n\t// this will let you see these branches as prettified json\n\t// gui.Log.Info(utils.AsJson(gui.State.Branches[0:4]))\n\treturn gui.resizeCurrentPopupPanel(g)\n}", "func (nv *NetView) ShowNonDefaultParams() string {\n\tnds := nv.Net.NonDefaultParams()\n\tgiv.TextViewDialog(nv.ViewportSafe(), []byte(nds), giv.DlgOpts{Title: \"Non Default Params\"})\n\treturn nds\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (cons *VgaTextConsole) Dimensions(dim Dimension) (uint32, uint32) {\n\tswitch dim {\n\tcase Characters:\n\t\treturn cons.width, cons.height\n\tdefault:\n\t\treturn cons.width * 8, cons.height * 16\n\t}\n}", "func (f *FileDialog) Show() {\n\tif f.save {\n\t\tif fileSaveOSOverride(f) {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tif fileOpenOSOverride(f) {\n\t\t\treturn\n\t\t}\n\t}\n\tif f.dialog != nil {\n\t\tf.dialog.win.Show()\n\t\treturn\n\t}\n\tf.dialog = showFile(f)\n}", "func (cc *ChainConfig) Show() {\n\tlog.Println(\"Name is \", cc.Name)\n\tlog.Println(\"Prefix is \", cc.Prefix)\n\tlog.Println(\"Suffix is \", cc.Suffix)\n\tlog.Println(\"Interval is \", cc.Interval)\n\tlog.Printf(\"Inputer is %v\\n\", cc.Chain)\n}", "func (g *Game) Layout(w, h int) (int, int){\n\tgd := NewGameData()\n\treturn gd.ScreenWidth, gd.ScreenHeight\n}" ]
[ "0.6001489", "0.5772772", "0.56969374", "0.5690174", "0.5652094", "0.5509766", "0.54795647", "0.5317228", "0.52441", "0.5234786", "0.5104025", "0.51008934", "0.50893235", "0.50009257", "0.49380773", "0.49087965", "0.4873878", "0.48338032", "0.4814243", "0.47754005", "0.47702596", "0.47641438", "0.4749104", "0.47133005", "0.46985728", "0.46860132", "0.46687064", "0.46670365", "0.46622", "0.46344092", "0.46148923", "0.46018645", "0.45903552", "0.45893535", "0.45603064", "0.45537502", "0.4548743", "0.45427942", "0.45270094", "0.45190194", "0.45180282", "0.45102593", "0.45025474", "0.45012385", "0.4483664", "0.4483115", "0.44827312", "0.4476443", "0.44709256", "0.44674832", "0.44588414", "0.4450831", "0.44434774", "0.44264635", "0.44181538", "0.44175375", "0.44088903", "0.44065693", "0.43943134", "0.43880498", "0.43810955", "0.43807635", "0.43743607", "0.4360444", "0.4358022", "0.43549094", "0.43514925", "0.43474138", "0.43426713", "0.43337134", "0.43302822", "0.4321673", "0.4298087", "0.42980123", "0.42960423", "0.4290249", "0.42887118", "0.42831898", "0.42806533", "0.42725626", "0.42725182", "0.42719853", "0.42669606", "0.4263153", "0.4253097", "0.42521897", "0.4249613", "0.4238342", "0.42312166", "0.42275122", "0.42227337", "0.42207262", "0.42159307", "0.42142868", "0.421096", "0.421096", "0.42076135", "0.41975945", "0.41960734", "0.41950554" ]
0.7078683
0
/ DSP attributes. NOTE: Not implement yet TODO: add more docs Retrieves information about the current DSP unit, including name, version, default channels and width and height of configuration dialog box if it exists.
func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error { //FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight); return ErrNoImpl }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *FwGeneral) Show() (Config, error) {\n c.con.LogQuery(\"(show) general settings\")\n return c.details(c.con.Show)\n}", "func (d *DSP) ParameterInfo(index C.int, desc **C.FMOD_DSP_PARAMETER_DESC) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);\n\treturn ErrNoImpl\n}", "func (d *DSP) ShowConfigDialog(hwnd *interface{}, show C.FMOD_BOOL) error {\n\t//FMOD_RESULT F_API FMOD_DSP_ShowConfigDialog (FMOD_DSP *dsp, void *hwnd, FMOD_BOOL show);\n\treturn ErrNoImpl\n}", "func displayDetails(dev *device.SDRDevice) {\n\n\tfmt.Printf(\"-------------------\\n\")\n\tfmt.Printf(\"Device Information\\n\")\n\tfmt.Printf(\"-------------------\\n\")\n\n\t// Function from identification API\n\tfmt.Printf(\"Identification / DriverKey: %v\\n\", dev.GetDriverKey())\n\tfmt.Printf(\"Identification / HardwareKey: %v\\n\", dev.GetHardwareKey())\n\n\thardwareInfo := dev.GetHardwareInfo()\n\tif len(hardwareInfo) > 0 {\n\t\tfor k, v := range hardwareInfo {\n\t\t\tfmt.Printf(\"Identification / HardwareInfo: {%v:%v}\\n\", k, v)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Identification / HardwareInfo: [none]\\n\")\n\t}\n\n\t//\n\t// GPIO\n\t//\n\tbanks := dev.ListGPIOBanks()\n\tif len(banks) > 0 {\n\t\tfor i, bank := range banks {\n\t\t\tfmt.Printf(\"GPIO / Bank #%d: %v\\n\", i, bank)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"GPIO / Banks: [none]\\n\")\n\t}\n\n\t//\n\t// Settings\n\t//\n\tsettings := dev.GetSettingInfo()\n\tif len(settings) > 0 {\n\t\tfor i, setting := range settings {\n\t\t\tfmt.Printf(\"Settings / Setting #%d: %v\\n\", i, setting.ToString())\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Settings: [none]\\n\")\n\t}\n\n\t//\n\t// UARTs\n\t//\n\tuarts := dev.ListUARTs()\n\tif len(settings) > 0 {\n\t\tfor i, uart := range uarts {\n\t\t\tfmt.Printf(\"UARTs #%d: / UART: %v\\n\", i, uart)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"UARTs: [none]\\n\")\n\t}\n\n\t//\n\t// Clocking\n\t//\n\tfmt.Printf(\"MasterClockRate: %v\\n\", dev.GetMasterClockRate())\n\tclockRanges := dev.GetMasterClockRates()\n\tif len(clockRanges) > 0 {\n\t\tfor i, clockRange := range clockRanges {\n\t\t\tfmt.Printf(\"MasterClockRate range #%d: %v\\n\", i, clockRange)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"MasterClockRate ranges: [none]\\n\")\n\t}\n\tclockSources := dev.ListClockSources()\n\tif len(clockSources) > 0 {\n\t\tfor i, clockSource := range clockSources {\n\t\t\tfmt.Printf(\"Clock source #%d: %v\\n\", i, clockSource)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Clock sources: [none]\\n\")\n\t}\n\n\t//\n\t// Register\n\t//\n\tregisters := dev.ListRegisterInterfaces()\n\tif len(registers) > 0 {\n\t\tfor i, register := range registers {\n\t\t\tfmt.Printf(\"Register #%d: %v\\n\", i, register)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Registers: [none]\\n\")\n\t}\n\n\t//\n\t// Device Sensor\n\t//\n\tsensors := dev.ListSensors()\n\tif len(sensors) > 0 {\n\t\tfor i, sensor := range sensors {\n\t\t\tfmt.Printf(\"Sensor #%d: %v\\n\", i, sensor)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Sensors: [none]\\n\")\n\t}\n\n\t//\n\t// TimeSource\n\t//\n\ttimeSources := dev.ListTimeSources()\n\tif len(timeSources) > 0 {\n\t\tfor i, timeSource := range timeSources {\n\t\t\tfmt.Printf(\"Time source #%d: %v\\n\", i, timeSource)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Time sources: [none]\\n\")\n\t}\n\thasHardwareTime := dev.HasHardwareTime(\"\")\n\tfmt.Printf(\"Time source / Has hardware time: %v\\n\", hasHardwareTime)\n\tif hasHardwareTime {\n\t\tfmt.Printf(\"Time source / Hardware time: %v\\n\", dev.GetHardwareTime(\"\"))\n\t}\n\n\tdisplayDirectionDetails(dev, device.DirectionTX)\n\tdisplayDirectionDetails(dev, device.DirectionRX)\n}", "func (this *Device) Info() IDeviceInfo {\n return this.info\n}", "func (syn *Synth) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Synth\")\n\tgi.SetAppAbout(`This demonstrates synthesizing a sound (phone or word)`)\n\n\twin := gi.NewMainWindow(\"one\", \"Auditory ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\tsyn.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMax()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(syn)\n\n\ttview := gi.AddNewTabView(split, \"tv\")\n\n\tplt := tview.AddNewTab(eplot.KiT_Plot2D, \"wave\").(*eplot.Plot2D)\n\tsyn.WavePlot = syn.ConfigWavePlot(plt, syn.SignalData)\n\n\t// tbar.AddAction(gi.ActOpts{Label: \"Update Wave\", Icon: \"new\"}, win.This(),\n\t// \tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t// \t\tsyn.GetWaveData()\n\t// \t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Synthesize\", Icon: \"new\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tsyn.Synthesize()\n\t\t})\n\n\tsplit.SetSplitsList([]float32{.3, .7})\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func ConfigShow() error {\n\n\tfmt.Printf(\"\\nCurrently saved values:\\n\")\n\n\tif Config.Secure {\n\t\tfmt.Printf(\" -https\\n\")\n\t} else {\n\t\tfmt.Printf(\" -http\\n\")\n\t}\n\n\tif Config.Hub != \"\" && Config.Hub != notehub.DefaultAPIService {\n\t\tfmt.Printf(\" -hub %s\\n\", Config.Hub)\n\t}\n\tif Config.App != \"\" {\n\t\tfmt.Printf(\" -app %s\\n\", Config.App)\n\t}\n\tif Config.Product != \"\" {\n\t\tfmt.Printf(\" -product %s\\n\", Config.Product)\n\t}\n\tif Config.Device != \"\" {\n\t\tfmt.Printf(\" -device %s\\n\", Config.Device)\n\t}\n\tif Config.Root != \"\" {\n\t\tfmt.Printf(\" -root %s\\n\", Config.Root)\n\t}\n\tif Config.Cert != \"\" {\n\t\tfmt.Printf(\" -cert %s\\n\", Config.Cert)\n\t}\n\tif Config.Key != \"\" {\n\t\tfmt.Printf(\" -key %s\\n\", Config.Key)\n\t}\n\tif Config.Interface != \"\" {\n\t\tfmt.Printf(\" -interface %s\\n\", Config.Interface)\n\t\tif Config.Port == \"\" {\n\t\t\tfmt.Printf(\" -port -\\n\")\n\t\t\tfmt.Printf(\" -portconfig -\\n\")\n\t\t} else {\n\t\t\tfmt.Printf(\" -port %s\\n\", Config.Port)\n\t\t\tfmt.Printf(\" -portconfig %d\\n\", Config.PortConfig)\n\t\t}\n\t}\n\n\treturn nil\n\n}", "func (ap *App) ConfigGui() *gi.Window {\n\tgi.SetAppName(\"Gabor View\")\n\tgi.SetAppAbout(\"Application/Utility to allow viewing of gabor convolution with sound\")\n\n\tap.GUI.Win = gi.NewMainWindow(\"gb\", \"Gabor View\", 1600, 1200)\n\tap.GUI.ViewPort = ap.GUI.Win.Viewport\n\tap.GUI.ViewPort.UpdateStart()\n\n\tmfr := ap.GUI.Win.SetMainFrame()\n\n\tap.GUI.ToolBar = gi.AddNewToolBar(mfr, \"tbar\")\n\tap.GUI.ToolBar.SetStretchMaxWidth()\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Init\", Icon: \"update\",\n\t\tTooltip: \"Initialize everything including network weights, and start over. Also applies current params.\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\tap.Init()\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Open Sound Files\",\n\t\tIcon: \"file-open\",\n\t\tTooltip: \"Opens a file dialog for selecting a single sound file or a directory of sound files (only .wav files work at this time)\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\texts := \".wav\"\n\t\t\tgiv.FileViewDialog(ap.GUI.ViewPort, ap.OpenPath, exts, giv.DlgOpts{Title: \"Open .wav Sound File\", Prompt: \"Open a .wav file, or directory of .wav files, for sound processing.\"}, nil,\n\t\t\t\tap.GUI.Win.This(), func(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\t\t\tif sig == int64(gi.DialogAccepted) {\n\t\t\t\t\t\tdlg, _ := send.Embed(gi.KiT_Dialog).(*gi.Dialog)\n\t\t\t\t\t\tfn := giv.FileViewDialogValue(dlg)\n\t\t\t\t\t\tinfo, err := os.Stat(fn)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tfmt.Println(\"error stating %s\", fn)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif info.IsDir() {\n\t\t\t\t\t\t\t// Could do fully recursive by passing path var to LoadTranscription but I\n\t\t\t\t\t\t\t// tried it and it didn't return from TIMIT/TRAIN/DR1 even after 10 minutes\n\t\t\t\t\t\t\t// This way it does one level directory only and is fast\n\t\t\t\t\t\t\tfilepath.Walk(fn, func(path string, info os.FileInfo, err error) error {\n\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\tlog.Fatalf(err.Error())\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif info.IsDir() == false {\n\t\t\t\t\t\t\t\t\t//fmt.Printf(\"File Name: %s\\n\", info.Name())\n\t\t\t\t\t\t\t\t\tfp := filepath.Join(fn, info.Name())\n\t\t\t\t\t\t\t\t\tap.LoadTranscription(fp)\n\t\t\t\t\t\t\t\t}\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} else {\n\t\t\t\t\t\t\tap.LoadTranscription(fn)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tap.ConfigTableView(ap.SndsTable.View)\n\t\t\t\t\t\tap.GUI.IsRunning = true\n\t\t\t\t\t\tap.GUI.ToolBar.UpdateActions()\n\t\t\t\t\t\tap.GUI.Win.UpdateSig()\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Unload Sounds\",\n\t\tIcon: \"file-close\",\n\t\tTooltip: \"Clears the table of sounds and closes the open sound files\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.SndsTable.Table.SetNumRows(0)\n\t\t\tap.SndsTable.View.UpdateTable()\n\t\t\tap.GUI.IsRunning = false\n\t\t\tap.GUI.ToolBar.UpdateActions()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Process 1\", Icon: \"play\",\n\t\tTooltip: \"Process the segment of audio from SegmentStart to SegmentEnd applying the gabor filters to the Mel tensor\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\terr := ap.ProcessSetup(&ap.WParams1, &ap.CurSnd1)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams1, &ap.PParams1, &ap.GParams1)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams1, &ap.GParams1)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Process 2\", Icon: \"play\",\n\t\tTooltip: \"Process the segment of audio from SegmentStart to SegmentEnd applying the gabor filters to the Mel tensor\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\terr := ap.ProcessSetup(&ap.WParams2, &ap.CurSnd2)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams2, &ap.PParams2, &ap.GParams2)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams2, &ap.GParams2)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Next 1\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Process the next segment of audio\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\t// setup the next segment of sound\n\t\t\tif ap.WParams1.TimeMode == false { // default\n\t\t\t\tap.SndsTable.View.ResetSelectedIdxs()\n\t\t\t\tif ap.Row == ap.SndsTable.View.DispRows-1 {\n\t\t\t\t\tap.Row = 0\n\t\t\t\t} else {\n\t\t\t\t\tap.Row += 1\n\t\t\t\t}\n\t\t\t\tap.SndsTable.View.SelectedIdx = ap.Row\n\t\t\t\tap.SndsTable.View.SelectIdx(ap.Row)\n\t\t\t} else {\n\t\t\t\td := ap.WParams1.SegmentEnd - ap.WParams1.SegmentStart\n\t\t\t\tap.WParams1.SegmentStart += d\n\t\t\t\tap.WParams1.SegmentEnd += d\n\t\t\t}\n\t\t\terr := ap.ProcessSetup(&ap.WParams1, &ap.CurSnd1)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams1, &ap.PParams1, &ap.GParams1)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams1, &ap.GParams1)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Next 2\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Process the next segment of audio\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\t// setup the next segment of sound\n\t\t\tif ap.WParams2.TimeMode == false { // default\n\t\t\t\tap.SndsTable.View.ResetSelectedIdxs()\n\t\t\t\tif ap.Row == ap.SndsTable.View.DispRows-1 {\n\t\t\t\t\tap.Row = 0\n\t\t\t\t} else {\n\t\t\t\t\tap.Row += 1\n\t\t\t\t}\n\t\t\t\tap.SndsTable.View.SelectedIdx = ap.Row\n\t\t\t\tap.SndsTable.View.SelectIdx(ap.Row)\n\t\t\t} else {\n\t\t\t\td := ap.WParams2.SegmentEnd - ap.WParams2.SegmentStart\n\t\t\t\tap.WParams2.SegmentStart += d\n\t\t\t\tap.WParams2.SegmentEnd += d\n\t\t\t}\n\t\t\terr := ap.ProcessSetup(&ap.WParams2, &ap.CurSnd2)\n\t\t\tif err == nil {\n\t\t\t\terr = ap.Process(&ap.WParams2, &ap.PParams2, &ap.GParams2)\n\t\t\t\tif err == nil {\n\t\t\t\t\tap.ApplyGabor(&ap.PParams2, &ap.GParams2)\n\t\t\t\t\tap.GUI.UpdateWindow()\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Update Gabors\", Icon: \"update\",\n\t\tTooltip: \"Call this to see the result of changing the Gabor specifications\",\n\t\tActive: egui.ActiveAlways,\n\t\tFunc: func() {\n\t\t\tap.UpdateGabors(&ap.GParams1)\n\t\t\tap.UpdateGabors(&ap.GParams2)\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Save 1\", Icon: \"fast-fwd\",\n\t\tTooltip: \"Save the mel and result grids\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.SnapShot1()\n\t\t},\n\t})\n\n\t//ap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Copy 1 -> 2\", Icon: \"copy\",\n\t//\tTooltip: \"Copy all set 1 params (window, process, gabor) to set 2\",\n\t//\tActive: egui.ActiveAlways,\n\t//\tFunc: func() {\n\t//\t\tap.CopyOne()\n\t//\t\tap.GUI.UpdateWindow()\n\t//\t},\n\t//})\n\t//\n\t//ap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Copy 2 -> 1\", Icon: \"copy\",\n\t//\tTooltip: \"Copy all set 2 params (window, process, gabor) to set 1\",\n\t//\tActive: egui.ActiveAlways,\n\t//\tFunc: func() {\n\t//\t\tap.CopyTwo()\n\t//\t\tap.GUI.UpdateWindow()\n\t//\t},\n\t//})\n\n\tap.GUI.ToolBar.AddSeparator(\"filt\")\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Filter sounds...\", Icon: \"search\",\n\t\tTooltip: \"filter the table of sounds for sounds containing string...\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tgiv.CallMethod(ap, \"FilterSounds\", ap.GUI.ViewPort)\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"Unilter sounds...\", Icon: \"reset\",\n\t\tTooltip: \"clear sounds table filter\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.UnfilterSounds()\n\t\t\tap.GUI.UpdateWindow()\n\t\t},\n\t})\n\n\tap.GUI.AddToolbarItem(egui.ToolbarItem{Label: \"View\", Icon: \"file-open\",\n\t\tTooltip: \"opens spectrogram view of selected sound in external application 'Audacity' - edit code to use a different application\",\n\t\tActive: egui.ActiveRunning,\n\t\tFunc: func() {\n\t\t\tap.View()\n\t\t\t//giv.CallMethod(ap, \"ViewSpectrogram\", ap.GUI.ViewPort)\n\t\t},\n\t})\n\n\tsplit1 := gi.AddNewSplitView(mfr, \"split1\")\n\tsplit1.Dim = 0\n\tsplit1.SetStretchMax()\n\n\tsplit := gi.AddNewSplitView(split1, \"split\")\n\tsplit.Dim = 1\n\tsplit.SetStretchMax()\n\n\ttv1 := gi.AddNewTabView(split1, \"tv1\")\n\tap.SndsTable.View = tv1.AddNewTab(etview.KiT_TableView, \"Sounds\").(*etview.TableView)\n\tap.ConfigTableView(ap.SndsTable.View)\n\tap.SndsTable.View.SetTable(ap.SndsTable.Table, nil)\n\n\tsplit1.SetSplits(.75, .25)\n\n\tap.GUI.StructView = giv.AddNewStructView(split, \"app\")\n\tap.GUI.StructView.SetStruct(ap)\n\n\tspecs := giv.AddNewTableView(split, \"specs1\")\n\tspecs.Viewport = ap.GUI.ViewPort\n\tspecs.SetSlice(&ap.GParams1.GaborSpecs)\n\n\tspecs = giv.AddNewTableView(split, \"specs2\")\n\tspecs.Viewport = ap.GUI.ViewPort\n\tspecs.SetSlice(&ap.GParams2.GaborSpecs)\n\n\ttv := gi.AddNewTabView(split, \"tv\")\n\n\ttg := tv.AddNewTab(etview.KiT_TensorGrid, \"Gabors\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams1.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.GParams1.GaborSet.Filters)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Power\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams1.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.PParams1.LogPowerSegment)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Mel\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MelFBankSegment)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Result\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams1.GborOutput)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"MFCC\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCSegment)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"Deltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv.AddNewTab(etview.KiT_TensorGrid, \"DeltaDeltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams1.MFCCDeltaDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttv2 := gi.AddNewTabView(split, \"tv2\")\n\tsplit.SetSplits(.3, .15, .15, .2, .2)\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Gabors\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams2.GaborSet.Filters)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Power\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\tap.PParams2.LogPowerSegment.SetMetaData(\"grid-min\", \"10\")\n\ttg.SetTensor(&ap.PParams2.LogPowerSegment)\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Mel\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MelFBankSegment)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Result\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.GParams2.GborOutput)\n\t// set Display after setting tensor\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"MFCC\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCSegment)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"Deltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCDeltas)\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\ttg = tv2.AddNewTab(etview.KiT_TensorGrid, \"DeltaDeltas\").(*etview.TensorGrid)\n\ttg.SetStretchMax()\n\ttg.SetTensor(&ap.PParams2.MFCCDeltaDeltas)\n\t// set Display after setting tensor\n\ttg.Disp.ColorMap = \"ColdHot\"\n\ttg.Disp.Range.FixMin = false\n\ttg.Disp.Range.FixMax = false\n\n\tap.StatLabel = gi.AddNewLabel(mfr, \"status\", \"Status...\")\n\tap.StatLabel.SetStretchMaxWidth()\n\tap.StatLabel.Redrawable = true\n\n\tap.GUI.FinalizeGUI(false)\n\treturn ap.GUI.Win\n}", "func (frame *AvFrame) GetInfo() (width int, height int, linesize [8]int32, data [8]*uint8) {\n\twidth = int(frame.linesize[0])\n\theight = int(frame.height)\n\tfor i := range linesize {\n\t\tlinesize[i] = int32(frame.linesize[i])\n\t}\n\tfor i := range data {\n\t\tdata[i] = (*uint8)(frame.data[i])\n\t}\n\t// log.Println(\"Linesize is \", frame.linesize, \"Data is\", data)\n\treturn\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\t// tv := gi.AddNewTabView(split, \"tv\")\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Reset\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.Reset()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Load Params\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.LoadParams()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Wavs\", Icon: \"new\", Tooltip: \"Generate the .wav files\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Split Wavs\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.SplitWavs()\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func (m *sineOsc) Info() *core.ModuleInfo {\n\treturn &m.info\n}", "func displayDirectionChannelDetails(dev *device.SDRDevice, direction device.Direction, channel uint) {\n\n\t// Settings\n\tsettings := dev.GetChannelSettingInfo(direction, channel)\n\tif len(settings) > 0 {\n\t\tfor i, setting := range settings {\n\t\t\tfmt.Printf(\"Channel #%d / Setting #%d: / Banks: %v\\n\", channel, i, setting)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Channel #%d / Settings: [none]\\n\", channel)\n\t}\n\n\t//\n\t// Channel\n\t//\n\n\tchannelInfo := dev.GetChannelInfo(direction, channel)\n\tif len(channelInfo) > 0 {\n\t\tfor k, v := range channelInfo {\n\t\t\tfmt.Printf(\"Channel #%d / ChannelInfo: {%v:%v}\\n\", channel, k, v)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Channel #%d / ChannelInfo: [none]\\n\", channel)\n\t}\n\n\tfmt.Printf(\"Channel #%d / FullDuplex: %v\\n\", channel, dev.GetFullDuplex(direction, channel))\n\n\t//\n\t// Antenna\n\t//\n\n\tantennas := dev.ListAntennas(direction, channel)\n\tfmt.Printf(\"Channel #%d / NumAntennas: %v\\n\", channel, len(antennas))\n\n\tfor i, antenna := range antennas {\n\t\tfmt.Printf(\"Channel #%d / Antenna #%d: %v\\n\", channel, i, antenna)\n\t}\n\n\t//\n\t// Bandwidth\n\t//\n\n\tfmt.Printf(\"Channel #%d / Baseband filter width Hz: %v Hz\\n\", channel, dev.GetBandwidth(direction, channel))\n\n\tbandwidthRanges := dev.GetBandwidthRanges(direction, channel)\n\tfor i, bandwidthRange := range bandwidthRanges {\n\t\tfmt.Printf(\"Channel #%d / Baseband filter #%d: %v\\n\", channel, i, bandwidthRange)\n\t}\n\n\t//\n\t// Gain\n\t//\n\n\tfmt.Printf(\"Channel #%d / HasGainMode (Automatic gain possible): %v\\n\", channel, dev.HasGainMode(direction, channel))\n\tfmt.Printf(\"Channel #%d / GainMode (Automatic gain enabled): %v\\n\", channel, dev.GetGainMode(direction, channel))\n\tfmt.Printf(\"Channel #%d / Gain: %v\\n\", channel, dev.GetGain(direction, channel))\n\tfmt.Printf(\"Channel #%d / GainRange: %v\\n\", channel, dev.GetGainRange(direction, channel).ToString())\n\n\tgainElements := dev.ListGains(direction, channel)\n\tfmt.Printf(\"Channel #%d / NumGainElements: %v\\n\", channel, len(gainElements))\n\n\tfor i, gainElement := range gainElements {\n\t\tfmt.Printf(\"Channel #%d / Gain Element #%d / Name: %v\\n\", channel, i, gainElement)\n\t\tfmt.Printf(\"Channel #%d / Gain Element #%d / Value: %v\\n\", channel, i, dev.GetGainElement(direction, channel, gainElement))\n\t\tfmt.Printf(\"Channel #%d / Gain Element #%d / Range: %v\\n\", channel, i, dev.GetGainElementRange(direction, channel, gainElement).ToString())\n\t}\n\n\t//\n\t// SampleRate\n\t//\n\n\tfmt.Printf(\"Channel #%d / Sample Rate: %v\\n\", channel, dev.GetSampleRate(direction, channel))\n\tfor i, sampleRateRange := range dev.GetSampleRateRange(direction, channel) {\n\t\tfmt.Printf(\"Channel #%d / Sample Rate Range #%d: %v\\n\", channel, i, sampleRateRange.ToString())\n\t}\n\n\t//\n\t// Frequencies\n\t//\n\n\tfmt.Printf(\"Channel #%d / Frequency: %v\\n\", channel, dev.GetFrequency(direction, channel))\n\tfor i, frequencyRange := range dev.GetFrequencyRange(direction, channel) {\n\t\tfmt.Printf(\"Channel #%d / Frequency Range #%d: %v\\n\", channel, i, frequencyRange.ToString())\n\t}\n\n\tfrequencyArgsInfos := dev.GetFrequencyArgsInfo(direction, channel)\n\tif len(frequencyArgsInfos) > 0 {\n\t\tfor i, argInfo := range frequencyArgsInfos {\n\t\t\tfmt.Printf(\"Channel #%d / Frequency ArgInfo #%d: %v\\n\", channel, i, argInfo.ToString())\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Channel #%d / Frequency ArgInfo: [none]\\n\", channel)\n\t}\n\n\tfrequencyComponents := dev.ListFrequencies(direction, channel)\n\tfmt.Printf(\"Channel #%d / NumFrequencyComponents: %v\\n\", channel, len(frequencyComponents))\n\n\tfor i, frequencyComponent := range frequencyComponents {\n\t\tfmt.Printf(\"Channel #%d / Frequency Component #%d / Name: %v\\n\", channel, i, frequencyComponent)\n\t\tfmt.Printf(\"Channel #%d / Frequency Component #%d / Frequency: %v\\n\", channel, i, dev.GetFrequencyComponent(direction, channel, frequencyComponent))\n\n\t\tfrequencyRanges := dev.GetFrequencyRangeComponent(direction, channel, frequencyComponent)\n\t\tfor j, frequencyRange := range frequencyRanges {\n\t\t\tfmt.Printf(\"Channel #%d / Frequency Component #%d / Frequency Range #%d: %v\\n\", channel, i, j, frequencyRange.ToString())\n\t\t}\n\t}\n\n\t//\n\t// Stream\n\t//\n\n\tfmt.Printf(\"Channel #%d / Stream / Formats: %v\\n\", channel, dev.GetStreamFormats(direction, channel))\n\tnativeStreamFormat, nativeStreamFullScale := dev.GetNativeStreamFormat(direction, channel)\n\tfmt.Printf(\"Channel #%d / Stream / NativeFormat: %v (fullScale: %v)\\n\", channel, nativeStreamFormat, nativeStreamFullScale)\n\n\tstreamArgsInfos := dev.GetStreamArgsInfo(direction, channel)\n\tif len(streamArgsInfos) > 0 {\n\t\tfor i, argInfo := range streamArgsInfos {\n\t\t\tfmt.Printf(\"Channel #%d / Stream ArgInfo #%d: %v\\n\", channel, i, argInfo.ToString())\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Channel #%d / Stream ArgInfo: [none]\\n\", channel)\n\t}\n\n\t//\n\t// Front-end correction\n\t//\n\tavailable := dev.HasDCOffsetMode(direction, channel)\n\tfmt.Printf(\"Channel #%d / Stream / Correction / Auto DC correction available: %v\\n\", channel, available)\n\tif available {\n\t\tfmt.Printf(\"Channel #%d / Stream / Correction / Auto DC correction: %v\\n\", channel, dev.GetDCOffsetMode(direction, channel))\n\t}\n\tavailable = dev.HasDCOffset(direction, channel)\n\tfmt.Printf(\"Channel #%d / Stream / Correction / DC correction available: %v\\n\", channel, available)\n\tif available {\n\t\tI, Q, err := dev.GetDCOffset(direction, channel)\n\t\tfmt.Printf(\"Channel #%d / Stream / Correction / DC correction I: %v, Q: %v, err :%v\\n\", channel, I, Q, err)\n\t}\n\tavailable = dev.HasIQBalance(direction, channel)\n\tfmt.Printf(\"Channel #%d / Stream / Correction / IQ Balance available: %v\\n\", channel, available)\n\tif available {\n\t\tI, Q, err := dev.GetIQBalance(direction, channel)\n\t\tfmt.Printf(\"Channel #%d / Stream / Correction / IQ Balance I: %v, Q: %v, err :%v\\n\", channel, I, Q, err)\n\t}\n\tavailable = dev.HasFrequencyCorrection(direction, channel)\n\tfmt.Printf(\"Channel #%d / Stream / Correction / Frequency correction available: %v\\n\", channel, available)\n\tif available {\n\t\tfmt.Printf(\"Channel #%d / Stream / Correction / Frequency correction: %v PPM\\n\", channel, dev.GetFrequencyCorrection(direction, channel))\n\t}\n\n\t//\n\t// Channel Sensor\n\t//\n\tsensors := dev.ListChannelSensors(direction, channel)\n\tif len(sensors) > 0 {\n\t\tfor i, sensor := range sensors {\n\t\t\tfmt.Printf(\"Channel #%d / Sensor #%d: %v\\n\", channel, i, sensor)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\"Channel #%d / Sensors: [none]\\n\", channel)\n\t}\n}", "func (*GetDeviceConfigurationResponse) Descriptor() ([]byte, []int) {\n\treturn file_pkg_pb_protobuf_api_proto_rawDescGZIP(), []int{33}\n}", "func (*GetDeviceConfigurationRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_pb_protobuf_api_proto_rawDescGZIP(), []int{30}\n}", "func (memif *Memif) GetDetails() (details *MemifDetails, err error) {\n\tcDetails := C.govpp_memif_details_t{}\n\tvar buf *C.char\n\n\t// Get memif details from C-libmemif.\n\terrCode := C.govpp_memif_get_details(memif.cHandle, &cDetails, &buf)\n\terr = getMemifError(int(errCode))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer C.free(unsafe.Pointer(buf))\n\n\t// Convert details from C to Go.\n\tdetails = &MemifDetails{}\n\t// - metadata:\n\tdetails.IfName = C.GoString(cDetails.if_name)\n\tdetails.InstanceName = C.GoString(cDetails.inst_name)\n\tdetails.ConnID = uint32(cDetails.id)\n\tdetails.SocketFilename = C.GoString(cDetails.socket_path)\n\tif cDetails.secret != nil {\n\t\tdetails.Secret = C.GoString(cDetails.secret)\n\t}\n\tdetails.IsMaster = cDetails.role == C.uint8_t(0)\n\tswitch cDetails.mode {\n\tcase C.MEMIF_INTERFACE_MODE_ETHERNET:\n\t\tdetails.Mode = IfModeEthernet\n\tcase C.MEMIF_INTERFACE_MODE_IP:\n\t\tdetails.Mode = IfModeIP\n\tcase C.MEMIF_INTERFACE_MODE_PUNT_INJECT:\n\t\tdetails.Mode = IfModePuntInject\n\tdefault:\n\t\tdetails.Mode = IfModeEthernet\n\t}\n\t// - connection details:\n\tdetails.RemoteIfName = C.GoString(cDetails.remote_if_name)\n\tdetails.RemoteInstanceName = C.GoString(cDetails.remote_inst_name)\n\tdetails.HasLink = cDetails.link_up_down == C.uint8_t(1)\n\t// - RX queues:\n\tvar i uint8\n\tfor i = 0; i < uint8(cDetails.rx_queues_num); i++ {\n\t\tcRxQueue := C.govpp_get_rx_queue_details(&cDetails, C.int(i))\n\t\tqueueDetails := MemifQueueDetails{\n\t\t\tQueueID: uint8(cRxQueue.qid),\n\t\t\tRingSize: uint32(cRxQueue.ring_size),\n\t\t\tBufferSize: uint16(cRxQueue.buffer_size),\n\t\t}\n\t\tdetails.RxQueues = append(details.RxQueues, queueDetails)\n\t}\n\t// - TX queues:\n\tfor i = 0; i < uint8(cDetails.tx_queues_num); i++ {\n\t\tcTxQueue := C.govpp_get_tx_queue_details(&cDetails, C.int(i))\n\t\tqueueDetails := MemifQueueDetails{\n\t\t\tQueueID: uint8(cTxQueue.qid),\n\t\t\tRingSize: uint32(cTxQueue.ring_size),\n\t\t\tBufferSize: uint16(cTxQueue.buffer_size),\n\t\t}\n\t\tdetails.TxQueues = append(details.TxQueues, queueDetails)\n\t}\n\n\treturn details, nil\n}", "func (l *Libvirt) StoragePoolGetInfo(Pool StoragePool) (rState uint8, rCapacity uint64, rAllocation uint64, rAvailable uint64, err error) {\n\tvar buf []byte\n\n\targs := StoragePoolGetInfoArgs {\n\t\tPool: Pool,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(87, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// State: uint8\n\t_, err = dec.Decode(&rState)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Capacity: uint64\n\t_, err = dec.Decode(&rCapacity)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Allocation: uint64\n\t_, err = dec.Decode(&rAllocation)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Available: uint64\n\t_, err = dec.Decode(&rAvailable)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (l *Libvirt) DomainGetInfo(Dom Domain) (rState uint8, rMaxMem uint64, rMemory uint64, rNrVirtCPU uint16, rCPUTime uint64, err error) {\n\tvar buf []byte\n\n\targs := DomainGetInfoArgs {\n\t\tDom: Dom,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(16, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// State: uint8\n\t_, err = dec.Decode(&rState)\n\tif err != nil {\n\t\treturn\n\t}\n\t// MaxMem: uint64\n\t_, err = dec.Decode(&rMaxMem)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Memory: uint64\n\t_, err = dec.Decode(&rMemory)\n\tif err != nil {\n\t\treturn\n\t}\n\t// NrVirtCPU: uint16\n\t_, err = dec.Decode(&rNrVirtCPU)\n\tif err != nil {\n\t\treturn\n\t}\n\t// CPUTime: uint64\n\t_, err = dec.Decode(&rCPUTime)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (*SystemGetInfo) Descriptor() ([]byte, []int) {\n\treturn file_system_proto_rawDescGZIP(), []int{2}\n}", "func getSideInfoSize(frame *MP3Frame) (size int) {\n\n if frame.MPEGLayer == MPEGLayerIII {\n if frame.MPEGVersion == MPEGVersion1 {\n if frame.ChannelMode == Mono {\n size = 17\n } else {\n size = 32\n }\n } else {\n if frame.ChannelMode == Mono {\n size = 9\n } else {\n size = 17\n }\n }\n }\n\n return size\n}", "func (device *SilentStepperBrick) GetBasicConfiguration() (standstillCurrent uint16, motorRunCurrent uint16, standstillDelayTime uint16, powerDownTime uint16, stealthThreshold uint16, coolstepThreshold uint16, classicThreshold uint16, highVelocityChopperMode bool, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetBasicConfiguration), buf.Bytes())\n\tif err != nil {\n\t\treturn standstillCurrent, motorRunCurrent, standstillDelayTime, powerDownTime, stealthThreshold, coolstepThreshold, classicThreshold, highVelocityChopperMode, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 23 {\n\t\t\treturn standstillCurrent, motorRunCurrent, standstillDelayTime, powerDownTime, stealthThreshold, coolstepThreshold, classicThreshold, highVelocityChopperMode, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 23)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn standstillCurrent, motorRunCurrent, standstillDelayTime, powerDownTime, stealthThreshold, coolstepThreshold, classicThreshold, highVelocityChopperMode, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &standstillCurrent)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &motorRunCurrent)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &standstillDelayTime)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &powerDownTime)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &stealthThreshold)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &coolstepThreshold)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &classicThreshold)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &highVelocityChopperMode)\n\n\t}\n\n\treturn standstillCurrent, motorRunCurrent, standstillDelayTime, powerDownTime, stealthThreshold, coolstepThreshold, classicThreshold, highVelocityChopperMode, nil\n}", "func (d *Device) infoString() string {\n\treturn fmt.Sprintf(\"%04X:%04X:%04X\", d.Data.Bus, d.Data.VendorID, d.Data.ProductID)\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 (device *Dev) String() string {\n\treturn fmt.Sprintf(\"UnicornHD{%d, %d}\", width, height)\n}", "func (*MbusOpt) Descriptor() ([]byte, []int) {\n\treturn file_synerex_proto_rawDescGZIP(), []int{9}\n}", "func GetBasicInfo(img imgmeta.Image) (info BasicInfo) {\n\twidth, err := img.ReadTagValue(\"SOF0\", imgmeta.SOF0ImageWidth)\n\tif err == nil {\n\t\tinfo.Width = width\n\t} else {\n\t\tlog.Error(err.Error())\n\t}\n\theight, err := img.ReadTagValue(\"SOF0\", imgmeta.SOF0ImageHeight)\n\tif err == nil {\n\t\tinfo.Height = height.(uint32)\n\t} else {\n\t\tlog.Error(err.Error())\n\t}\n\tkeyword, err := img.ReadTagValue(\"IPTC\", imgmeta.IptcTagApplication2Keywords)\n\tif err == nil {\n\t\tinfo.Keywords = []string{keyword.(string)}\n\t}\n\tdatetime, err := img.ReadTagValue(\"EXIF\", imgmeta.ExifTagDateTimeOriginal)\n\tif err == nil {\n\t\tlog.Info(fmt.Sprintf(\"datetime:%v\\n\", datetime))\n\t}\n\n\timgTitle, err := img.ReadTagValue(\"IPTC\", imgmeta.IptcTagApplication2Caption)\n\tif err == nil {\n\t\tinfo.Title = imgTitle.(string)\n\t}\n\n\treturn\n}", "func Configuration() string {\n\treturn C.GoString(C.avformat_configuration())\n}", "func Info(ctx *dgc.Ctx) *discordgo.MessageEmbed {\n\t// Read the memstats\n\tvar memStats runtime.MemStats\n\truntime.ReadMemStats(&memStats)\n\theapInUse := datasize.ByteSize(memStats.HeapInuse)\n\tstackInUse := datasize.ByteSize(memStats.StackInuse)\n\n\treturn &discordgo.MessageEmbed{\n\t\tTitle: \"Information\",\n\t\tTimestamp: time.Now().Format(time.RFC3339),\n\t\tColor: 0x0893d8,\n\t\tFields: []*discordgo.MessageEmbedField{\n\t\t\t{\n\t\t\t\tName: \"Application\",\n\t\t\t\tValue: \"Mode: `\" + static.Mode + \"`\" +\n\t\t\t\t\t\"\\nVersion: `\" + static.Version + \"`\" +\n\t\t\t\t\t\"\\nUptime: `\" + time.Since(static.StartupTime).Round(time.Second).String() + \"`\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"Discord\",\n\t\t\t\tValue: \"Guilds: `\" + strconv.Itoa(len(ctx.Session.State.Guilds)) + \"`\" +\n\t\t\t\t\t\"\\nAPI latency: `\" + ctx.Session.HeartbeatLatency().Round(time.Millisecond).String() + \"`\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"System\",\n\t\t\t\tValue: \"OS: `\" + runtime.GOOS + \"`\" +\n\t\t\t\t\t\"\\nArchitecture: `\" + runtime.GOARCH + \"`\" +\n\t\t\t\t\t\"\\nCurrent Goroutines: `\" + strconv.Itoa(runtime.NumGoroutine()) + \"`\" +\n\t\t\t\t\t\"\\nOccupied heap: `\" + heapInUse.HumanReadable() + \"`\" +\n\t\t\t\t\t\"\\nOccupied stack: `\" + stackInUse.HumanReadable() + \"`\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"General\",\n\t\t\t\tValue: \"Developer(s): `Lukaesebrot#8001`\" +\n\t\t\t\t\t\"\\nGitHub repository: [here](http://github.com/Lukaesebrot/asterisk)\" +\n\t\t\t\t\t\"\\nInvite me: [here](https://discord.com/api/oauth2/authorize?client_id=\" + static.Self.ID + \"&permissions=0&scope=bot)\" +\n\t\t\t\t\t\"\\nSupport guild: [here](https://discord.gg/ddz9b86)\",\n\t\t\t},\n\t\t},\n\t}\n}", "func (*OSVerDetails) Descriptor() ([]byte, []int) {\n\treturn file_config_baseosconfig_proto_rawDescGZIP(), []int{1}\n}", "func (*UnitInfo) Descriptor() ([]byte, []int) {\n\treturn file_server_combat_combat_proto_rawDescGZIP(), []int{0}\n}", "func (dev *SDRDevice) GetHardwareInfo() (hardwareInfo map[string]string) {\n\n\tinfo := (C.SoapySDRKwargs)(C.SoapySDRDevice_getHardwareInfo(dev.device))\n\tdefer argsClear(info)\n\n\treturn args2Go(info)\n}", "func (self *PhysicsP2) Config() interface{}{\n return self.Object.Get(\"config\")\n}", "func (d *ceph) Info() Info {\n\treturn Info{\n\t\tName: \"ceph\",\n\t\tVersion: cephVersion,\n\t\tOptimizedImages: true,\n\t\tPreservesInodes: false,\n\t\tRemote: d.isRemote(),\n\t\tVolumeTypes: []VolumeType{VolumeTypeCustom, VolumeTypeImage, VolumeTypeContainer, VolumeTypeVM},\n\t\tBlockBacking: true,\n\t\tRunningCopyFreeze: true,\n\t\tDirectIO: true,\n\t\tIOUring: true,\n\t\tMountedRoot: false,\n\t}\n}", "func (ws *WindowSurface) Configure() {\n\tws.txtSimStatus = NewText(ws.nFont, ws.renderer)\n\terr := ws.txtSimStatus.SetText(\"Sim Status: \", sdl.Color{R: 0, G: 0, B: 255, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtFPSLabel = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtFPSLabel.SetText(\"FPS: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtMousePos = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtMousePos.SetText(\"Mouse: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.txtLoopLabel = NewText(ws.nFont, ws.renderer)\n\terr = ws.txtLoopLabel.SetText(\"Loop: \", sdl.Color{R: 200, G: 200, B: 200, A: 255})\n\tif err != nil {\n\t\tws.Close()\n\t\tpanic(err)\n\t}\n\n\tws.dynaTxt = NewDynaText(ws.nFont, ws.renderer, sdl.Color{R: 255, G: 255, B: 255, A: 255})\n}", "func (me TxsdPresentationAttributesGraphicsDisplay) String() string { return xsdt.String(me).String() }", "func ShowConf(iface string) ([]byte, error) {\n\tcmd := exec.Command(\"wg\", \"showconf\", iface)\n\tvar stderr, stdout bytes.Buffer\n\tcmd.Stderr = &stderr\n\tcmd.Stdout = &stdout\n\tif err := cmd.Run(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read the WireGuard configuration: %s\", stderr.String())\n\t}\n\treturn stdout.Bytes(), nil\n}", "func (*Identifier) Descriptor() ([]byte, []int) {\n\treturn file_ocis_messages_settings_v0_settings_proto_rawDescGZIP(), []int{1}\n}", "func (c *FwGeneral) Get() (Config, error) {\n c.con.LogQuery(\"(get) general settings\")\n return c.details(c.con.Get)\n}", "func (*DeviceInfoResponse) Descriptor() ([]byte, []int) {\n\treturn file_bitbox02_system_proto_rawDescGZIP(), []int{3}\n}", "func (w *ConfigModule) Description(info *GuildInfo) string { return \"Manages the configuration file.\" }", "func (*SmartCampaignSetting) Descriptor() ([]byte, []int) {\n\treturn file_google_ads_googleads_v8_resources_smart_campaign_setting_proto_rawDescGZIP(), []int{0}\n}", "func ManagedDeviceInfo(ctx context.Context, s *testing.State) {\n\tconst uiTimeout = 10 * time.Second\n\n\t// Reserve some time for various cleanup.\n\tcleanupCtx := ctx\n\tctx, cancel := ctxutil.Shorten(ctx, 10*time.Second)\n\tdefer cancel()\n\n\t// Start a Browser instance that will fetch policies from the FakeDMS.\n\tfdms := s.FixtValue().(fakedms.HasFakeDMS).FakeDMS()\n\tbt := s.Param().(browser.Type)\n\topts := []chrome.Option{\n\t\tchrome.FakeLogin(chrome.Creds{User: fixtures.Username, Pass: fixtures.Password}),\n\t\tchrome.DMSPolicy(fdms.URL),\n\t\tchrome.EnableFeatures(\"ManagedDeviceUIRedesign\"),\n\t}\n\tcr, br, closeBrowser, err := browserfixt.SetUpWithNewChrome(ctx, bt, lacrosfixt.NewConfig(), opts...)\n\tif err != nil {\n\t\ts.Fatal(\"Chrome login failed: \", err)\n\t}\n\tdefer cr.Close(cleanupCtx)\n\tdefer closeBrowser(cleanupCtx)\n\n\t// Connect to Test API to use it with the UI library.\n\ttconn, err := cr.TestAPIConn(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to create Test API connection: \", err)\n\t}\n\tdefer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)\n\n\tif err := quicksettings.Show(ctx, tconn); err != nil {\n\t\ts.Fatal(\"Failed to show Quick Settings: \", err)\n\t}\n\tdefer quicksettings.Hide(ctx, tconn)\n\n\t// Check if management information is shown.\n\tui := uiauto.New(tconn)\n\tmanagedBtn := quicksettings.ManagedInfoView\n\tif err := ui.WithTimeout(uiTimeout).WaitUntilExists(managedBtn)(ctx); err != nil {\n\t\ts.Fatal(\"Failed to find managed info button: \", err)\n\t}\n\n\t// Check if the information contains the managed domain name or indication that the device is \"enterprise managed\" (depending on test account configuration).\n\tinfo, err := ui.Info(ctx, managedBtn)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to get management information button info: \", err)\n\t}\n\tif !strings.Contains(info.Name, \"managedchrome.com\") && !strings.Contains(info.Name, \"enterprise managed\") {\n\t\ts.Fatalf(\"Managed info string: %q, expected containing management domain name or enterprise managed indication\", info.Name)\n\t}\n\n\tif err := ui.LeftClick(managedBtn)(ctx); err != nil {\n\t\ts.Fatal(\"Failed to click management information button: \", err)\n\t}\n\n\t// Check if management page is open after clicking the button.\n\tif _, err := br.NewConnForTarget(ctx, chrome.MatchTargetURL(\"chrome://management/\")); err != nil {\n\t\ts.Fatal(\"Management page did not open: \", err)\n\t}\n}", "func (*DeviceInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_bitbox02_system_proto_rawDescGZIP(), []int{2}\n}", "func (frame *AvFrame) SetInfo(width int, height int, pixFmt int) (err error) {\n\tframe.width = C.int(width)\n\tframe.height = C.int(height)\n\tframe.format = C.int(pixFmt)\n\tif ret := C.av_frame_get_buffer((*C.struct_AVFrame)(unsafe.Pointer(frame)), 32 /*alignment*/); ret < 0 {\n\t\terr = fmt.Errorf(\"Error allocating avframe buffer. Err: %v\", ret)\n\t\treturn\n\t}\n\treturn\n}", "func (this *fileStruct) SampleFormat() uint16 {\n\treturn this.sampleFormat\n}", "func getDeviceInfo(nanos *ledger.NanoS) error {\n\terr := nanos.GetVersion()\n\tif err != nil {\n\t\tlog.Println(errGetAppVersion)\n\t\treturn err\n\t}\n\terr = nanos.GetConfiguration()\n\tif err != nil {\n\t\tlog.Println(errGetConfig)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (w *Wioctl) Config() *Config {\n\tw.lock.Lock()\n\tcfg := w.cfg\n\tw.lock.Unlock()\n\treturn cfg\n}", "func (*CSVCMsg_GameSessionConfiguration) Descriptor() ([]byte, []int) {\n\treturn file_artifact_networkbasetypes_proto_rawDescGZIP(), []int{21}\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\t// tv := gi.AddNewTabView(split, \"tv\")\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen cat string\", Icon: \"new\", Tooltip: \"Generate a new initial random seed to get different results. By default, Init re-establishes the same initial seed every time.\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.CatNoRepeat(gn.syls1)\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func (c *Config) getHelp() {\n\tcm := cmds.Command{\n\t\tName: \"help\",\n\t\tDescription: \"prints information about how to use pod\",\n\t\tEntrypoint: helpFunction,\n\t\tCommands: nil,\n\t}\n\t// first add all the options\n\tc.ForEach(func(ifc opt.Option) bool {\n\t\to := fmt.Sprintf(\"Parallelcoin Pod All-in-One Suite\\n\\n\")\n\t\tvar dt details\n\t\tswitch ii := ifc.(type) {\n\t\tcase *binary.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\tcase *list.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\tcase *float.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\tcase *integer.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\tcase *text.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\tcase *duration.Opt:\n\t\t\tdt = details{ii.GetMetadata().Name, ii.Option, ii.Description, fmt.Sprint(ii.Def), ii.Aliases,\n\t\t\t\tii.Documentation,\n\t\t\t}\n\t\t}\n\t\tcm.Commands = append(cm.Commands, cmds.Command{\n\t\t\tName: dt.option,\n\t\t\tDescription: dt.desc,\n\t\t\tEntrypoint: func(ifc interface{}) (e error) {\n\t\t\t\to += fmt.Sprintf(\"Help information about %s\\n\\n\\toption name:\\n\\t\\t%s\\n\\taliases:\\n\\t\\t%s\\n\\tdescription:\\n\\t\\t%s\\n\\tdefault:\\n\\t\\t%v\\n\",\n\t\t\t\t\tdt.name, dt.option, dt.aliases, dt.desc, dt.def,\n\t\t\t\t)\n\t\t\t\tif dt.documentation != \"\" {\n\t\t\t\t\to += \"\\tdocumentation:\\n\\t\\t\" + dt.documentation + \"\\n\\n\"\n\t\t\t\t}\n\t\t\t\tfmt.Fprint(os.Stderr, o)\n\t\t\t\treturn\n\t\t\t},\n\t\t\tCommands: nil,\n\t\t},\n\t\t)\n\t\treturn true\n\t},\n\t)\n\t// next add all the commands\n\tc.Commands.ForEach(func(cm cmds.Command) bool {\n\t\t\n\t\treturn true\n\t}, 0, 0,\n\t)\n\tc.Commands = append(c.Commands, cm)\n\treturn\n}", "func (config AudioConfig) values() (url.Values, error) {\n\tv, err := config.BaseChat.values()\n\tif err != nil {\n\t\treturn v, err\n\t}\n\n\tv.Add(config.name(), config.FileID)\n\tif config.Duration != 0 {\n\t\tv.Add(\"duration\", strconv.Itoa(config.Duration))\n\t}\n\n\tif config.Performer != \"\" {\n\t\tv.Add(\"performer\", config.Performer)\n\t}\n\tif config.Title != \"\" {\n\t\tv.Add(\"title\", config.Title)\n\t}\n\tif config.Caption != \"\" {\n\t\tv.Add(\"caption\", config.Caption)\n\t\tif config.ParseMode != \"\" {\n\t\t\tv.Add(\"parse_mode\", config.ParseMode)\n\t\t}\n\t}\n\n\treturn v, nil\n}", "func (*StorageFormat_IcebergOptions) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dataplex_v1_metadata_proto_rawDescGZIP(), []int{14, 2}\n}", "func (m *MediaPrompt) GetMediaInfo()(MediaInfoable) {\n return m.mediaInfo\n}", "func InitBandinfo() Bandinfo {\n\treturn Bandinfo{Init(&CommandItem{\n\t\tName: \"bandinfo\",\n\t\tDescription: \"Gets information on the current playing band\",\n\t\tAliases: []string{\"bi\", \"artistinfo\", \"ai\"},\n\t\tUsage: \"bandinfo Darkthrone\",\n\t\tParameters: []Parameter{},\n\t})}\n}", "func (*MIIMonitor) Descriptor() ([]byte, []int) {\n\treturn file_config_devmodel_proto_rawDescGZIP(), []int{6}\n}", "func (gn *Gen) ConfigGui() *gi.Window {\n\twidth := 1600\n\theight := 1200\n\n\tgi.SetAppName(\"Gen\")\n\tgi.SetAppAbout(`Gen concatenated strings of syllables`)\n\n\twin := gi.NewMainWindow(\"one\", \"Gen ...\", width, height)\n\n\tvp := win.WinViewport2D()\n\tupdt := vp.UpdateStart()\n\n\tmfr := win.SetMainFrame()\n\n\ttbar := gi.AddNewToolBar(mfr, \"tbar\")\n\ttbar.SetStretchMaxWidth()\n\t// vi.ToolBar = tbar\n\n\tsplit := gi.AddNewSplitView(mfr, \"split\")\n\tsplit.Dim = gi.X\n\tsplit.SetStretchMaxWidth()\n\tsplit.SetStretchMaxHeight()\n\n\tsv := giv.AddNewStructView(split, \"sv\")\n\tsv.SetStruct(gn)\n\tgn.StructView = sv\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen TriSyllable Strings\", Icon: \"new\", Tooltip: \"Generate all combinations of tri syllabic strings from the sets of syllables for each position\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenTriSyllables()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Write TriSyls Strings\", Icon: \"new\", Tooltip: \"\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.WriteTriSyllables()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Shuffle CVs\", Icon: \"new\", Tooltip: \"Shuffle the syllables and add this shuffle to the list of shuffles\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.ShuffleCVs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Write Shuffled CVs\", Icon: \"new\", Tooltip: \"WriteShuffles writes an individual file for each of the shuffled CV lists generated\\n// and also writes a file called \\\"ls\\\" that is a list of the files written!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.WriteShuffles()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Speech\", Icon: \"new\", Tooltip: \"Calls GnuSpeech on content of files\\n// and also writes a file called \\\"ls\\\" that is a list of the files written!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenSpeech(gn.ShufflesIn, gn.ShufflesOut)\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Rename Individual CVs\", Icon: \"new\", Tooltip: \"Must run this after splitting shuffle files into individual CVs before concatenating!\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.Rename()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Whole Word Wavs\", Icon: \"new\", Tooltip: \"Generates wav files of 3 CVs where the second and third are fully predictable based on first CV\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenWholeWordWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Gen Part Word Wavs\", Icon: \"new\", Tooltip: \"Generates wav files of 3 CVs, the second CV is of a set (so partially predictable), the third CV is predictable based on second\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.GenPartWordWavs()\n\t\t})\n\n\ttbar.AddAction(gi.ActOpts{Label: \"Wav sequence from tri wavs\", Icon: \"new\", Tooltip: \"Write wav file that is the concatenation of wav files of tri CVs\"}, win.This(),\n\t\tfunc(recv, send ki.Ki, sig int64, data interface{}) {\n\t\t\tgn.SequenceFromTriCVs()\n\t\t})\n\n\tvp.UpdateEndNoSig(updt)\n\n\t// main menu\n\tappnm := gi.AppName()\n\tmmen := win.MainMenu\n\tmmen.ConfigMenus([]string{appnm, \"File\", \"Edit\", \"Window\"})\n\n\tamen := win.MainMenu.ChildByName(appnm, 0).(*gi.Action)\n\tamen.Menu.AddAppMenu(win)\n\n\temen := win.MainMenu.ChildByName(\"Edit\", 1).(*gi.Action)\n\temen.Menu.AddCopyCutPaste(win)\n\n\tvp.UpdateEndNoSig(updt)\n\n\twin.MainMenuUpdated()\n\treturn win\n}", "func (o *GetTextGDIPlusPropertiesParams) Name() string {\n\treturn \"GetTextGDIPlusProperties\"\n}", "func (*ValueWithIdentifier) Descriptor() ([]byte, []int) {\n\treturn file_ocis_messages_settings_v0_settings_proto_rawDescGZIP(), []int{0}\n}", "func (m Mixer) Config() Config {\n\treturn m.config\n}", "func (*SignatureHelpClientCapabilities_SignatureInformation_ParameterInformation) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{114, 0, 0}\n}", "func (*CMsgDOTARealtimeGameStats_BuildingDetails) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_common_proto_rawDescGZIP(), []int{27, 6}\n}", "func (d *Driver) UnitInfo() dex.UnitInfo {\n\treturn dexeth.UnitInfo\n}", "func PrintInfo(s Solid) {\n\tfmt.Println(s)\n\tfmt.Printf(\"Volume: %0.3f\\n\", s.Volume())\n\tfmt.Printf(\"Surface Area: %0.3f\\n\", s.SurfaceArea())\n}", "func (v Vehicle) GuiSettings() (*GuiSettings, error) {\n\tstateRequest, err := fetchState(\"/gui_settings\", v.ID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn stateRequest.Response.GuiSettings, nil\n}", "func (a *api) Size() string { return a.Name(\"Size\") }", "func (*NvmeAddDeviceResp) Descriptor() ([]byte, []int) {\n\treturn file_ctl_storage_proto_rawDescGZIP(), []int{8}\n}", "func (me TxsdPresentationAttributesGraphicsDisplay) IsCompact() bool { return me.String() == \"compact\" }", "func (*CMsgDOTARealtimeGameStatsTerse_BuildingDetails) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_common_proto_rawDescGZIP(), []int{28, 2}\n}", "func (hf *HeaderFrame) Channel() uint16 { return hf.ChannelID }", "func (*EngineSetting) Descriptor() ([]byte, []int) {\n\treturn file_menu_proto_rawDescGZIP(), []int{5}\n}", "func (l *Libvirt) StorageVolGetInfoFlags(Vol StorageVol, Flags uint32) (rType int8, rCapacity uint64, rAllocation uint64, err error) {\n\tvar buf []byte\n\n\targs := StorageVolGetInfoFlagsArgs {\n\t\tVol: Vol,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(378, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Type: int8\n\t_, err = dec.Decode(&rType)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Capacity: uint64\n\t_, err = dec.Decode(&rCapacity)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Allocation: uint64\n\t_, err = dec.Decode(&rAllocation)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (*RecognitionAudio) Descriptor() ([]byte, []int) {\n\treturn file_cubic_proto_rawDescGZIP(), []int{13}\n}", "func (*NvmeAddDeviceReq) Descriptor() ([]byte, []int) {\n\treturn file_ctl_storage_proto_rawDescGZIP(), []int{7}\n}", "func (cc *ChainConfig) Show() {\n\tlog.Println(\"Name is \", cc.Name)\n\tlog.Println(\"Prefix is \", cc.Prefix)\n\tlog.Println(\"Suffix is \", cc.Suffix)\n\tlog.Println(\"Interval is \", cc.Interval)\n\tlog.Printf(\"Inputer is %v\\n\", cc.Chain)\n}", "func (d *DeviceBase) DeviceInfo() DeviceInfo {\n\treturn d.Info\n}", "func GetInfo() adapter.Info {\n\treturn adapter.Info{\n\t\tName: \"statsd\",\n\t\tImpl: \"istio.io/istio/mixer/adapter/statsd\",\n\t\tDescription: \"Produces statsd metrics\",\n\t\tSupportedTemplates: []string{\n\t\t\tmetric.TemplateName,\n\t\t},\n\t\tDefaultConfig: &config.Params{\n\t\t\tAddress: \"localhost:8125\",\n\t\t\tPrefix: \"\",\n\t\t\tFlushDuration: 300 * time.Millisecond,\n\t\t\tFlushBytes: 512,\n\t\t\tSamplingRate: 1.0,\n\t\t},\n\n\t\tNewBuilder: func() adapter.HandlerBuilder { return &builder{} },\n\t}\n}", "func (*SDConfig) Name() string { return \"file\" }", "func (me XsdGoPkgHasAttr_Show) ShowDefault() TxsdShow { return TxsdShow(\"embed\") }", "func (self *Graphics) Width() int{\n return self.Object.Get(\"width\").Int()\n}", "func (*NrFrequencyInfo_SulInformation) Descriptor() ([]byte, []int) {\n\treturn file_gnb_proto_rawDescGZIP(), []int{4, 0}\n}", "func (config VoiceConfig) params() (map[string]string, error) {\n\tparams, _ := config.BaseFile.params()\n\n\tif config.Duration != 0 {\n\t\tparams[\"duration\"] = strconv.Itoa(config.Duration)\n\t}\n\tif config.Caption != \"\" {\n\t\tparams[\"caption\"] = config.Caption\n\t\tif config.ParseMode != \"\" {\n\t\t\tparams[\"parse_mode\"] = config.ParseMode\n\t\t}\n\t}\n\n\treturn params, nil\n}", "func NewDeviceManagementSettings()(*DeviceManagementSettings) {\n m := &DeviceManagementSettings{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func (h *Handler) getDeveloperAttributes(c *gin.Context) handlerResponse {\n\n\tdeveloper, err := h.service.Developer.Get(c.Param(developerParameter))\n\tif err != nil {\n\t\treturn handleError(err)\n\t}\n\treturn handleOKAttributes(developer.Attributes)\n}", "func GetInfo() adapter.Info {\n\treturn adapter.Info{\n\t\tName: \"svcctrl\",\n\t\tImpl: \"istio.io/istio/mixer/adapter/svcctrl\",\n\t\tDescription: \"Interface to Google Service Control\",\n\t\tSupportedTemplates: []string{\n\t\t\tmetric.TemplateName,\n\t\t},\n\t\tDefaultConfig: &config.Params{\n\t\t\tServiceName: \"library-example.sandbox.googleapis.com\",\n\t\t},\n\n\t\tNewBuilder: func() adapter.HandlerBuilder { return &builder{} },\n\t}\n}", "func (device *SilentStepperBrick) GetMiscConfiguration() (disableShortToGroundProtection bool, synchronizePhaseFrequency uint8, err error) {\n\tvar buf bytes.Buffer\n\n\tresultBytes, err := device.device.Get(uint8(FunctionGetMiscConfiguration), buf.Bytes())\n\tif err != nil {\n\t\treturn disableShortToGroundProtection, synchronizePhaseFrequency, err\n\t}\n\tif len(resultBytes) > 0 {\n\t\tvar header PacketHeader\n\n\t\theader.FillFromBytes(resultBytes)\n\n\t\tif header.Length != 10 {\n\t\t\treturn disableShortToGroundProtection, synchronizePhaseFrequency, fmt.Errorf(\"Received packet of unexpected size %d, instead of %d\", header.Length, 10)\n\t\t}\n\n\t\tif header.ErrorCode != 0 {\n\t\t\treturn disableShortToGroundProtection, synchronizePhaseFrequency, DeviceError(header.ErrorCode)\n\t\t}\n\n\t\tresultBuf := bytes.NewBuffer(resultBytes[8:])\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &disableShortToGroundProtection)\n\t\tbinary.Read(resultBuf, binary.LittleEndian, &synchronizePhaseFrequency)\n\n\t}\n\n\treturn disableShortToGroundProtection, synchronizePhaseFrequency, nil\n}", "func (m *DeviceManagementConfigurationSettingDefinition) GetHelpText()(*string) {\n val, err := m.GetBackingStore().Get(\"helpText\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (w *WindowWidget) CurrentSize() (width, height float32) {\n\tsize := w.getState().currentSize\n\treturn size.X, size.Y\n}", "func hwinfo() string {\n\tb1, err := exec.Command(\"vcgencmd\", \"measure_clock\", \"arm\").Output()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tb2, err := exec.Command(\"vcgencmd\", \"measure_clock\", \"core\").Output()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tif len(b1) < 17 || len(b2) < 17 {\n\t\treturn \"bad len\"\n\t}\n\treturn fmt.Sprintf(\"arm=%sMhz core=%sMHz\", b1[14:17], b2[13:16])\n}", "func (t *Track) buildAudioManifestRepresentation() string {\n\tres := `\n <Representation\n id=\"audio` + strconv.Itoa(t.index) + `\"\n bandwidth=\"` + strconv.Itoa(t.bandwidth) + `\"\n codecs=\"` + t.codec + `\"\n audioSamplingRate=\"` + strconv.Itoa(t.sampleRate) + `\">\n <AudioChannelConfiguration\n schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\"\n value=\"2\">\n </AudioChannelConfiguration>\n </Representation>`\n\treturn res\n}", "func (l *Libvirt) StorageVolGetInfo(Vol StorageVol) (rType int8, rCapacity uint64, rAllocation uint64, err error) {\n\tvar buf []byte\n\n\targs := StorageVolGetInfoArgs {\n\t\tVol: Vol,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar r response\n\tr, err = l.requestStream(98, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Return value unmarshaling\n\ttpd := typedParamDecoder{}\n\tct := map[string]xdr.TypeDecoder{\"libvirt.TypedParam\": tpd}\n\trdr := bytes.NewReader(r.Payload)\n\tdec := xdr.NewDecoderCustomTypes(rdr, 0, ct)\n\t// Type: int8\n\t_, err = dec.Decode(&rType)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Capacity: uint64\n\t_, err = dec.Decode(&rCapacity)\n\tif err != nil {\n\t\treturn\n\t}\n\t// Allocation: uint64\n\t_, err = dec.Decode(&rAllocation)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func NewDeviceInfo() (DeviceInfo, error) {\n\td := DeviceInfo{Created: time.Now()}\n\n\t// Get the operating system\n\tout, err := exec.Command(\"uname\").Output()\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"executable file not found\") {\n\t\t\td.OS = \"WindowsNT\"\n\t\t} else {\n\t\t\treturn d, errors.New(\"Error getting device Operating System. \" + err.Error())\n\t\t}\n\t} else {\n\t\td.OS = strings.TrimSpace(string(out))\n\t}\n\n\t// Get the Host Name\n\tout, err = exec.Command(\"hostname\").Output()\n\tif err != nil {\n\t\treturn d, errors.New(\"Error getting device HostName. \" + err.Error())\n\t}\n\td.HostName = strings.TrimSpace(string(out))\n\n\t// Get the Machine ID\n\tif strings.ToLower(d.OS) == \"linux\" {\n\t\ttxt, err := ReadAllText(\"/etc/machine-id\")\n\t\tif err != nil {\n\t\t\treturn d, errors.New(\"Error getting device Machine-ID. \" + err.Error())\n\t\t}\n\t\td.MachineID = txt\n\t} else {\n\t\ttxt, err := GetClientID()\n\t\tif err != nil {\n\t\t\treturn d, errors.New(\"Error getting device Client-ID. \" + err.Error())\n\t\t}\n\t\td.MachineID = txt\n\t}\n\tif d.MachineID != \"\" {\n\t\t// Generate the SHA1 hash of the Machine ID\n\t\tsum := sha1.Sum([]byte(d.MachineID))\n\t\td.MachineID = fmt.Sprintf(\"%x\", sum)\n\t}\n\n\t// Get the IP addresses\n\tip, err := GetLocalIPAddresses()\n\tif err != nil {\n\t\treturn d, errors.New(\"Error getting device IP addresses. \" + err.Error())\n\t}\n\td.IPAddress = ip\n\n\treturn d, nil\n}", "func Configuration() string {\n\treturn C.GoString(C.avfilter_configuration())\n}", "func (obj *GenericMeasure) GetInfo(ctx context.Context) (*NxInfo, error) {\n\tresult := &struct {\n\t\tInfo *NxInfo `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (*CMsgGCPlayerInfoRequest_PlayerInfo) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{117, 0}\n}", "func (*GetSettingResponse) Descriptor() ([]byte, []int) {\n\treturn file_menu_proto_rawDescGZIP(), []int{4}\n}", "func (turingMachine *TuringMachine) GetConfiguration() string {\n return turingMachine.tape.GetConfiguration(turingMachine.currentState.name)\n}", "func (*SystemAdapter) Descriptor() ([]byte, []int) {\n\treturn file_config_devmodel_proto_rawDescGZIP(), []int{0}\n}", "func (config VoiceConfig) values() (url.Values, error) {\n\tv, err := config.BaseChat.values()\n\tif err != nil {\n\t\treturn v, err\n\t}\n\n\tv.Add(config.name(), config.FileID)\n\tif config.Duration != 0 {\n\t\tv.Add(\"duration\", strconv.Itoa(config.Duration))\n\t}\n\tif config.Caption != \"\" {\n\t\tv.Add(\"caption\", config.Caption)\n\t\tif config.ParseMode != \"\" {\n\t\t\tv.Add(\"parse_mode\", config.ParseMode)\n\t\t}\n\t}\n\n\treturn v, nil\n}", "func (*SessionDevice) Descriptor() ([]byte, []int) {\n\treturn file_session_service_proto_rawDescGZIP(), []int{15}\n}", "func (*BaseOS) Descriptor() ([]byte, []int) {\n\treturn file_config_baseosconfig_proto_rawDescGZIP(), []int{3}\n}", "func (m *Dash) Build() error {\n\tm.head.Text = \"IRobot Create 2 - Command and Control\"\n\tm.head.Height = 3\n\n\tm.tmstmp.Height = 3\n\n\tm.modeDisp.Height = 3\n\n\tm.stasis.Height = 3\n\n\t// Command list.\n\tm.cmd.Items = []string{\n\t\t\"[↑] Move forward\",\n\t\t\"[→] Turn Right\",\n\t\t\"[↓] Move backward\",\n\t\t\"[←] Turn Right\",\n\t\t\"[p] Passive Mode \",\n\t\t\"[f] Full Mode\",\n\t\t\"[s] Safe Mode\",\n\t\t\"[o] Stop\",\n\t\t\"[d] Power Down\",\n\t\t\"[k] Seek Dock\",\n\t}\n\tm.cmd.ItemFgColor = ui.ColorYellow\n\tm.cmd.Height = 13\n\tm.cmd.BorderLabel = \"Commands\"\n\tm.cmd.Align()\n\n\t// Encoder, rotation levels.\n\tm.movSensor.BorderLabel = \"Encoder, Rotation\"\n\tm.movSensor.Data = []int{3231, 2223, 5234, 32, 312}\n\tm.movSensor.Height = 10\n\tm.movSensor.DataLabels = []string{\"Enc(L)\", \"Enc(R)\", \"Rad(mm)\", \"Ang(deg)\", \"Dist(mm)\"}\n\tm.movSensor.TextColor = ui.ColorGreen\n\tm.movSensor.BarColor = ui.ColorMagenta\n\tm.movSensor.NumColor = ui.ColorYellow\n\tm.movSensor.BarWidth = 8\n\tm.movSensor.Align()\n\n\t// Velocity.\n\tm.velSensor.BorderLabel = \"Velocity (mm/s)\"\n\tm.velSensor.Data = []int{231, 200, 100}\n\tm.velSensor.Height = 10\n\tm.velSensor.DataLabels = []string{\"Total\", \"Right\", \"Left\"}\n\tm.velSensor.TextColor = ui.ColorGreen\n\tm.velSensor.BarColor = ui.ColorBlue\n\tm.velSensor.NumColor = ui.ColorYellow\n\tm.velSensor.BarWidth = 5\n\tm.velSensor.Width = 3\n\tm.velSensor.Align()\n\n\t// Currents levels.\n\tm.currSensor.BorderLabel = \"Motor Current (mAh)\"\n\tm.currSensor.Data = []int{2223, 5234, 3223, 3122}\n\tm.currSensor.Height = 10\n\tm.currSensor.DataLabels = []string{\"Left\", \"Right\", \"Main\", \"Side\"}\n\tm.currSensor.TextColor = ui.ColorGreen\n\tm.currSensor.BarColor = ui.ColorBlue\n\tm.currSensor.NumColor = ui.ColorYellow\n\tm.currSensor.BarWidth = 5\n\tm.currSensor.Align()\n\n\t// Dirtlevel 0-255\n\tm.dirtLvl.Percent = 0\n\tm.dirtLvl.Height = 3\n\tm.dirtLvl.BorderLabel = \"Dirt Level\"\n\tm.dirtLvl.Label = \"({{percent}}%) dirt detection\"\n\tm.dirtLvl.PercentColor = ui.ColorYellow\n\tm.dirtLvl.BarColor = ui.ColorGreen\n\tm.dirtLvl.PercentColorHighlighted = ui.ColorBlack\n\n\t// Battery state gauges.\n\tm.battMeter.Percent = 50\n\tm.battMeter.Height = 3\n\tm.battMeter.BorderLabel = \"Batt Level\"\n\tm.battMeter.Label = \"({{percent}}%) 1500/2698 mAH\"\n\tm.battMeter.PercentColor = ui.ColorYellow\n\tm.battMeter.BarColor = ui.ColorGreen\n\tm.battMeter.PercentColorHighlighted = ui.ColorBlack\n\n\tm.battLvl.BorderLabel = \"Batt Level (%)\"\n\tm.battLvl.Data = []float64{0}\n\tm.battLvl.Height = 13\n\t//m.battLvl.Mode = \"dot\"\n\tm.battLvl.AxesColor = ui.ColorWhite\n\tm.battLvl.LineColor = ui.ColorGreen | ui.AttrBold\n\n\t// Battery data.\n\tm.battState.Rows = [][]string{\n\t\t[]string{\"Batt Status\", \"\"},\n\t\t[]string{\"Temp (C)\", \"1023\"},\n\t\t[]string{\"Volts (mV)\", \"\"},\n\t\t[]string{\"Current (mA)\", \"\"},\n\t\t[]string{\"Charge\", \"Trickle\"},\n\t}\n\tm.battState.FgColor = ui.ColorWhite\n\tm.battState.BgColor = ui.ColorDefault\n\tm.battState.TextAlign = ui.AlignCenter\n\tm.battState.Separator = false\n\tm.battState.Analysis()\n\tm.battState.SetSize()\n\tm.battState.Border = true\n\n\t// IRCode.\n\tm.irCode.Rows = [][]string{\n\t\t[]string{\"IR Code\", \"\"},\n\t\t[]string{\"Omni\", \"1023\"},\n\t\t[]string{\"Left\", \"\"},\n\t\t[]string{\"Right\", \"\"},\n\t}\n\tm.irCode.FgColor = ui.ColorWhite\n\tm.irCode.BgColor = ui.ColorDefault\n\tm.irCode.TextAlign = ui.AlignCenter\n\tm.irCode.Separator = false\n\tm.irCode.Border = true\n\tm.irCode.Analysis()\n\tm.irCode.SetSize()\n\tm.irCode.Height = 10\n\n\t// OverCurrent Data.\n\tm.ocSensor.Rows = [][]string{\n\t\t[]string{\"Overcurrent\"},\n\t\t[]string{\"Right Wheel\"},\n\t\t[]string{\"Left Wheel\"},\n\t\t[]string{\"Main Brush\"},\n\t\t[]string{\"Side Brush\"},\n\t}\n\tm.ocSensor.FgColor = ui.ColorWhite\n\tm.ocSensor.BgColor = ui.ColorDefault\n\tm.ocSensor.TextAlign = ui.AlignCenter\n\tm.ocSensor.Separator = false\n\tm.ocSensor.Analysis()\n\tm.ocSensor.SetSize()\n\tm.ocSensor.Border = true\n\n\t// Bump sensors.\n\tm.bumpSensor.Rows = [][]string{\n\t\t[]string{\"Light Bumper\", \"Signal\"},\n\t\t[]string{\"Left\", \"1023\"},\n\t\t[]string{\"Front Left\", \"\"},\n\t\t[]string{\"Center Left\", \"\"},\n\t\t[]string{\"Center Right\", \"\"},\n\t\t[]string{\"Front Right\", \"\"},\n\t\t[]string{\"Right\", \"\"},\n\t}\n\n\tm.bumpSensor.FgColor = ui.ColorWhite\n\tm.bumpSensor.BgColor = ui.ColorDefault\n\tm.bumpSensor.TextAlign = ui.AlignCenter\n\tm.bumpSensor.Separator = false\n\tm.bumpSensor.Analysis()\n\tm.bumpSensor.SetSize()\n\tm.bumpSensor.BgColors[1] = ui.ColorRed\n\tm.bumpSensor.BgColors[3] = ui.ColorRed\n\tm.bumpSensor.Border = true\n\tm.bumpSensor.Height = 10\n\n\t// Cliff sensors.\n\tm.cliffSensor.Rows = [][]string{\n\t\t[]string{\"Cliff Sensor\", \"Signal\"},\n\t\t[]string{\"Left\", \"1023\"},\n\t\t[]string{\"Left Front\", \"\"},\n\t\t[]string{\"Front Right\", \"\"},\n\t\t[]string{\"Right\", \"\"},\n\t\t[]string{\"Wall\", \"\"},\n\t}\n\tm.cliffSensor.FgColor = ui.ColorWhite\n\tm.cliffSensor.BgColor = ui.ColorDefault\n\tm.cliffSensor.TextAlign = ui.AlignCenter\n\tm.cliffSensor.Separator = false\n\tm.cliffSensor.Analysis()\n\tm.cliffSensor.SetSize()\n\tm.cliffSensor.Border = true\n\tm.cliffSensor.Height = 10\n\n\t// External Sensors.\n\tm.wheelSensor.Rows = [][]string{\n\t\t[]string{\"Wheel Sensor\"},\n\t\t[]string{\"Right Bump\"},\n\t\t[]string{\"Left Bump\"},\n\t\t[]string{\"Right Drop\"},\n\t\t[]string{\"Left Drop\"},\n\t}\n\tm.wheelSensor.FgColor = ui.ColorWhite\n\tm.wheelSensor.BgColor = ui.ColorDefault\n\tm.wheelSensor.TextAlign = ui.AlignCenter\n\tm.wheelSensor.Separator = false\n\tm.wheelSensor.Analysis()\n\tm.wheelSensor.SetSize()\n\tm.wheelSensor.BgColors[1] = ui.ColorRed\n\tm.wheelSensor.BgColors[3] = ui.ColorRed\n\tm.wheelSensor.Border = true\n\tm.wheelSensor.Height = 10\n\n\t// Align widgets.\n\tui.Body.AddRows(\n\t\tui.NewRow(\n\t\t\tui.NewCol(9, 0, m.head),\n\t\t\tui.NewCol(3, 0, m.tmstmp),\n\t\t),\n\t\tui.NewRow(\n\t\t\tui.NewCol(2, 0, m.cmd),\n\t\t\tui.NewCol(3, 0, m.battMeter, m.battState, m.dirtLvl),\n\t\t\tui.NewCol(2, 0, m.modeDisp, m.ocSensor, m.stasis),\n\t\t\tui.NewCol(5, 0, m.battLvl),\n\t\t),\n\t\tui.NewRow(\n\t\t\tui.NewCol(3, 0, m.currSensor),\n\t\t\tui.NewCol(5, 0, m.movSensor),\n\t\t\tui.NewCol(4, 0, m.irCode),\n\t\t),\n\t\tui.NewRow(\n\t\t\tui.NewCol(3, 0, m.cliffSensor),\n\t\t\tui.NewCol(2, 0, m.velSensor),\n\t\t\tui.NewCol(3, 0, m.bumpSensor),\n\t\t\tui.NewCol(2, 0, m.wheelSensor),\n\t\t),\n\t)\n\treturn nil\n}" ]
[ "0.5147057", "0.49287525", "0.4910068", "0.48899913", "0.47973734", "0.47837022", "0.47504675", "0.47305447", "0.47194964", "0.47093368", "0.4672182", "0.4603544", "0.4598562", "0.45500627", "0.4516141", "0.4483894", "0.44713327", "0.44680083", "0.4465377", "0.44537315", "0.4444672", "0.4430538", "0.44287997", "0.44072065", "0.44060063", "0.44053668", "0.44022816", "0.44016522", "0.43933776", "0.43929666", "0.43723294", "0.43611613", "0.4359779", "0.4352526", "0.4349784", "0.43430018", "0.4341714", "0.43343624", "0.43330458", "0.43229407", "0.43197078", "0.4317261", "0.4315805", "0.43149257", "0.4313654", "0.4310823", "0.4310268", "0.43090147", "0.42995003", "0.42966428", "0.429217", "0.4291871", "0.42860544", "0.42728516", "0.42679915", "0.42650265", "0.4259867", "0.4256754", "0.42555922", "0.42542383", "0.4248964", "0.42375875", "0.42287743", "0.42192635", "0.42159423", "0.42109078", "0.42107657", "0.42032644", "0.42023346", "0.41982153", "0.41960195", "0.41936445", "0.41935205", "0.41877863", "0.4179899", "0.41793454", "0.41693318", "0.4168394", "0.41670215", "0.41616538", "0.4160185", "0.41586822", "0.41570345", "0.41566065", "0.4151559", "0.41497698", "0.414398", "0.41425505", "0.4142478", "0.41385928", "0.41360533", "0.4129975", "0.41258445", "0.41254118", "0.41212887", "0.4120134", "0.4120072", "0.41186664", "0.41165456", "0.41152826" ]
0.62397474
0
Retrieves the predefined type of a FMOD registered DSP unit. This is only valid for built in FMOD effects. Any user plugins will simply return "DSP_TYPE_UNKNOWN".
func (d *DSP) Type() (DSPType, error) { var typ C.FMOD_DSP_TYPE res := C.FMOD_DSP_GetType(d.cptr, &typ) return DSPType(typ), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getMetricType(short string) (int, error) {\n\tswitch {\n\tcase \"c\" == short:\n\t\treturn MetricTypeCounter, nil\n\tcase \"g\" == short:\n\t\treturn MetricTypeGauge, nil\n\tcase \"s\" == short:\n\t\treturn MetricTypeSet, nil\n\tcase \"ms\" == short:\n\t\treturn MetricTypeTimer, nil\n\t}\n\treturn MetricTypeUnknown, errors.New(\"unknown metric type\")\n}", "func GetDataType(fourCC [4]byte) ResourceDataType {\n\tvalue := string(fourCC[:])\n\tswitch value {\n\tcase \"NULL\":\n\t\treturn DataNull\n\tcase \"RAWD\":\n\t\treturn DataRaw\n\tcase \"TEXT\":\n\t\treturn DataText\n\tcase \"IMGE\":\n\t\treturn DataImage\n\tcase \"WAVE\":\n\t\treturn DataWave\n\tcase \"VRTX\":\n\t\treturn DataVertex\n\tcase \"FNTG\":\n\t\treturn DataFontGlyphs\n\tcase \"LINK\":\n\t\treturn DataLink\n\tcase \"CDIR\":\n\t\treturn DataDirectory\n\tdefault:\n\t\treturn 0\n\t}\n}", "func GetType(entropyName string) uint32 {\n\tswitch strings.ToUpper(entropyName) {\n\n\tcase \"HUFFMAN\":\n\t\treturn HUFFMAN_TYPE\n\n\tcase \"ANS0\":\n\t\treturn ANS0_TYPE\n\n\tcase \"ANS1\":\n\t\treturn ANS1_TYPE\n\n\tcase \"RANGE\":\n\t\treturn RANGE_TYPE\n\n\tcase \"FPAQ\":\n\t\treturn FPAQ_TYPE\n\n\tcase \"CM\":\n\t\treturn CM_TYPE\n\n\tcase \"TPAQ\":\n\t\treturn TPAQ_TYPE\n\n\tcase \"TPAQX\":\n\t\treturn TPAQX_TYPE\n\n\tcase \"NONE\":\n\t\treturn NONE_TYPE\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unsupported entropy codec type: '%s'\", entropyName))\n\t}\n}", "func (psis PSISensor) TypeString() string {\n return psis.Type\n}", "func (m *Message) DSP() (*DSP, error) {\n\tps, err := m.Parse(\"DSP\")\n\tpst, ok := ps.(*DSP)\n\tif ok {\n\t\treturn pst, err\n\t}\n\treturn nil, err\n}", "func (o *ShowSystem) GetType() string {\n\tif o == nil || IsNil(o.Type) {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Type\n}", "func (o *V0037DiagRpcm) GetTypeId() int32 {\n\tif o == nil || o.TypeId == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.TypeId\n}", "func getDeviceType(r apis.RaidGroup) string {\n\tif r.IsReadCache {\n\t\treturn DeviceTypeReadCache\n\t} else if r.IsSpare {\n\t\treturn DeviceTypeSpare\n\t} else if r.IsWriteCache {\n\t\treturn DeviceTypeWriteCache\n\t}\n\treturn DeviceTypeEmpty\n}", "func (m *WindowsInformationProtectionDeviceRegistration) GetDeviceType()(*string) {\n val, err := m.GetBackingStore().Get(\"deviceType\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func phpType(smdType string) string {\n\tswitch smdType {\n\tcase smd.String:\n\t\treturn phpString\n\tcase smd.Array:\n\t\treturn phpArray\n\tcase smd.Boolean:\n\t\treturn phpBoolean\n\tcase smd.Float:\n\t\treturn phpFloat\n\tcase smd.Integer:\n\t\treturn phpInt\n\tcase smd.Object:\n\t\treturn phpObject\n\t}\n\treturn \"mixed\"\n}", "func (m Chan) TypeString() string {\n\treturn m.String()\n}", "func (script *Script) Type(name string) (Type, bool) {\n\tgslangType, ok := script.types[name]\n\n\treturn gslangType, ok\n}", "func (s Shop) GetShopTypeString() (result string) {\n\treturn shopTypesEnum[s.Type]\n}", "func (s *StringEnum) Type() string { return \"string\" }", "func (inst *InstFMul) Type() types.Type {\n\t// Cache type if not present.\n\tif inst.Typ == nil {\n\t\tinst.Typ = inst.X.Type()\n\t}\n\treturn inst.Typ\n}", "func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input bool) string {\n\t// Remove the union with `undefined` for optional types,\n\t// since we will show that information separately anyway.\n\tif optional, ok := t.(*schema.OptionalType); ok {\n\t\tt = optional.ElementType\n\t}\n\n\tmodCtx := &modContext{\n\t\tpkg: pkg.Reference(),\n\t\tmod: moduleName,\n\t}\n\ttypeName := modCtx.typeString(t, input, nil)\n\n\t// Remove any package qualifiers from the type name.\n\ttypeQualifierPackage := \"inputs\"\n\tif !input {\n\t\ttypeQualifierPackage = \"outputs\"\n\t}\n\ttypeName = strings.ReplaceAll(typeName, typeQualifierPackage+\".\", \"\")\n\ttypeName = strings.ReplaceAll(typeName, \"enums.\", \"\")\n\n\treturn typeName\n}", "func (hfsc *HfscClass) Type() string {\n\treturn \"hfsc\"\n}", "func PureTypeEnumFromValue(value string) PureTypeEnum {\r\n switch value {\r\n case \"kStorageArray\":\r\n return PureType_KSTORAGEARRAY\r\n case \"kVolume\":\r\n return PureType_KVOLUME\r\n default:\r\n return PureType_KSTORAGEARRAY\r\n }\r\n}", "func Get(ext string) Type {\n\tif tmp, ok := Types.Load(ext); ok {\n\t\tkind := tmp.(Type)\n\t\tif kind.Extension != \"\" {\n\t\t\treturn kind\n\t\t}\n\t}\n\treturn Unknown\n}", "func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input bool) string {\n\ttypeDetails := map[*schema.ObjectType]*typeDetails{}\n\tmod := &modContext{\n\t\tpkg: pkg.Reference(),\n\t\tmod: moduleName,\n\t\ttypeDetails: typeDetails,\n\t}\n\ttypeName := mod.typeString(t, input, false /*acceptMapping*/)\n\n\t// Remove any package qualifiers from the type name.\n\tif !input {\n\t\ttypeName = strings.ReplaceAll(typeName, \"outputs.\", \"\")\n\t}\n\n\t// Remove single quote from type names.\n\ttypeName = strings.ReplaceAll(typeName, \"'\", \"\")\n\n\treturn typeName\n}", "func getInstallationType(installationType string) (string, error) {\n\tswitch installationType {\n\tcase installationTypeServer:\n\t\treturn windowsServerFull, nil\n\tcase installationTypeServerCore:\n\t\treturn windowsServerCore, nil\n\tdefault:\n\t\treturn \"\", errors.Errorf(\"unsupported installation type: %s\", installationType)\n\t}\n}", "func PkgTypeEnumFromValue(value string) PkgTypeEnum {\r\n switch value {\r\n case \"kScript\":\r\n return PkgType_KSCRIPT\r\n case \"kRPM\":\r\n return PkgType_KRPM\r\n case \"kSuseRPM\":\r\n return PkgType_KSUSERPM\r\n case \"kDEB\":\r\n return PkgType_KDEB\r\n default:\r\n return PkgType_KSCRIPT\r\n }\r\n}", "func GetType(args []string) (Type, string) {\n\tif len(args) == 1 {\n\t\treturn Hotseat, \"\"\n\t}\n\n\tswitch args[1] {\n\tcase \"hotseat\", \"\":\n\t\treturn Hotseat, \"\"\n\tcase \"server\":\n\t\treturn Server, \"\"\n\tcase \"client\":\n\t\tif len(args) < 3 {\n\t\t\treturn Unknown, \"\"\n\t\t}\n\n\t\treturn Client, args[2]\n\tdefault:\n\t\treturn Unknown, \"\"\n\t}\n}", "func (Phosphorus) GetCategory() string {\n\tvar c categoryType = nonMetal\n\treturn c.get()\n}", "func getGqlType(t reflect.Type, typeMap TypeMap) graphql.Output {\n\tm, exists := typeMap[t]\n\tif exists {\n\t\treturn m.Output\n\t}\n\t// no predefined output in the map\n\treturn nil\n}", "func (UDim) Type() string {\n\treturn \"UDim\"\n}", "func (d *Device) MfrsDeviceType() byte { return d.DevType }", "func UsageTypeEnumFromValue(value string) UsageTypeEnum {\r\n switch value {\r\n case \"kArchival\":\r\n return UsageType_KARCHIVAL\r\n case \"kCloudSpill\":\r\n return UsageType_KCLOUDSPILL\r\n default:\r\n return UsageType_KARCHIVAL\r\n }\r\n}", "func (*StorageFileMp3) TypeID() uint32 {\n\treturn StorageFileMp3TypeID\n}", "func getMetricTypeAsString(metric telegraf.Metric) (metricType string, err error) {\n\tswitch metric.Type() {\n\tcase telegraf.Counter:\n\t\tmetricType = \"counter\"\n\tcase telegraf.Gauge:\n\t\tmetricType = \"gauge\"\n\tcase telegraf.Summary:\n\t\tmetricType = \"summary\"\n\t\terr = fmt.Errorf(\"summary metrics will be sent as gauges\")\n\tcase telegraf.Histogram:\n\t\tmetricType = \"histogram\"\n\t\terr = fmt.Errorf(\"histogram metrics will be sent as gauges\")\n\tcase telegraf.Untyped:\n\t\tmetricType = \"untyped\"\n\t\terr = fmt.Errorf(\"untyped metrics will be sent as gauges\")\n\tdefault:\n\t\tmetricType = \"unrecognized\"\n\t\terr = fmt.Errorf(\"unrecognized metric type defaulting to gauge\")\n\t}\n\treturn metricType, err\n}", "func (f *FakeOutput) Type() string { return \"fake_output\" }", "func generateMMType() string {\n\trnd := generateNumber(1, 2)\n\ttypes, err := readNameFile(\"./data/massivemonsters/type0\" + strconv.Itoa(rnd) + \".names\")\n\tif err != nil {\n\t\tlog.Fatalf(\"readLines: %s\", err)\n\t}\n\n\trnd2 := generateNumber(1, 2)\n\tforms, err := readNameFile(\"./data/massivemonsters/form0\" + strconv.Itoa(rnd2) + \".names\")\n\tif err != nil {\n\t\tlog.Fatalf(\"readLines: %s\", err)\n\t}\n\n\treturn types[generateNumber(0, len(types)-1)] + \" \" + forms[generateNumber(0, len(forms)-1)]\n}", "func (*MessageFileTypeUnknown) TypeID() uint32 {\n\treturn MessageFileTypeUnknownTypeID\n}", "func GetType(schemaID *facet.SchemaID) string {\n\n\tif schemaID.Namespace == \"pd\" {\n\t\tswitch schemaID.Name {\n\t\tcase \"host\", \"vm\", \"cloudResource\", \"computeHost\", \"discovery\":\n\t\t\treturn fmt.Sprintf(\"%s_host\", schemaID.Namespace)\n\t\t}\n\t} else {\n\t\t// some special cases. Longer term we should update the facets, to\n\t\t// provide this info.\n\t\tswitch schemaID.Name {\n\t\tcase \"computeInstance\":\n\t\t\treturn \"pd_host\"\n\t\t}\n\t}\n\n\treturn strings.Join([]string{schemaID.Namespace, schemaID.Name}, \"_\")\n}", "func (t DataType) TypeName() string { return typeNames[t] }", "func (*StorageFileUnknown) TypeID() uint32 {\n\treturn StorageFileUnknownTypeID\n}", "func (*InputInlineQueryResultAudio) TypeID() uint32 {\n\treturn InputInlineQueryResultAudioTypeID\n}", "func (*StringSetting) Typ() string {\n\treturn \"s\"\n}", "func (f *receiverFactory) Type() string {\n\treturn typeStr\n}", "func (m *sdt) Type() string {\n\treturn \"SDT\"\n}", "func (m *Device) GetType() (val string, set bool) {\n\tif m.Type == nil {\n\t\treturn\n\t}\n\n\treturn *m.Type, true\n}", "func (r *Riddler) Type() string {\n\treturn r.SourceType\n}", "func getRegistryType(fullType string) *registry.Type {\n\ttList := strings.Split(fullType, \":\")\n\tif len(tList) != 2 {\n\t\treturn nil\n\t}\n\n\treturn &registry.Type{\n\t\tName: tList[0],\n\t\tVersion: tList[1],\n\t}\n}", "func (pstFile *File) GetFormatType() (string, error) {\n\tformatType, err := pstFile.Read(2, 10)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tswitch binary.LittleEndian.Uint16(formatType) {\n\tcase 14:\n\t\treturn FormatTypeANSI, nil\n\tcase 15:\n\t\treturn FormatTypeANSI, nil\n\tcase 21:\n\t\treturn FormatTypeUnicode, nil\n\tcase 23:\n\t\treturn FormatTypeUnicode, nil\n\tcase 36:\n\t\treturn FormatTypeUnicode4k, nil\n\tdefault:\n\t\treturn \"\", errors.New(\"unsupported format type\")\n\t}\n}", "func (o *Ga4ghTumourboard) GetSomaticSampleType() string {\n\tif o == nil || o.SomaticSampleType == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.SomaticSampleType\n}", "func (a *AudioSampleEntryBox) Type() string {\n\treturn a.name\n}", "func (msf *ModuleSetFlag) Type() string {\n\treturn \"Modules Set Flag\"\n}", "func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string, err error) {\n\treturn client.GetModulationTypeCtx(context.Background())\n}", "func (m *Device) GetKind() (val string, set bool) {\n\tif m.Kind == nil {\n\t\treturn\n\t}\n\n\treturn *m.Kind, true\n}", "func (self *Rain) Type() string {\n\treturn rainTypes[self.typeId]\n}", "func (*SpeechRecognitionResultPending) TypeID() uint32 {\n\treturn SpeechRecognitionResultPendingTypeID\n}", "func (n Named) TypeString() string {\n\treturn n.String()\n}", "func (t systemIntType) String() string {\n\treturn \"SYSTEM_INT\"\n}", "func (i ID) Type() string {\n\tstuff := strings.Split(i.String(), \"/\")\n\treturn stuff[0]\n}", "func (st SampleType) Mime() string {\n\tswitch st {\n\tcase S16LE:\n\t\treturn \"l16\"\n\tdefault:\n\t\tpanic(\"Invalid SampleType\")\n\t}\n}", "func StorageTypeFromString(in string) StorageType {\n\tin = strings.ToLower(in)\n\tin = strings.TrimSpace(in)\n\n\tswitch in {\n\tcase \"\":\n\t\treturn StorageBolt\n\tcase \"memory\":\n\t\treturn StorageMemory\n\tcase \"bolt\":\n\t\treturn StorageBolt\n\tcase \"mysql\":\n\t\treturn StorageMysql\n\tcase \"filesystem\":\n\t\treturn StorageFilesystem\n\t}\n\n\treturn StorageInvalid\n}", "func (c *Context) GetTunerType() (rtlsdr_tuner int) {\n\treturn int(C.rtlsdr_get_tuner_type((*C.rtlsdr_dev_t)(c.dev)))\n}", "func (o *EquipmentBaseSensor) GetType() string {\n\tif o == nil || o.Type == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Type\n}", "func (*UpdateShortSentMessage) TypeID() uint32 {\n\treturn UpdateShortSentMessageTypeID\n}", "func (t systemIntType) String() string {\n\treturn \"system_int\"\n}", "func (o MfaPingidOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *MfaPingid) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)\n}", "func (vl StringValue) GetType() int {\n\treturn ParticleType.STRING\n}", "func (vl StringValue) GetType() int {\n\treturn ParticleType.STRING\n}", "func (o GuestOsFeatureResponseOutput) Type() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GuestOsFeatureResponse) string { return v.Type }).(pulumi.StringOutput)\n}", "func (client *XenClient) SMGetType(self string) (result string, err error) {\n\tobj, err := client.APICall(\"SM.get_type\", self)\n\tif err != nil {\n\t\treturn\n\t}\n\tresult = obj.(string)\n\treturn\n}", "func GetType(name string) (Type, bool) {\n\tt, f := typesByName[name]\n\treturn t, f\n}", "func (o *Handoff) GetHandoffType() (value string, ok bool) {\n\tok = o != nil && o.bitmap_&128 != 0\n\tif ok {\n\t\tvalue = o.handoffType\n\t}\n\treturn\n}", "func DefaultUnitType(name string) string {\n\treturn fmt.Sprintf(\"%s.service\", name)\n}", "func (*CallbackQueryPayloadGame) TypeID() uint32 {\n\treturn CallbackQueryPayloadGameTypeID\n}", "func (*SpeechRecognitionResultError) TypeID() uint32 {\n\treturn SpeechRecognitionResultErrorTypeID\n}", "func (ft FieldType) String() string {\n\tswitch ft {\n\tcase WorkFlowID:\n\t\treturn \"workflowId\"\n\tcase ExecutionID:\n\t\treturn \"executionId\"\n\tcase NodeID:\n\t\treturn \"nodeId\"\n\tcase InstanceID:\n\t\treturn \"instanceId\"\n\tcase InterfaceName:\n\t\treturn \"interfaceName\"\n\tcase OperationName:\n\t\treturn \"operationName\"\n\tcase TypeID:\n\t\treturn \"type\"\n\t}\n\treturn \"\"\n}", "func (d *Demo) Type() string {\n\tif d.ServerName() == \"localhost\" || len(strings.Split(d.ServerName(), \":\")) == 2 {\n\t\treturn \"POV\"\n\t}\n\treturn \"STV\"\n}", "func (*StorageFileMp4) TypeID() uint32 {\n\treturn StorageFileMp4TypeID\n}", "func fidlTypeString(t fidlgen.Type) string {\n\tn := nullableToString(t.Nullable)\n\tswitch t.Kind {\n\tcase fidlgen.PrimitiveType:\n\t\treturn string(t.PrimitiveSubtype)\n\tcase fidlgen.StringType:\n\t\treturn fmt.Sprintf(\"%s%s%s\",\n\t\t\tt.Kind, elementCountToString(t.ElementCount), n)\n\tcase fidlgen.ArrayType, fidlgen.VectorType:\n\t\treturn fidlNestedToString(t)\n\tcase fidlgen.HandleType:\n\t\tswitch t.HandleSubtype {\n\t\tcase fidlgen.Handle:\n\t\t\treturn fmt.Sprintf(\"handle%v\", n)\n\t\tdefault:\n\t\t\treturn fmt.Sprintf(\n\t\t\t\t\"zx/handle:zx/obj_type.%v%v\", strings.ToUpper(string(t.HandleSubtype)), n)\n\t\t}\n\tcase fidlgen.IdentifierType:\n\t\treturn fmt.Sprintf(\"%v%v\", string(t.Identifier), n)\n\tcase fidlgen.RequestType:\n\t\treturn fmt.Sprintf(\"request<%v>%v\", string(t.RequestSubtype), n)\n\tdefault:\n\t\treturn \"<not implemented>\"\n\t}\n}", "func (vl FloatValue) GetType() int {\n\treturn ParticleType.FLOAT\n}", "func (vl FloatValue) GetType() int {\n\treturn ParticleType.FLOAT\n}", "func (Sodium) GetCategory() string {\n\tvar c categoryType = alkaliMetal\n\treturn c.get()\n}", "func GetMeasureType(line string) (measuretype string, err error) {\n\tfor k, v := range measurevartypes {\n\t\tif strings.Contains(line, k) {\n\t\t\tmeasuretype, err = v, nil\n\t\t}\n\t}\n\treturn measuretype, err\n}", "func (this *ClockStr) Type() value.Type { return value.STRING }", "func GetInputType(inputType InputType) string {\n\tvar typeString string\n\tswitch inputType {\n\tcase InputNone:\n\t\ttypeString = \"Input None\"\n\tcase Legacy:\n\t\ttypeString = \"Legacy\"\n\tcase Compatibility:\n\t\ttypeString = \"Compatibility\"\n\tcase Witness:\n\t\ttypeString = \"Witness\"\n\t}\n\treturn typeString\n}", "func (t *BaseType) TypeString() string { panic(\"not implemented\") }", "func BloodTypeOf(id uint16, def *BloodType) *BloodType {\n\tif bloodType, ok := bloodMap[id]; ok {\n\t\treturn bloodType\n\t}\n\tif def == nil {\n\t\treturn BL_Unknown\n\t}\n\treturn def\n}", "func (sys *Sys) GetOsStrByType(iType int) string {\n\tlog.Debugln(\"GetOsStrByType ENTER\")\n\n\tosStr := \"Unknown\"\n\tswitch iType {\n\tcase OsRhel:\n\t\tosStr = \"RHEL\"\n\tcase OsSuse:\n\t\tosStr = \"SUSE\"\n\tcase OsUbuntu:\n\t\tosStr = \"Ubuntu\"\n\tcase OsCoreOs:\n\t\tosStr = \"CoreOS\"\n\tcase OsMac:\n\t\tosStr = \"OSX\"\n\t}\n\n\tlog.Debugln(\"GetOsStrByType =\", osStr)\n\tlog.Debugln(\"GetOsStrByType LEAVE\")\n\treturn osStr\n}", "func (o *SoftwarerepositoryCategoryMapper) GetFileType() string {\n\tif o == nil || o.FileType == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.FileType\n}", "func (c *Sound) GetFormat() int {\n\treturn c.Format\n}", "func (s *Device) GetType() DeviceType {\n\tif s == nil {\n\t\treturn \"\"\n\t}\n\treturn s.Type\n}", "func (this *NowStr) Type() value.Type { return value.STRING }", "func (o *Ga4ghChemotherapy) GetType() string {\n\tif o == nil || o.Type == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Type\n}", "func (m *MdiaBox) Type() string {\n\treturn \"mdia\"\n}", "func (d Device) Type() string {\n\treturn \"device\"\n}", "func (d DUIDEN) DUIDType() DUIDType {\n\treturn DUID_EN\n}", "func (*GetLanguagePackStringRequest) TypeName() string {\n\treturn \"getLanguagePackString\"\n}", "func (vl WildCardValue) GetType() int {\n\tpanic(\"Invalid particle type: WildCard\")\n}", "func GetName(entropyType uint32) string {\n\tswitch entropyType {\n\n\tcase HUFFMAN_TYPE:\n\t\treturn \"HUFFMAN\"\n\n\tcase ANS0_TYPE:\n\t\treturn \"ANS0\"\n\n\tcase ANS1_TYPE:\n\t\treturn \"ANS1\"\n\n\tcase RANGE_TYPE:\n\t\treturn \"RANGE\"\n\n\tcase FPAQ_TYPE:\n\t\treturn \"FPAQ\"\n\n\tcase CM_TYPE:\n\t\treturn \"CM\"\n\n\tcase TPAQ_TYPE:\n\t\treturn \"TPAQ\"\n\n\tcase TPAQX_TYPE:\n\t\treturn \"TPAQX\"\n\n\tcase NONE_TYPE:\n\t\treturn \"NONE\"\n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unsupported entropy codec type: '%c'\", entropyType))\n\t}\n}", "func GetTypeOf(input interface{}) string {\n\tswitch input.(type) {\n\tcase int:\n\t\treturn \"int\"\n\tcase string:\n\t\treturn \"string\"\n\tdefault:\n\t\treturn \"unknown\"\n\t}\n}", "func (b *baseSysInit) Type() string {\n\treturn b.sysInitType\n}", "func (e Timing) TypeString() string {\n\treturn \"Timing\"\n}", "func (m NameTypeMap) GetType(name string) (enumspb.IndexedValueType, error) {\n\treturn m.getType(name, systemCategory|predefinedCategory|customCategory)\n}", "func (o StorageSettingOutput) Type() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v StorageSetting) *string { return v.Type }).(pulumi.StringPtrOutput)\n}", "func (mh *MessageHandler) Type() MessageHandlerType {\n\tret := C.EnvGetDefmessageHandlerType(mh.class.env.env, mh.class.clptr, mh.index)\n\treturn MessageHandlerType(C.GoString(ret))\n}" ]
[ "0.5548259", "0.5395189", "0.5375581", "0.53314674", "0.5309829", "0.5291026", "0.5245516", "0.52000815", "0.5149595", "0.5131474", "0.51293916", "0.5127297", "0.5116281", "0.509483", "0.50922245", "0.5064179", "0.5018902", "0.5002624", "0.49894", "0.49836275", "0.4964918", "0.49648696", "0.49646097", "0.49277812", "0.49139395", "0.49087608", "0.48771262", "0.4872562", "0.485307", "0.48355985", "0.48319367", "0.48266253", "0.48127955", "0.4809532", "0.48049578", "0.48015213", "0.47937655", "0.47894102", "0.4785967", "0.477313", "0.477213", "0.4770865", "0.47644585", "0.47576344", "0.47524947", "0.47463587", "0.47433373", "0.4742369", "0.47237465", "0.47227964", "0.47191453", "0.4714874", "0.47120535", "0.47111356", "0.4708868", "0.47048628", "0.47003853", "0.4696917", "0.4693759", "0.46932286", "0.46916065", "0.4689973", "0.4689973", "0.4684773", "0.46825948", "0.46798918", "0.4677178", "0.46769595", "0.46764478", "0.46756428", "0.46699744", "0.4668437", "0.4666649", "0.46664387", "0.46593344", "0.46593344", "0.46504745", "0.4646984", "0.4642932", "0.46402022", "0.46371493", "0.4635148", "0.4630065", "0.46288204", "0.46265864", "0.46259302", "0.46215197", "0.46194342", "0.4618686", "0.4610827", "0.46029553", "0.45990974", "0.45937786", "0.45929602", "0.45915362", "0.4591261", "0.45893052", "0.4585126", "0.45800287", "0.45782694" ]
0.67880154
0
Retrieves the idle state of a DSP. A DSP is idle when no signal is coming into it. This can be a useful method of determining if a DSP sub branch is finished processing, so it can be disconnected for example. The idle state takes into account things like tails of echo filters, even if a wavetable or dsp has finished generating sound. When all nodes in a graph have finished processing, only then will it set the top level DSP state to idle.
func (d *DSP) Idle() (bool, error) { var idle C.FMOD_BOOL res := C.FMOD_DSP_GetIdle(d.cptr, &idle) return setBool(idle), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func idle() State_t {\n\t\n}", "func (pool *Pool) Idle() int {\n\treturn int(atomic.LoadInt32(&pool.numIdle))\n}", "func (cp *Pool) IdleClosed() int64 {\n\tp := cp.pool()\n\tif p == nil {\n\t\treturn 0\n\t}\n\treturn p.IdleClosed()\n}", "func (s *Stream) idleTick() {\n\tif len(s.workCh) == 0 && s.sessST.CAS(active, inactive) {\n\t\ts.workCh <- &Obj{Hdr: ObjHdr{Opcode: opcIdleTick}}\n\t\tif verbose {\n\t\t\tnlog.Infof(\"%s: active => inactive\", s)\n\t\t}\n\t}\n}", "func (c *Client) Idle() (err error) {\n\ttag, err := c.prepareCmd(\"IDLE\")\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer c.cleanCmd()\n\n\terr = c.writeString(tag + \" IDLE\\r\\n\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tc.doneEmitted = false\n\tc.idling = true\n\tdefer func() {\n\t\tc.idling = false\n\t\tc.doneEmitted = false\n\t}()\n\n\trep := <-c.rep\n\tif rep == nil {\n\t\terr = ErrNilRep\n\t\treturn\n\t}\n\tif rep.err != nil {\n\t\terr = rep.err\n\t\treturn\n\t}\n\treturn\n}", "func (r *Radio) State() string {\n\treturn \"idle\"\n}", "func (p *Pool) Idle() int {\n\treturn len(p.ch)\n}", "func assessidle() {\n\tlog.Printf(\"Launching %v for idle state resource usage assessment\", icmd.Path)\n\tlog.Println(\"Trying to determine idle state resource usage (no external traffic)\")\n\ticmd.Run()\n\tf := Findings{}\n\tif icmd.ProcessState != nil {\n\t\tf.MemoryMaxRSS = int64(icmd.ProcessState.SysUsage().(*syscall.Rusage).Maxrss)\n\t\tf.CPUuser = int64(icmd.ProcessState.SysUsage().(*syscall.Rusage).Utime.Usec)\n\t\tf.CPUsys = int64(icmd.ProcessState.SysUsage().(*syscall.Rusage).Stime.Usec)\n\t}\n\tidlef <- f\n}", "func (c *cpuMonitor) idle() (float32, error) {\n\tcmd := exec.Command(\"top\", \"-b\", \"-n\", \"3\", \"-d\", \"3\")\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\tstr := string(out)\n\tlines := strings.Split(str, \"\\n\")\n\tvar cpuline string\n\tfor _, line := range lines {\n\t\tif strings.Contains(line, \"Cpu\") {\n\t\t\tcpuline = line\n\t\t}\n\t}\n\tvar cpu string\n\titems := strings.Split(cpuline, \" \")\n\tfor i, item := range items {\n\t\tif item == \"id,\" && i > 0 {\n\t\t\tcpu = items[i-1]\n\t\t}\n\t}\n\tvar v float32\n\tif n, err := fmt.Sscanf(cpu, \"%f\", &v); n != 1 || err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to parse\")\n\t}\n\treturn v, nil\n}", "func (c *Client) Idle() (bool, error) {\n\treturn c.GetBoolProperty(\"idle\")\n}", "func NewIdle() *Idle {\n\treturn &Idle{}\n}", "func (u *VectorMemoryUnit) IsIdle() bool {\n\tu.isIdle = (u.numInstInFlight == 0) && (u.numTransactionInFlight == 0)\n\treturn u.isIdle\n}", "func (d *DFA) Initial() State {\n\treturn d.initial\n}", "func (cs *ConnectivityState) SetStateIdle() {\n\tcs.SetState(\"idle\")\n}", "func (c *ConnExt) Idle() bool {\n\tif time.Since(c.LastActivity) > c.Config.IdleThresholdSec {\n\t\treturn true\n\t}\n\treturn false\n}", "func (r *RollDPoS) CurrentState() fsm.State {\n\treturn r.cfsm.CurrentState()\n}", "func (cp *Pool) IdleTimeout() time.Duration {\n\tp := cp.pool()\n\tif p == nil {\n\t\treturn 0\n\t}\n\treturn p.IdleTimeout()\n}", "func (m *InMemory) Current() (qaclana.State, error) {\n\treturn m.s, nil\n}", "func (o *V0037Node) GetIdleCpus() int64 {\n\tif o == nil || o.IdleCpus == nil {\n\t\tvar ret int64\n\t\treturn ret\n\t}\n\treturn *o.IdleCpus\n}", "func (sm *State52) CurrentState() string {\n\tsm.stateMutex.RLock()\n\tdefer sm.stateMutex.RUnlock()\n\treturn sm.currentState\n}", "func (machine *Machine) Current() StateType {\n\tmachine.lock.Lock()\n\tdefer machine.lock.Unlock()\n\treturn machine.current\n}", "func (pool *SessionPool) getSessionFromIdle() (*pureSession, error) {\n\tpool.rwLock.Lock()\n\tdefer pool.rwLock.Unlock()\n\t// Get a session from the idle queue if possible\n\tif pool.idleSessions.Len() > 0 {\n\t\tsession := pool.idleSessions.Front().Value.(*pureSession)\n\t\tpool.idleSessions.Remove(pool.idleSessions.Front())\n\t\treturn session, nil\n\t} else if pool.activeSessions.Len() < pool.conf.maxSize {\n\t\treturn nil, nil\n\t}\n\t// There is no available session in the pool and the total session count has reached the limit\n\treturn nil, fmt.Errorf(\"failed to get session: no session available in the\" +\n\t\t\" session pool and the total session count has reached the limit\")\n}", "func (s *Servo) isIdle() bool {\n\ts.lock.RLock()\n\tdefer s.lock.RUnlock()\n\n\treturn s.idle\n}", "func (state *StateMachine) Current() int {\n\treturn state.State.Value\n}", "func idleAdd(context *MainContext, f func() bool) (SourceHandle, error) {\n\tc := C.g_idle_source_new()\n\tif c == nil {\n\t\treturn 0, nilPtrErr\n\t}\n\tvar ctx *C.GMainContext = nil\n\tif context != nil {\n\t\tctx = (*C.GMainContext)(context.ptr)\n\t}\n\tvar closure *C.GClosure\n\tclosure = ClosureNew(func() bool {\n\t\tok := f()\n\t\tif !ok {\n\t\t\tC.g_closure_invalidate(closure)\n\t\t}\n\t\treturn ok\n\t})\n\tC.g_source_set_closure(c, closure)\n\tcid := C.g_source_attach(c, ctx)\n\treturn SourceHandle(cid), nil\n}", "func IdleAdd(f func() bool) (SourceHandle, error) {\n\treturn idleAdd(nil, f)\n}", "func (f *Idle) GetIdleTime() int {\n\tif f == nil {\n\t\treturn 0\n\t}\n\treturn f.getIdleTime()\n}", "func (cp *Pool) Active() int64 {\n\tp := cp.pool()\n\tif p == nil {\n\t\treturn 0\n\t}\n\treturn p.Active()\n}", "func (s *Stat) IdleConns() int32 {\n\treturn s.s.IdleResources()\n}", "func (vol *VolumeInfoSimple) IsIdle() bool {\n\treturn vol.Status == proto.VolumeStatusIdle\n}", "func (g *GoPool) Active() int64 {\n\treturn atomic.LoadInt64(&g.activeRoutines)\n}", "func IdleTime(idleTime time.Duration) PoolOption {\n\tif idleTime <= 0 {\n\t\tpanic(\"idle time should always be positive\")\n\t}\n\treturn func(p *GoroutinePool) {\n\t\tp.idle = idleTime\n\t}\n}", "func (cs *ConnectivityState) GetCurrentState() int64 {\n\treturn cs.state\n}", "func (m *AccessPackageAssignment) GetState()(*AccessPackageAssignmentState) {\n return m.state\n}", "func (c *Context) State() *iavl.MutableTree {\n\tif c.IsCheckOnly() {\n\t\treturn c.state.CheckTxTree()\n\t}\n\treturn c.state.DeliverTxTree()\n}", "func (d *mlDelegate) LocalState(bool) []byte { return nil }", "func (evpool *EvidencePool) State() State {\n\tevpool.mtx.Lock()\n\tdefer evpool.mtx.Unlock()\n\treturn evpool.state\n}", "func GetCurrentState() {\n\n}", "func (o ListenerOutput) IdleTimeout() pulumi.IntOutput {\n\treturn o.ApplyT(func(v *Listener) pulumi.IntOutput { return v.IdleTimeout }).(pulumi.IntOutput)\n}", "func (m *Machine) State() State {\n\treturn m.currentState\n}", "func NewIdlePool(size int) *IdlePool {\n\treturn &IdlePool{\n\t\telems: make([]io.Closer, size),\n\t\ttimes: make([]time.Time, size),\n\t}\n}", "func (p *Pool) Active() int {\n\treturn int(atomic.LoadInt64(&p.active))\n}", "func (c *Config) GetIdleAfter() int {\n\treturn c.IdleAfter\n}", "func (s *stateMachine) State() (*State, time.Time) {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn s.state, s.ts\n}", "func (ctn *Connection) isIdle() bool {\n\treturn ctn.idleTimeout > 0 && time.Now().After(ctn.idleDeadline)\n}", "func (ctn *Connection) isIdle() bool {\n\treturn ctn.idleTimeout > 0 && time.Now().After(ctn.idleDeadline)\n}", "func (i *idlenessManagerImpl) exitIdleMode() error {\n\ti.idleMu.Lock()\n\tdefer i.idleMu.Unlock()\n\n\tif !i.actuallyIdle {\n\t\t// This can happen in two scenarios:\n\t\t// - handleIdleTimeout() set the calls count to -math.MaxInt32 and called\n\t\t// tryEnterIdleMode(). But before the latter could grab the lock, an RPC\n\t\t// came in and onCallBegin() noticed that the calls count is negative.\n\t\t// - Channel is in idle mode, and multiple new RPCs come in at the same\n\t\t// time, all of them notice a negative calls count in onCallBegin and get\n\t\t// here. The first one to get the lock would got the channel to exit idle.\n\t\t//\n\t\t// Either way, nothing to do here.\n\t\treturn nil\n\t}\n\n\tif err := i.enforcer.exitIdleMode(); err != nil {\n\t\treturn fmt.Errorf(\"channel failed to exit idle mode: %v\", err)\n\t}\n\n\t// Undo the idle entry process. This also respects any new RPC attempts.\n\tatomic.AddInt32(&i.activeCallsCount, math.MaxInt32)\n\ti.actuallyIdle = false\n\n\t// Start a new timer to fire after the configured idle timeout.\n\ti.timer = timeAfterFunc(time.Duration(i.timeout), i.handleIdleTimeout)\n\treturn nil\n}", "func (t *SignalingState) Get() SignalingState {\n\treturn SignalingState(atomic.LoadInt32((*int32)(t)))\n}", "func (*OpenconfigSystem_System_Cpus_Cpu_State_Idle) IsYANGGoStruct() {}", "func (c *connection) state_active(pc net.PacketConn, tq *timerQueue, cd *connectionData) connectionState {\n\n\tvar (\n\t\tincoming, outgoing []Packet\n\t\tprevTimeout time.Time\n\t\treadTimeout = timer{\n\t\t\tCond: &c.Cond,\n\t\t}\n\t)\n\n\tfor {\n\t\t// wait for something to do\n\t\tc.L.Lock()\n\t\tfor c.shouldWaitOnCV(tq, cd) && !c.closeCalled && c.readData.timeout.Equal(prevTimeout) {\n\t\t\tc.Wait()\n\t\t}\n\t\tnewTimeout := c.readData.timeout\n\t\tcloseCalled := c.closeCalled\n\t\tincoming = append(incoming, c.Incoming...)\n\t\toutgoing = append(outgoing, c.Outgoing...)\n\t\tc.Incoming, c.Outgoing = c.Incoming[:0], c.Outgoing[:0]\n\n\t\t// did the read operation timeout?\n\t\treadTimedout := c.locked_readOperationTimedOut(tq, cd)\n\t\tif readTimedout {\n\t\t\tif c.ReadErr == nil {\n\t\t\t\tc.ReadErr = ErrReadTimeout\n\t\t\t}\n\n\t\t\treadTimedout = c.readData.p != nil // need an unblock?\n\t\t\tc.readData.p = nil\n\t\t\tc.readData.timeout = time.Time{}\n\t\t}\n\n\t\tc.L.Unlock()\n\n\t\t// need to unblock a timedout Read?\n\t\tif readTimedout {\n\t\t\ttq.StopTimer(&readTimeout)\n\t\t\tc.readData.Done()\n\t\t}\n\n\t\t// Start new read timeout\n\t\tif !newTimeout.Equal(prevTimeout) {\n\t\t\tprevTimeout = newTimeout\n\t\t\ttq.StopTimer(&readTimeout)\n\t\t\tif !newTimeout.IsZero() {\n\t\t\t\td := newTimeout.Sub(tq.Now())\n\t\t\t\tif d > 0 {\n\t\t\t\t\ttq.StartTimer(&readTimeout, d)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// process client data and release packets\n\t\terr := cd.Process(pc, c.addr, tq, incoming, outgoing)\n\t\tfor _, p := range incoming {\n\t\t\tp.Free()\n\t\t}\n\t\tfor _, p := range outgoing {\n\t\t\tp.Free()\n\t\t}\n\t\tincoming, outgoing = incoming[:0], outgoing[:0]\n\n\t\t// process any failures\n\t\tif err != nil {\n\t\t\tc.L.Lock()\n\t\t\tc.ReadErr = err\n\t\t\tc.WriteErr = err\n\t\t\tc.L.Unlock()\n\t\t\treturn connectionAbort\n\t\t}\n\n\t\t// deliver any application data\n\t\tc.deliverApplicationData(cd)\n\n\t\t// it's an error to receive a SHUTDOWN-ACK packet here\n\t\tif cd.ReceivedShutdownAck {\n\t\t\tc.L.Lock()\n\t\t\tc.ReadErr = ProtocolPacketError{Type: PacketShutdownAck}\n\t\t\tc.WriteErr = c.ReadErr\n\t\t\tc.L.Unlock()\n\t\t\treturn connectionAbort\n\t\t}\n\n\t\t// received a Close() notification\n\t\tif closeCalled {\n\t\t\treturn connectionShutdownPending\n\t\t}\n\n\t\tif cd.ReceivedShutdown {\n\t\t\treturn connectionShutdownReceived\n\t\t}\n\t}\n}", "func (c current) Active() prometheus.Gauge {\n\treturn c.active\n}", "func (machine *Machine) UnsafeCurrent() StateType {\n\treturn machine.current\n}", "func (d *Device) WaitIdle() error {\n\treturn vk.Error(vk.DeviceWaitIdle(d.VKDevice))\n}", "func (o GetListenersListenerOutput) IdleTimeout() pulumi.IntOutput {\n\treturn o.ApplyT(func(v GetListenersListener) int { return v.IdleTimeout }).(pulumi.IntOutput)\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (s *SketchLimiter) State() LoadState {\n\ts.m.RLock()\n\tdefer s.m.RUnlock()\n\treturn s.current\n}", "func (t *OpenconfigSystem_System_Cpus_Cpu_State_Idle) Validate(opts ...ygot.ValidationOption) error {\n\tif err := ytypes.Validate(SchemaTree[\"OpenconfigSystem_System_Cpus_Cpu_State_Idle\"], t, opts...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (sp *SerialPort) closeIdle() {\n\tif sp.IdleTimeout <= 0 {\n\t\treturn\n\t}\n\tidle := time.Now().Sub(sp.lastActivity)\n\tif idle >= sp.IdleTimeout {\n\t\tsp.Logger.Errorf(\"serial: closing connection due to idle timeout: %v\", idle)\n\t\tsp.close()\n\t}\n}", "func (o *V0037Node) GetIdleCpusOk() (*int64, bool) {\n\tif o == nil || o.IdleCpus == nil {\n\t\treturn nil, false\n\t}\n\treturn o.IdleCpus, true\n}", "func (o *V0037Node) HasIdleCpus() bool {\n\tif o != nil && o.IdleCpus != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (as *AllState) BlankState() {\n\tas.Status = NotInit\n\tas.Breaks = []*Break{{}}\n\tas.Threads = []*Thread{{}}\n\tas.Tasks = []*Task{{}}\n\tas.Stack = []*Frame{{}}\n\tas.Vars = []*Variable{{}}\n\tas.GlobalVars = []*Variable{{}}\n\tas.FindFrames = []*Frame{{}}\n}", "func (g *Gameboi) GetState() string {\n\treturn fmt.Sprintf(\"Acc: %d Ptr: %d Instr: %#v\\n\", g.acc, g.instrPointer, g.program[g.instrPointer])\n}", "func (self *stateRestIterator) Current() (*types.State, error) {\n\terr := self.checkCurrent()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata := self.getCurrent().(*types.State)\n\treturn data, nil\n}", "func (b Bot) CurrentState() RobotState {\n\tb.mu.Lock()\n\tdefer b.mu.Unlock()\n\tlog.Println(b.state)\n\treturn b.state\n}", "func (e HybridKFEstimate) State() *mat64.Vector {\n\treturn e.state\n}", "func (t Fixed) Idle() bool {\n\treturn len(t) == cap(t)\n}", "func (a *MobileNetState) State() keybase1.MobileNetworkState {\n\ta.Lock()\n\tdefer a.Unlock()\n\treturn a.state\n}", "func (m *PulseManager) Current() (*core.Pulse, error) {\n\tpulseNum := m.db.GetCurrentPulse()\n\tentropy, err := m.db.GetEntropy(pulseNum)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpulse := core.Pulse{\n\t\tPulseNumber: pulseNum,\n\t\tEntropy: *entropy,\n\t}\n\treturn &pulse, nil\n}", "func (r *Network) Internal() pulumi.BoolOutput {\n\treturn (pulumi.BoolOutput)(r.s.State[\"internal\"])\n}", "func (p *Processus) Active(body string) (interface{}, int, error) {\n\treturn p.engine.Active(), -1, nil\n}", "func (f *Machine) State() uint8 {\n\treturn f.state\n}", "func (se *StateEngine) State() States {\n\tco := se.curr\n\n\tif co == nil {\n\t\t// return se.owner\n\t\treturn nil\n\t}\n\n\treturn co.Engine().State()\n}", "func (n *Node) GetState() ginterface.INodeState {\n\treturn n.State\n}", "func (model *Model) get_uninitialized_state() State {\n\tstateId := Query.Unintialized_state_by_model[model.Id]\n\tstate := Inputs.States[stateId]\n\treturn state\n}", "func (d *DSP) IsActive() (bool, error) {\n\tvar active C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetActive(d.cptr, &active)\n\treturn setBool(active), errs[res]\n}", "func (r *IntCode) State() []int { return r.prog }", "func (peer *Peer) CurrentState() uint64 {\n\tpeer.lock.RLock()\n\tdefer peer.lock.RUnlock()\n\treturn peer.state\n}", "func (ld *LibvirtDomain) GetState() (DomainState, error) {\n\treturn DOMAIN_NOSTATE, fmt.Errorf(\"not supported\")\n}", "func (p *tubePool) clearIdleConnections() tube {\n\thead := p.top\n\tp.top = nil\n\tp.lastActive = nil\n\treturn head\n}", "func (o JobOutput) CurrentState() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Job) pulumi.StringOutput { return v.CurrentState }).(pulumi.StringOutput)\n}", "func (se *StateEngine) State() *state.State {\n\treturn se.state\n}", "func (o *NotificationAllOf) GetState() string {\n\tif o == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\n\treturn o.State\n}", "func (d delegate) LocalState(join bool) []byte { return nil }", "func (fsm *Fsm) State() State {\n\treturn fsm.state\n}", "func (o BackendServiceConnectionTrackingPolicyOutput) IdleTimeoutSec() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v BackendServiceConnectionTrackingPolicy) *int { return v.IdleTimeoutSec }).(pulumi.IntPtrOutput)\n}", "func (srv *Server) closeIdleConns() bool {\n\tsrv.mu.Lock()\n\tdefer srv.mu.Unlock()\n\n\tquiescent := true\n\tfor c := range srv.activeConn {\n\t\tst, unixSec := c.getState()\n\t\t// Issue 22682: treat StateNew connections as if\n\t\t// they're idle if we haven't read the first request's\n\t\t// header in over 5 seconds.\n\t\tif st == StateNew && unixSec < time.Now().Unix()-5 {\n\t\t\tst = StateIdle\n\t\t}\n\t\tif st != StateIdle || unixSec == 0 {\n\t\t\t// Assume unixSec == 0 means it's a very new\n\t\t\t// connection, without state set yet.\n\t\t\tquiescent = false\n\t\t\tcontinue\n\t\t}\n\t\tc.rwc.Close()\n\t\tdelete(srv.activeConn, c)\n\t}\n\treturn quiescent\n}", "func (mb *serialPort) closeIdle() {\n\tmb.mu.Lock()\n\tdefer mb.mu.Unlock()\n\n\tif mb.IdleTimeout <= 0 {\n\t\treturn\n\t}\n\tidle := time.Now().Sub(mb.lastActivity)\n\tif idle >= mb.IdleTimeout {\n\t\tmb.logf(\"modbus: closing connection due to idle timeout: %v\", idle)\n\t\tmb.close()\n\t}\n}", "func (c *Easee) Currents() (float64, float64, float64, error) {\n\tc.mux.Lock()\n\tdefer c.mux.Unlock()\n\n\treturn c.currentL1, c.currentL2, c.currentL3, nil\n}", "func detectCstate() (map[string]string, error) {\n\tcstate := make(map[string]string)\n\n\t// Check that sysfs is available\n\tsysfsBase := hostpath.SysfsDir.Path(\"devices/system/cpu\")\n\tif _, err := os.Stat(sysfsBase); err != nil {\n\t\treturn cstate, fmt.Errorf(\"unable to detect cstate status: %w\", err)\n\t}\n\tcpuidleDir := filepath.Join(sysfsBase, \"cpuidle\")\n\tif _, err := os.Stat(cpuidleDir); os.IsNotExist(err) {\n\t\tklog.V(1).InfoS(\"cpuidle disabled in the kernel\")\n\t\treturn cstate, nil\n\t}\n\n\t// When the intel_idle driver is in use (default), check setting of max_cstates\n\tdriver, err := os.ReadFile(filepath.Join(cpuidleDir, \"current_driver\"))\n\tif err != nil {\n\t\treturn cstate, fmt.Errorf(\"cannot get driver for cpuidle: %w\", err)\n\t}\n\n\tif d := strings.TrimSpace(string(driver)); d != \"intel_idle\" {\n\t\t// Currently only checking intel_idle driver for cstates\n\t\tklog.V(1).InfoS(\"intel_idle driver is not in use\", \"currentIdleDriver\", d)\n\t\treturn cstate, nil\n\t}\n\n\tdata, err := os.ReadFile(hostpath.SysfsDir.Path(\"module/intel_idle/parameters/max_cstate\"))\n\tif err != nil {\n\t\treturn cstate, fmt.Errorf(\"cannot determine cstate from max_cstates: %w\", err)\n\t}\n\tcstates, err := strconv.Atoi(strings.TrimSpace(string(data)))\n\tif err != nil {\n\t\treturn cstate, fmt.Errorf(\"non-integer value of cstates: %w\", err)\n\t}\n\n\tcstate[\"enabled\"] = strconv.FormatBool(cstates > 0)\n\n\treturn cstate, nil\n}", "func (s *Server) OnIdle(sess *Session) {\n\tlog.Printf(\"Session(%s) Idled\", sess)\n\ts.cleanSession(sess)\n}", "func (d *Driver) GetState() (state.State, error) {\n\terr := d.connectAPI()\n\tif err != nil {\n\t\treturn state.Paused, err\n\t}\n\n\tif d.ping() {\n\t\treturn state.Running, nil\n\t}\n\treturn state.Paused, nil\n}", "func (o *EquipmentBaseSensor) GetState() string {\n\tif o == nil || o.State == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.State\n}", "func (smc *SpotMC) idleWatcher() {\n\tgrace := time.Duration(smc.idleWatchGraceTime) * time.Second\n\tlog.Infof(\"idle watcher starts after %.2f mins\", grace.Minutes())\n\ttime.Sleep(grace) // Wait for a grace period\n\n\tfullPath := smc.dataDirPath + \"/\" + smc.idleWatchPath\n\td := time.Duration(smc.maxIdleTime) * time.Second\n\n\tlog.WithFields(log.Fields{\"idleWatchPath\": fullPath, \"maxIdleTime\": smc.maxIdleTime}).Info(\"idle watcher starting\")\n\n\tfor true {\n\t\ttime.Sleep(d / 12)\n\t\tfi, err := os.Stat(fullPath)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"os.Stat failed(%s): %s\", fullPath, err)\n\t\t\tlog.WithFields(log.Fields{\"idleWatchPath\": fullPath, \"err\": err}).Error(\"os.Stat failed\")\n\t\t\tcontinue\n\t\t}\n\t\tmtime := fi.ModTime()\n\t\tlog.Infof(\"time.Since(mtime): %.2f minutes (%s)\",\n\t\t\ttime.Since(mtime).Minutes(), fullPath)\n\t\tif time.Since(mtime) > d {\n\t\t\tlog.Infof(\"idle time exceeded limit, shutdown the cluster\")\n\t\t\tbreak\n\t\t}\n\t}\n\tsmc.msgs <- msgShutdownCluster\n}", "func (s *Server) closeIdleConns() bool {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tquiescent := true\n\tfor c := range s.activeConn {\n\t\tst, unixSec := c.getState()\n\t\t// Issue 22682: treat StateNew connections as if\n\t\t// they're idle if we haven't read the first request's\n\t\t// header in over 5 seconds.\n\t\tif st == StateNew && unixSec < time.Now().Unix()-5 {\n\t\t\tst = StateIdle\n\t\t}\n\t\tif st != StateIdle || unixSec == 0 {\n\t\t\t// Assume unixSec == 0 means it's a very new\n\t\t\t// connection, without state set yet.\n\t\t\tquiescent = false\n\t\t\tcontinue\n\t\t}\n\t\tc.rwc.Close()\n\t\tdelete(s.activeConn, c)\n\t}\n\treturn quiescent\n}", "func (pool *Pool) State() (state PoolState, err error) {\n\tif pool.list == nil {\n\t\terr = errors.New(msgPoolIsNil)\n\t} else {\n\t\tstate = PoolState(C.zpool_read_state(pool.list.zph))\n\t}\n\treturn\n}", "func (manager *SessionManager) GetActiveSession() int {\n\treturn manager.provider.SessionAll()\n}", "func (o BackendServiceConnectionTrackingPolicyPtrOutput) IdleTimeoutSec() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *BackendServiceConnectionTrackingPolicy) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.IdleTimeoutSec\n\t}).(pulumi.IntPtrOutput)\n}", "func (srv *Server) closeIdleConns() bool {\n\tsrv.mu.Lock()\n\tdefer srv.mu.Unlock()\n\tquiescent := true\n\tfor c := range srv.activeConn {\n\t\tst, unixSec := c.getState()\n\t\t// Issue 22682: treat StateNew connections as if\n\t\t// they're idle if we haven't read the first request's\n\t\t// header in over 5 seconds.\n\t\tif st == ConnStateNew && unixSec < time.Now().Unix()-5 {\n\t\t\tst = ConnStateIdle\n\t\t}\n\t\tif st != ConnStateIdle || unixSec == 0 {\n\t\t\t// Assume unixSec == 0 means it's a very new\n\t\t\t// connection, without state set yet.\n\t\t\tquiescent = false\n\t\t\tcontinue\n\t\t}\n\t\tc.close()\n\t\tdelete(srv.activeConn, c)\n\t}\n\treturn quiescent\n}", "func (s *State) Active() bool {\n\treturn atomic.LoadInt64(&s.active) == 1\n}" ]
[ "0.663045", "0.5780748", "0.5675647", "0.5623482", "0.562016", "0.5557798", "0.5474286", "0.54616606", "0.5169588", "0.51223713", "0.5080805", "0.5037334", "0.49907482", "0.4984945", "0.49232996", "0.49159414", "0.48989785", "0.48699948", "0.48219734", "0.47114727", "0.4694924", "0.46909523", "0.46338847", "0.46137518", "0.45703202", "0.45467013", "0.45397168", "0.45124215", "0.45003542", "0.44849703", "0.44735706", "0.44616696", "0.4460623", "0.4460406", "0.44478154", "0.4409785", "0.4394449", "0.43757692", "0.43712947", "0.43667027", "0.4358644", "0.43475565", "0.43035322", "0.42972034", "0.42823076", "0.42823076", "0.42822435", "0.4275105", "0.42694363", "0.42630368", "0.42554656", "0.42446196", "0.4241118", "0.42362857", "0.42305255", "0.42305255", "0.42305255", "0.42244554", "0.42046914", "0.41954237", "0.41852838", "0.41825306", "0.41825125", "0.41772252", "0.41738623", "0.4171228", "0.41553152", "0.41465798", "0.41457504", "0.41250467", "0.41191763", "0.41168508", "0.4106107", "0.41049257", "0.41032583", "0.4096297", "0.40857697", "0.40793535", "0.40769643", "0.40745157", "0.40606365", "0.4060426", "0.40565848", "0.40343937", "0.40342215", "0.40320966", "0.4031426", "0.40226018", "0.4021973", "0.40153167", "0.4013729", "0.4013459", "0.40130985", "0.4001083", "0.39993486", "0.39814392", "0.39699107", "0.3967793", "0.39629078", "0.39599463" ]
0.70104456
0
/ Userdata set/get. Sets a user value that the DSP object will store internally. Can be retrieved with "DSP.UserData". This function is primarily used in case the user wishes to 'attach' data to an FMOD object. It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know which object it is (if many of these types of objects exist). Using "DSP.UserData" would help in the identification of the object.
func (d *DSP) SetUserData(userdata interface{}) error { data := *(*[]*C.char)(unsafe.Pointer(&userdata)) res := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&data)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *SoundGroup) SetUserData(userdata interface{}) error {\n\tdata := *(*[]*C.char)(unsafe.Pointer(&userdata))\n\tres := C.FMOD_SoundGroup_SetUserData(s.cptr, unsafe.Pointer(&data))\n\treturn errs[res]\n}", "func (c *wagonContext) SetUserData(key string, value interface{}) {\n\tc.userData[key] = value\n}", "func (d *DSP) UserData() (interface{}, error) {\n\tvar userdata *interface{}\n\tcUserdata := unsafe.Pointer(userdata)\n\tres := C.FMOD_DSP_GetUserData(d.cptr, &cUserdata)\n\treturn *(*interface{})(cUserdata), errs[res]\n}", "func (m *WindowsInformationProtectionDeviceRegistration) SetUserId(value *string)() {\n err := m.GetBackingStore().Set(\"userId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *SecurityActionState) SetUser(value *string)() {\n err := m.GetBackingStore().Set(\"user\", value)\n if err != nil {\n panic(err)\n }\n}", "func (p *Param) SetUserData() error {\n\treturn errors.New(\"Param.SetUserData() has not been implemented yet.\")\n}", "func UserDataValue(u *UserData) Value {\n\treturn Value{iface: u}\n}", "func (s *SoundGroup) UserData() (interface{}, error) {\n\tvar userdata *interface{}\n\tcUserdata := unsafe.Pointer(userdata)\n\tres := C.FMOD_SoundGroup_GetUserData(s.cptr, &cUserdata)\n\treturn *(*interface{})(cUserdata), errs[res]\n}", "func setUser(ctx context.Context, data *User) error {\n\t// clear session_token and API_token for user\n\tk := datastore.NameKey(\"Users\", strings.ToLower(data.Username), nil)\n\n\t// New struct, to not add body, author etc\n\n\tif _, err := dbclient.Put(ctx, k, data); err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r *user) SetValue(key string, value string, expiry time.Duration) error {\n\terr := r.redis.Set(key, value, expiry).Err()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *SmsLogRow) SetUserId(value *string)() {\n err := m.GetBackingStore().Set(\"userId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (init *SPH_UDF_INIT) setvalue(value uintptr) {\n\t*(*uintptr)(unsafe.Pointer(&init.func_data)) = value\n}", "func (d UserData) Set(field models.FieldName, value interface{}) m.UserData {\n\treturn &UserData{\n\t\td.ModelData.Set(field, value),\n\t}\n}", "func LightUserDataValue(d LightUserData) Value {\n\treturn Value{iface: d}\n}", "func (w *World) UserDataOf(v types.Value, t string) *lua.LUserData {\n\t// Normally, a new userdata will be created every single time a value needs\n\t// to be pushed. This is fine for most cases; __eq will take care of most\n\t// comparison checks. One problem is that such userdata cannot be properly\n\t// used as a table key, because the table doesn't know when two userdata\n\t// refer to the same underlying value.\n\t//\n\t// To fix this, a value must consistently map to the same userdata. This\n\t// could be done by caching the association of the value to its userdata in\n\t// a map. The problem is that this map will accumulate garbage userdata that\n\t// has no references other than the map itself. Finalizers can't be used\n\t// because the map still has that single reference.\n\t//\n\t// This problem is resolved by storing a uintptr pointing to the userdata\n\t// instead. By eliminating the strong reference to the userdata, a finalizer\n\t// can be used to remove the association when the userdata has no more\n\t// references.\n\t//\n\t// This method is safe for the register-based calling convention, since the\n\t// produced userdata is never a function argument while it is converted\n\t// between an unsafe pointer.\n\n\tw.udmut.Lock()\n\tdefer w.udmut.Unlock()\n\n\tif p, ok := w.userdata[v]; ok {\n\t\tu := (*lua.LUserData)(unsafe.Pointer(p.p))\n\t\t// GC may have finalized u during this time, so tell the finalizer that\n\t\t// u has been resurrected.\n\t\tp.resurrected = true\n\t\treturn u\n\t}\n\n\tmt := w.l.GetTypeMetatable(t)\n\tif mt == lua.LNil {\n\t\tpanic(\"expected metatable for type \" + t)\n\t}\n\tu := w.LuaState().NewUserData(v)\n\tw.l.SetMetatable(u, mt)\n\n\tif w.userdata == nil {\n\t\tw.userdata = map[interface{}]*udptr{}\n\t}\n\tw.userdata[v] = &udptr{p: uintptr(unsafe.Pointer(u))}\n\truntime.SetFinalizer(u, w.finalize)\n\treturn u\n}", "func SetUserDataLayer(ud UserData) {\n\tuserData = ud\n}", "func (ctx *Context) SetUserValue(key string, value interface{}) {\n\tctx.UserValue[key] = value\n}", "func SetValue(name string, value interface{}) error {\n\tif log.RootLogger().TraceEnabled() {\n\t\tlog.RootLogger().Tracef(\"Set App Value '%s': %v\", name, value)\n\t}\n\treturn appData.SetValue(name, value)\n}", "func SetUser(next echo.HandlerFunc) echo.HandlerFunc {\n\treturn func(c echo.Context) error {\n\t\tc.Set(\"userIdFromToken\", \"12345\")\n\t\treturn next(c)\n\t}\n}", "func (s *LoadSaver) SetValue(id ident.Id, value interface{}) (err error) {\n\tif field, ok := s.data[id]; ok {\n\t\tfield.Value = value\n\t\ts.data[id] = field // record value back; it's not a pointer.\n\t\ts.changed = true\n\t} else if prop, ok := s.GetProperty(id); !ok {\n\t\terr = fmt.Errorf(\"couldnt find property %s.%s\", s, id)\n\t} else {\n\t\ts.data[id] = FieldValue{prop.GetType(), value}\n\t\ts.changed = true\n\t}\n\treturn\n}", "func (ctx *context) SetValue(obj string, prop string, value interface{}) {\n\tctx.Data[obj+prop] = value\n\n}", "func (dev *Device) SetUser(user unsafe.Pointer) {\n\tC.freenect_set_user(dev.ptr(), user)\n}", "func WriteUserData(userID string, userData map[string]interface{}) (err error) {\n\n err = checkInit()\n if err != nil {\n return\n }\n\n err = createError(030)\n\n if v, ok := data[\"users\"].(map[string]interface{})[userID].(map[string]interface{}); ok {\n\n v[\"data\"] = userData\n err = saveDatabase(data)\n\n } else {\n return\n }\n\n return\n}", "func (o *CollectionOfUser) SetValue(v []User) {\n\to.Value = v\n}", "func (ud *UserData) Set(id string, in interface{}) error {\n\tb, err := yaml.Marshal(in)\n\tif err != nil {\n\t\treturn err\n\t}\n\tud.Store(id, string(b))\n\treturn nil\n}", "func (m *SecureScoreControlProfile) SetUserImpact(value *string)() {\n err := m.GetBackingStore().Set(\"userImpact\", value)\n if err != nil {\n panic(err)\n }\n}", "func (win *Window) SetUserPointer(pointer *interface{}) {\n\tC.glfwSetWindowUserPointer(win.c(), unsafe.Pointer(pointer))\n}", "func (n *Namespace) SetUser(req *acomm.Request) (interface{}, *url.URL, error) {\n\tvar args UserArgs\n\tif err := req.UnmarshalArgs(&args); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tuidMapPath := fmt.Sprintf(\"/proc/%d/uid_map\", args.PID)\n\tif err := writeIDMapFile(uidMapPath, args.UIDs); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tgidMapPath := fmt.Sprintf(\"/proc/%d/gid_map\", args.PID)\n\tif err := writeIDMapFile(gidMapPath, args.GIDs); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn nil, nil, nil\n}", "func (m *DeviceManagementIntentDeviceState) SetUserName(value *string)() {\n err := m.GetBackingStore().Set(\"userName\", value)\n if err != nil {\n panic(err)\n }\n}", "func (win *Window) SetUserPointer(pointer unsafe.Pointer) {\n\tC.glfwSetWindowUserPointer(win.c(), pointer)\n}", "func (m *AadUserConversationMember) SetUser(value Userable)() {\n m.user = value\n}", "func (m *RegistryKeyState) SetValueData(value *string)() {\n m.valueData = value\n}", "func SetUserInfoField(socketID string, k string, v interface{}) error {\n\treturn db.Redis().HSet(userInfoKey(socketID), k, v).Err()\n}", "func (k Keeper) SetValue(ctx sdk.Context, accessPath *vm_grpc.VMAccessPath, value []byte) {\n\tk.modulePerms.AutoCheck(types.PermStorageWrite)\n\n\tk.setValue(ctx, accessPath, value)\n}", "func (m *WindowsKioskProfile) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (self *Conn) Userdata() unsafe.Pointer {\n\treturn unsafe.Pointer(C.CString(self.ID))\n}", "func (m *ImportedWindowsAutopilotDeviceIdentityState) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (c Context) SetData(p interface{}) error {\n\t// TODO\n\treturn nil\n}", "func (m *MailboxSettings) SetUserPurpose(value *UserPurpose)() {\n err := m.GetBackingStore().Set(\"userPurpose\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *User) SetPreferredDataLocation(value *string)() {\n m.preferredDataLocation = value\n}", "func (monitor *Monitor) SetUserPointer(pointer unsafe.Pointer) {\n\tC.glfwSetMonitorUserPointer(monitor.c(), pointer)\n}", "func (self *Graphics) SetDataA(member interface{}) {\n self.Object.Set(\"data\", member)\n}", "func SetUsermetaViaMetaValue(iMetaValue string, usermeta *Usermeta) (int64, error) {\n\tusermeta.MetaValue = iMetaValue\n\treturn Engine.Insert(usermeta)\n}", "func (o InstanceOutput) UserData() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringPtrOutput { return v.UserData }).(pulumi.StringPtrOutput)\n}", "func (v Value) AsUserData() *UserData {\n\treturn v.iface.(*UserData)\n}", "func (m *DeviceHealth) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (me *CONFIGURATION_IMPL) SetUserId(userId string) {\r\n me.user-id = userId\r\n}", "func (g *Generator) SetData(name string, d interface{}) {\n\tg.data[name] = d\n}", "func (s *SecureSessionStore) SetValue(key string, value interface{}, rw http.ResponseWriter, req *http.Request) error {\n\tserialized, err := json.Marshal(value)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn s.Set(key, string(serialized), rw, req)\n}", "func SetCurrentUser(next buffalo.Handler) buffalo.Handler {\n\treturn func(c buffalo.Context) error {\n\t\tif uid := c.Session().Get(\"current_user_id\"); uid != nil {\n\t\t\tu := &models.User{}\n\t\t\ttx := c.Value(\"tx\").(*pop.Connection)\n\t\t\terr := tx.Find(u, uid)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\t\t\tc.Set(\"current_user\", u)\n\t\t}\n\t\treturn next(c)\n\t}\n}", "func SetCurrentUser(next buffalo.Handler) buffalo.Handler {\n\treturn func(c buffalo.Context) error {\n\t\tif uid := c.Session().Get(\"current_user_id\"); uid != nil {\n\t\t\tu := &models.User{}\n\t\t\ttx := c.Value(\"tx\").(*pop.Connection)\n\t\t\terr := tx.Find(u, uid)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\t\t\tc.Set(\"current_user\", u)\n\t\t}\n\t\treturn next(c)\n\t}\n}", "func (j Joystick) SetUserPointer(pointer unsafe.Pointer) {\n\tC.glfwSetJoystickUserPointer(C.int(j), pointer)\n}", "func setUID(genericData map[string]interface{}) error {\n\treturn setJSONValue(genericData, []string{\"metadata\", \"uid\"}, uuid.NewUUID())\n}", "func (m *VirtualEndpoint) SetUserSettings(value []CloudPcUserSettingable)() {\n err := m.GetBackingStore().Set(\"userSettings\", value)\n if err != nil {\n panic(err)\n }\n}", "func (c *Context) SetData(name string, value interface{}) {\n\tc.data[name] = value\n}", "func (c *Context) Set(name string, value interface{}) {\n\tc.data.Set(name, value)\n}", "func (m *AgreementAcceptance) SetUserId(value *string)() {\n m.userId = value\n}", "func SetValue(c echo.Context, key string, value interface{}) error {\n\tsess, _ := Get(c)\n\tsess.Values[key] = value\n\treturn nil\n}", "func (m *DeviceManagementSettings) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (uu *UserUpdate) SetData(i *interface{}) *UserUpdate {\n\tuu.mutation.SetData(i)\n\treturn uu\n}", "func (m *MicrosoftManagedDesktop) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func SetUser(userin UserAdd) (lastid int64, err error) {\n\t// var user UserOut\n\t// var kontak contact.ContactIn\n\tvar user UserIn\n\tvar userup UserUpdate\n\n\tuser.Uname = userin.Uname\n\n\tusers, err := FindUser(user)\n\tlog.Printf(\"%+v\", users)\n\tlog.Printf(\"%+v\", user)\n\tlog.Printf(\"%+v\", userin)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif len(users) < 1 {\n\t\treturn 0, errors.New(\"User not found.\")\n\t}\n\n\tif len(users) < 1 {\n\t\treturn InsertUser(userin)\n\t} else {\n\t\tuserup.ContactType = userin.ContactType\n\t\tuserup.Upass = userin.Upass\n\t\treturn UpdateUser(users[0].Uid, userup)\n\t}\n\n\treturn\n}", "func (d UserData) SetUser(value m.UserSet) m.UserData {\n\td.ModelData.Set(models.NewFieldName(\"User\", \"user_id\"), value)\n\treturn d\n}", "func (self *TileSprite) SetDataA(member interface{}) {\n self.Object.Set(\"data\", member)\n}", "func (u *UdMap) Set(key, value string) { u.Data[key] = value }", "func (uuo *UserUpdateOne) SetData(i *interface{}) *UserUpdateOne {\n\tuuo.mutation.SetData(i)\n\treturn uuo\n}", "func (c *Context) Set(key string, value interface{}) {\n\tc.moot.Lock()\n\tdefer c.moot.Unlock()\n\n\tc.data[key] = value\n}", "func (d *Data) SetData(data *Data) error {\n\tvar err error\n\tfor k, dType := range d.Values {\n\t\tswitch dType {\n\t\tdefault:\n\t\t\td.Data[k] = data.Data[k]\n\t\tcase STRINGPOINTER:\n\t\t\tsp := d.cache[k].(*string)\n\t\t\t*sp = data.Data[k].(string)\n\t\t\td.Data[k] = sp\n\t\tcase INT:\n\t\t\tvar v float64\n\t\t\tv, err = interfaceToFloat(data.Data[k])\n\t\t\td.Data[k] = int(v)\n\t\tcase INTPOINTER:\n\t\t\tvar v float64\n\t\t\tv, err = interfaceToFloat(data.Data[k])\n\t\t\tip := d.cache[k].(*int)\n\t\t\t*ip = int(v)\n\t\t\td.Data[k] = ip\n\t\tcase FUNCPOINTER:\n\t\t\tfp := d.cache[k].(*func())\n\t\t\t*fp = data.unexportedData[k].(func())\n\t\t\td.Data[k] = fp\n\t\tcase FLOAT64:\n\t\t\tvar v float64\n\t\t\tv, err = interfaceToFloat(data.Data[k])\n\t\t\td.Data[k] = v\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (h *Host) SetUser(u string) {\n}", "func (t *SimpleChaincode) set_user(stub *shim.ChaincodeStub, args []string) ([]byte, error) {\n var err error\n \n // 0 1\n // \"name\", \"bob\"\n if len(args) < 2 {\n return nil, errors.New(\"Incorrect number of arguments. Expecting 2\")\n }\n \n fmt.Println(\"- start set user\")\n fmt.Println(args[0] + \" - \" + args[1])\n termAsBytes, err := stub.GetState(args[0])\n if err != nil {\n return nil, errors.New(\"Failed to get thing\")\n }\n res := SearchTerm{}\n json.Unmarshal(termAsBytes, &res) //un stringify it aka JSON.parse()\n res.User = args[1] //change the user\n \n jsonAsBytes, _ := json.Marshal(res)\n err = stub.PutState(args[0], jsonAsBytes) //rewrite the term with id as key\n if err != nil {\n return nil, err\n }\n \n fmt.Println(\"- end set user\")\n return nil, nil\n}", "func (m *InvitedUserMessageInfo) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *DeviceManagementSettingDependency) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (option ApplicationCommandInteractionDataOption) UserIDValue() (value string, ok bool) {\n\treturn option.StringValue()\n}", "func (s *Store) Set(user string, m *fsm.FSM) {\n\tmachine := FSMORM{}\n\ts.DB.First(&machine, \"user = ?\", user)\n\tmachine.User = user\n\tmachine.State = m.State\n\tmachine.Slots = slotsToJSONString(m.Slots)\n\tif res := s.DB.Save(&machine); res.Error != nil {\n\t\tlog.Error(res.Error)\n\t}\n}", "func (recv *Object) SetData(key string, data uintptr) {\n\tc_key := C.CString(key)\n\tdefer C.free(unsafe.Pointer(c_key))\n\n\tc_data := (C.gpointer)(data)\n\n\tC.g_object_set_data((*C.GObject)(recv.native), c_key, c_data)\n\n\treturn\n}", "func (o *Sensorefficiency) SetValue(v string) {\n\to.Value = v\n}", "func Set(c *template.Context, value interface{}) error {\n\tid := c.ID()\n\n\t// Get the store.\n\ts, err := getStore(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The context has to be locked to perform any changes.\n\tif !IsLocked(c) {\n\t\treturn fmt.Errorf(\"store.Set: can't set store data if the context is not locked by the session!\")\n\t}\n\n\t// Lock the mutex.\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\n\t// Create the map if it doesn't exists.\n\ts.data.createMapIfNil()\n\n\t// Set the value. The key is the context's ID.\n\ts.data.Values[id] = newDBStoreData(value)\n\n\t// Update data to the database.\n\terr = flushUpdatesToDB(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Broadcast changes to other sessions in edit mode.\n\tbroadcastChangedContext(id, c.Session())\n\n\treturn nil\n}", "func (c Connector) SetValue(key string, value interface{}) {\n\terr := c.Client.Set(key, value, 0).Err()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (m *Setting) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (o *Domain) SetValue(v string) {\n\to.Value = v\n}", "func (m *WorkbookNamedItem) SetValue(value Jsonable)() {\n err := m.GetBackingStore().Set(\"value\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *TeamworkActivePeripherals) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (fb *Facebook) SetUser(response *http.Response) (OauthUser, error) {\n\tfacebookUser := &OauthUser{}\n\tdefer response.Body.Close()\n\tbody, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\treturn *facebookUser, err\n\t}\n\tjson.Unmarshal(body, &facebookUser)\n\treturn *facebookUser, nil\n}", "func (m *Middleware) SetDeviceUID(w http.ResponseWriter, value ksuid.KSUID) {\n\tc := *m.duidCookieSettings\n\tc.Value = value.String()\n\thttp.SetCookie(w, &c)\n}", "func (_m *ContainerIface) SetData(path string, name string, data string) {\n\t_m.Called(path, name, data)\n}", "func (m *ProgramControl) SetOwner(value UserIdentityable)() {\n err := m.GetBackingStore().Set(\"owner\", value)\n if err != nil {\n panic(err)\n }\n}", "func (cmd *FuelPressure) SetValue(result *Result) error {\n\tpayload, err := result.PayloadAsByte()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Value = uint32(payload) * 3\n\n\treturn nil\n}", "func Set(name string, value interface{}) {\n\tinitialize()\n\tlock.Lock()\n\tnotGlobals[name] = value\n\tlock.Unlock()\n}", "func (o *Stock) SetUserP(exec boil.Executor, insert bool, related *User) {\n\tif err := o.SetUser(exec, insert, related); err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n}", "func (m *User) SetUserType(value *string)() {\n m.userType = value\n}", "func (a *ActiveDevice) Set(m MetaContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID,\n\tsigKey, encKey GenericKey, deviceName string, deviceCtime keybase1.Time, keychainMode KeychainMode) error {\n\ta.Lock()\n\tdefer a.Unlock()\n\n\tif err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {\n\t\treturn err\n\t}\n\n\ta.signingKey = sigKey\n\ta.encryptionKey = encKey\n\ta.deviceName = deviceName\n\ta.deviceCtime = deviceCtime\n\ta.nistFactory = NewNISTFactory(m.G(), uv.Uid, deviceID, sigKey)\n\ta.secretSyncer = NewSecretSyncer(m.G())\n\ta.keychainMode = keychainMode\n\n\treturn nil\n}", "func (l *Lockbox) SetValue(path, value []byte) error {\n\tif l.Locked {\n\t\treturn errors.New(\"cannot set value while lockbox is locked\")\n\t}\n\n\t// encrypt the provided value with the current users encryption key.\n\tencval, err := encrypt(value, l.CurrentUser.EncryptionKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// store the encrypted value at the desired path\n\treturn l.Store.Update(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(l.CurrentNamespace))\n\t\terr := b.Put(path, encval)\n\t\treturn err\n\t})\n}", "func (m *AadUserConversationMember) SetUserId(value *string)() {\n m.userId = value\n}", "func SetUser(stmt *sql.Stmt, device, user string) error {\n\terr := exec(stmt, user, device)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (atomic *_atomic) SetValue(v interface{}) {\n\tatomic.mutex.Lock()\n\tatomic.value = v\n\tatomic.mutex.Unlock()\n}", "func (ctx *Context) SetData(key, val interface{}) {\r\n\tif ctx.data == nil {\r\n\t\tctx.data = make(map[interface{}]interface{})\r\n\t}\r\n\tctx.data[key] = val\r\n}", "func (m *AppliedAuthenticationEventListener) SetAdditionalData(value map[string]any)() {\n err := m.GetBackingStore().Set(\"additionalData\", value)\n if err != nil {\n panic(err)\n }\n}", "func (o *SettingsObjectUpdate) SetValue(v map[string]interface{}) {\n\to.Value = v\n}", "func (o *EquipmentBaseSensor) SetValue(v string) {\n\to.Value = &v\n}", "func (o OceanOutput) UserData() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Ocean) pulumi.StringPtrOutput { return v.UserData }).(pulumi.StringPtrOutput)\n}" ]
[ "0.67778385", "0.6660982", "0.64165705", "0.6365807", "0.62359315", "0.6204318", "0.61297154", "0.60952216", "0.6065654", "0.6030655", "0.59105045", "0.59067404", "0.5891905", "0.5882205", "0.5876744", "0.5866614", "0.5865278", "0.58043444", "0.5793301", "0.576205", "0.57273436", "0.57246333", "0.56773996", "0.56692046", "0.5666274", "0.56518435", "0.5625654", "0.5594357", "0.55476546", "0.554607", "0.5516946", "0.54968965", "0.54950714", "0.5430964", "0.5417626", "0.54121894", "0.5410296", "0.54076463", "0.5404075", "0.5400268", "0.53983825", "0.53863907", "0.5373239", "0.5372497", "0.5364474", "0.5353826", "0.535005", "0.5334368", "0.53329057", "0.53304154", "0.53304154", "0.5323694", "0.531166", "0.53059584", "0.5301794", "0.53007406", "0.5282164", "0.5266026", "0.52615285", "0.525511", "0.52532345", "0.5251928", "0.5251612", "0.5236587", "0.5235946", "0.52349585", "0.5231184", "0.5227", "0.5223166", "0.5212302", "0.51997626", "0.5196634", "0.5192867", "0.5186229", "0.51860213", "0.5175512", "0.51739985", "0.515982", "0.5156626", "0.51445866", "0.51421916", "0.5139964", "0.51398724", "0.5138925", "0.5138429", "0.5133636", "0.51307327", "0.51284784", "0.51264346", "0.51253676", "0.51043946", "0.51031846", "0.5102128", "0.50984186", "0.50944453", "0.5093641", "0.50932664", "0.50919235", "0.5086962", "0.5073688" ]
0.7467645
0
Retrieves the user value that that was set by calling the "DSP.SetUserData" function.
func (d *DSP) UserData() (interface{}, error) { var userdata *interface{} cUserdata := unsafe.Pointer(userdata) res := C.FMOD_DSP_GetUserData(d.cptr, &cUserdata) return *(*interface{})(cUserdata), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *Param) GetUserData() error {\n\treturn errors.New(\"Param.GetUserData() has not been implemented yet.\")\n}", "func (c *wagonContext) GetUserData(key string) interface{} {\n\treturn c.userData[key]\n}", "func (s *SoundGroup) UserData() (interface{}, error) {\n\tvar userdata *interface{}\n\tcUserdata := unsafe.Pointer(userdata)\n\tres := C.FMOD_SoundGroup_GetUserData(s.cptr, &cUserdata)\n\treturn *(*interface{})(cUserdata), errs[res]\n}", "func (r *LaunchConfiguration) UserData() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"userData\"])\n}", "func UserDataValue(u *UserData) Value {\n\treturn Value{iface: u}\n}", "func (m *WindowsInformationProtectionDeviceRegistration) GetUserId()(*string) {\n val, err := m.GetBackingStore().Get(\"userId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (option ApplicationCommandInteractionDataOption) UserIDValue() (value string, ok bool) {\n\treturn option.StringValue()\n}", "func (o InstanceOutput) UserData() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Instance) pulumi.StringPtrOutput { return v.UserData }).(pulumi.StringPtrOutput)\n}", "func (f *FakeInstance) GetUserData(_ context.Context, _ string) (*govultr.UserData, *http.Response, error) {\n\tpanic(\"implement me\")\n}", "func (self *Conn) Userdata() unsafe.Pointer {\n\treturn unsafe.Pointer(C.CString(self.ID))\n}", "func (d *DSP) SetUserData(userdata interface{}) error {\n\tdata := *(*[]*C.char)(unsafe.Pointer(&userdata))\n\tres := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&data))\n\treturn errs[res]\n}", "func (ctx *Context) User() interface{} {\n\treturn ctx.UserValue[\"user\"]\n}", "func LightUserDataValue(d LightUserData) Value {\n\treturn Value{iface: d}\n}", "func (dev *Device) GetUser() unsafe.Pointer {\n\treturn C.freenect_get_user(dev.ptr())\n}", "func (c *Client) GetUserData() ([]byte, error) {\n\treturn json.Marshal(c.userData)\n}", "func (o OceanOutput) UserData() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Ocean) pulumi.StringPtrOutput { return v.UserData }).(pulumi.StringPtrOutput)\n}", "func (m *SecurityActionState) GetUser()(*string) {\n val, err := m.GetBackingStore().Get(\"user\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (c *Client) GetUserData() (string, error) {\n\tresp, err := c.httpClient.Get(instanceMetadataBaseURL + \"/latest/user-data\")\n\tif err != nil {\n\t\tvar neterr net.Error\n\t\t// TODO handle \"dial tcp 169.254.169.254:80: connect: host is down\" as a RetryableError\n\t\tif errors.As(err, &neterr) && (neterr.Timeout() || neterr.Temporary()) {\n\t\t\treturn \"\", &errorx.RetryableError{Message: \"timeout or temporary error in HTTP request\", Err: neterr}\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"error in http request: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"unexpected status code %d != 200\", resp.StatusCode)\n\t}\n\tuserDataB, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error reading response body: %w\", err)\n\t}\n\treturn string(userDataB), nil\n}", "func (c *Clients) GetUserData(ctx context.Context, inst *at.Instance) (*string, error) {\n\tinput := ec2.DescribeInstanceAttributeInput{\n\t\tAttribute: et.InstanceAttributeNameUserData,\n\t\tInstanceId: inst.InstanceId,\n\t}\n\n\toutput, err := c.EC2Client.DescribeInstanceAttribute(ctx, &input)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Error describing userdata for instance %s\", *inst.InstanceId)\n\t}\n\n\treturn output.UserData.Value, nil\n}", "func (m *DeviceManagementIntentDeviceState) GetUserName()(*string) {\n val, err := m.GetBackingStore().Get(\"userName\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (v Value) TryUserData() (u *UserData, ok bool) {\n\tu, ok = v.iface.(*UserData)\n\treturn\n}", "func GetUserData(c echo.Context) error {\r\n\r\n\tconfig := config.GetInstance()\r\n\r\n\ttoken := c.Request().Header.Get(\"token\")\r\n\r\n\treq, err := http.NewRequest(\"GET\", config.GetRemoteURL()+\"/process-request.php?command-name=get-user-data\", nil)\r\n\tif err != nil {\r\n\t\treturn c.JSON(500, &models.Response{\r\n\t\t\tStatus: 1,\r\n\t\t\tSuccess: false,\r\n\t\t\tMessage: err.Error(),\r\n\t\t})\r\n\t}\r\n\r\n\tsess, _ := session.Get(\"Session\", c)\r\n\tif sess != nil && sess.Values[\"PHPSESSID\"] != nil {\r\n\t\tsetCookie(req, \"PHPSESSID\", sess.Values[\"PHPSESSID\"].(string))\r\n\t}\r\n\r\n\tsetCookie(req, \"auth-key\", config.RemoteAuthKey)\r\n\tsetCookie(req, \"user-token\", token)\r\n\r\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded; param=value;charset=UTF-8\")\r\n\r\n\tclient := http.Client{}\r\n\tres, err := client.Do(req)\r\n\tif err != nil {\r\n\t\treturn c.JSON(500, &models.Response{\r\n\t\t\tStatus: 2,\r\n\t\t\tSuccess: false,\r\n\t\t\tMessage: err.Error(),\r\n\t\t})\r\n\t}\r\n\r\n\tdefer res.Body.Close()\r\n\r\n\tvar httpResponseData models.HTTPResponse\r\n\r\n\tif err := json.NewDecoder(res.Body).Decode(&httpResponseData); err != nil {\r\n\t\treturn c.JSON(500, &models.Response{\r\n\t\t\tStatus: 3,\r\n\t\t\tSuccess: false,\r\n\t\t\tMessage: err.Error(),\r\n\t\t})\r\n\t}\r\n\r\n\treturn c.JSON(200, httpResponseData)\r\n}", "func (v Value) AsUserData() *UserData {\n\treturn v.iface.(*UserData)\n}", "func (o EcsLaunchTemplateOutput) Userdata() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *EcsLaunchTemplate) pulumi.StringOutput { return v.Userdata }).(pulumi.StringOutput)\n}", "func (v *AsyncResult) GetUserData() uintptr {\n\tc := C.g_async_result_get_user_data(v.native())\n\treturn uintptr(unsafe.Pointer(c))\n}", "func (r Virtual_Guest) GetUserData() (resp []datatypes.Virtual_Guest_Attribute, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getUserData\", nil, &r.Options, &resp)\n\treturn\n}", "func (m *WindowsInformationProtectionDeviceRegistration) SetUserId(value *string)() {\n err := m.GetBackingStore().Set(\"userId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (ws *WSConn) getUserData(arg *pb.CUserData) {\n\ts2c := new(pb.SUserData)\n\ts2c.UserInfo = &pb.UserData{\n\t\tUserid: ws.user.ID,\n\t\tNickName: ws.user.NickName,\n\t\tAvatarUrl: ws.user.AvatarUrl,\n\t\tGender: ws.user.Gender,\n\t\tDiamond: ws.user.Diamond,\n\t\tCoin: ws.user.Coin,\n\t\tEnergy: ws.user.Energy,\n\t}\n\tws.Send(s2c)\n}", "func (s *Client) GetAny(username string) (*sessions.UserData, error) {\n\thistory, err := s.GetHistory(username)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlast_match, err := s.GetLastMatch(username)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar variables map[string]string = make(map[string]string)\n\trows, err := s.db.Query(`SELECT key,value FROM user_variables WHERE user_id = (SELECT id FROM users WHERE username = ?);`, username)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\tvar key, value string\n\tfor rows.Next() {\n\t\terr = rows.Scan(&key, &value)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tvariables[key] = value\n\t}\n\n\treturn &sessions.UserData{\n\t\tHistory: history,\n\t\tLastMatch: last_match,\n\t\tVariables: variables,\n\t}, nil\n}", "func (m *User) GetPreferredDataLocation()(*string) {\n return m.preferredDataLocation\n}", "func (m *SmsLogRow) GetUserId()(*string) {\n val, err := m.GetBackingStore().Get(\"userId\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (s *Client) Get(username, name string) (string, error) {\n\tvar value string\n\trow := s.db.QueryRow(`SELECT value FROM user_variables WHERE user_id = (SELECT id FROM users WHERE username = ?) AND key = ?;`, username, name)\n\tswitch err := row.Scan(&value); err {\n\tcase sql.ErrNoRows:\n\t\treturn \"\", fmt.Errorf(\"no %s variable found for user %s\", name, username)\n\tcase nil:\n\t\treturn value, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown sql error\")\n\t}\n}", "func (t *SimpleChaincode) readuser(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar name, 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 var to query\")\n\t}\n\n\tname = args[0]\n\tvalAsbytes, err := stub.GetState(name) //get the key value from chaincode state\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for \" + name + \"\\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\n\treturn valAsbytes, nil //send it onward\n}", "func (i *InstanceServiceHandler) GetUserData(ctx context.Context, instanceID string) (*UserData, error) {\n\turi := fmt.Sprintf(\"%s/%s/user-data\", instancePath, instanceID)\n\treq, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuserData := new(userDataBase)\n\tif err = i.client.DoWithContext(ctx, req, userData); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn userData.UserData, nil\n}", "func (o AzureSynapseOutputDataSourceResponseOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSynapseOutputDataSourceResponse) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (o AzureSynapseOutputDataSourceOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSynapseOutputDataSource) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (u *User) Phone() string { return u.userData.Phone }", "func (w *World) UserDataOf(v types.Value, t string) *lua.LUserData {\n\t// Normally, a new userdata will be created every single time a value needs\n\t// to be pushed. This is fine for most cases; __eq will take care of most\n\t// comparison checks. One problem is that such userdata cannot be properly\n\t// used as a table key, because the table doesn't know when two userdata\n\t// refer to the same underlying value.\n\t//\n\t// To fix this, a value must consistently map to the same userdata. This\n\t// could be done by caching the association of the value to its userdata in\n\t// a map. The problem is that this map will accumulate garbage userdata that\n\t// has no references other than the map itself. Finalizers can't be used\n\t// because the map still has that single reference.\n\t//\n\t// This problem is resolved by storing a uintptr pointing to the userdata\n\t// instead. By eliminating the strong reference to the userdata, a finalizer\n\t// can be used to remove the association when the userdata has no more\n\t// references.\n\t//\n\t// This method is safe for the register-based calling convention, since the\n\t// produced userdata is never a function argument while it is converted\n\t// between an unsafe pointer.\n\n\tw.udmut.Lock()\n\tdefer w.udmut.Unlock()\n\n\tif p, ok := w.userdata[v]; ok {\n\t\tu := (*lua.LUserData)(unsafe.Pointer(p.p))\n\t\t// GC may have finalized u during this time, so tell the finalizer that\n\t\t// u has been resurrected.\n\t\tp.resurrected = true\n\t\treturn u\n\t}\n\n\tmt := w.l.GetTypeMetatable(t)\n\tif mt == lua.LNil {\n\t\tpanic(\"expected metatable for type \" + t)\n\t}\n\tu := w.LuaState().NewUserData(v)\n\tw.l.SetMetatable(u, mt)\n\n\tif w.userdata == nil {\n\t\tw.userdata = map[interface{}]*udptr{}\n\t}\n\tw.userdata[v] = &udptr{p: uintptr(unsafe.Pointer(u))}\n\truntime.SetFinalizer(u, w.finalize)\n\treturn u\n}", "func (p *Param) SetUserData() error {\n\treturn errors.New(\"Param.SetUserData() has not been implemented yet.\")\n}", "func (s *SessionData) User() security.SQLUsername {\n\treturn s.UserProto.Decode()\n}", "func (m *SecureScoreControlProfile) GetUserImpact()(*string) {\n val, err := m.GetBackingStore().Get(\"userImpact\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (o AzureSqlDatabaseOutputDataSourceResponseOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSqlDatabaseOutputDataSourceResponse) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (p Provider) UserData(\n\tspec clusterv1alpha1.MachineSpec,\n\tkubeconfig *clientcmdapi.Config,\n\tccProvider cloud.ConfigProvider,\n\tclusterDNSIPs []net.IP,\n) (string, error) {\n\n\ttmpl, err := template.New(\"user-data\").Funcs(machinetemplate.TxtFuncMap()).Parse(ctTemplate)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse user-data template: %v\", err)\n\t}\n\n\tkubeletVersion, err := semver.NewVersion(spec.Versions.Kubelet)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid kubelet version: '%v'\", err)\n\t}\n\n\tcpConfig, cpName, err := ccProvider.GetCloudConfig(spec)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get cloud config: %v\", err)\n\t}\n\n\tpconfig, err := providerconfig.GetConfig(spec.ProviderConfig)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get provider config: %v\", err)\n\t}\n\n\tif pconfig.OverwriteCloudConfig != nil {\n\t\tcpConfig = *pconfig.OverwriteCloudConfig\n\t}\n\n\tif pconfig.Network != nil {\n\t\treturn \"\", errors.New(\"static IP config is not supported with CentOS\")\n\t}\n\n\tosConfig, err := getConfig(pconfig.OperatingSystemSpec)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse OperatingSystemSpec: '%v'\", err)\n\t}\n\n\tbootstrapToken, err := userdatahelper.GetTokenFromKubeconfig(kubeconfig)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error extracting token: %v\", err)\n\t}\n\n\tkubeadmCACertHash, err := userdatahelper.GetKubeadmCACertHash(kubeconfig)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error extracting kubeadm cacert hash: %v\", err)\n\t}\n\n\tserverAddr, err := userdatahelper.GetServerAddressFromKubeconfig(kubeconfig)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error extracting server address from kubeconfig: %v\", err)\n\t}\n\n\tdata := struct {\n\t\tMachineSpec clusterv1alpha1.MachineSpec\n\t\tProviderConfig *providerconfig.Config\n\t\tOSConfig *Config\n\t\tBoostrapToken string\n\t\tCloudProvider string\n\t\tCloudConfig string\n\t\tKubeletVersion string\n\t\tClusterDNSIPs []net.IP\n\t\tKubeadmCACertHash string\n\t\tServerAddr string\n\t\tJournaldMaxSize string\n\t}{\n\t\tMachineSpec: spec,\n\t\tProviderConfig: pconfig,\n\t\tOSConfig: osConfig,\n\t\tBoostrapToken: bootstrapToken,\n\t\tCloudProvider: cpName,\n\t\tCloudConfig: cpConfig,\n\t\tKubeletVersion: kubeletVersion.String(),\n\t\tClusterDNSIPs: clusterDNSIPs,\n\t\tKubeadmCACertHash: kubeadmCACertHash,\n\t\tServerAddr: serverAddr,\n\t\tJournaldMaxSize: userdatahelper.JournaldMaxUse,\n\t}\n\tb := &bytes.Buffer{}\n\terr = tmpl.Execute(b, data)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to execute user-data template: %v\", err)\n\t}\n\treturn b.String(), nil\n}", "func (p Provider) UserData(req plugin.UserDataRequest) (string, error) {\n\n tmpl, err := template.New(\"user-data\").Funcs(userdatahelper.TxtFuncMap()).Parse(userDataTemplate)\n if err != nil {\n return \"\", fmt.Errorf(\"failed to parse user-data template: %v\", err)\n }\n\n kubeletVersion, err := semver.NewVersion(req.MachineSpec.Versions.Kubelet)\n if err != nil {\n return \"\", fmt.Errorf(\"invalid kubelet version: %v\", err)\n }\n\n dockerVersion, err := userdatahelper.DockerVersionApt(kubeletVersion)\n if err != nil {\n return \"\", fmt.Errorf(\"invalid docker version: %v\", err)\n }\n\n pconfig, err := providerconfigtypes.GetConfig(req.MachineSpec.ProviderSpec)\n if err != nil {\n return \"\", fmt.Errorf(\"failed to get providerSpec: %v\", err)\n }\n\n if pconfig.OverwriteCloudConfig != nil {\n req.CloudConfig = *pconfig.OverwriteCloudConfig\n }\n\n if pconfig.Network != nil {\n return \"\", errors.New(\"static IP config is not supported with Ubuntu\")\n }\n\n ubuntuConfig, err := LoadConfig(pconfig.OperatingSystemSpec)\n if err != nil {\n return \"\", fmt.Errorf(\"failed to get ubuntu config from provider config: %v\", err)\n }\n\n serverAddr, err := userdatahelper.GetServerAddressFromKubeconfig(req.Kubeconfig)\n if err != nil {\n return \"\", fmt.Errorf(\"error extracting server address from kubeconfig: %v\", err)\n }\n\n kubeconfigString, err := userdatahelper.StringifyKubeconfig(req.Kubeconfig)\n if err != nil {\n return \"\", err\n }\n\n kubernetesCACert, err := userdatahelper.GetCACert(req.Kubeconfig)\n if err != nil {\n return \"\", fmt.Errorf(\"error extracting cacert: %v\", err)\n }\n\n data := struct {\n plugin.UserDataRequest\n ProviderSpec *providerconfigtypes.Config\n OSConfig *Config\n ServerAddr string\n KubeletVersion string\n DockerVersion string\n Kubeconfig string\n KubernetesCACert string\n NodeIPScript string\n }{\n UserDataRequest: req,\n ProviderSpec: pconfig,\n OSConfig: ubuntuConfig,\n ServerAddr: serverAddr,\n KubeletVersion: kubeletVersion.String(),\n DockerVersion: dockerVersion,\n Kubeconfig: kubeconfigString,\n KubernetesCACert: kubernetesCACert,\n NodeIPScript: userdatahelper.SetupNodeIPEnvScript(),\n }\n b := &bytes.Buffer{}\n err = tmpl.Execute(b, data)\n if err != nil {\n return \"\", fmt.Errorf(\"failed to execute user-data template: %v\", err)\n }\n return userdatahelper.CleanupTemplateOutput(b.String())\n}", "func (p *PhidgetCurrentInput) GetValue() (float64, error) {\n\tvar r C.double\n\tcerr := C.PhidgetCurrentInput_getCurrent(p.handle, &r)\n\tif cerr != C.EPHIDGET_OK {\n\t\treturn 0, p.phidgetError(cerr)\n\t}\n\treturn float64(r), nil\n}", "func (o AzureSqlDatabaseOutputDataSourceOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSqlDatabaseOutputDataSource) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (s *StorePaymentPurposeGiftedPremium) GetUserID() (value int64) {\n\tif s == nil {\n\t\treturn\n\t}\n\treturn s.UserID\n}", "func (c *wagonContext) SetUserData(key string, value interface{}) {\n\tc.userData[key] = value\n}", "func (s *PerProcessStat) User() string {\n\treturn s.user\n}", "func (u *UserSettingResolver) Value() string {\n\treturn u.value\n}", "func (o AzureSqlReferenceInputDataSourcePropertiesResponseOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSqlReferenceInputDataSourcePropertiesResponse) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (c *Config) GetUser() string {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\n\treturn c.UserName\n}", "func User() string {\n\treturn user\n}", "func (d *WebAuthnDevice) DataValueLastUsedAt() *time.Time {\n\tif d.LastUsedAt.Valid {\n\t\tvalue := time.Unix(d.LastUsedAt.Time.Unix(), int64(d.LastUsedAt.Time.Nanosecond()))\n\n\t\treturn &value\n\t}\n\n\treturn nil\n}", "func (a *Funcs) UserID() (string, error) {\n\ta.stsInit.Do(a.initSTS)\n\treturn a.sts.UserID()\n}", "func (r *reader) GetUser() (s string, err error) {\n\tdefer func() {\n\t\tunsetenvErr := r.unsetEnv(\"USER\")\n\t\tif err == nil {\n\t\t\terr = unsetenvErr\n\t\t}\n\t}()\n\treturn r.envParams.GetEnv(\"USER\", libparams.CaseSensitiveValue(), libparams.Compulsory())\n}", "func (o AzureSqlReferenceInputDataSourcePropertiesOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v AzureSqlReferenceInputDataSourceProperties) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func GetU(name string, defvals ...uint) uint {\n\tif global == nil {\n\t\tif len(defvals) == 0 {\n\t\t\treturn 0\n\t\t}\n\n\t\treturn defvals[0]\n\t}\n\n\treturn global.GetU(name, defvals...)\n}", "func (m *MailboxSettings) GetUserPurpose()(*UserPurpose) {\n val, err := m.GetBackingStore().Get(\"userPurpose\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*UserPurpose)\n }\n return nil\n}", "func ReadUserData(userID string) (userData map[string]interface{}, err error) {\n\n err = checkInit()\n if err != nil {\n return\n }\n\n err = createError(031)\n\n if v, ok := data[\"users\"].(map[string]interface{})[userID].(map[string]interface{}); ok {\n userData = v[\"data\"].(map[string]interface{})\n err = nil\n\n return\n }\n\n return\n}", "func isUserData(lv lua.LValue) (*lua.LUserData, bool) {\n\tif lv.Type() == lua.LTUserData {\n\t\tudata := lv.(*lua.LUserData)\n\t\treturn udata, true\n\t}\n\treturn nil, false\n}", "func (g *Google) GetRemoteUserData(r *http.Request, w http.ResponseWriter) (string, error) {\n\n\tstate := r.FormValue(\"state\")\n\tif state != utils.Cfg.OauthSettings.GoogleSettings.Statestr {\n\t\tlog.Warnf(\"controllers.oauth.google.getRemoteUserData. Invalid oauth state, expected '%s', got '%s'\\n\", utils.Cfg.OauthSettings.GoogleSettings.Statestr, state)\n\t\treturn \"\", models.NewAppError(\"OAuth state\", \"controllers.oauth.google\", \"Invalid oauth state\", 500)\n\t}\n\n\tcode := r.FormValue(\"code\")\n\ttoken, err := g.oauthConf.Exchange(oauth2.NoContext, code)\n\tif err != nil {\n\t\tlog.Warnf(\"controllers.oauth.google.getRemoteUserData. Code exchange failed with '%s'\\n\", err)\n\t\treturn \"\", models.NewAppError(\"Code exchange failed\", \"controllers.oauth.google\", err.Error(), 500)\n\t}\n\n\tresponse, err := http.Get(\"https://www.googleapis.com/oauth2/v2/userinfo?access_token=\" + token.AccessToken)\n\tif err != nil {\n\t\tlog.Warn(\"controllers.oauth.google.getRemoteUserData. Cannot get user info using Google API\")\n\t\treturn \"\", models.NewAppError(\"Cannot get user info using Google API\", \"controllers.oauth.google\", err.Error(), 500)\n\t}\n\n\tdefer utils.Check(response.Body.Close)\n\tcontents, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\tlog.Warn(\"controllers.oauth.google.getRemoteUserData. Error parsing Google user data\")\n\t\treturn \"\", models.NewAppError(\"Error parsing Google user data\", \"controllers.oauth.google\", err.Error(), 500)\n\t}\n\t// fmt.Fprintf(w, \"Content: %s\\n\", contents)\n\n\treturn string(contents), nil\n}", "func (s *UintSetting) Value() interface{} {\n\treturn *s.UintValue\n}", "func (f *FastURL) GetUser() []byte {\n\treturn f.user\n}", "func (inputReader InputReader) GetUserInput() string {\n\tdata, _ := inputReader.reader.ReadString('\\n')\n\treturn strings.TrimSuffix(data, \"\\n\")\n}", "func GetUser(r *http.Request) string {\n\tres, _ := noodle.Value(r, userKey).(string)\n\treturn res\n}", "func (m *RegistryKeyState) GetValueData()(*string) {\n return m.valueData\n}", "func GetUserSetting(userID int64, key string, def ...string) (string, error) {\n\tif err := validateUserSettingKey(key); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tsetting := &Setting{UserID: userID, SettingKey: key}\n\thas, err := db.GetEngine(db.DefaultContext).Get(setting)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif !has {\n\t\tif len(def) == 1 {\n\t\t\treturn def[0], nil\n\t\t}\n\t\treturn \"\", nil\n\t}\n\treturn setting.SettingValue, nil\n}", "func (o *os) GetUserDataDir() gdnative.String {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetUserDataDir()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_user_data_dir\")\n\n\t// Call the parent method.\n\t// String\n\tretPtr := gdnative.NewEmptyString()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewStringFromPointer(retPtr)\n\treturn ret\n}", "func GetLicenseUserMetadata(key string, value *string) int {\n\tcKey := goToCString(key)\n\tvar cValue = getCArray()\n\tstatus := C.GetLicenseUserMetadata(cKey, &cValue[0], maxCArrayLength)\n\t*value = ctoGoString(&cValue[0])\n\tfreeCString(cKey)\n\treturn int(status)\n}", "func (o IopingSpecVolumeVolumeSourceRbdOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IopingSpecVolumeVolumeSourceRbd) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (m *AgreementAcceptance) GetUserId()(*string) {\n return m.userId\n}", "func (o *Vm) GetUserMetadata() string {\n\tif o == nil || o.UserMetadata == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.UserMetadata\n}", "func (me *CONFIGURATION_IMPL) UserId() string{\r\n return me.user-id\r\n}", "func (c *client) getUserData(ctx context.Context) error {\n\tif c.delegate.usesAppsAuth {\n\t\tresp, err := c.GetAppWithContext(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tc.userData = &UserData{\n\t\t\tName: resp.Name,\n\t\t\tLogin: resp.Slug,\n\t\t\tEmail: fmt.Sprintf(\"%[email protected]\", resp.Slug),\n\t\t}\n\t\treturn nil\n\t}\n\tc.log(\"User\")\n\tvar u User\n\t_, err := c.requestWithContext(ctx, &request{\n\t\tmethod: http.MethodGet,\n\t\tpath: \"/user\",\n\t\texitCodes: []int{200},\n\t}, &u)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.userData = &UserData{\n\t\tName: u.Name,\n\t\tLogin: u.Login,\n\t\tEmail: u.Email,\n\t}\n\t// email needs to be publicly accessible via the profile\n\t// of the current account. Read below for more info\n\t// https://developer.github.com/v3/users/#get-a-single-user\n\n\t// record information for the user\n\tauthHeaderHash := fmt.Sprintf(\"%x\", sha256.Sum256([]byte(c.authHeader()))) // use %x to make this a utf-8 string for use as a label\n\tuserInfo.With(prometheus.Labels{\"token_hash\": authHeaderHash, \"login\": c.userData.Login, \"email\": c.userData.Email}).Set(1)\n\treturn nil\n}", "func (o AzureSqlReferenceInputDataSourcePropertiesResponsePtrOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AzureSqlReferenceInputDataSourcePropertiesResponse) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.User\n\t}).(pulumi.StringPtrOutput)\n}", "func GetCurrentUser(ctx context.Context) string {\n\treturn ctx.Value(userIdKey).(string)\n}", "func (settings *Settings) GetMCPUser() string {\n\treturn settings.McpUser\n}", "func (*InstUIToFP) isValue() {}", "func (u *User) ID() string { return u.userData.ID.Hex() }", "func (o *AccessRequestData) GetUserId() string {\n\tif o == nil || o.UserId == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.UserId\n}", "func (m Logon) GetRawData() (v string, err quickfix.MessageRejectError) {\n\tvar f field.RawDataField\n\tif err = m.Get(&f); err == nil {\n\t\tv = f.Value()\n\t}\n\treturn\n}", "func (_Smartchef *SmartchefCaller) UserInfo(opts *bind.CallOpts, arg0 common.Address) (struct {\n\tAmount *big.Int\n\tRewardDebt *big.Int\n}, error) {\n\tret := new(struct {\n\t\tAmount *big.Int\n\t\tRewardDebt *big.Int\n\t})\n\tout := ret\n\terr := _Smartchef.contract.Call(opts, out, \"userInfo\", arg0)\n\treturn *ret, err\n}", "func (o AzureSqlReferenceInputDataSourcePropertiesPtrOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *AzureSqlReferenceInputDataSourceProperties) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.User\n\t}).(pulumi.StringPtrOutput)\n}", "func (c *ConfigurationData) GetCacheControlUser() string {\n\treturn c.v.GetString(varCacheControlUser)\n}", "func (u *UserService) Get(userID int32) *User {\n\treturn u.Dict[userID]\n}", "func (m *ImportedWindowsAutopilotDeviceIdentityState) GetAdditionalData()(map[string]any) {\n val , err := m.backingStore.Get(\"additionalData\")\n if err != nil {\n panic(err)\n }\n if val == nil {\n var value = make(map[string]any);\n m.SetAdditionalData(value);\n }\n return val.(map[string]any)\n}", "func GetUser() string {\n\tif cuser == \"\" {\n\t\tcuser = GetCmdStr(\"echo $USER\")\n\t}\n\tif cuser == \"\" {\n\t\tcuser = GetCmdStr(\"whoami\")\n\t}\n\treturn cuser\n}", "func (db *Ops) ReadUserData(ctx context.Context, artistPastelID string) (userdata.ProcessRequest, error) {\n\tcommand, err := substituteTemplate(db.queryTemplate, artistPastelID)\n\tif err != nil {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"error while subtitute template: %w\", err)\n\t}\n\n\tqueryResult, err := db.metaDB.Query(ctx, command, queryLevelNone)\n\tif err != nil {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"error while querying db: %w\", err)\n\t}\n\n\tnrows := queryResult.NumRows()\n\tif nrows == 0 {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"no artist with pastel id = %s\", artistPastelID)\n\t} else if nrows > 1 {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"upto %d records are returned\", nrows)\n\t}\n\n\t//right here we make sure that there is just 1 row in the result\n\tqueryResult.Next()\n\tresultMap, err := queryResult.Map()\n\tif err != nil {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"error while extracting result: %w\", err)\n\t}\n\n\tvar dbResult UserdataReadResult\n\tif err := mapstructure.Decode(resultMap, &dbResult); err != nil {\n\t\treturn userdata.ProcessRequest{}, errors.Errorf(\"error while decoding result: %w\", err)\n\t}\n\n\treturn dbResult.ToUserData(), nil\n}", "func getSysData(hwnd _HWND) *sysData {\n\treturn (*sysData)(unsafe.Pointer(getWindowLongPtr(hwnd, negConst(_GWLP_USERDATA))))\n}", "func (o *BasicBot) GetUserId() interface{} {\n\tif o == nil {\n\t\tvar ret interface{}\n\t\treturn ret\n\t}\n\treturn o.UserId\n}", "func (item *KVItem) UserMeta() byte {\n\treturn item.userMeta\n}", "func (p *EC2Provisioner) GetUser() string { return p.user }", "func GetCurrentUser(r *http.Request, ctx *handlers.Context) *users.User {\r\n\tsessionState := &handlers.SessionState{}\r\n\t_, err := sessions.GetState(r, ctx.SessionKey, ctx.SessionStore, sessionState)\r\n\tif err != nil {\r\n\t\tfmt.Printf(\"Error cannot get session state: \"+err.Error(), http.StatusUnauthorized)\r\n\t}\r\n\tsessionUser := sessionState.User\r\n\treturn sessionUser\r\n}", "func (o FioSpecVolumeVolumeSourceRbdOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v FioSpecVolumeVolumeSourceRbd) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func (w Watch) GetUserID() int64 {\n\tuserWatchIndex := watchIndex[w.ID]\n\tindexes := strings.Split(userWatchIndex, \"-\")\n\n\t// parse all index to integer\n\tuIndex, _ := strconv.Atoi(indexes[0])\n\n\treturn data.Users[uIndex].ID\n}", "func (o IopingSpecVolumeVolumeSourceQuobyteOutput) User() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v IopingSpecVolumeVolumeSourceQuobyte) *string { return v.User }).(pulumi.StringPtrOutput)\n}", "func testUserData(t *testing.T) {\n\tsigner, err := createSigner()\n\trequire.NoError(t, err, \"error creating signer using private key\")\n\tpubKeyBytes := ssh.MarshalAuthorizedKey(signer.PublicKey())\n\trequire.NotNil(t, pubKeyBytes, \"failed to retrieve public key using signer for private key\")\n\tfound := &core.Secret{}\n\terr = framework.Global.Client.Get(context.TODO(), kubeTypes.NamespacedName{Name: \"windows-user-data\", Namespace: \"openshift-machine-api\"}, found)\n\trequire.NoError(t, err, \"could not find Windows user data secret in required namespace\")\n\tassert.Contains(t, string(found.Data[\"userData\"][:]), string(pubKeyBytes[:]), \"expected user data not present in required namespace\")\n}", "func (_Smartchef *SmartchefCallerSession) UserInfo(arg0 common.Address) (struct {\n\tAmount *big.Int\n\tRewardDebt *big.Int\n}, error) {\n\treturn _Smartchef.Contract.UserInfo(&_Smartchef.CallOpts, arg0)\n}", "func GetValue(name string) (value interface{}, exists bool) {\n\tif log.RootLogger().TraceEnabled() {\n\t\tlog.RootLogger().Tracef(\"Getting App Value '%s': %v\", name)\n\t}\n\treturn appData.GetValue(name)\n}" ]
[ "0.6483064", "0.6465429", "0.643284", "0.6355805", "0.62308776", "0.6169278", "0.61169446", "0.61165094", "0.6091875", "0.6071054", "0.60605794", "0.59515584", "0.59476525", "0.5886042", "0.5807458", "0.5727947", "0.5686936", "0.5685083", "0.56633145", "0.5563138", "0.5507332", "0.5498811", "0.5478626", "0.5473799", "0.54668105", "0.54465455", "0.544624", "0.5415045", "0.5409775", "0.54010993", "0.53986937", "0.53949285", "0.538477", "0.5373326", "0.5366438", "0.53598857", "0.5357105", "0.5326754", "0.5322583", "0.53051454", "0.5302838", "0.52945995", "0.52812153", "0.52549326", "0.5252841", "0.5245787", "0.52345014", "0.5227099", "0.5225335", "0.52173203", "0.51966256", "0.51815397", "0.51800716", "0.51759356", "0.5168958", "0.51682097", "0.5167332", "0.5161341", "0.51601464", "0.5159644", "0.51545405", "0.51466954", "0.51425797", "0.5126706", "0.51214665", "0.51195425", "0.51096755", "0.51078933", "0.510501", "0.5102891", "0.50967157", "0.5092272", "0.5090061", "0.50804013", "0.5078321", "0.5069464", "0.5067522", "0.5060234", "0.50582856", "0.505807", "0.503102", "0.5022316", "0.5022029", "0.50219494", "0.50210625", "0.5016134", "0.50150317", "0.5012112", "0.50121033", "0.500407", "0.5002635", "0.49928066", "0.4991553", "0.4988222", "0.49844968", "0.49827096", "0.4978673", "0.4977864", "0.49723884", "0.49699426" ]
0.7204786
0
/ Metering. Enable metering for a DSP unit so that "DSP.MeteringInfo" will return metering information, and so that FMOD Studio profiler tool can visualize the levels. inputEnabled: Enable metering for the input signal (preprocessing). Specify true to turn on input level metering, false to turn it off. outputEnabled: Enable metering for the output signal (postprocessing). Specify true to turn on output level metering, false to turn it off. "INIT_PROFILE_METER_ALL" with "System.Init" will automatically turn on metering for all DSP units inside the FMOD mixer graph.
func (d *DSP) SetMeteringEnabled(inputEnabled, outputEnabled bool) error { res := C.FMOD_DSP_SetMeteringEnabled(d.cptr, getBool(inputEnabled), getBool(outputEnabled)) return errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *DSP) MeteringEnabled() (bool, bool, error) {\n\tvar inputEnabled, outputEnabled C.FMOD_BOOL\n\tres := C.FMOD_DSP_GetMeteringEnabled(d.cptr, &inputEnabled, &outputEnabled)\n\treturn setBool(inputEnabled), setBool(outputEnabled), errs[res]\n}", "func Meter(component interface{}, sampleRate signal.SampleRate) ResetFunc {\n\tt := getType(component)\n\tmetric := components.get(t)\n\tmetric.components.Add(1)\n\treturn func() MeasureFunc {\n\t\tcalledAt := time.Now()\n\t\tvar (\n\t\t\tbufferSize int\n\t\t\tbufferDuration time.Duration\n\t\t)\n\t\treturn func(s int) {\n\t\t\tmetric.latency.set(time.Since(calledAt))\n\t\t\tmetric.messages.Add(1)\n\t\t\tmetric.samples.Add(int64(s))\n\t\t\t// recalculate buffer duration only when buffer size has changed\n\t\t\tif bufferSize != s {\n\t\t\t\tbufferSize = s\n\t\t\t\tbufferDuration = sampleRate.DurationOf(s)\n\t\t\t}\n\t\t\tmetric.duration.add(bufferDuration)\n\t\t\tcalledAt = time.Now()\n\t\t}\n\t}\n}", "func (f *falconMeter) Update() {\n\tfalcon.SetMeterCount(f.name, 1)\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func (m *Manager) Meter(delay time.Duration) *Meter {\n\treturn &Meter{\n\t\tm: m,\n\t\tdelay: delay,\n\t\tnext: time.Now(),\n\t}\n}", "func (this *meterStruct) SetEnabled(value bool) {\n\tthis.mutex.Lock()\n\tenabled := this.enabled\n\n\t/*\n\t * Check if value must be changed.\n\t */\n\tif value != enabled {\n\t\tchannelMeters := this.channelMeters\n\n\t\t/*\n\t\t * Enable or disable each channel meter.\n\t\t */\n\t\tfor _, channelMeter := range channelMeters {\n\t\t\tchannelMeter.setEnabled(value)\n\t\t}\n\n\t\tthis.enabled = value\n\t}\n\n\tthis.mutex.Unlock()\n}", "func (this *meterStruct) Enabled() bool {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\treturn enabled\n}", "func (d *DSP) MeteringInfo() (DSPMeteringInfo, DSPMeteringInfo, error) {\n\tvar cinputInfo, coutputInfo C.FMOD_DSP_METERING_INFO\n\tvar inputInfo, outputInfo DSPMeteringInfo\n\tres := C.FMOD_DSP_GetMeteringInfo(d.cptr, &cinputInfo, &coutputInfo)\n\tinputInfo.fromC(cinputInfo)\n\toutputInfo.fromC(coutputInfo)\n\treturn inputInfo, outputInfo, errs[res]\n}", "func (this *channelMeterStruct) setEnabled(value bool) {\n\tthis.mutex.Lock()\n\tenabled := this.enabled\n\n\t/*\n\t * Check if status of meter must be changed.\n\t */\n\tif value != enabled {\n\n\t\t/*\n\t\t * If level meter should be disabled, clear state.\n\t\t */\n\t\tif !value {\n\t\t\tthis.currentValue = 0.0\n\t\t\tthis.peakValue = 0.0\n\t\t\tthis.sampleCounter = 0\n\t\t}\n\n\t\tthis.enabled = value\n\t}\n\n\tthis.mutex.Unlock()\n}", "func (m *MeterMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func Meter(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"meter\", Attributes: attrs, Children: children}\n}", "func InitMeter(db persistence.Conn) func() {\n\tcleanupFunc := func() {}\n\n\tmetricProvider := os.Getenv(\"METRIC_PROVIDER\")\n\tif metricProvider == \"\" {\n\t\tlog(nil, nil).Info(\"METRIC_PROVIDER not set, metrics will not be generated.\")\n\t\treturn cleanupFunc\n\t}\n\n\tvar err error\n\tswitch metricProvider {\n\tcase STDOUT, PRETTY:\n\t\tvar pusher *push.Controller\n\t\tpusher, err = metricstdout.InstallNewPipeline(metricstdout.Config{\n\t\t\tQuantiles: []float64{},\n\t\t\tPrettyPrint: metricProvider == PRETTY,\n\t\t}, push.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcleanupFunc = pusher.Stop\n\tcase PROMETHEUS:\n\t\tvar exporter *prometheus.Exporter\n\t\texporter, err = prometheus.InstallNewPipeline(prometheus.Config{}, pull.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\thttp.HandleFunc(\"/metrics\", exporter.ServeHTTP)\n\t\tgo func() {\n\t\t\t_ = http.ListenAndServe(\":2222\", nil)\n\t\t}()\n\tdefault:\n\t\tlog(nil, nil).WithField(\"provider\", metricProvider).Fatal(\"Unsupported metric provider\")\n\t}\n\n\tif err != nil {\n\t\tlog(nil, err).WithField(\"provider\", metricProvider).Fatal(\"failed to initialize metric stdout exporter\")\n\t}\n\n\tinitSystemStatsObserver(db)\n\n\treturn cleanupFunc\n}", "func NewMeter(name string) metics.Meter {\n\tif !Enabled {\n\t\treturn new(metics.NilMeter)\n\t}\n\treturn metics.GetOrRegisterMeter(name, metics.DefaultRegistry)\n}", "func Meter(props *MeterProps, children ...Element) *MeterElem {\n\trProps := &_MeterProps{\n\t\tBasicHTMLElement: newBasicHTMLElement(),\n\t}\n\n\tif props != nil {\n\t\tprops.assign(rProps)\n\t}\n\n\treturn &MeterElem{\n\t\tElement: createElement(\"meter\", rProps, children...),\n\t}\n}", "func meterReader(d *db.DB) error {\n\tsect := d.Config.GetSection(\"meter\")\n\tif sect == nil {\n\t\treturn nil\n\t}\n\tvar angle float64\n\ta, err := sect.GetArg(\"rotate\")\n\tif err == nil {\n\t\tangle, err = strconv.ParseFloat(a, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tsource, err := sect.GetArg(\"source\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tr, err := NewReader(sect, d.Trace)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.AddDiff(db.D_IN_POWER, time.Minute*5)\n\td.AddDiff(db.D_OUT_POWER, time.Minute*5)\n\td.AddAccum(db.A_IN_TOTAL, true)\n\td.AddAccum(db.A_OUT_TOTAL, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\tlog.Printf(\"Registered meter LCD reader\\n\")\n\tgo runReader(d, r, source, angle)\n\treturn nil\n}", "func (m *HistoMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func SetMeterProvider(mp metric.Provider) {\n\tglobalMeter.Store(meterProvider{mp: mp})\n}", "func (site *Site) updateMeter(name string, meter api.Meter, power *float64) error {\n\tvalue, err := meter.CurrentPower()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*power = value // update value if no error\n\n\tsite.log.DEBUG.Printf(\"%s power: %.0fW\", name, *power)\n\tsite.publish(name+\"Power\", *power)\n\n\treturn nil\n}", "func WithMeter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func (sd *stackediff) ProfilingEnable() {\n\tsd.profiletimer = profiletimer.StartProfileTimer()\n}", "func (c *Configuration) NewMeter(name string, options ...Option) (metric.Meter, error) {\n\tif !c.Enabled {\n\t\treturn metric.NoopProvider{}.Meter(name), nil\n\t}\n\n\tif c.AgentEndpoint == \"\" {\n\t\treturn metric.Meter{}, fmt.Errorf(\"missing agent address, please set environment variable %s\", envAgentEndpoint)\n\t}\n\n\topts := applyOptions(options...)\n\texporter := sotlp.SingletonExporter()\n\tif exporter == nil {\n\t\texp, err := otlp.NewExporter(otlp.WithInsecure(),\n\t\t\totlp.WithAddress(c.AgentEndpoint),\n\t\t\totlp.WithReconnectionPeriod(time.Minute),\n\t\t\totlp.WithGRPCDialOption(grpc.WithTimeout(5*time.Second)))\n\t\tif err != nil {\n\t\t\treturn metric.Meter{}, fmt.Errorf(\"failed to create the collector exporter: %w\", err)\n\t\t}\n\t\texporter = exp\n\t\tsotlp.SetExporter(exporter)\n\t\topts.Logger.With(zap.String(\"agentEndpoint\", c.AgentEndpoint)).Info(\"success to otlp agent\")\n\t}\n\t// exporter.Stop()\n\n\tif meterPusher == nil {\n\t\tmeterPusher = push.New(\n\t\t\tbasic.New(\n\t\t\t\tsimple.NewWithExactDistribution(),\n\t\t\t\texporter,\n\t\t\t),\n\t\t\texporter,\n\t\t\tpush.WithPeriod(30*time.Second),\n\t\t\t//push.WithTimeout(10*time.Second),\n\t\t)\n\t\tmeterProvider = meterPusher.Provider()\n\t\tmeterPusher.Start()\n\t\topts.Logger.With(zap.String(\"agentEndpoint\", c.AgentEndpoint)).Info(\"success to create metric pusher and start to push metric\")\n\t}\n\n\treturn meterProvider.Meter(name), nil\n}", "func MeterProvider() metric.Provider {\n\tif gp := globalMeter.Load(); gp != nil {\n\t\treturn gp.(meterProvider).mp\n\t}\n\treturn metric.NoopProvider{}\n}", "func WithMeterProvider(provider metric.MeterProvider) Option {\n\treturn optionFunc(func(c *config) {\n\t\tif provider != nil {\n\t\t\tc.meterProvider = provider\n\t\t}\n\t})\n}", "func (em *MultiFactorDUO) Enable(enabled bool) error {\n\treturn em.m.put(em.m.uri(\"guardian\", \"factors\", \"duo\"), &MultiFactor{\n\t\tEnabled: &enabled,\n\t})\n}", "func (s *Systemctl) Start(acc telegraf.Accumulator) error {\n\t// lock the function\n\ts.mux.Lock()\n\t// release the lock at the end of the function\n\tdefer s.mux.Unlock()\n\t// check that the sampler has been initiatised\n\tif s.Sampler == nil {\n\t\treturn errors.New(\"Systemctl.Sampler has not been set\")\n\t}\n\t// check the sampler is not already running\n\tif s.running {\n\t\treturn nil\n\t}\n\n\tSetLogLevel(s.LogLevel)\n\tlog.WithFields(log.Fields{\n\t\t\"InputPlugin\": \"systemctl\",\n\t}).Debug(\"Starting\")\n\n\t// check the sample has not already initalised the aggregators\n\tif s.Aggregators == nil {\n\t\t// create an aggregator for each service defined within the configuration\n\t\tserviceCount := len(s.Services)\n\t\ts.Aggregators = make([]StateAggregator, serviceCount)\n\t\tfor i, service := range s.Services {\n\t\t\ts.Aggregators[i] = StateAggregator{\n\t\t\t\tResourceName: service,\n\t\t\t\tAggState: make(map[string]uint64),\n\t\t\t\tCurrentState: \"unknown\",\n\t\t\t\tCurrentStateDuration: 0,\n\t\t\t\tStateCollector: Collector{\n\t\t\t\t\tSampleRate: s.SampleRate,\n\t\t\t\t\tDone: make(chan bool),\n\t\t\t\t\tCollect: make(chan bool),\n\t\t\t\t\tSampleResults: make(chan []Sample),\n\t\t\t\t},\n\t\t\t}\n\t\t\t// start collecting samples for each aggregator in a separate go routine\n\t\t\t// providing the service name and the sampler used to collect data\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"InputPlugin\": \"systemctl\",\n\t\t\t\t\"ResourceName\": service,\n\t\t\t}).Debug(\"Starting CollectSamples\")\n\t\t\tgo s.Aggregators[i].StateCollector.CollectSamples(service, s.Sampler)\n\t\t}\n\t}\n\n\t// set the state that the input plugin has started\n\ts.running = true\n\n\tlog.WithFields(log.Fields{\n\t\t\"InputPlugin\": \"systemctl\",\n\t}).Debug(\"Started\")\n\n\treturn nil\n}", "func Start(opts ...Option) error {\n\tcfg := newConfig(opts...)\n\tif cfg.MeterProvider == nil {\n\t\tcfg.MeterProvider = otel.GetMeterProvider()\n\t}\n\tc, err := newCputime(cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.register()\n}", "func NewMeterProvider() *MeterProvider {\n\treturn &MeterProvider{}\n}", "func (s *Tplink) GetMeterInto() (SysInfo, error) {\n\tvar (\n\t\tpayload meterInfo\n\t\tjsonResp SysInfo\n\t)\n\n\tj, _ := json.Marshal(payload)\n\n\tdata := encrypt(string(j))\n\tresp, err := send(s.Host, data)\n\tif err != nil {\n\t\treturn jsonResp, err\n\t}\n\n\tif err := json.Unmarshal([]byte(decrypt(resp)), &jsonResp); err != nil {\n\t\treturn jsonResp, err\n\t}\n\treturn jsonResp, nil\n}", "func init() {\n\tfor _, arg := range os.Args {\n\t\tif flag := strings.TrimLeft(arg, \"-\"); flag == MetricsEnabledFlag || flag == DashboardEnabledFlag {\n\t\t\tbgmlogs.Info(\"Enabling metics collection\")\n\t\t\tEnabled = true\n\t\t}\n\t}\n\texp.Exp(metics.DefaultRegistry)\n}", "func (p *ProgressMeter) Start() {\n\tif atomic.CompareAndSwapInt32(&p.started, 0, 1) {\n\t\tgo p.writer()\n\t}\n}", "func (f *flusher) FlushMeter(m Meter) {\n\tf.mu.Lock()\n\tm.FlushReading(f.sink)\n\tf.mu.Unlock()\n}", "func metricEnabled() bool {\n\treturn enabled\n}", "func NewMeter(name string, options ...Option) Meter {\n\treturn newMeter(name, options...)\n}", "func (telemetry *Telemetry) startTelemetryTicker(cfg map[string]interface{}, debug bool) {\n\t// for some reason map[string]interface{} thinks value is float64\n\tcheckTelemetryTimer := cfg[\"checkTelemetryTimer\"].(float64)\n\tduration := 0\n\n\tticker := time.NewTicker(time.Duration(1 * time.Second))\n\tlog.Printf(\"[INFO] Telemetry check every %d seconds\\n\", int(checkTelemetryTimer))\n\ttelemetry.init(true)\n\tdone := make(chan bool)\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\treturn\n\t\t\tcase <-ticker.C:\n\t\t\t\tif duration > int(checkTelemetryTimer) {\n\t\t\t\t\tif len(telemetry.datasets) > 0 {\n\t\t\t\t\t\tlog.Println(\"[INFO] Telemetry check\")\n\t\t\t\t\t\ttelemetry.CheckDatasetTelemetry()\n\t\t\t\t\t\t// telemetry.CheckSensorsTelemetry()\n\t\t\t\t\t}\n\t\t\t\t\tduration = 0\n\t\t\t\t}\n\t\t\t\t// controllers require extra precision so a check is done every second\n\t\t\t\ttelemetry.CheckControllersTelemetry()\n\t\t\t\tduration++\n\t\t\t}\n\t\t}\n\t}()\n}", "func (d *cudaDevice) IsMigEnabled() (bool, error) {\n\treturn false, nil\n}", "func startTelemetry(c *config) {\n\tif telemetry.Disabled() {\n\t\t// Do not do extra work populating config data if instrumentation telemetry is disabled.\n\t\treturn\n\t}\n\tprofileEnabled := func(t ProfileType) bool {\n\t\t_, ok := c.types[t]\n\t\treturn ok\n\t}\n\tconfigs := []telemetry.Configuration{}\n\ttelemetry.GlobalClient.ProductStart(telemetry.NamespaceProfilers,\n\t\tappend(configs, []telemetry.Configuration{\n\t\t\t{Name: \"delta_profiles\", Value: c.deltaProfiles},\n\t\t\t{Name: \"agentless\", Value: c.agentless},\n\t\t\t{Name: \"profile_period\", Value: c.period.String()},\n\t\t\t{Name: \"cpu_duration\", Value: c.cpuDuration.String()},\n\t\t\t{Name: \"cpu_profile_rate\", Value: c.cpuProfileRate},\n\t\t\t{Name: \"block_profile_rate\", Value: c.blockRate},\n\t\t\t{Name: \"mutex_profile_fraction\", Value: c.mutexFraction},\n\t\t\t{Name: \"max_goroutines_wait\", Value: c.maxGoroutinesWait},\n\t\t\t{Name: \"cpu_profile_enabled\", Value: profileEnabled(CPUProfile)},\n\t\t\t{Name: \"heap_profile_enabled\", Value: profileEnabled(HeapProfile)},\n\t\t\t{Name: \"block_profile_enabled\", Value: profileEnabled(BlockProfile)},\n\t\t\t{Name: \"mutex_profile_enabled\", Value: profileEnabled(MutexProfile)},\n\t\t\t{Name: \"goroutine_profile_enabled\", Value: profileEnabled(GoroutineProfile)},\n\t\t\t{Name: \"goroutine_wait_profile_enabled\", Value: profileEnabled(expGoroutineWaitProfile)},\n\t\t\t{Name: \"upload_timeout\", Value: c.uploadTimeout.String()},\n\t\t\t{Name: \"execution_trace_enabled\", Value: c.traceConfig.Enabled},\n\t\t\t{Name: \"execution_trace_period\", Value: c.traceConfig.Period.String()},\n\t\t\t{Name: \"execution_trace_size_limit\", Value: c.traceConfig.Limit},\n\t\t\t{Name: \"endpoint_count_enabled\", Value: c.endpointCountEnabled},\n\t\t}...))\n}", "func WithMeterProvider(provider metric.MeterProvider) Option {\n\treturn metricProviderOption{provider}\n}", "func (this *meterStruct) Process(buffers [][]float64, sampleRate uint32) error {\n\tchannelMeters := this.channelMeters\n\tnumChannels := len(channelMeters)\n\tnumBuffers := len(buffers)\n\n\t/*\n\t * Make sure that the correct number of buffers is provided.\n\t */\n\tif numChannels != numBuffers {\n\t\treturn fmt.Errorf(\"Number of input buffers (%d) does not match number of channels (%d) for this level meter.\", numBuffers, numChannels)\n\t} else {\n\n\t\t/*\n\t\t * Feed input from each channel to the corresponding level meter.\n\t\t */\n\t\tfor i, buffer := range buffers {\n\t\t\tchannelMeter := channelMeters[i]\n\t\t\tchannelMeter.process(buffer, sampleRate)\n\t\t}\n\n\t\treturn nil\n\t}\n\n}", "func (mi MeterInfo) MarshalJSON() ([]byte, error) {\n\tobjectMap := make(map[string]interface{})\n\tif mi.MeterID != nil {\n\t\tobjectMap[\"MeterId\"] = mi.MeterID\n\t}\n\tif mi.MeterName != nil {\n\t\tobjectMap[\"MeterName\"] = mi.MeterName\n\t}\n\tif mi.MeterCategory != nil {\n\t\tobjectMap[\"MeterCategory\"] = mi.MeterCategory\n\t}\n\tif mi.MeterSubCategory != nil {\n\t\tobjectMap[\"MeterSubCategory\"] = mi.MeterSubCategory\n\t}\n\tif mi.Unit != nil {\n\t\tobjectMap[\"Unit\"] = mi.Unit\n\t}\n\tif mi.MeterTags != nil {\n\t\tobjectMap[\"MeterTags\"] = mi.MeterTags\n\t}\n\tif mi.MeterRegion != nil {\n\t\tobjectMap[\"MeterRegion\"] = mi.MeterRegion\n\t}\n\tif mi.MeterRates != nil {\n\t\tobjectMap[\"MeterRates\"] = mi.MeterRates\n\t}\n\tif mi.EffectiveDate != nil {\n\t\tobjectMap[\"EffectiveDate\"] = mi.EffectiveDate\n\t}\n\tif mi.IncludedQuantity != nil {\n\t\tobjectMap[\"IncludedQuantity\"] = mi.IncludedQuantity\n\t}\n\treturn json.Marshal(objectMap)\n}", "func Enable(b bool) func() {\n\tif !b {\n\t\tenabled = false\n\t\treturn func() {}\n\t}\n\tenabled = true\n\tregisterAll()\n\treturn printMetrics\n}", "func (b *Basic) EnableMetrics(collector MetricsCollector, updateFreqMillis int64) error {\n\tname := fmt.Sprintf(\"%v\", b)\n\n\tb.mux.Lock()\n\tdefer b.mux.Unlock()\n\n\tb.metrics = true\n\tb.metricsUpdateFreqMillis = updateFreqMillis\n\n\tvar err error\n\n\tif b.queueSizeGauge, err = collector.QueueSizeGauge(name); err != nil {\n\t\treturn err\n\t}\n\tif b.loggedCounter, err = collector.LoggedCounter(name); err != nil {\n\t\treturn err\n\t}\n\tif b.errorCounter, err = collector.ErrorCounter(name); err != nil {\n\t\treturn err\n\t}\n\tif b.droppedCounter, err = collector.DroppedCounter(name); err != nil {\n\t\treturn err\n\t}\n\tif b.blockedCounter, err = collector.BlockedCounter(name); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (sm *MultiFactorSMS) Enable(enabled bool) error {\n\treturn sm.m.put(sm.m.uri(\"guardian\", \"factors\", \"sms\"), &MultiFactor{\n\t\tEnabled: &enabled,\n\t})\n}", "func (p *Profile) Start() error {\n\tsuccess, err := C.MXSetProfilerState(C.int(1))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif success != 0 {\n\t\treturn GetLastError()\n\t}\n\tp.startTime = time.Now()\n\tp.started = true\n\n\treturn nil\n}", "func (p *Profile) Start() error {\n\tsuccess, err := C.MXSetProfilerState(C.int(1))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif success != 0 {\n\t\treturn GetLastError()\n\t}\n\tp.startTime = time.Now()\n\tp.started = true\n\n\treturn nil\n}", "func (o DeviceDexTestOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v *DeviceDexTest) pulumi.BoolOutput { return v.Enabled }).(pulumi.BoolOutput)\n}", "func Enable() {\n\tenableOutput = true\n}", "func (em *MultiFactorOTP) Enable(enabled bool) error {\n\treturn em.m.put(em.m.uri(\"guardian\", \"factors\", \"otp\"), &MultiFactor{\n\t\tEnabled: &enabled,\n\t})\n}", "func (o ArgoCDSpecPrometheusOutput) Enabled() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecPrometheus) bool { return v.Enabled }).(pulumi.BoolOutput)\n}", "func InitGameProfilers() {\r\n\tupdateProfiler = system.NewProfiler(\"update\")\r\n\tcollisionProfiler = system.NewProfiler(\"collision\")\r\n\tmusicProfiler = system.NewProfiler(\"music\")\r\n\tweatherProfiler = system.NewProfiler(\"weather\")\r\n\tgameModeProfiler = system.NewProfiler(\"gameMode\")\r\n\tdrawProfiler = system.NewProfiler(\"draw\")\r\n\tsortRenderProfiler = system.NewProfiler(\"sortRender\")\r\n\tcullRenderProfiler = system.NewProfiler(\"cullRender\")\r\n\tlightingProfiler = system.NewProfiler(\"lighting\")\r\n\tscriptingProfiler = system.NewProfiler(\"scripting\")\r\n\r\n\tframeRateString = \"total time: 0 ms (0 FPS)\"\r\n\totherTimeString = \"measured time: 0 ms\"\r\n}", "func NewMeter(options ...meterOption) *ProgressMeter {\n\tm := &ProgressMeter{\n\t\tlogger: &progressLogger{},\n\t\tstartTime: time.Now(),\n\t\tfileIndex: make(map[string]int64),\n\t\tfileIndexMutex: &sync.Mutex{},\n\t\tfinished: make(chan interface{}),\n\t}\n\n\tfor _, opt := range options {\n\t\topt(m)\n\t}\n\n\treturn m\n}", "func MeasureWorker(channel chan Measurement, adc adcpi.Interface, flexingChannel byte, extendingChannel byte,\n speedChannel byte, speed int, interval float64) {\n\n // Measure data and write it to the channel\n // Passing true to the for loop creates an infinite loop that never stops, unless\n // The program is terminated.\n for true {\n\n // Read from the flexing muscle\n flexing := adc.ReadRaw(flexingChannel)\n\n // Read from the extending muscle\n extending := adc.ReadRaw(extendingChannel)\n\n // Read the speed value from a potentiometer, if dynamic speed is enabled\n if speed < 0 {\n speed = adc.ReadRaw(speedChannel)\n }\n\n // Send the values to the motor thread\n channel <- Measurement{ Flexing:flexing, Extending:extending, Speed:speed }\n\n // Wait for a certain amount of time\n time.Sleep(time.Duration(interval * 1000 * 1000 * 1000))\n }\n}", "func (p *PWMPin) Enabled() (bool, error) {\n\treturn p.enabled, nil\n}", "func (c *Easee) Enable(enable bool) error {\n\tc.mux.Lock()\n\tenablingRequired := enable && !c.chargerEnabled\n\tc.mux.Unlock()\n\n\t// enable charger once if it's switched off\n\tif enablingRequired {\n\t\tdata := easee.ChargerSettings{\n\t\t\tEnabled: &enable,\n\t\t}\n\n\t\turi := fmt.Sprintf(\"%s/chargers/%s/settings\", easee.API, c.charger)\n\t\tif _, err := c.postJSONAndWait(uri, data); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// do not send pause/resume if disconnected or unauthenticated\n\tif c.opMode == easee.ModeDisconnected || c.opMode == easee.ModeAwaitingAuthentication {\n\t\treturn nil\n\t}\n\n\t// resume/stop charger\n\taction := easee.ChargePause\n\tvar expectedEnabledState bool\n\tvar targetCurrent float64\n\tif enable {\n\t\taction = easee.ChargeResume\n\t\texpectedEnabledState = true\n\t\ttargetCurrent = 32\n\t}\n\n\turi := fmt.Sprintf(\"%s/chargers/%s/commands/%s\", easee.API, c.charger, action)\n\t_, err := c.postJSONAndWait(uri, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.waitForChargerEnabledState(expectedEnabledState); err != nil {\n\t\treturn err\n\t}\n\tif err := c.waitForDynamicChargerCurrent(targetCurrent); err != nil {\n\t\treturn err\n\t}\n\n\tif enable {\n\t\t// reset currents after enable, as easee automatically resets to maxA\n\t\treturn c.MaxCurrent(int64(c.current))\n\t}\n\n\treturn nil\n}", "func (a *Adapter) Enable() error {\n\tif a.poweredChan != nil {\n\t\treturn errors.New(\"already calling Enable function\")\n\t}\n\n\t// wait until powered\n\ta.poweredChan = make(chan error, 1)\n\n\ta.cmd = &centralManagerDelegate{a: a}\n\ta.cm.SetDelegate(a.cmd)\n\n\tif a.cm.State() != cbgo.ManagerStatePoweredOn {\n\t\tselect {\n\t\tcase <-a.poweredChan:\n\t\tcase <-time.NewTimer(10 * time.Second).C:\n\t\t\treturn errors.New(\"timeout enabling CentralManager\")\n\t\t}\n\t}\n\n\t// drain any extra powered-on events from channel\n\tfor len(a.poweredChan) > 0 {\n\t\t<-a.poweredChan\n\t}\n\n\t// wait until powered?\n\ta.pmd = &peripheralManagerDelegate{a: a}\n\ta.pm.SetDelegate(a.pmd)\n\n\treturn nil\n}", "func EnableProfiling() {\n\truntime.SetBlockProfileRate(1000)\n\truntime.SetCPUProfileRate(1000)\n\truntime.SetMutexProfileFraction(10)\n\truntime.MemProfileRate = 10\n}", "func Metal(index int32) Device {\n return Device{KDLMetal, index}\n}", "func (p *hardwareProfiler) Profile() (*HardwareProfile, error) {\n\tvar err error\n\thwProfile := &HardwareProfile{}\n\tfor profilerType, profiler := range p.profilers {\n\t\tprofileVal, err2 := profiler.Profile()\n\t\terr = multierr.Append(err, err2)\n\t\tif err2 == nil {\n\t\t\tif hwProfile.TimeEnabled == nil {\n\t\t\t\thwProfile.TimeEnabled = &profileVal.TimeEnabled\n\t\t\t}\n\t\t\tif hwProfile.TimeRunning == nil {\n\t\t\t\thwProfile.TimeRunning = &profileVal.TimeRunning\n\t\t\t}\n\t\t\tswitch profilerType {\n\t\t\tcase unix.PERF_COUNT_HW_CPU_CYCLES:\n\t\t\t\thwProfile.CPUCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_INSTRUCTIONS:\n\t\t\t\thwProfile.Instructions = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_REFERENCES:\n\t\t\t\thwProfile.CacheRefs = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_MISSES:\n\t\t\t\thwProfile.CacheMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_INSTRUCTIONS:\n\t\t\t\thwProfile.BranchInstr = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_MISSES:\n\t\t\t\thwProfile.BranchMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BUS_CYCLES:\n\t\t\t\thwProfile.BusCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_FRONTEND:\n\t\t\t\thwProfile.StalledCyclesFrontend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_BACKEND:\n\t\t\t\thwProfile.StalledCyclesBackend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_REF_CPU_CYCLES:\n\t\t\t\thwProfile.RefCPUCycles = &profileVal.Value\n\t\t\t}\n\t\t}\n\t}\n\tif len(multierr.Errors(err)) == len(p.profilers) {\n\t\treturn nil, err\n\t}\n\n\treturn hwProfile, nil\n}", "func Info(cmdTag, format string, a ...interface{}) {\n\tfmt.Printf(format+\"\\n\", a...)\n\tif level < LevelInfo || !logging {\n\t\treturn\n\t}\n\tif _, ok := cmdMap[cmdTag]; !ok {\n\t\tcmdTag = Mixer\n\t}\n\tlogTag(\"INF\", cmdTag, format, a...)\n}", "func init() {\n\n\t// cpu\n\tRegistryMetricCreateInput(\"cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"mem\", \"Memory\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\t// vm_cpu\n\tRegistryMetricCreateInput(\"vm_cpu\", \"Guest CPU usage\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_pcore\", \"CPU utilization rate per core\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_idle_pcore\", \"CPU idle rate per core\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_system\", \"CPU system state time\", monitor.METRIC_UNIT_MS, 4),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_user\", \"CPU user state time\", monitor.METRIC_UNIT_MS, 5),\n\t\t\tnewMetricFieldCreateInput(\"thread_count\", \"The number of threads used by the process\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t})\n\n\t// vm_diskio\n\tRegistryMetricCreateInput(\"vm_diskio\", \"Guest disk traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BYTEPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BYTEPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\n\t// vm_mem\n\tRegistryMetricCreateInput(\"vm_mem\", \"Guest memory\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"vms\", \"Virtual memory consumption\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"rss\", \"Actual use of physical memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t})\n\n\t// vm_netio\n\tRegistryMetricCreateInput(\"vm_netio\", \"Guest network traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// oss_latency\n\tRegistryMetricCreateInput(\"oss_latency\", \"Object storage latency\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_late\", \"Request average E2E delay\", monitor.METRIC_UNIT_MS, 1),\n\t\t})\n\n\t// oss_netio\n\tRegistryMetricCreateInput(\"oss_netio\", \"Object storage network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Receive byte\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send byte\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t})\n\n\t// oss_req\n\tRegistryMetricCreateInput(\"oss_req\", \"Object store request\", monitor.METRIC_RES_TYPE_OSS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_count\", \"request count\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// rds_conn\n\tRegistryMetricCreateInput(\"rds_conn\", \"Rds connect\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_cpu\n\tRegistryMetricCreateInput(\"rds_cpu\", \"Rds CPU usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t})\n\n\t// rds_mem\n\tRegistryMetricCreateInput(\"rds_mem\", \"Rds memory\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_netio\n\tRegistryMetricCreateInput(\"rds_netio\", \"Rds network traffic\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// rds_disk\n\tRegistryMetricCreateInput(\"rds_disk\", \"Rds disk usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_cpu\n\tRegistryMetricCreateInput(\"dcs_cpu\", \"Redis CPU usage\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_percent\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_mem\n\tRegistryMetricCreateInput(\"dcs_mem\", \"Redis memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_netio\n\tRegistryMetricCreateInput(\"dcs_netio\", \"Redis network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// dcs_conn\n\tRegistryMetricCreateInput(\"dcs_conn\", \"Redis connect\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_instantopt\n\tRegistryMetricCreateInput(\"dcs_instantopt\", \"Redis operator\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"opt_sec\", \"Number of commands processed per second\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_cachekeys\n\tRegistryMetricCreateInput(\"dcs_cachekeys\", \"Redis keys\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 6, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"key_count\", \"Number of cache keys\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_datamem\n\tRegistryMetricCreateInput(\"dcs_datamem\", \"Redis data memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_byte\", \"Data node memory usage\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t})\n\n\t// cloudaccount_balance\n\tRegistryMetricCreateInput(\"cloudaccount_balance\", \"Cloud account balance\",\n\t\tmonitor.METRIC_RES_TYPE_CLOUDACCOUNT,\n\t\tmonitor.METRIC_DATABASE_METER, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"balance\", \"balance\", monitor.METRIC_UNIT_RMB, 1),\n\t\t})\n\n\t// cpu\n\tRegistryMetricCreateInput(\"agent_cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"agent_disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"agent_diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"agent_mem\", \"Memory\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"agent_net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\tRegistryMetricCreateInput(\"storage\", \"Storage usage\",\n\t\tmonitor.METRIC_RES_TYPE_STORAGE, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"Storage utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free storage\", monitor.METRIC_UNIT_MB, 2),\n\t\t})\n\n\t//jenkins\n\tRegistryMetricCreateInput(\"jenkins_node\", \"jenkins node\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"disk_available\", \"disk_available\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"temp_available\", \"temp_available\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"memory_available\", \"memory_available\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"memory_total\", \"memory_total\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"swap_available\", \"swap_available\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"swap_total\", \"swap_total\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\tRegistryMetricCreateInput(\"jenkins_job\", \"jenkins job\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"duration\", \"duration\", monitor.METRIC_UNIT_MS, 1),\n\t\t\tnewMetricFieldCreateInput(\"number\", \"number\", monitor.METRIC_UNIT_COUNT, 2),\n\t\t})\n\n}", "func enablePrometheusOutput(req *http.Request) bool {\n\tif format := req.URL.Query().Get(\"format\"); format == \"prometheus\" {\n\t\treturn true\n\t}\n\treturn false\n}", "func Start(meter metric.Meter, interval time.Duration) error {\n\tr := &runtime{\n\t\tmeter: meter,\n\t\tinterval: interval,\n\t}\n\treturn r.register()\n}", "func (inj *Injector) UpdateSpeed() bool {\n\tsumVusers := int64(0)\n\tcSec := (int64)(time.Now().Sub(inj.startTime) / time.Second) //#sec after start of the test\n\tif cSec > inj.rampDuration {\n\t\t//fmt.Printf(\"Run lasted: %d and rampDuration %d \\n\", cSec, inj.rampDuration)\n\t\treturn false\n\t}\n\n\tfor v := 0; v < len(inj.ramp); v += 2 {\n\t\tcStepRate := inj.ramp[v]\n\t\tcStepDura := inj.ramp[v+1]\n\t\t//fmt.Printf(\"UpdateSpeed v=%d Rate=%d Duration=%d cSec=%d, sumVusers=%d\\n\", v, cStepRate, cStepDura, cSec, sumVusers)\n\n\t\tif cSec > cStepDura {\n\t\t\tsumVusers += cStepRate * cStepDura\n\t\t\tcSec -= cStepDura\n\t\t} else {\n\t\t\tsumVusers += cStepRate * cSec\n\t\t\t//fmt.Println(\"We break here\")\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\tdelta := sumVusers - int64(len(inj.Users))\n\t//fmt.Printf(\"Elapsed time(s):%d Computed Requested Vusers: %d, Current Vusers :%d, we need to add:%d\\n\", cSec, sumVusers, int64(len(inj.Users)), delta)\n\n\tfor i := int64(0); i < delta; i++ {\n\t\tu := NewIuser(inj)\n\t\tinj.Users = append(inj.Users, u)\n\n\t\t// Instanciate plugin instance for every VU\n\t\ts1, err := inj.plugin.Lookup(\"NewScenario\")\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Damned, no 'scenario' in .so script\")\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\ts2, ok := s1.(func(*Iuser) Iscenario)\n\t\t//fmt.Printf(\"result: %T %v %v\\n\", s2, s2, ok)\n\n\t\tif !ok {\n\t\t\tfmt.Println(\"unexpected type from module symbol\")\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\t// Instanciate a new scenario for the user\n\t\tu.Scenario = s2(u)\n\n\t\t// This is our first user, run InitOnce\n\t\tif len(inj.Users) == 1 {\n\t\t\tu.DoInitOnce()\n\t\t}\n\t\tu.DoInit()\n\t\tgo u.DoRun()\n\t}\n\n\treturn true\n\n}", "func (d *Device) startOutputEnableTimer() {\n\tcount := d.brightness << d.colorBit\n\tfor i := uint32(0); i < count; i++ {\n\t\td.oe.Low()\n\t}\n\td.oe.High()\n}", "func (ut *utilizationTracker) Start() error {\n\tut.Lock()\n\tdefer ut.Unlock()\n\n\tif ut.started {\n\t\treturn fmt.Errorf(\"Attempted to use UtilizationTracker.Start() when the tracker was already started\")\n\t}\n\n\tif ut.stopped {\n\t\treturn fmt.Errorf(\"Attempted to use UtilizationTracker.Start() after the tracker was stopped\")\n\t}\n\n\t// Initialize the worker expvar\n\texpvars.SetWorkerStats(\n\t\tut.workerName,\n\t\t&expvars.WorkerStats{\n\t\t\tUtilization: 0,\n\t\t},\n\t)\n\n\t// Start the ticker\n\terr := ut.utilizationStats.Start(ut.pollingFunc, ut.statsUpdateFunc)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tut.started = true\n\n\treturn nil\n}", "func (w *Writer) WriteMeter() (n int, d time.Duration) {\n\tw.Lock()\n\tdefer w.Unlock()\n\n\tn = w.n\n\td = w.d\n\tw.n = 0\n\tw.d = 0\n\treturn\n}", "func (s *HelloSystem) Enabled() bool {\n return s.enabled\n}", "func (this *Stats) InputBitRate() float32 { return float32(this.ptr.f_input_bitrate) }", "func (self *TileSprite) SetInputEnabledA(member bool) {\n self.Object.Set(\"inputEnabled\", member)\n}", "func (e *Engine) SetDevices(inputDeviceInfo, outputDeviceInfo *portaudio.DeviceInfo) error {\n\tif !e.initialized {\n\t\treturn errorEngineNotInitialized\n\t}\n\t// create a new (low latency) stream parameter configuration.\n\t// Hopefully you (at least) passed in an output device, otherwise\n\t// Start() will blow up later)\n\tstreamParameters := portaudio.LowLatencyParameters(inputDeviceInfo, outputDeviceInfo)\n\t// copy the relevant old stream parameter values into the new stream\n\t// parameter values\n\tstreamParameters.SampleRate = e.streamParameters.SampleRate\n\tstreamParameters.FramesPerBuffer = e.streamParameters.FramesPerBuffer\n\t// force stereo output. NB, the output device *must* support stereo\n\t// (otherwise this entire library will not work) if it doesn't support\n\t// stereo, well, you'll find out when Start() is called won't you\n\tstreamParameters.Output.Channels = 2\n\t// if we acquired an input device\n\tif streamParameters.Input.Device != nil {\n\t\t// prefer stereo input (if it has >2 possible channels)\n\t\tif streamParameters.Input.Device.MaxInputChannels >= 2 {\n\t\t\tstreamParameters.Input.Channels = 2\n\t\t}\n\t\t// else there's only mono input, and it's set already (I think)\n\t}\n\t// update the stream parameters\n\te.streamParameters = streamParameters\n\treturn nil\n}", "func (this *channelMeterStruct) process(buffer []float64, sampleRate uint32) {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\n\t/*\n\t * Only perform processing if this channel is enabled.\n\t */\n\tif enabled {\n\t\tthis.mutex.RLock()\n\t\tcurrentValue := this.currentValue\n\t\tpeakValue := this.peakValue\n\t\tsampleCounter := this.sampleCounter\n\t\tthis.mutex.RUnlock()\n\t\tsampleRateFloat := float64(sampleRate)\n\t\tholdTimeSamples := uint64(PEAK_HOLD_TIME_SECONDS * sampleRateFloat)\n\t\tdecayExp := -1.0 / (TIME_CONSTANT * sampleRateFloat)\n\t\tdecayFactor := math.Pow(10.0, decayExp)\n\n\t\t/*\n\t\t * Process each sample.\n\t\t */\n\t\tfor _, sample := range buffer {\n\t\t\tcurrentValue *= decayFactor\n\n\t\t\t/*\n\t\t\t * If we're above the hold time, let the peak indicator decay,\n\t\t\t * otherwise increment sample counter.\n\t\t\t */\n\t\t\tif sampleCounter > holdTimeSamples {\n\t\t\t\tpeakValue *= decayFactor\n\t\t\t} else {\n\t\t\t\tsampleCounter++\n\t\t\t}\n\n\t\t\tsampleAbs := math.Abs(sample)\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger amplitude, update current value.\n\t\t\t */\n\t\t\tif sampleAbs > currentValue {\n\t\t\t\tcurrentValue = sampleAbs\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * If we got a sample with larger or equal amplitude, update peak value.\n\t\t\t */\n\t\t\tif sampleAbs >= peakValue {\n\t\t\t\tpeakValue = sampleAbs\n\t\t\t\tsampleCounter = 0\n\t\t\t}\n\n\t\t}\n\n\t\tthis.mutex.Lock()\n\t\tthis.currentValue = currentValue\n\t\tthis.peakValue = peakValue\n\t\tthis.sampleCounter = sampleCounter\n\t\tthis.mutex.Unlock()\n\t}\n\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func (gl *WebGL) Enable(option GLEnum) {\n\tgl.context.Call(\"enable\", option)\n}", "func (lp *ChargerHandler) Enabled() bool {\n\treturn lp.enabled\n}", "func (m *Mode) Enable() {\n\tm.enabled = true\n}", "func NewMeter(client Client, name string, tagOptions ...TagOption) (*Meter, error) {\n\tif err := validateMetricName(name); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Meter{\n\t\tclient: client,\n\t\tname: name,\n\t\ttags: GetTags(tagOptions...),\n\t}, nil\n}", "func meterHelp() string {\n\ts := fmt.Sprintf(\"\\n %s\", \"RTU\")\n\ttypes := make([]string, 0)\n\tfor t := range rs485.Producers {\n\t\ttypes = append(types, t)\n\t}\n\n\tsort.Strings(types)\n\n\tfor _, t := range types {\n\t\tp := rs485.Producers[t]()\n\t\ts += fmt.Sprintf(\"\\n %-10s%s\", t, p.Description())\n\t}\n\n\ts += fmt.Sprintf(\"\\n %s\", \"TCP\")\n\ts += fmt.Sprintf(\"\\n %-10s%s\", \"SUNS\", \"Sunspec-compatible MODBUS TCP device (SMA, SolarEdge, KOSTAL, etc)\")\n\n\treturn s\n}", "func (p *pwmGroup) Enable(enable bool) {\n\tp.enable(enable)\n}", "func NewMeter(name string, snapshotInterval time.Duration) *Meter {\n\tm := Meter{}\n\tm.name = name\n\tm.printInterval = snapshotInterval\n\tm.Reset()\n\treturn &m\n}", "func (f *flusher) register(m Meter) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\tf.meters = append(f.meters, m)\n\tif a, ok := m.(autoFlusher); ok {\n\t\ta.setFlusher(f)\n\t}\n}", "func SetThrottle(iC *InterfaceConfig, degreeVal int) bool {\n dutyCycle := 0\n if degreeVal > 0 {\n dutyCycle = calcdutyCycleFromNeutralZero(iC, Tchannel, degreeVal)\n iC.pca.SetChannel(Tchannel, 0, dutyCycle)\n } else if degreeVal == 0 {\n dutyCycle = calcdutyCycleFromNeutralZero(iC, Tchannel, 0)\n iC.pca.SetChannel(Tchannel, 0, dutyCycle)\n }\n return true\n}", "func (d *LevelWrapper) InfoEnabled() bool {\n\treturn d.LogLevel.InfoEnabled()\n}", "func Enable() {\n\tdebug = true\n}", "func init() {\n\tprometheus.MustRegister(powerConsumption)\n\tgetPower()\n}", "func (r *Reader) ReadMeter() (n int, d time.Duration) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\td = r.d\n\tn = r.n\n\tr.n = 0\n\tr.d = 0\n\treturn\n}", "func (ct *cpuTracker) getMeter(vdr ids.ShortID) uptime.Meter {\n\tmeter, exists := ct.cpuSpenders[vdr]\n\tif exists {\n\t\treturn meter\n\t}\n\n\tnewMeter := ct.factory.New(ct.halflife)\n\tct.cpuSpenders[vdr] = newMeter\n\treturn newMeter\n}", "func (p *hardwareProfiler) Start() error {\n\tif len(p.profilers) == 0 {\n\t\treturn ErrNoProfiler\n\t}\n\tvar err error\n\tfor _, profiler := range p.profilers {\n\t\terr = multierr.Append(err, profiler.Start())\n\t}\n\treturn err\n}", "func Enable() Ender {\n\tglobalProbe.Enable()\n\treturn globalProbe.ender\n}", "func (m *CirconusMetrics) Start() {\n\t// nop\n}", "func (m *modules) Start(sampleRate int) {\n\tm.keyboard.Start(sampleRate)\n\tm.dspEngine.Start(sampleRate)\n}", "func (s *MpuSensor) IsEnabled() (bool, error) {\n\toptions := make(map[string]interface{})\n\n\tval, err := s.cfg.ReadValue(options)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tbuf := bytes.NewBuffer(val)\n\tenabled, err := binary.ReadVarint(buf)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn (enabled == 1), nil\n}", "func (o StorageClusterSpecMonitoringPrometheusOutput) Enabled() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v StorageClusterSpecMonitoringPrometheus) *bool { return v.Enabled }).(pulumi.BoolPtrOutput)\n}", "func (m *Meter) Add(amount int64) {\n\tm.totalCount += amount\n}", "func (self *Graphics) InputEnabled() bool{\n return self.Object.Get(\"inputEnabled\").Bool()\n}", "func (b *Bar) SetSpeedInfo(total float64, units string) {\n\tb.total = total\n\tb.units = units\n}", "func super(s structs.Saiyan) {\n\ts.Power += 1000\n\n}", "func (*PlexLogger) Enabled() bool {\n\treturn true\n}", "func Init(level string, enableStdout bool, enableFile bool, filePrefix string) error {\n\tvar minLevel, err = convertLogLevel(level)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif logLevel(minLevel) < _DebugLevel || logLevel(minLevel) > _ErrorLevel {\n\t\treturn ErrParam\n\t}\n\tif !enableStdout && !enableFile {\n\t\treturn ErrParam\n\t}\n\tvar devs = make([]device, 0, 2)\n\tif enableStdout {\n\t\tdevs = append(devs, newStdoutDevice())\n\t}\n\tif enableFile {\n\t\tdev, err := newFileDevice(filePrefix)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdevs = append(devs, dev)\n\t}\n\tcurrentLogger = &logger{\n\t\tminLevel: logLevel(minLevel),\n\t\tdevices: devs,\n\t}\n\tcurrentLogger.bgWork()\n\treturn nil\n}", "func (d *Driver) Measure() error {\n\tif d.IsImporting() {\n\t\treturn errors.New(\"importing\")\n\t}\n\t// write measure request\n\treturn d.write(newMeasureRequest())\n}" ]
[ "0.6174791", "0.55225664", "0.5347806", "0.530505", "0.530505", "0.530505", "0.52688307", "0.52661425", "0.5246003", "0.5190838", "0.5162985", "0.51319885", "0.50423974", "0.5034071", "0.5016491", "0.49761972", "0.4873128", "0.4872541", "0.47567642", "0.4741281", "0.4702456", "0.46856093", "0.4658808", "0.45950344", "0.45737103", "0.45611146", "0.45220128", "0.45162684", "0.4463867", "0.44625825", "0.43768048", "0.43620417", "0.43396553", "0.43242344", "0.43170142", "0.42877433", "0.42771748", "0.42739978", "0.4273164", "0.42647892", "0.42620987", "0.42530718", "0.42447472", "0.4242363", "0.4236119", "0.4236119", "0.4234854", "0.423452", "0.42305312", "0.41997722", "0.41838184", "0.41774663", "0.41633323", "0.4158726", "0.4131274", "0.40959808", "0.40894553", "0.40847045", "0.40721503", "0.40683728", "0.40592742", "0.4055962", "0.40494895", "0.40441078", "0.40435445", "0.40331107", "0.40315235", "0.4028966", "0.40218672", "0.4006851", "0.3983659", "0.39818034", "0.39783356", "0.39696035", "0.39688683", "0.39624217", "0.3960882", "0.3956539", "0.39554462", "0.39438528", "0.39416128", "0.3934219", "0.39265895", "0.39151525", "0.39143077", "0.39018902", "0.3896614", "0.38911203", "0.38878888", "0.38777995", "0.3877701", "0.38662654", "0.38654688", "0.38605148", "0.3855697", "0.38555565", "0.3849308", "0.3847935", "0.38473403", "0.38463116" ]
0.55552506
1
Retrieve the information about metering for a particular DSP to see if it is enabled or not. "INIT_PROFILE_METER_ALL" with "System.Init" will automatically turn on metering for all DSP units inside the FMOD mixer graph.
func (d *DSP) MeteringEnabled() (bool, bool, error) { var inputEnabled, outputEnabled C.FMOD_BOOL res := C.FMOD_DSP_GetMeteringEnabled(d.cptr, &inputEnabled, &outputEnabled) return setBool(inputEnabled), setBool(outputEnabled), errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func InitGameProfilers() {\r\n\tupdateProfiler = system.NewProfiler(\"update\")\r\n\tcollisionProfiler = system.NewProfiler(\"collision\")\r\n\tmusicProfiler = system.NewProfiler(\"music\")\r\n\tweatherProfiler = system.NewProfiler(\"weather\")\r\n\tgameModeProfiler = system.NewProfiler(\"gameMode\")\r\n\tdrawProfiler = system.NewProfiler(\"draw\")\r\n\tsortRenderProfiler = system.NewProfiler(\"sortRender\")\r\n\tcullRenderProfiler = system.NewProfiler(\"cullRender\")\r\n\tlightingProfiler = system.NewProfiler(\"lighting\")\r\n\tscriptingProfiler = system.NewProfiler(\"scripting\")\r\n\r\n\tframeRateString = \"total time: 0 ms (0 FPS)\"\r\n\totherTimeString = \"measured time: 0 ms\"\r\n}", "func InitMeter(db persistence.Conn) func() {\n\tcleanupFunc := func() {}\n\n\tmetricProvider := os.Getenv(\"METRIC_PROVIDER\")\n\tif metricProvider == \"\" {\n\t\tlog(nil, nil).Info(\"METRIC_PROVIDER not set, metrics will not be generated.\")\n\t\treturn cleanupFunc\n\t}\n\n\tvar err error\n\tswitch metricProvider {\n\tcase STDOUT, PRETTY:\n\t\tvar pusher *push.Controller\n\t\tpusher, err = metricstdout.InstallNewPipeline(metricstdout.Config{\n\t\t\tQuantiles: []float64{},\n\t\t\tPrettyPrint: metricProvider == PRETTY,\n\t\t}, push.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcleanupFunc = pusher.Stop\n\tcase PROMETHEUS:\n\t\tvar exporter *prometheus.Exporter\n\t\texporter, err = prometheus.InstallNewPipeline(prometheus.Config{}, pull.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\thttp.HandleFunc(\"/metrics\", exporter.ServeHTTP)\n\t\tgo func() {\n\t\t\t_ = http.ListenAndServe(\":2222\", nil)\n\t\t}()\n\tdefault:\n\t\tlog(nil, nil).WithField(\"provider\", metricProvider).Fatal(\"Unsupported metric provider\")\n\t}\n\n\tif err != nil {\n\t\tlog(nil, err).WithField(\"provider\", metricProvider).Fatal(\"failed to initialize metric stdout exporter\")\n\t}\n\n\tinitSystemStatsObserver(db)\n\n\treturn cleanupFunc\n}", "func (p *hardwareProfiler) Profile() (*HardwareProfile, error) {\n\tvar err error\n\thwProfile := &HardwareProfile{}\n\tfor profilerType, profiler := range p.profilers {\n\t\tprofileVal, err2 := profiler.Profile()\n\t\terr = multierr.Append(err, err2)\n\t\tif err2 == nil {\n\t\t\tif hwProfile.TimeEnabled == nil {\n\t\t\t\thwProfile.TimeEnabled = &profileVal.TimeEnabled\n\t\t\t}\n\t\t\tif hwProfile.TimeRunning == nil {\n\t\t\t\thwProfile.TimeRunning = &profileVal.TimeRunning\n\t\t\t}\n\t\t\tswitch profilerType {\n\t\t\tcase unix.PERF_COUNT_HW_CPU_CYCLES:\n\t\t\t\thwProfile.CPUCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_INSTRUCTIONS:\n\t\t\t\thwProfile.Instructions = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_REFERENCES:\n\t\t\t\thwProfile.CacheRefs = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_MISSES:\n\t\t\t\thwProfile.CacheMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_INSTRUCTIONS:\n\t\t\t\thwProfile.BranchInstr = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_MISSES:\n\t\t\t\thwProfile.BranchMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BUS_CYCLES:\n\t\t\t\thwProfile.BusCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_FRONTEND:\n\t\t\t\thwProfile.StalledCyclesFrontend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_BACKEND:\n\t\t\t\thwProfile.StalledCyclesBackend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_REF_CPU_CYCLES:\n\t\t\t\thwProfile.RefCPUCycles = &profileVal.Value\n\t\t\t}\n\t\t}\n\t}\n\tif len(multierr.Errors(err)) == len(p.profilers) {\n\t\treturn nil, err\n\t}\n\n\treturn hwProfile, nil\n}", "func (f *falconMeter) Update() {\n\tfalcon.SetMeterCount(f.name, 1)\n}", "func (m *HistoMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func (d *DSP) MeteringInfo() (DSPMeteringInfo, DSPMeteringInfo, error) {\n\tvar cinputInfo, coutputInfo C.FMOD_DSP_METERING_INFO\n\tvar inputInfo, outputInfo DSPMeteringInfo\n\tres := C.FMOD_DSP_GetMeteringInfo(d.cptr, &cinputInfo, &coutputInfo)\n\tinputInfo.fromC(cinputInfo)\n\toutputInfo.fromC(coutputInfo)\n\treturn inputInfo, outputInfo, errs[res]\n}", "func (m *MeterMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func (c *switchBotCollector) init() error {\n\tdevices, _, err := c.client.Device().List(context.Background())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, d := range devices {\n\t\tswitch d.Type {\n\t\tcase switchbot.Meter:\n\t\t\tc.meters = append(c.meters, d)\n\t\t\tlog.Printf(\"adding meter with device id: %s, name: %s\\n\", d.ID, d.Name)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *DevStat) Init(id string, tm map[string]string, l *logrus.Logger) {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\ts.id = id\n\ts.TagMap = tm\n\ts.log = l\n\ts.Counters = make([]interface{}, DevStatTypeSize)\n\ts.Counters[SnmpGetQueries] = 0\n\ts.Counters[SnmpWalkQueries] = 0\n\ts.Counters[SnmpGetErrors] = 0\n\ts.Counters[SnmpWalkErrors] = 0\n\ts.Counters[SnmpQueryTimeouts] = 0\n\ts.Counters[SnmpOIDGetAll] = 0\n\ts.Counters[SnmpOIDGetProcessed] = 0\n\ts.Counters[SnmpOIDGetErrors] = 0\n\ts.Counters[EvalMetricsAll] = 0\n\ts.Counters[EvalMetricsOk] = 0\n\ts.Counters[EvalMetricsErrors] = 0\n\ts.Counters[MetricSent] = 0\n\ts.Counters[MeasurementSent] = 0\n\ts.Counters[MetricSentErrors] = 0\n\ts.Counters[MeasurementSentErrors] = 0\n\ts.Counters[CycleGatherStartTime] = 0\n\ts.Counters[CycleGatherDuration] = 0.0\n\ts.Counters[FilterStartTime] = 0\n\ts.Counters[FilterDuration] = 0.0\n\ts.Counters[BackEndSentStartTime] = 0\n\ts.Counters[BackEndSentDuration] = 0.0\n\ts.Counters[DeviceActive] = 0\n\ts.Counters[DeviceConnected] = 0\n}", "func Init() {\n\n\tprometheus.MustRegister(FunctionDurations)\n\tprometheus.MustRegister(FunctionCountTotal)\n\n}", "func init() {\n\tprometheus.MustRegister(powerConsumption)\n\tgetPower()\n}", "func (m *Metrics) Init() error {\n\tm.missedCount = make(map[string]int64)\n\tm.hitCount = make(map[string]int64)\n\tm.Logger.Debug().Msgf(\"fake metrics: %v\", m.GraphiteMode)\n\tswitch m.GraphiteMode {\n\tcase graphiteOff:\n\n\tcase graphiteStdout:\n\t\tgo goMetrics.Log(m.EveryHourRegister, 30*time.Second, log.New(os.Stderr, \"METRICS_HOUR: \", log.Lmicroseconds))\n\t\tgo goMetrics.Log(m.EveryMinuteRegister, 30*time.Second, log.New(os.Stderr, \"METRICS_MINUTE: \", log.Lmicroseconds))\n\n\tcase graphiteRemote:\n\t\taddr, err := net.ResolveTCPAddr(\"tcp\", m.GraphiteHost)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgo graphite.Graphite(m.EveryHourRegister, time.Minute*30, \"\", addr)\n\t\tgo graphite.Graphite(m.EveryMinuteRegister, time.Second*30, \"\", addr)\n\t}\n\n\treturn nil\n}", "func init() {\n\tprometheus.MustRegister(logicTotal)\n\tprometheus.MustRegister(logicLatency)\n}", "func MeterProvider() metric.Provider {\n\tif gp := globalMeter.Load(); gp != nil {\n\t\treturn gp.(meterProvider).mp\n\t}\n\treturn metric.NoopProvider{}\n}", "func (s *Tplink) GetMeterInto() (SysInfo, error) {\n\tvar (\n\t\tpayload meterInfo\n\t\tjsonResp SysInfo\n\t)\n\n\tj, _ := json.Marshal(payload)\n\n\tdata := encrypt(string(j))\n\tresp, err := send(s.Host, data)\n\tif err != nil {\n\t\treturn jsonResp, err\n\t}\n\n\tif err := json.Unmarshal([]byte(decrypt(resp)), &jsonResp); err != nil {\n\t\treturn jsonResp, err\n\t}\n\treturn jsonResp, nil\n}", "func Meter(component interface{}, sampleRate signal.SampleRate) ResetFunc {\n\tt := getType(component)\n\tmetric := components.get(t)\n\tmetric.components.Add(1)\n\treturn func() MeasureFunc {\n\t\tcalledAt := time.Now()\n\t\tvar (\n\t\t\tbufferSize int\n\t\t\tbufferDuration time.Duration\n\t\t)\n\t\treturn func(s int) {\n\t\t\tmetric.latency.set(time.Since(calledAt))\n\t\t\tmetric.messages.Add(1)\n\t\t\tmetric.samples.Add(int64(s))\n\t\t\t// recalculate buffer duration only when buffer size has changed\n\t\t\tif bufferSize != s {\n\t\t\t\tbufferSize = s\n\t\t\t\tbufferDuration = sampleRate.DurationOf(s)\n\t\t\t}\n\t\t\tmetric.duration.add(bufferDuration)\n\t\t\tcalledAt = time.Now()\n\t\t}\n\t}\n}", "func Register() {\n\tregisterConstMetrics()\n\t{{[- if .API.Enabled ]}}\n\tregisterGRPCMetrics()\n\t{{[- end ]}}\n\t{{[- if .Storage.Enabled ]}}\n\tregisterDatabaseMetrics()\n\t{{[- end ]}}\n\tregisterBusinessMetrics()\n}", "func (device *Device) profile() {\n\tdevice.getOS()\n}", "func (this *meterStruct) Enabled() bool {\n\tthis.mutex.RLock()\n\tenabled := this.enabled\n\tthis.mutex.RUnlock()\n\treturn enabled\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func GetInfo() adapter.Info {\n\treturn adapter.Info{\n\t\tName: \"statsd\",\n\t\tImpl: \"istio.io/istio/mixer/adapter/statsd\",\n\t\tDescription: \"Produces statsd metrics\",\n\t\tSupportedTemplates: []string{\n\t\t\tmetric.TemplateName,\n\t\t},\n\t\tDefaultConfig: &config.Params{\n\t\t\tAddress: \"localhost:8125\",\n\t\t\tPrefix: \"\",\n\t\t\tFlushDuration: 300 * time.Millisecond,\n\t\t\tFlushBytes: 512,\n\t\t\tSamplingRate: 1.0,\n\t\t},\n\n\t\tNewBuilder: func() adapter.HandlerBuilder { return &builder{} },\n\t}\n}", "func init() {\n\tprometheus.MustRegister(uptime, reqCount, reqCountPerEndpoint, userCPU, systemCPU, memUsage, diskUsage)\n\tinitStat, err := stat.GetServerStat()\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tgo recordServerMetrics(initStat)\n}", "func Init() error {\n\tif CPUProfileFlag != \"\" {\n\t\tf, err := os.Create(CPUProfileFlag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = pprof.StartCPUProfile(f)\n\t\tif err != nil {\n\t\t\t_ = f.Close()\n\t\t\treturn err\n\t\t}\n\t\tcpuProfileFile = f\n\t}\n\tif HeapProfileFlag != \"\" {\n\t\tf, err := os.Create(HeapProfileFlag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\theapProfileFile = f\n\t}\n\tif ThreadProfileFlag != \"\" {\n\t\tf, err := os.Create(ThreadProfileFlag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tthreadProfileFile = f\n\t}\n\tif BlockProfileFlag != \"\" {\n\t\tf, err := os.Create(BlockProfileFlag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tblockProfileFile = f\n\t}\n\treturn nil\n}", "func defaultServerMeasures() {\n\tvar err error\n\n\tif RPCServerErrorCount, err = stats.NewMeasureInt64(\"grpc.io/server/error_count\", \"RPC Errors\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/error_count: %v\", err)\n\t}\n\tif RPCServerServerElapsedTime, err = stats.NewMeasureFloat64(\"grpc.io/server/server_elapsed_time\", \"Server elapsed time in msecs\", unitMillisecond); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/server_elapsed_time: %v\", err)\n\t}\n\tif RPCServerRequestBytes, err = stats.NewMeasureInt64(\"grpc.io/server/request_bytes\", \"Request bytes\", unitByte); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/request_bytes: %v\", err)\n\t}\n\tif RPCServerResponseBytes, err = stats.NewMeasureInt64(\"grpc.io/server/response_bytes\", \"Response bytes\", unitByte); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/response_bytes: %v\", err)\n\t}\n\tif RPCServerStartedCount, err = stats.NewMeasureInt64(\"grpc.io/server/started_count\", \"Number of server RPCs (streams) started\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/started_count: %v\", err)\n\t}\n\tif RPCServerFinishedCount, err = stats.NewMeasureInt64(\"grpc.io/server/finished_count\", \"Number of server RPCs (streams) finished\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/finished_count: %v\", err)\n\t}\n\tif RPCServerRequestCount, err = stats.NewMeasureInt64(\"grpc.io/server/request_count\", \"Number of server RPC request messages\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/request_count: %v\", err)\n\t}\n\tif RPCServerResponseCount, err = stats.NewMeasureInt64(\"grpc.io/server/response_count\", \"Number of server RPC response messages\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/response_count: %v\", err)\n\t}\n}", "func profiler() (profiler interface{ Stop() }) {\n\tvar kind func(*profile.Profile)\n\tswitch Settings.Kind {\n\tcase settings.ProfileCpu:\n\t\tkind = profile.CPUProfile\n\tcase settings.ProfileMutex:\n\t\tkind = profile.MutexProfile\n\tdefault:\n\t\tkind = profile.MemProfile\n\t}\n\tif len(Settings.Profiler.Path) == 0 {\n\t\treturn\n\t}\n\tsettings := Settings.Profiler\n\tlog = log.WithValues(\n\t\t\"duration\",\n\t\tsettings.Duration,\n\t\t\"kind\",\n\t\tsettings.Kind,\n\t\t\"path\",\n\t\tSettings.Path)\n\tprofiler = profile.Start(\n\t\tprofile.ProfilePath(settings.Path),\n\t\tprofile.NoShutdownHook,\n\t\tkind)\n\tlog.Info(\"Profiler started.\")\n\tif settings.Duration > 0 {\n\t\tgo func() {\n\t\t\ttime.Sleep(settings.Duration)\n\t\t\tprofiler.Stop()\n\t\t\tlog.Info(\"Profiler stopped.\")\n\t\t}()\n\t}\n\n\treturn\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"psoft\", \"stat\", New)\n}", "func (ct *cpuTracker) getMeter(vdr ids.ShortID) uptime.Meter {\n\tmeter, exists := ct.cpuSpenders[vdr]\n\tif exists {\n\t\treturn meter\n\t}\n\n\tnewMeter := ct.factory.New(ct.halflife)\n\tct.cpuSpenders[vdr] = newMeter\n\treturn newMeter\n}", "func (m *Manager) Meter(delay time.Duration) *Meter {\n\treturn &Meter{\n\t\tm: m,\n\t\tdelay: delay,\n\t\tnext: time.Now(),\n\t}\n}", "func (e *HueEmulator) getDeviceInfo(w http.ResponseWriter, _ *http.Request, params httprouter.Params) {\n\tlightID := params.ByName(\"lightID\")\n\tfor _, v := range e.devices {\n\t\tif lightID == v.internalHash {\n\t\t\te.logger.Debug(\"Requested device state info\", common.LogIDToken, v.DeviceID)\n\t\t\te.sendJSON(w, getDevice(v))\n\t\t\treturn\n\t\t}\n\t}\n\n\te.logger.Warn(\"Requested unknown device state info\", common.LogIDToken, lightID)\n}", "func (p *Prometheus) Init() {\n\tp.fileApplyCount = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tName: \"file_apply_count\",\n\t\tHelp: \"Success metric for every file applied\",\n\t},\n\t\t[]string{\n\t\t\t// Path of the file that was applied\n\t\t\t\"file\",\n\t\t\t// Result: true if the apply was successful, false otherwise\n\t\t\t\"success\",\n\t\t},\n\t)\n\tp.runLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{\n\t\tName: \"run_latency_seconds\",\n\t\tHelp: \"Latency for completed apply runs\",\n\t},\n\t\t[]string{\n\t\t\t// Result: true if the run was successful, false otherwise\n\t\t\t\"success\",\n\t\t},\n\t)\n\n\tprometheus.MustRegister(p.fileApplyCount)\n\tprometheus.MustRegister(p.runLatency)\n}", "func InitializeAll() {\n\t// TODO introduce isFanOut parameter to determine when to create fan-out controller/daemon metrics\n\tif haveInitialized {\n\t\tklog.Infof(\"metrics have already been initialized\")\n\t} else {\n\t\tinitializeDaemonMetrics()\n\t\tinitializeControllerMetrics()\n\t\t// TODO include dataplane health metrics:\n\t\t// num failures for apply ipsets, updating policies, deleting policies, and running periodic policy tasks, etc.\n\t\tlog.Logf(\"Finished initializing all Prometheus metrics\")\n\t\thaveInitialized = true\n\t}\n}", "func NewMeter(name string) metics.Meter {\n\tif !Enabled {\n\t\treturn new(metics.NilMeter)\n\t}\n\treturn metics.GetOrRegisterMeter(name, metics.DefaultRegistry)\n}", "func (p *hardwareProfiler) Start() error {\n\tif len(p.profilers) == 0 {\n\t\treturn ErrNoProfiler\n\t}\n\tvar err error\n\tfor _, profiler := range p.profilers {\n\t\terr = multierr.Append(err, profiler.Start())\n\t}\n\treturn err\n}", "func (obj *GenericMeasure) GetInfo(ctx context.Context) (*NxInfo, error) {\n\tresult := &struct {\n\t\tInfo *NxInfo `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (s *Stats) GetAllCPUInfo() {\n s.GetCPUInfo()\n s.GetCPUTimes()\n}", "func (t *Telemetry) init(runTelemetryCheck bool) {\n\t// loading sensor into memory\n\tt.sensors = GetSensorsList(t.db)\n\tlog.Printf(\"[INFO] loading telemetry sensor list...\")\n\tif len(t.sensors) == 0 {\n\t\tlog.Printf(\"[WARNING] no sensors available in database\")\n\t}\n\n\t// loading dataset into memory\n\tt.datasets = GetDatasetsList(t.db)\n\tlog.Printf(\"[INFO] loading telemetry dataset list...\")\n\tif len(t.datasets) == 0 {\n\t\tlog.Printf(\"[WARNING] No datasets available in database\")\n\t}\n\n\t// loading controllers into memory\n\tt.controllers, _ = GetControllersListFromDB(t.db)\n\t// TODO handle error\n\tlog.Printf(\"[INFO] loading telemetry controllers list...\")\n\tif len(t.controllers) == 0 {\n\t\tlog.Printf(\"[WARNING] No active controllers\")\n\t}\n\n\tfor _, dset := range t.sensors {\n\t\tfmt.Printf(\"=> monitoring sensor telemetry for '%s'\\n\", dset.Title)\n\t}\n\n\tfor _, dset := range t.datasets {\n\t\tfmt.Printf(\"=> monitoring dataset telemetry for '%s'\\n\", dset.Title)\n\t}\n\n\tfor _, c := range t.controllers {\n\t\tfmt.Printf(\"=> monitoring controllers telemetry for '%v'\\n\", c.Title)\n\t}\n\n\tif runTelemetryCheck {\n\t\t// t.CheckSensorsTelemetry()\n\t\tt.CheckDatasetTelemetry()\n\t\tt.CheckControllersTelemetry()\n\t}\n}", "func GetDevStats() map[string]*stats.GatherStats {\n\tdevstats := make(map[string]*stats.GatherStats)\n\tmutex.RLock()\n\tfor k, v := range devices {\n\t\tdevstats[k] = v.GetBasicStats()\n\t}\n\tmutex.RUnlock()\n\treturn devstats\n}", "func init() {\n\tdb.RegisterInit(meterReader)\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"mssql\", \"performance\", New,\n\t\tmb.DefaultMetricSet(),\n\t\tmb.WithHostParser(mssql.HostParser))\n}", "func meterHelp() string {\n\ts := fmt.Sprintf(\"\\n %s\", \"RTU\")\n\ttypes := make([]string, 0)\n\tfor t := range rs485.Producers {\n\t\ttypes = append(types, t)\n\t}\n\n\tsort.Strings(types)\n\n\tfor _, t := range types {\n\t\tp := rs485.Producers[t]()\n\t\ts += fmt.Sprintf(\"\\n %-10s%s\", t, p.Description())\n\t}\n\n\ts += fmt.Sprintf(\"\\n %s\", \"TCP\")\n\ts += fmt.Sprintf(\"\\n %-10s%s\", \"SUNS\", \"Sunspec-compatible MODBUS TCP device (SMA, SolarEdge, KOSTAL, etc)\")\n\n\treturn s\n}", "func hwinfo() string {\n\tb1, err := exec.Command(\"vcgencmd\", \"measure_clock\", \"arm\").Output()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tb2, err := exec.Command(\"vcgencmd\", \"measure_clock\", \"core\").Output()\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tif len(b1) < 17 || len(b2) < 17 {\n\t\treturn \"bad len\"\n\t}\n\treturn fmt.Sprintf(\"arm=%sMhz core=%sMHz\", b1[14:17], b2[13:16])\n}", "func (mock *GpuInstanceMock) GetInfoCalls() []struct {\n} {\n\tvar calls []struct {\n\t}\n\tmock.lockGetInfo.RLock()\n\tcalls = mock.calls.GetInfo\n\tmock.lockGetInfo.RUnlock()\n\treturn calls\n}", "func (s *Stream) Info() *StreamInfo {\n\ti := C.Pa_GetStreamInfo(s.paStream)\n\tif i == nil {\n\t\treturn nil\n\t}\n\treturn &StreamInfo{duration(i.inputLatency), duration(i.outputLatency), float64(i.sampleRate)}\n}", "func (ooc *MockOpenoltClient) GetDeviceInfo(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.DeviceInfo, error) {\n\tif ooc.counter == 0 {\n\t\tooc.counter++\n\t\tdeviceInfo := &openolt.DeviceInfo{Vendor: \"Openolt\", Model: \"1.0\", HardwareVersion: \"1.0\", FirmwareVersion: \"1.0\", DeviceId: \"olt\", DeviceSerialNumber: \"olt\"}\n\t\treturn deviceInfo, nil\n\t}\n\tif ooc.counter == 1 {\n\t\tooc.counter++\n\t\tdeviceInfo := &openolt.DeviceInfo{Vendor: \"Openolt\", Model: \"1.0\", HardwareVersion: \"1.0\", FirmwareVersion: \"1.0\", DeviceId: \"\", DeviceSerialNumber: \"olt\"}\n\t\treturn deviceInfo, nil\n\t}\n\tif ooc.counter == 2 {\n\t\tooc.counter++\n\t\treturn nil, nil\n\t}\n\n\treturn nil, errors.New(\"device info not found\")\n}", "func Init() {\n\tprometheus.MustRegister(\n\t\tHTTPRequestsCounter,\n\t\tHTTPRequestsDurationHistogram,\n\t\tDAOFindResultCounter,\n\t\tDAOOperationsCounter,\n\t\tDAOOperationsDurationHistogram,\n\t)\n}", "func (m *RdmaDevPlugin) GetInfo(ctx context.Context, rqt *registerapi.InfoRequest) (*registerapi.PluginInfo, error) {\n\tpluginInfoResponse := &registerapi.PluginInfo{\n\t\tType: registerapi.DevicePlugin,\n\t\tName: m.resourceName,\n\t\tEndpoint: filepath.Join(sockDir, m.socketName),\n\t\tSupportedVersions: []string{\"v1alpha1\", \"v1beta1\"},\n\t}\n\treturn pluginInfoResponse, nil\n}", "func GetSamplesInfo(stream StreamInfo, fragmentInfo FragmentInfo) (sampleInfo []SampleInfo) {\n\n\tsampleInfo = make([]SampleInfo, fragmentInfo.getSampleCount())\n\n\t// Get size And offset of the sample in MDat\n\tregisterSamplesSizes(stream, fragmentInfo, &sampleInfo)\n\n\tif stream.isVideo() {\n\n\t\t// Retrieve all NAL unit length in this sample\n\t\tregisterNalUnits(stream, &sampleInfo)\n\n\t\t// Registers all iFrames\n\t\tregisterISamples(fragmentInfo, &sampleInfo)\n\t}\n\n\t// Retrieve the compositionTimeOffset and decodingTimeOffset\n\tregisterCTSAndDTSSamples(stream, fragmentInfo, &sampleInfo)\n\n\t// Compute the pcr\n\tregisterPCRSamples(stream, fragmentInfo, &sampleInfo)\n\n\t// Scale timestamps with the timeScale\n\tScaleTimeStamps(stream, &sampleInfo)\n\n\treturn\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"connection\", \"load_stats\", New)\n}", "func (s *Stats) GetCPUInfo() {\n\n if s.CPUInfo == nil {\n s.CPUInfo = new(CPUInfo)\n }\n\n s.CPUInfo.CPU, _ = cpu.Info()\n}", "func (s *SplitStore) Info() map[string]interface{} {\n\tinfo := make(map[string]interface{})\n\tinfo[\"base epoch\"] = s.baseEpoch\n\tinfo[\"warmup epoch\"] = s.warmupEpoch.Load()\n\tinfo[\"compactions\"] = s.compactionIndex\n\tinfo[\"prunes\"] = s.pruneIndex\n\tinfo[\"compacting\"] = s.compacting == 1\n\n\tsizer, ok := s.hot.(bstore.BlockstoreSize)\n\tif ok {\n\t\tsize, err := sizer.Size()\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"error getting hotstore size: %s\", err)\n\t\t} else {\n\t\t\tinfo[\"hotstore size\"] = size\n\t\t}\n\t}\n\n\treturn info\n}", "func (this *Device) Info() IDeviceInfo {\n return this.info\n}", "func MeterStatistics(client *gophercloud.ServiceClient, n string, opts MeterStatisticsOptsBuilder) StatisticsResult {\n\tvar res StatisticsResult\n\turl := statisticsURL(client, n)\n\n\tif opts != nil {\n\t\tquery, err := opts.ToMeterStatisticsQuery()\n\t\tif err != nil {\n\t\t\tres.Err = err\n\t\t\treturn res\n\t\t}\n\t\turl += query\n\t}\n\n\t_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})\n\treturn res\n}", "func All() (*performancev2.PerformanceProfileList, error) {\n\tprofiles := &performancev2.PerformanceProfileList{}\n\tif err := testclient.Client.List(context.TODO(), profiles); err != nil {\n\t\treturn nil, err\n\t}\n\treturn profiles, nil\n}", "func (s *SystemdTimings) Gather(acc telegraf.Accumulator) error {\n\tif !bootIsFinished() {\n\t\t// We are not ready to collect yet, telegraf will call us later to\n\t\t// try again.\n\t\treturn nil\n\t}\n\n\tif s.Periodic == false {\n\t\t// We only want to run once.\n\t\tif collectionDone == true {\n\t\t\t// By default we only collect once since these are generally boot\n\t\t\t// time metrics.\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Connect to the systemd dbus.\n\tdbusConn, err := dbus.NewSystemConnection()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer dbusConn.Close()\n\n\terr = postAllManagerProps(dbusConn, acc)\n\tif err != nil {\n\t\tacc.AddError(err)\n\t\treturn err\n\t}\n\n\t// Read all unit timing data.\n\terr = postAllUnitTimingData(dbusConn, acc, s)\n\tif err != nil {\n\t\tacc.AddError(err)\n\t\treturn err\n\t}\n\n\tif err == nil {\n\t\tcollectionDone = true\n\t}\n\n\treturn err\n}", "func init() {\n\tprometheus.MustRegister(duration)\n\tprometheus.MustRegister(counter)\n\tprometheus.MustRegister(requestsTotal)\n}", "func (cpuCollector *CPUCollector) Init() {\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cpuTotal)\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cpuUtilization)\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cupIdle)\n}", "func Init() {\n\tglobalStats = make(map[Type]time.Duration)\n\tminMaxTimeStats = make(map[Type]minMaxTime)\n\tcountStats = make(map[Type]int)\n\tmutex = &sync.RWMutex{}\n}", "func (client DDMetricsClient) GetInfo() (*DDInfo, error) {\n\tinfoURL := client.endpoint\n\tinfoURL.Path = \"/info\"\n\tresp, err := client.httpClient.Get(infoURL.String())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := DDInfo{}\n\terr = json.NewDecoder(resp.Body).Decode(&info)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogrus.Debugln(\"Received /info from Deepdetect :\", info)\n\treturn &info, nil\n}", "func (m *Meter) MaybeStats() *MeterStats {\n\tnow := time.Now()\n\telapsedInIntervalMs := now.Sub(m.lastIntervalStart).Milliseconds()\n\tif elapsedInIntervalMs > m.printInterval.Milliseconds() {\n\t\tintervalCount := m.totalCount - m.lastCount\n\t\tintervalRatePerS := float64(intervalCount) / float64(elapsedInIntervalMs) * 1000.0\n\t\tm.lastCount = m.totalCount\n\t\tm.lastIntervalStart = now\n\n\t\telapsedTotalMs := now.Sub(m.start).Milliseconds()\n\t\ttotalRatePerS := float64(m.totalCount) / float64(elapsedTotalMs) * 1000.0\n\n\t\tm.lastStats = MeterStats{\n\t\t\tName: m.name,\n\t\t\tStart: m.start,\n\t\t\tTotalCount: m.totalCount,\n\t\t\tTotalRatePerS: totalRatePerS,\n\t\t\tIntervalCount: intervalCount,\n\t\t\tIntervalRatePerS: intervalRatePerS,\n\t\t}\n\t\treturn &m.lastStats\n\t}\n\treturn nil\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"kvm\", \"dommemstat\", New,\n\t\tmb.DefaultMetricSet(),\n\t)\n}", "func All() (*performancev1.PerformanceProfileList, error) {\n\tprofiles := &performancev1.PerformanceProfileList{}\n\tif err := testclient.Client.List(context.TODO(), profiles); err != nil {\n\t\treturn nil, err\n\t}\n\treturn profiles, nil\n}", "func (sr *ServicedStatsReporter) gatherStats(t time.Time) []Sample {\n\tstats := []Sample{}\n\t// Handle the host metrics.\n\treg, _ := sr.hostRegistry.(*metrics.StandardRegistry)\n\treg.Each(func(name string, i interface{}) {\n\t\ttagmap := map[string]string{\n\t\t\t\"controlplane_host_id\": sr.hostID,\n\t\t}\n\t\tswitch metric := i.(type) {\n\t\tcase metrics.Gauge:\n\t\t\tstats = append(stats, Sample{name, strconv.FormatInt(metric.Value(), 10), t.Unix(), tagmap})\n\t\tcase metrics.GaugeFloat64:\n\t\t\tstats = append(stats, Sample{name, strconv.FormatFloat(metric.Value(), 'f', -1, 32), t.Unix(), tagmap})\n\t\t}\n\t})\n\t// Handle each container's metrics.\n\tfor key, registry := range sr.containerRegistries {\n\t\treg, _ := registry.(*metrics.StandardRegistry)\n\t\treg.Each(func(name string, i interface{}) {\n\t\t\ttagmap := map[string]string{\n\t\t\t\t\"controlplane_host_id\": sr.hostID,\n\t\t\t\t\"controlplane_service_id\": key.serviceID,\n\t\t\t\t\"controlplane_instance_id\": strconv.FormatInt(int64(key.instanceID), 10),\n\t\t\t}\n\t\t\tswitch metric := i.(type) {\n\t\t\tcase metrics.Gauge:\n\t\t\t\tstats = append(stats, Sample{name, strconv.FormatInt(metric.Value(), 10), t.Unix(), tagmap})\n\t\t\tcase metrics.GaugeFloat64:\n\t\t\t\tstats = append(stats, Sample{name, strconv.FormatFloat(metric.Value(), 'f', -1, 32), t.Unix(), tagmap})\n\t\t\t}\n\t\t})\n\t}\n\treturn stats\n}", "func IsStatsMode() bool {\n\tc := GetConfig()\n\treturn c.FederatedPromInterval != \"\"\n}", "func countDevices(managers map[string]*meters.Manager) int {\n\tvar count int\n\tfor _, m := range managers {\n\t\tm.All(func(id uint8, dev meters.Device) {\n\t\t\tconf := dev.Descriptor()\n\t\t\tlog.Printf(\"config: declared device %s:%d.%d\", conf.Type, id, conf.SubDevice)\n\t\t\tcount++\n\t\t})\n\t}\n\treturn count\n}", "func init() {\n\tif err := mb.Registry.AddMetricSet(\"haproxy\", \"info\", New); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (m *manager) AllStats() []*device.DeviceGroupStats {\n\t// Go through each plugin and collect stats\n\tvar stats []*device.DeviceGroupStats\n\tfor _, i := range m.instances {\n\t\tstats = append(stats, i.AllStats()...)\n\t}\n\n\treturn stats\n}", "func (hem *GW) Init(rootURL string, username string, password string) {\n\them.rootURL = rootURL\n\them.username = username\n\them.password = password\n\them.loadSmartMeterAttribute()\n}", "func (m *sineOsc) Info() *core.ModuleInfo {\n\treturn &m.info\n}", "func init() {\n\n\t// cpu\n\tRegistryMetricCreateInput(\"cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"mem\", \"Memory\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\t// vm_cpu\n\tRegistryMetricCreateInput(\"vm_cpu\", \"Guest CPU usage\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_pcore\", \"CPU utilization rate per core\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_idle_pcore\", \"CPU idle rate per core\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_system\", \"CPU system state time\", monitor.METRIC_UNIT_MS, 4),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_user\", \"CPU user state time\", monitor.METRIC_UNIT_MS, 5),\n\t\t\tnewMetricFieldCreateInput(\"thread_count\", \"The number of threads used by the process\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t})\n\n\t// vm_diskio\n\tRegistryMetricCreateInput(\"vm_diskio\", \"Guest disk traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BYTEPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BYTEPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\n\t// vm_mem\n\tRegistryMetricCreateInput(\"vm_mem\", \"Guest memory\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"vms\", \"Virtual memory consumption\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"rss\", \"Actual use of physical memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t})\n\n\t// vm_netio\n\tRegistryMetricCreateInput(\"vm_netio\", \"Guest network traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// oss_latency\n\tRegistryMetricCreateInput(\"oss_latency\", \"Object storage latency\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_late\", \"Request average E2E delay\", monitor.METRIC_UNIT_MS, 1),\n\t\t})\n\n\t// oss_netio\n\tRegistryMetricCreateInput(\"oss_netio\", \"Object storage network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Receive byte\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send byte\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t})\n\n\t// oss_req\n\tRegistryMetricCreateInput(\"oss_req\", \"Object store request\", monitor.METRIC_RES_TYPE_OSS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_count\", \"request count\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// rds_conn\n\tRegistryMetricCreateInput(\"rds_conn\", \"Rds connect\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_cpu\n\tRegistryMetricCreateInput(\"rds_cpu\", \"Rds CPU usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t})\n\n\t// rds_mem\n\tRegistryMetricCreateInput(\"rds_mem\", \"Rds memory\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_netio\n\tRegistryMetricCreateInput(\"rds_netio\", \"Rds network traffic\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// rds_disk\n\tRegistryMetricCreateInput(\"rds_disk\", \"Rds disk usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_cpu\n\tRegistryMetricCreateInput(\"dcs_cpu\", \"Redis CPU usage\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_percent\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_mem\n\tRegistryMetricCreateInput(\"dcs_mem\", \"Redis memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_netio\n\tRegistryMetricCreateInput(\"dcs_netio\", \"Redis network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// dcs_conn\n\tRegistryMetricCreateInput(\"dcs_conn\", \"Redis connect\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_instantopt\n\tRegistryMetricCreateInput(\"dcs_instantopt\", \"Redis operator\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"opt_sec\", \"Number of commands processed per second\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_cachekeys\n\tRegistryMetricCreateInput(\"dcs_cachekeys\", \"Redis keys\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 6, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"key_count\", \"Number of cache keys\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_datamem\n\tRegistryMetricCreateInput(\"dcs_datamem\", \"Redis data memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_byte\", \"Data node memory usage\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t})\n\n\t// cloudaccount_balance\n\tRegistryMetricCreateInput(\"cloudaccount_balance\", \"Cloud account balance\",\n\t\tmonitor.METRIC_RES_TYPE_CLOUDACCOUNT,\n\t\tmonitor.METRIC_DATABASE_METER, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"balance\", \"balance\", monitor.METRIC_UNIT_RMB, 1),\n\t\t})\n\n\t// cpu\n\tRegistryMetricCreateInput(\"agent_cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"agent_disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"agent_diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"agent_mem\", \"Memory\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"agent_net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\tRegistryMetricCreateInput(\"storage\", \"Storage usage\",\n\t\tmonitor.METRIC_RES_TYPE_STORAGE, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"Storage utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free storage\", monitor.METRIC_UNIT_MB, 2),\n\t\t})\n\n\t//jenkins\n\tRegistryMetricCreateInput(\"jenkins_node\", \"jenkins node\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"disk_available\", \"disk_available\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"temp_available\", \"temp_available\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"memory_available\", \"memory_available\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"memory_total\", \"memory_total\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"swap_available\", \"swap_available\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"swap_total\", \"swap_total\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\tRegistryMetricCreateInput(\"jenkins_job\", \"jenkins job\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"duration\", \"duration\", monitor.METRIC_UNIT_MS, 1),\n\t\t\tnewMetricFieldCreateInput(\"number\", \"number\", monitor.METRIC_UNIT_COUNT, 2),\n\t\t})\n\n}", "func (s *Simulator) Stats() *Stats {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\telapsed := time.Since(s.now).Seconds()\n\tpThrough := float64(s.writtenN) / elapsed\n\trespMean := 0\n\tif len(s.latencyHistory) > 0 {\n\t\trespMean = int(s.totalLatency) / len(s.latencyHistory) / int(time.Millisecond)\n\t}\n\tstats := &Stats{\n\t\tTime: time.Unix(0, int64(time.Since(s.now))),\n\t\tTags: s.ReportTags,\n\t\tFields: models.Fields(map[string]interface{}{\n\t\t\t\"T\": int(elapsed),\n\t\t\t\"points_written\": s.writtenN,\n\t\t\t\"values_written\": s.writtenN * s.FieldsPerPoint,\n\t\t\t\"points_ps\": pThrough,\n\t\t\t\"values_ps\": pThrough * float64(s.FieldsPerPoint),\n\t\t\t\"write_error\": s.currentErrors,\n\t\t\t\"resp_wma\": int(s.wmaLatency),\n\t\t\t\"resp_mean\": respMean,\n\t\t\t\"resp_90\": int(s.quartileResponse(0.9) / time.Millisecond),\n\t\t\t\"resp_95\": int(s.quartileResponse(0.95) / time.Millisecond),\n\t\t\t\"resp_99\": int(s.quartileResponse(0.99) / time.Millisecond),\n\t\t}),\n\t}\n\n\tvar isCreating bool\n\tif s.writtenN < s.SeriesN() {\n\t\tisCreating = true\n\t}\n\tstats.Tags[\"creating_series\"] = fmt.Sprint(isCreating)\n\n\t// Reset error count for next reporting.\n\ts.currentErrors = 0\n\n\t// Add runtime stats for the remote instance.\n\tvar vars Vars\n\tresp, err := http.Get(strings.TrimSuffix(s.Host, \"/\") + \"/debug/vars\")\n\tif err != nil {\n\t\t// Don't log error as it can get spammy.\n\t\treturn stats\n\t}\n\tdefer resp.Body.Close()\n\n\tif err := json.NewDecoder(resp.Body).Decode(&vars); err != nil {\n\t\tfmt.Fprintln(s.Stderr, err)\n\t\treturn stats\n\t}\n\n\tstats.Fields[\"heap_alloc\"] = vars.Memstats.HeapAlloc\n\tstats.Fields[\"heap_in_use\"] = vars.Memstats.HeapInUse\n\tstats.Fields[\"heap_objects\"] = vars.Memstats.HeapObjects\n\treturn stats\n}", "func (m *migdevice) GetProfile() (MigProfile, error) {\n\tif m.profile != nil {\n\t\treturn m.profile, nil\n\t}\n\n\tparent, ret := m.Device.GetDeviceHandleFromMigDeviceHandle()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting parent device handle: %v\", ret)\n\t}\n\n\tparentMemoryInfo, ret := parent.GetMemoryInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting parent memory info: %v\", ret)\n\t}\n\n\tattributes, ret := m.Device.GetAttributes()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device attributes: %v\", ret)\n\t}\n\n\tgiID, ret := m.Device.GetGpuInstanceId()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device GPU Instance ID: %v\", ret)\n\t}\n\n\tciID, ret := m.Device.GetComputeInstanceId()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device Compute Instance ID: %v\", ret)\n\t}\n\n\tgi, ret := parent.GetGpuInstanceById(giID)\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting GPU Instance: %v\", ret)\n\t}\n\n\tci, ret := gi.GetComputeInstanceById(ciID)\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting Compute Instance: %v\", ret)\n\t}\n\n\tgiInfo, ret := gi.GetInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting GPU Instance info: %v\", ret)\n\t}\n\n\tciInfo, ret := ci.GetInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting Compute Instance info: %v\", ret)\n\t}\n\n\tfor i := 0; i < nvml.GPU_INSTANCE_PROFILE_COUNT; i++ {\n\t\tgiProfileInfo, ret := parent.GetGpuInstanceProfileInfo(i)\n\t\tif ret == nvml.ERROR_NOT_SUPPORTED {\n\t\t\tcontinue\n\t\t}\n\t\tif ret == nvml.ERROR_INVALID_ARGUMENT {\n\t\t\tcontinue\n\t\t}\n\t\tif ret != nvml.SUCCESS {\n\t\t\treturn nil, fmt.Errorf(\"error getting GPU Instance profile info: %v\", ret)\n\t\t}\n\n\t\tif giProfileInfo.Id != giInfo.ProfileId {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor j := 0; j < nvml.COMPUTE_INSTANCE_PROFILE_COUNT; j++ {\n\t\t\tfor k := 0; k < nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT; k++ {\n\t\t\t\tciProfileInfo, ret := gi.GetComputeInstanceProfileInfo(j, k)\n\t\t\t\tif ret == nvml.ERROR_NOT_SUPPORTED {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif ret == nvml.ERROR_INVALID_ARGUMENT {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif ret != nvml.SUCCESS {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error getting Compute Instance profile info: %v\", ret)\n\n\t\t\t\t}\n\n\t\t\t\tif ciProfileInfo.Id != ciInfo.ProfileId {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tp, err := m.lib.NewMigProfile(i, j, k, attributes.MemorySizeMB, parentMemoryInfo.Total)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error creating MIG profile: %v\", err)\n\t\t\t\t}\n\n\t\t\t\tm.profile = p\n\t\t\t\treturn p, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"no matching profile IDs found\")\n}", "func (p MigProfileInfo) GetInfo() MigProfileInfo {\n\treturn p\n}", "func meterReader(d *db.DB) error {\n\tsect := d.Config.GetSection(\"meter\")\n\tif sect == nil {\n\t\treturn nil\n\t}\n\tvar angle float64\n\ta, err := sect.GetArg(\"rotate\")\n\tif err == nil {\n\t\tangle, err = strconv.ParseFloat(a, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tsource, err := sect.GetArg(\"source\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tr, err := NewReader(sect, d.Trace)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.AddDiff(db.D_IN_POWER, time.Minute*5)\n\td.AddDiff(db.D_OUT_POWER, time.Minute*5)\n\td.AddAccum(db.A_IN_TOTAL, true)\n\td.AddAccum(db.A_OUT_TOTAL, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\tlog.Printf(\"Registered meter LCD reader\\n\")\n\tgo runReader(d, r, source, angle)\n\treturn nil\n}", "func (s *Systemctl) Start(acc telegraf.Accumulator) error {\n\t// lock the function\n\ts.mux.Lock()\n\t// release the lock at the end of the function\n\tdefer s.mux.Unlock()\n\t// check that the sampler has been initiatised\n\tif s.Sampler == nil {\n\t\treturn errors.New(\"Systemctl.Sampler has not been set\")\n\t}\n\t// check the sampler is not already running\n\tif s.running {\n\t\treturn nil\n\t}\n\n\tSetLogLevel(s.LogLevel)\n\tlog.WithFields(log.Fields{\n\t\t\"InputPlugin\": \"systemctl\",\n\t}).Debug(\"Starting\")\n\n\t// check the sample has not already initalised the aggregators\n\tif s.Aggregators == nil {\n\t\t// create an aggregator for each service defined within the configuration\n\t\tserviceCount := len(s.Services)\n\t\ts.Aggregators = make([]StateAggregator, serviceCount)\n\t\tfor i, service := range s.Services {\n\t\t\ts.Aggregators[i] = StateAggregator{\n\t\t\t\tResourceName: service,\n\t\t\t\tAggState: make(map[string]uint64),\n\t\t\t\tCurrentState: \"unknown\",\n\t\t\t\tCurrentStateDuration: 0,\n\t\t\t\tStateCollector: Collector{\n\t\t\t\t\tSampleRate: s.SampleRate,\n\t\t\t\t\tDone: make(chan bool),\n\t\t\t\t\tCollect: make(chan bool),\n\t\t\t\t\tSampleResults: make(chan []Sample),\n\t\t\t\t},\n\t\t\t}\n\t\t\t// start collecting samples for each aggregator in a separate go routine\n\t\t\t// providing the service name and the sampler used to collect data\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"InputPlugin\": \"systemctl\",\n\t\t\t\t\"ResourceName\": service,\n\t\t\t}).Debug(\"Starting CollectSamples\")\n\t\t\tgo s.Aggregators[i].StateCollector.CollectSamples(service, s.Sampler)\n\t\t}\n\t}\n\n\t// set the state that the input plugin has started\n\ts.running = true\n\n\tlog.WithFields(log.Fields{\n\t\t\"InputPlugin\": \"systemctl\",\n\t}).Debug(\"Started\")\n\n\treturn nil\n}", "func Init() {\n\tGlobalStats = make(map[Type]time.Duration)\n\tCountStats = make(map[Type]int)\n\tmutex = &sync.RWMutex{}\n}", "func (c *Client) GetMempoolInfo() (info *MempoolInfo, err error) {\r\n\r\n\tvar resp string\r\n\t// https://api.whatsonchain.com/v1/bsv/<network>/mempool/info\r\n\tif resp, err = c.request(fmt.Sprintf(\"%s%s/mempool/info\", apiEndpoint, c.Network), http.MethodGet, nil); err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\terr = json.Unmarshal([]byte(resp), &info)\r\n\treturn\r\n}", "func (a API) GetMempoolInfoChk() (isNew bool) {\n\tselect {\n\tcase o := <-a.Ch.(chan GetMempoolInfoRes):\n\t\tif o.Err != nil {\n\t\t\ta.Result = o.Err\n\t\t} else {\n\t\t\ta.Result = o.Res\n\t\t}\n\t\tisNew = true\n\tdefault:\n\t}\n\treturn\n}", "func (*manager) PluginType() string { return base.PluginTypeDevice }", "func Meter(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"meter\", Attributes: attrs, Children: children}\n}", "func (s *Mobius) Init() {\n\ts.app_ids = s.InterestMap.GetApps()\n\ts.num_apps = len(s.app_ids)\n\tif s.num_apps < 1 {\n\t\tlog.Fatalf(\"[mobius] found %d apps; must have at least 1\", s.num_apps)\n\t}\n\ts.min_app_id = s.app_ids[0]\n\n\t// setup logging: CSV of allocations\n\tif s.Dir != \"\" {\n\t\ts.frontier_writer = common.CreateCSVWriter(s.Dir + \"/frontier.csv\")\n\n\t\t// write header\n\t\t// solver, app1, ..., appN\n\t\theader := make([]string, 2+s.num_apps)\n\t\theader[0] = \"env\"\n\t\theader[1] = \"solver\"\n\t\tfor i := 2; i < len(header); i++ {\n\t\t\theader[i] = fmt.Sprintf(\"app%d\", i-1)\n\t\t}\n\t\ts.frontier_writer.Write(header)\n\t}\n\n\t// compute warm start schedules\n\ts.heuristics = make(map[string]vrp.Schedule)\n\ts.warm_start()\n\ts.last_face = nil\n}", "func (obj *GenericMeasure) GetInfoRaw(ctx context.Context) (json.RawMessage, error) {\n\tresult := &struct {\n\t\tInfo json.RawMessage `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (p *Profile) Start() error {\n\tsuccess, err := C.MXSetProfilerState(C.int(1))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif success != 0 {\n\t\treturn GetLastError()\n\t}\n\tp.startTime = time.Now()\n\tp.started = true\n\n\treturn nil\n}", "func (p *Profile) Start() error {\n\tsuccess, err := C.MXSetProfilerState(C.int(1))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif success != 0 {\n\t\treturn GetLastError()\n\t}\n\tp.startTime = time.Now()\n\tp.started = true\n\n\treturn nil\n}", "func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) ListResult {\n\tvar res ListResult\n\turl := listURL(client)\n\n\tif opts != nil {\n\t\tquery, err := opts.ToMeterListQuery()\n\t\tif err != nil {\n\t\t\tres.Err = err\n\t\t\treturn res\n\t\t}\n\t\turl += query\n\t}\n\n\t_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})\n\treturn res\n}", "func (fetcher *Fetcher) Init() {\n\tfetcher.cpuUsageUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + CPU_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n\tfetcher.memUsageUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + MEM_USAGE_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n\tfetcher.diskFreeUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + DISK_FREE_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n}", "func IsProfiling() bool {\n\treturn globalProbe.IsProfiling()\n}", "func (m *resiliencyMetrics) Init(id string) error {\n\tm.enabled = true\n\tm.appID = id\n\treturn view.Register(\n\t\tdiagUtils.NewMeasureView(m.policiesLoadCount, []tag.Key{appIDKey, resiliencyNameKey, namespaceKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(m.executionCount, []tag.Key{appIDKey, resiliencyNameKey, policyKey, namespaceKey, flowDirectionKey, targetKey, statusKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(m.activationsCount, []tag.Key{appIDKey, resiliencyNameKey, policyKey, namespaceKey, flowDirectionKey, targetKey, statusKey}, view.Count()),\n\t)\n}", "func extraServiceInfo() map[string]interface{} {\n\textraInfo := make(map[string]interface{})\n\textraInfo[\"uptime\"] = time.Now().Round(time.Second).Sub(startTime).String()\n\textraInfo[\"hit count: /profiler/info.html\"] = atomic.LoadUint64(&infoHTMLHitCount)\n\textraInfo[\"hit count: /profiler/info\"] = atomic.LoadUint64(&infoHitCount)\n\treturn extraInfo\n}", "func (m *SnmpMetricCfg) Init() error {\n\t//valIDate config values\n\tif len(m.FieldName) == 0 {\n\t\treturn errors.New(\"FieldName not set in metric Config \" + m.ID)\n\t}\n\tif len(m.BaseOID) == 0 && m.DataSrcType != \"STRINGEVAL\" && m.DataSrcType != \"CONDITIONEVAL\" {\n\t\treturn fmt.Errorf(\"BaseOid not set in metric Config %s type %s\"+m.ID, m.DataSrcType)\n\t}\n\t//https://tools.ietf.org/html/rfc2578 (SMIv2)\n\t//https://tools.ietf.org/html/rfc2579 (Textual Conventions for SMIv2)\n\t//https://tools.ietf.org/html/rfc2851 (Textual Conventions for Internet Network Address)\n\tswitch m.DataSrcType {\n\tcase \"INTEGER\", \"Integer32\":\n\tcase \"Gauge32\":\n\tcase \"UInteger32\", \"Unsigned32\":\n\tcase \"Counter32\", \"COUNTER32\": //raw and cooked increment of Counter32\n\tcase \"Counter64\", \"COUNTER64\": //raw and Cooked increment of Counter64\n\tcase \"COUNTERXX\": //raw and Coocked increment with non_negative behaviour of Counters\n\tcase \"TimeTicks\", \"TIMETICKS\": //raw and cooked to second of timeticks\n\tcase \"BITS\", \"BITSCHK\":\n\tcase \"OCTETSTRING\":\n\tcase \"OID\":\n\tcase \"HWADDR\":\n\tcase \"IpAddress\":\n\tcase \"STRINGPARSER\":\n\tcase \"STRINGEVAL\":\n\tcase \"CONDITIONEVAL\":\n\tdefault:\n\t\treturn errors.New(\"UnkNown DataSourceType:\" + m.DataSrcType + \" in metric Config \" + m.ID)\n\t}\n\tif m.DataSrcType == \"BITSCHK\" {\n\t\tif len(m.ExtraData) == 0 {\n\t\t\treturn errors.New(\"BITSCHK type requires extradata to work \" + m.ID)\n\t\t}\n\t\t_, err := strconv.Atoi(m.ExtraData)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"BITSCHK type requires extradata to be a positive integer to work: ERROR \" + err.Error())\n\t\t}\n\t}\n\tif m.DataSrcType == \"BITS\" {\n\t\tif len(m.ExtraData) == 0 {\n\t\t\treturn errors.New(\"BITS type requires extradata to work \" + m.ID)\n\t\t}\n\t\t//named bits array construction for this Config\n\t\tre := regexp.MustCompile(\"([a-zA-Z0-9]+)\\\\(([0-9]+)\\\\)\")\n\t\tm.Names = make(map[int]string)\n\t\tstr := re.FindAllStringSubmatch(m.ExtraData, -1)\n\t\tfor _, x := range str {\n\t\t\ti, _ := strconv.Atoi(x[2])\n\t\t\tm.Names[i] = x[1]\n\t\t}\n\t}\n\tif m.DataSrcType != \"STRINGEVAL\" && m.DataSrcType != \"CONDITIONEVAL\" && !strings.HasPrefix(m.BaseOID, \".\") {\n\t\treturn errors.New(\"Bad BaseOid format:\" + m.BaseOID + \" in metric Config \" + m.ID)\n\t}\n\tif m.DataSrcType == \"STRINGPARSER\" && len(m.ExtraData) == 0 {\n\t\treturn errors.New(\"STRINGPARSER type requires extradata to work \" + m.ID)\n\t}\n\tif m.DataSrcType == \"STRINGEVAL\" && len(m.ExtraData) == 0 {\n\t\treturn fmt.Errorf(\"ExtraData not set in metric Config %s type %s\"+m.ID, m.DataSrcType)\n\t}\n\tif m.DataSrcType == \"CONDITIONEVAL\" && len(m.ExtraData) == 0 {\n\t\treturn fmt.Errorf(\"ExtraData not set in metric Config %s type %s\"+m.ID, m.DataSrcType)\n\t}\n\treturn nil\n}", "func Metal(index int32) Device {\n return Device{KDLMetal, index}\n}", "func (param *LoadParams) Info() string {\n\treturn fmt.Sprintf(\"current loader[qps=%d, durations=%v,timeout=%v]\", param.QPS, param.Duration, param.Timeout)\n}", "func init() {\n\tfor _, arg := range os.Args {\n\t\tif flag := strings.TrimLeft(arg, \"-\"); flag == MetricsEnabledFlag || flag == DashboardEnabledFlag {\n\t\t\tbgmlogs.Info(\"Enabling metics collection\")\n\t\t\tEnabled = true\n\t\t}\n\t}\n\texp.Exp(metics.DefaultRegistry)\n}", "func metricEnabled() bool {\n\treturn enabled\n}", "func (lp *LoadPoint) HasChargeMeter() bool {\n\t_, isWrapped := lp.chargeMeter.(*wrapper.ChargeMeter)\n\treturn lp.chargeMeter != nil && !isWrapped\n}", "func InitMetrics() error {\n\terr := view.Register(\n\t\tdiagUtils.NewMeasureView(sidecarInjectionRequestsTotal, noKeys, view.Count()),\n\t\tdiagUtils.NewMeasureView(succeededSidecarInjectedTotal, []tag.Key{appIDKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(failedSidecarInjectedTotal, []tag.Key{appIDKey, failedReasonKey}, view.Count()),\n\t)\n\n\treturn err\n}", "func InitPrometheus() *Metrics {\n\tret := &Metrics{}\n\tret.CountTotal = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_total\",\n\t\tHelp: \"Total Requests\",\n\t})\n\n\tret.CountSSR = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_ssr\",\n\t\tHelp: \"SSR Requests\",\n\t})\n\n\tret.CountSSRCached = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_ssr_cached\",\n\t\tHelp: \"Cached SSR Requests\",\n\t})\n\n\tret.Duration = prometheus.NewHistogram(prometheus.HistogramOpts{\n\t\tName: \"rendora_latency_ssr\",\n\t\tHelp: \"SSR Latency\",\n\t\tBuckets: []float64{50, 100, 150, 200, 250, 300, 350, 400, 500},\n\t})\n\n\tprometheus.MustRegister(ret.CountTotal)\n\tprometheus.MustRegister(ret.CountSSR)\n\tprometheus.MustRegister(ret.Duration)\n\n\treturn ret\n}", "func (site *Site) updateMeter(name string, meter api.Meter, power *float64) error {\n\tvalue, err := meter.CurrentPower()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*power = value // update value if no error\n\n\tsite.log.DEBUG.Printf(\"%s power: %.0fW\", name, *power)\n\tsite.publish(name+\"Power\", *power)\n\n\treturn nil\n}", "func (p CognitoIdpPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tstat := make(map[string]interface{})\n\n\tfor _, met := range [...]metrics{\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"SignUpSuccesses\", MackerelName: \"SignUpSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"SignUpThrottles\", MackerelName: \"SignUpThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"SignInSuccesses\", MackerelName: \"SignInSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"SignInThrottles\", MackerelName: \"SignInThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"TokenRefreshSuccesses\", MackerelName: \"TokenRefreshSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"TokenRefreshThrottles\", MackerelName: \"TokenRefreshThrottles\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationSuccesses\", Type: metricsTypeSum},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationParcentageOfSuccessful\", Type: metricsTypeAverage},\n\t\t{CloudWatchName: \"FederationSuccesses\", MackerelName: \"FederationSampleCount\", Type: metricsTypeSampleCount},\n\t\t{CloudWatchName: \"FederationThrottles\", MackerelName: \"FederationThrottles\", Type: metricsTypeSum},\n\t} {\n\t\tv, err := p.getLastPoint(met)\n\t\tif err == nil {\n\t\t\tstat[met.MackerelName] = v\n\t\t} else {\n\t\t\tlog.Printf(\"%s: %s\", met, err)\n\t\t}\n\t}\n\treturn stat, nil\n}", "func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool) {\n\n if logGoMemory {\n if s.GoInfo == nil {\n s.initGoInfo()\n }\n\n runtime.ReadMemStats(s.GoInfo.Memory.mem)\n s.GoInfo.GoRoutines = runtime.NumGoroutine()\n s.GoInfo.Memory.Alloc = s.GoInfo.Memory.mem.Alloc\n s.GoInfo.Memory.HeapAlloc = s.GoInfo.Memory.mem.HeapAlloc\n s.GoInfo.Memory.HeapSys = s.GoInfo.Memory.mem.HeapSys\n\n if s.GoInfo.Memory.LastGC != s.GoInfo.Memory.mem.LastGC {\n s.GoInfo.Memory.LastGC = s.GoInfo.Memory.mem.LastGC\n s.GoInfo.Memory.NumGC = s.GoInfo.Memory.mem.NumGC - s.GoInfo.Memory.lastNumGC\n s.GoInfo.Memory.lastNumGC = s.GoInfo.Memory.mem.NumGC\n s.GoInfo.Memory.LastGCPauseDuration = s.GoInfo.Memory.mem.PauseNs[(s.GoInfo.Memory.mem.NumGC+255)%256]\n } else {\n s.GoInfo.Memory.NumGC = 0\n s.GoInfo.Memory.LastGCPauseDuration = 0\n }\n }\n\n if logMemory {\n\n if s.MemInfo == nil {\n s.MemInfo = new(MemInfo)\n }\n\n s.MemInfo.Memory, _ = mem.VirtualMemory()\n s.MemInfo.Swap, _ = mem.SwapMemory()\n }\n}", "func initMetrics() *metrics.Manager {\n\treturn metrics.New(\"calert\")\n}" ]
[ "0.539896", "0.53067774", "0.5249441", "0.5143005", "0.51400584", "0.51064706", "0.5102786", "0.5036036", "0.5020601", "0.4920699", "0.48788077", "0.4765713", "0.47069648", "0.46974233", "0.4680174", "0.4599874", "0.4551892", "0.45465773", "0.45447186", "0.45283294", "0.4526914", "0.4515087", "0.45086467", "0.4495089", "0.4488009", "0.44760835", "0.44543183", "0.44395033", "0.4417178", "0.4398293", "0.43948784", "0.4376258", "0.4363284", "0.4360561", "0.4353958", "0.4352054", "0.4339155", "0.43341425", "0.43249795", "0.43238887", "0.43215474", "0.43064952", "0.43062016", "0.43017185", "0.43015555", "0.42806587", "0.427863", "0.4278295", "0.4264802", "0.42640063", "0.42546627", "0.42525217", "0.42518565", "0.42517364", "0.42452857", "0.4240379", "0.42382926", "0.42337215", "0.42280486", "0.42189315", "0.42145047", "0.42110378", "0.42076185", "0.42037508", "0.42036274", "0.4199588", "0.41951808", "0.4189737", "0.4183484", "0.41824624", "0.41820407", "0.4179254", "0.41788298", "0.41715494", "0.41611", "0.41591597", "0.41527656", "0.41495696", "0.41489482", "0.41450813", "0.4142329", "0.41332278", "0.41332278", "0.41315708", "0.41305187", "0.41300458", "0.41255358", "0.4125247", "0.41218075", "0.41213718", "0.41106448", "0.41095036", "0.41089275", "0.41067803", "0.41058335", "0.410088", "0.4100285", "0.410006", "0.40996066", "0.40983725" ]
0.46326983
15
Retrieve the metering information for a particular DSP. "INIT_PROFILE_METER_ALL" with "System.Init" will automatically turn on metering for all DSP units inside the FMOD mixer graph.
func (d *DSP) MeteringInfo() (DSPMeteringInfo, DSPMeteringInfo, error) { var cinputInfo, coutputInfo C.FMOD_DSP_METERING_INFO var inputInfo, outputInfo DSPMeteringInfo res := C.FMOD_DSP_GetMeteringInfo(d.cptr, &cinputInfo, &coutputInfo) inputInfo.fromC(cinputInfo) outputInfo.fromC(coutputInfo) return inputInfo, outputInfo, errs[res] }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func InitMeter(db persistence.Conn) func() {\n\tcleanupFunc := func() {}\n\n\tmetricProvider := os.Getenv(\"METRIC_PROVIDER\")\n\tif metricProvider == \"\" {\n\t\tlog(nil, nil).Info(\"METRIC_PROVIDER not set, metrics will not be generated.\")\n\t\treturn cleanupFunc\n\t}\n\n\tvar err error\n\tswitch metricProvider {\n\tcase STDOUT, PRETTY:\n\t\tvar pusher *push.Controller\n\t\tpusher, err = metricstdout.InstallNewPipeline(metricstdout.Config{\n\t\t\tQuantiles: []float64{},\n\t\t\tPrettyPrint: metricProvider == PRETTY,\n\t\t}, push.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcleanupFunc = pusher.Stop\n\tcase PROMETHEUS:\n\t\tvar exporter *prometheus.Exporter\n\t\texporter, err = prometheus.InstallNewPipeline(prometheus.Config{}, pull.WithStateful(false))\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\thttp.HandleFunc(\"/metrics\", exporter.ServeHTTP)\n\t\tgo func() {\n\t\t\t_ = http.ListenAndServe(\":2222\", nil)\n\t\t}()\n\tdefault:\n\t\tlog(nil, nil).WithField(\"provider\", metricProvider).Fatal(\"Unsupported metric provider\")\n\t}\n\n\tif err != nil {\n\t\tlog(nil, err).WithField(\"provider\", metricProvider).Fatal(\"failed to initialize metric stdout exporter\")\n\t}\n\n\tinitSystemStatsObserver(db)\n\n\treturn cleanupFunc\n}", "func (f *falconMeter) Update() {\n\tfalcon.SetMeterCount(f.name, 1)\n}", "func (s *Tplink) GetMeterInto() (SysInfo, error) {\n\tvar (\n\t\tpayload meterInfo\n\t\tjsonResp SysInfo\n\t)\n\n\tj, _ := json.Marshal(payload)\n\n\tdata := encrypt(string(j))\n\tresp, err := send(s.Host, data)\n\tif err != nil {\n\t\treturn jsonResp, err\n\t}\n\n\tif err := json.Unmarshal([]byte(decrypt(resp)), &jsonResp); err != nil {\n\t\treturn jsonResp, err\n\t}\n\treturn jsonResp, nil\n}", "func InitGameProfilers() {\r\n\tupdateProfiler = system.NewProfiler(\"update\")\r\n\tcollisionProfiler = system.NewProfiler(\"collision\")\r\n\tmusicProfiler = system.NewProfiler(\"music\")\r\n\tweatherProfiler = system.NewProfiler(\"weather\")\r\n\tgameModeProfiler = system.NewProfiler(\"gameMode\")\r\n\tdrawProfiler = system.NewProfiler(\"draw\")\r\n\tsortRenderProfiler = system.NewProfiler(\"sortRender\")\r\n\tcullRenderProfiler = system.NewProfiler(\"cullRender\")\r\n\tlightingProfiler = system.NewProfiler(\"lighting\")\r\n\tscriptingProfiler = system.NewProfiler(\"scripting\")\r\n\r\n\tframeRateString = \"total time: 0 ms (0 FPS)\"\r\n\totherTimeString = \"measured time: 0 ms\"\r\n}", "func (p *hardwareProfiler) Profile() (*HardwareProfile, error) {\n\tvar err error\n\thwProfile := &HardwareProfile{}\n\tfor profilerType, profiler := range p.profilers {\n\t\tprofileVal, err2 := profiler.Profile()\n\t\terr = multierr.Append(err, err2)\n\t\tif err2 == nil {\n\t\t\tif hwProfile.TimeEnabled == nil {\n\t\t\t\thwProfile.TimeEnabled = &profileVal.TimeEnabled\n\t\t\t}\n\t\t\tif hwProfile.TimeRunning == nil {\n\t\t\t\thwProfile.TimeRunning = &profileVal.TimeRunning\n\t\t\t}\n\t\t\tswitch profilerType {\n\t\t\tcase unix.PERF_COUNT_HW_CPU_CYCLES:\n\t\t\t\thwProfile.CPUCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_INSTRUCTIONS:\n\t\t\t\thwProfile.Instructions = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_REFERENCES:\n\t\t\t\thwProfile.CacheRefs = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_CACHE_MISSES:\n\t\t\t\thwProfile.CacheMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_INSTRUCTIONS:\n\t\t\t\thwProfile.BranchInstr = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BRANCH_MISSES:\n\t\t\t\thwProfile.BranchMisses = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_BUS_CYCLES:\n\t\t\t\thwProfile.BusCycles = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_FRONTEND:\n\t\t\t\thwProfile.StalledCyclesFrontend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_STALLED_CYCLES_BACKEND:\n\t\t\t\thwProfile.StalledCyclesBackend = &profileVal.Value\n\t\t\tcase unix.PERF_COUNT_HW_REF_CPU_CYCLES:\n\t\t\t\thwProfile.RefCPUCycles = &profileVal.Value\n\t\t\t}\n\t\t}\n\t}\n\tif len(multierr.Errors(err)) == len(p.profilers) {\n\t\treturn nil, err\n\t}\n\n\treturn hwProfile, nil\n}", "func (s *DevStat) Init(id string, tm map[string]string, l *logrus.Logger) {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\ts.id = id\n\ts.TagMap = tm\n\ts.log = l\n\ts.Counters = make([]interface{}, DevStatTypeSize)\n\ts.Counters[SnmpGetQueries] = 0\n\ts.Counters[SnmpWalkQueries] = 0\n\ts.Counters[SnmpGetErrors] = 0\n\ts.Counters[SnmpWalkErrors] = 0\n\ts.Counters[SnmpQueryTimeouts] = 0\n\ts.Counters[SnmpOIDGetAll] = 0\n\ts.Counters[SnmpOIDGetProcessed] = 0\n\ts.Counters[SnmpOIDGetErrors] = 0\n\ts.Counters[EvalMetricsAll] = 0\n\ts.Counters[EvalMetricsOk] = 0\n\ts.Counters[EvalMetricsErrors] = 0\n\ts.Counters[MetricSent] = 0\n\ts.Counters[MeasurementSent] = 0\n\ts.Counters[MetricSentErrors] = 0\n\ts.Counters[MeasurementSentErrors] = 0\n\ts.Counters[CycleGatherStartTime] = 0\n\ts.Counters[CycleGatherDuration] = 0.0\n\ts.Counters[FilterStartTime] = 0\n\ts.Counters[FilterDuration] = 0.0\n\ts.Counters[BackEndSentStartTime] = 0\n\ts.Counters[BackEndSentDuration] = 0.0\n\ts.Counters[DeviceActive] = 0\n\ts.Counters[DeviceConnected] = 0\n}", "func Meter(component interface{}, sampleRate signal.SampleRate) ResetFunc {\n\tt := getType(component)\n\tmetric := components.get(t)\n\tmetric.components.Add(1)\n\treturn func() MeasureFunc {\n\t\tcalledAt := time.Now()\n\t\tvar (\n\t\t\tbufferSize int\n\t\t\tbufferDuration time.Duration\n\t\t)\n\t\treturn func(s int) {\n\t\t\tmetric.latency.set(time.Since(calledAt))\n\t\t\tmetric.messages.Add(1)\n\t\t\tmetric.samples.Add(int64(s))\n\t\t\t// recalculate buffer duration only when buffer size has changed\n\t\t\tif bufferSize != s {\n\t\t\t\tbufferSize = s\n\t\t\t\tbufferDuration = sampleRate.DurationOf(s)\n\t\t\t}\n\t\t\tmetric.duration.add(bufferDuration)\n\t\t\tcalledAt = time.Now()\n\t\t}\n\t}\n}", "func (c *switchBotCollector) init() error {\n\tdevices, _, err := c.client.Device().List(context.Background())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, d := range devices {\n\t\tswitch d.Type {\n\t\tcase switchbot.Meter:\n\t\t\tc.meters = append(c.meters, d)\n\t\t\tlog.Printf(\"adding meter with device id: %s, name: %s\\n\", d.ID, d.Name)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *Manager) Meter(delay time.Duration) *Meter {\n\treturn &Meter{\n\t\tm: m,\n\t\tdelay: delay,\n\t\tnext: time.Now(),\n\t}\n}", "func Init() {\n\n\tprometheus.MustRegister(FunctionDurations)\n\tprometheus.MustRegister(FunctionCountTotal)\n\n}", "func GetInfo() adapter.Info {\n\treturn adapter.Info{\n\t\tName: \"statsd\",\n\t\tImpl: \"istio.io/istio/mixer/adapter/statsd\",\n\t\tDescription: \"Produces statsd metrics\",\n\t\tSupportedTemplates: []string{\n\t\t\tmetric.TemplateName,\n\t\t},\n\t\tDefaultConfig: &config.Params{\n\t\t\tAddress: \"localhost:8125\",\n\t\t\tPrefix: \"\",\n\t\t\tFlushDuration: 300 * time.Millisecond,\n\t\t\tFlushBytes: 512,\n\t\t\tSamplingRate: 1.0,\n\t\t},\n\n\t\tNewBuilder: func() adapter.HandlerBuilder { return &builder{} },\n\t}\n}", "func (ct *cpuTracker) getMeter(vdr ids.ShortID) uptime.Meter {\n\tmeter, exists := ct.cpuSpenders[vdr]\n\tif exists {\n\t\treturn meter\n\t}\n\n\tnewMeter := ct.factory.New(ct.halflife)\n\tct.cpuSpenders[vdr] = newMeter\n\treturn newMeter\n}", "func init() {\n\tprometheus.MustRegister(powerConsumption)\n\tgetPower()\n}", "func MeterProvider() metric.Provider {\n\tif gp := globalMeter.Load(); gp != nil {\n\t\treturn gp.(meterProvider).mp\n\t}\n\treturn metric.NoopProvider{}\n}", "func meterReader(d *db.DB) error {\n\tsect := d.Config.GetSection(\"meter\")\n\tif sect == nil {\n\t\treturn nil\n\t}\n\tvar angle float64\n\ta, err := sect.GetArg(\"rotate\")\n\tif err == nil {\n\t\tangle, err = strconv.ParseFloat(a, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tsource, err := sect.GetArg(\"source\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tr, err := NewReader(sect, d.Trace)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.AddDiff(db.D_IN_POWER, time.Minute*5)\n\td.AddDiff(db.D_OUT_POWER, time.Minute*5)\n\td.AddAccum(db.A_IN_TOTAL, true)\n\td.AddAccum(db.A_OUT_TOTAL, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_IMPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\td.AddSubAccum(db.A_EXPORT, true)\n\tlog.Printf(\"Registered meter LCD reader\\n\")\n\tgo runReader(d, r, source, angle)\n\treturn nil\n}", "func Meter(attrs []htmlgo.Attribute, children ...HTML) HTML {\n\treturn &htmlgo.Tree{Tag: \"meter\", Attributes: attrs, Children: children}\n}", "func MeterStatistics(client *gophercloud.ServiceClient, n string, opts MeterStatisticsOptsBuilder) StatisticsResult {\n\tvar res StatisticsResult\n\turl := statisticsURL(client, n)\n\n\tif opts != nil {\n\t\tquery, err := opts.ToMeterStatisticsQuery()\n\t\tif err != nil {\n\t\t\tres.Err = err\n\t\t\treturn res\n\t\t}\n\t\turl += query\n\t}\n\n\t_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})\n\treturn res\n}", "func (m *Metrics) Init() error {\n\tm.missedCount = make(map[string]int64)\n\tm.hitCount = make(map[string]int64)\n\tm.Logger.Debug().Msgf(\"fake metrics: %v\", m.GraphiteMode)\n\tswitch m.GraphiteMode {\n\tcase graphiteOff:\n\n\tcase graphiteStdout:\n\t\tgo goMetrics.Log(m.EveryHourRegister, 30*time.Second, log.New(os.Stderr, \"METRICS_HOUR: \", log.Lmicroseconds))\n\t\tgo goMetrics.Log(m.EveryMinuteRegister, 30*time.Second, log.New(os.Stderr, \"METRICS_MINUTE: \", log.Lmicroseconds))\n\n\tcase graphiteRemote:\n\t\taddr, err := net.ResolveTCPAddr(\"tcp\", m.GraphiteHost)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgo graphite.Graphite(m.EveryHourRegister, time.Minute*30, \"\", addr)\n\t\tgo graphite.Graphite(m.EveryMinuteRegister, time.Second*30, \"\", addr)\n\t}\n\n\treturn nil\n}", "func (s *SystemdTimings) Gather(acc telegraf.Accumulator) error {\n\tif !bootIsFinished() {\n\t\t// We are not ready to collect yet, telegraf will call us later to\n\t\t// try again.\n\t\treturn nil\n\t}\n\n\tif s.Periodic == false {\n\t\t// We only want to run once.\n\t\tif collectionDone == true {\n\t\t\t// By default we only collect once since these are generally boot\n\t\t\t// time metrics.\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Connect to the systemd dbus.\n\tdbusConn, err := dbus.NewSystemConnection()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer dbusConn.Close()\n\n\terr = postAllManagerProps(dbusConn, acc)\n\tif err != nil {\n\t\tacc.AddError(err)\n\t\treturn err\n\t}\n\n\t// Read all unit timing data.\n\terr = postAllUnitTimingData(dbusConn, acc, s)\n\tif err != nil {\n\t\tacc.AddError(err)\n\t\treturn err\n\t}\n\n\tif err == nil {\n\t\tcollectionDone = true\n\t}\n\n\treturn err\n}", "func (d *DSP) Info(name *C.char, version *C.uint, channels, configwidth, configheight *C.int) error {\n\t//FMOD_RESULT F_API FMOD_DSP_GetInfo(FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\treturn ErrNoImpl\n}", "func GetDevStats() map[string]*stats.GatherStats {\n\tdevstats := make(map[string]*stats.GatherStats)\n\tmutex.RLock()\n\tfor k, v := range devices {\n\t\tdevstats[k] = v.GetBasicStats()\n\t}\n\tmutex.RUnlock()\n\treturn devstats\n}", "func (m *HistoMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func (obj *GenericMeasure) GetInfo(ctx context.Context) (*NxInfo, error) {\n\tresult := &struct {\n\t\tInfo *NxInfo `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (m *MeterMetric) IsMeter() bool {\n\treturn m.Type == meterMetricType\n}", "func defaultServerMeasures() {\n\tvar err error\n\n\tif RPCServerErrorCount, err = stats.NewMeasureInt64(\"grpc.io/server/error_count\", \"RPC Errors\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/error_count: %v\", err)\n\t}\n\tif RPCServerServerElapsedTime, err = stats.NewMeasureFloat64(\"grpc.io/server/server_elapsed_time\", \"Server elapsed time in msecs\", unitMillisecond); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/server_elapsed_time: %v\", err)\n\t}\n\tif RPCServerRequestBytes, err = stats.NewMeasureInt64(\"grpc.io/server/request_bytes\", \"Request bytes\", unitByte); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/request_bytes: %v\", err)\n\t}\n\tif RPCServerResponseBytes, err = stats.NewMeasureInt64(\"grpc.io/server/response_bytes\", \"Response bytes\", unitByte); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/response_bytes: %v\", err)\n\t}\n\tif RPCServerStartedCount, err = stats.NewMeasureInt64(\"grpc.io/server/started_count\", \"Number of server RPCs (streams) started\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/started_count: %v\", err)\n\t}\n\tif RPCServerFinishedCount, err = stats.NewMeasureInt64(\"grpc.io/server/finished_count\", \"Number of server RPCs (streams) finished\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/finished_count: %v\", err)\n\t}\n\tif RPCServerRequestCount, err = stats.NewMeasureInt64(\"grpc.io/server/request_count\", \"Number of server RPC request messages\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/request_count: %v\", err)\n\t}\n\tif RPCServerResponseCount, err = stats.NewMeasureInt64(\"grpc.io/server/response_count\", \"Number of server RPC response messages\", unitCount); err != nil {\n\t\tlog.Fatalf(\"Cannot create measure grpc.io/server/response_count: %v\", err)\n\t}\n}", "func NewMeter(name string) metics.Meter {\n\tif !Enabled {\n\t\treturn new(metics.NilMeter)\n\t}\n\treturn metics.GetOrRegisterMeter(name, metics.DefaultRegistry)\n}", "func (s *AppEngineService) GetDevicesStats(realm string) (DevicesStats, error) {\n\tcallURL, _ := url.Parse(s.appEngineURL.String())\n\tcallURL.Path = path.Join(callURL.Path, fmt.Sprintf(\"/v1/%s/stats/devices\", realm))\n\tdecoder, err := s.client.genericJSONDataAPIGET(callURL.String(), 200)\n\tif err != nil {\n\t\treturn DevicesStats{}, err\n\t}\n\tvar responseBody struct {\n\t\tData DevicesStats `json:\"data\"`\n\t}\n\terr = decoder.Decode(&responseBody)\n\tif err != nil {\n\t\treturn DevicesStats{}, err\n\t}\n\n\treturn responseBody.Data, nil\n}", "func GetSamplesInfo(stream StreamInfo, fragmentInfo FragmentInfo) (sampleInfo []SampleInfo) {\n\n\tsampleInfo = make([]SampleInfo, fragmentInfo.getSampleCount())\n\n\t// Get size And offset of the sample in MDat\n\tregisterSamplesSizes(stream, fragmentInfo, &sampleInfo)\n\n\tif stream.isVideo() {\n\n\t\t// Retrieve all NAL unit length in this sample\n\t\tregisterNalUnits(stream, &sampleInfo)\n\n\t\t// Registers all iFrames\n\t\tregisterISamples(fragmentInfo, &sampleInfo)\n\t}\n\n\t// Retrieve the compositionTimeOffset and decodingTimeOffset\n\tregisterCTSAndDTSSamples(stream, fragmentInfo, &sampleInfo)\n\n\t// Compute the pcr\n\tregisterPCRSamples(stream, fragmentInfo, &sampleInfo)\n\n\t// Scale timestamps with the timeScale\n\tScaleTimeStamps(stream, &sampleInfo)\n\n\treturn\n}", "func (sr *ServicedStatsReporter) gatherStats(t time.Time) []Sample {\n\tstats := []Sample{}\n\t// Handle the host metrics.\n\treg, _ := sr.hostRegistry.(*metrics.StandardRegistry)\n\treg.Each(func(name string, i interface{}) {\n\t\ttagmap := map[string]string{\n\t\t\t\"controlplane_host_id\": sr.hostID,\n\t\t}\n\t\tswitch metric := i.(type) {\n\t\tcase metrics.Gauge:\n\t\t\tstats = append(stats, Sample{name, strconv.FormatInt(metric.Value(), 10), t.Unix(), tagmap})\n\t\tcase metrics.GaugeFloat64:\n\t\t\tstats = append(stats, Sample{name, strconv.FormatFloat(metric.Value(), 'f', -1, 32), t.Unix(), tagmap})\n\t\t}\n\t})\n\t// Handle each container's metrics.\n\tfor key, registry := range sr.containerRegistries {\n\t\treg, _ := registry.(*metrics.StandardRegistry)\n\t\treg.Each(func(name string, i interface{}) {\n\t\t\ttagmap := map[string]string{\n\t\t\t\t\"controlplane_host_id\": sr.hostID,\n\t\t\t\t\"controlplane_service_id\": key.serviceID,\n\t\t\t\t\"controlplane_instance_id\": strconv.FormatInt(int64(key.instanceID), 10),\n\t\t\t}\n\t\t\tswitch metric := i.(type) {\n\t\t\tcase metrics.Gauge:\n\t\t\t\tstats = append(stats, Sample{name, strconv.FormatInt(metric.Value(), 10), t.Unix(), tagmap})\n\t\t\tcase metrics.GaugeFloat64:\n\t\t\t\tstats = append(stats, Sample{name, strconv.FormatFloat(metric.Value(), 'f', -1, 32), t.Unix(), tagmap})\n\t\t\t}\n\t\t})\n\t}\n\treturn stats\n}", "func meterHelp() string {\n\ts := fmt.Sprintf(\"\\n %s\", \"RTU\")\n\ttypes := make([]string, 0)\n\tfor t := range rs485.Producers {\n\t\ttypes = append(types, t)\n\t}\n\n\tsort.Strings(types)\n\n\tfor _, t := range types {\n\t\tp := rs485.Producers[t]()\n\t\ts += fmt.Sprintf(\"\\n %-10s%s\", t, p.Description())\n\t}\n\n\ts += fmt.Sprintf(\"\\n %s\", \"TCP\")\n\ts += fmt.Sprintf(\"\\n %-10s%s\", \"SUNS\", \"Sunspec-compatible MODBUS TCP device (SMA, SolarEdge, KOSTAL, etc)\")\n\n\treturn s\n}", "func (s *Simulator) Stats() *Stats {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\telapsed := time.Since(s.now).Seconds()\n\tpThrough := float64(s.writtenN) / elapsed\n\trespMean := 0\n\tif len(s.latencyHistory) > 0 {\n\t\trespMean = int(s.totalLatency) / len(s.latencyHistory) / int(time.Millisecond)\n\t}\n\tstats := &Stats{\n\t\tTime: time.Unix(0, int64(time.Since(s.now))),\n\t\tTags: s.ReportTags,\n\t\tFields: models.Fields(map[string]interface{}{\n\t\t\t\"T\": int(elapsed),\n\t\t\t\"points_written\": s.writtenN,\n\t\t\t\"values_written\": s.writtenN * s.FieldsPerPoint,\n\t\t\t\"points_ps\": pThrough,\n\t\t\t\"values_ps\": pThrough * float64(s.FieldsPerPoint),\n\t\t\t\"write_error\": s.currentErrors,\n\t\t\t\"resp_wma\": int(s.wmaLatency),\n\t\t\t\"resp_mean\": respMean,\n\t\t\t\"resp_90\": int(s.quartileResponse(0.9) / time.Millisecond),\n\t\t\t\"resp_95\": int(s.quartileResponse(0.95) / time.Millisecond),\n\t\t\t\"resp_99\": int(s.quartileResponse(0.99) / time.Millisecond),\n\t\t}),\n\t}\n\n\tvar isCreating bool\n\tif s.writtenN < s.SeriesN() {\n\t\tisCreating = true\n\t}\n\tstats.Tags[\"creating_series\"] = fmt.Sprint(isCreating)\n\n\t// Reset error count for next reporting.\n\ts.currentErrors = 0\n\n\t// Add runtime stats for the remote instance.\n\tvar vars Vars\n\tresp, err := http.Get(strings.TrimSuffix(s.Host, \"/\") + \"/debug/vars\")\n\tif err != nil {\n\t\t// Don't log error as it can get spammy.\n\t\treturn stats\n\t}\n\tdefer resp.Body.Close()\n\n\tif err := json.NewDecoder(resp.Body).Decode(&vars); err != nil {\n\t\tfmt.Fprintln(s.Stderr, err)\n\t\treturn stats\n\t}\n\n\tstats.Fields[\"heap_alloc\"] = vars.Memstats.HeapAlloc\n\tstats.Fields[\"heap_in_use\"] = vars.Memstats.HeapInUse\n\tstats.Fields[\"heap_objects\"] = vars.Memstats.HeapObjects\n\treturn stats\n}", "func Metal(index int32) Device {\n return Device{KDLMetal, index}\n}", "func init() {\n\tdb.RegisterInit(meterReader)\n}", "func (c *Client) GetMempoolInfo() (info *MempoolInfo, err error) {\r\n\r\n\tvar resp string\r\n\t// https://api.whatsonchain.com/v1/bsv/<network>/mempool/info\r\n\tif resp, err = c.request(fmt.Sprintf(\"%s%s/mempool/info\", apiEndpoint, c.Network), http.MethodGet, nil); err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\terr = json.Unmarshal([]byte(resp), &info)\r\n\treturn\r\n}", "func Meter(props *MeterProps, children ...Element) *MeterElem {\n\trProps := &_MeterProps{\n\t\tBasicHTMLElement: newBasicHTMLElement(),\n\t}\n\n\tif props != nil {\n\t\tprops.assign(rProps)\n\t}\n\n\treturn &MeterElem{\n\t\tElement: createElement(\"meter\", rProps, children...),\n\t}\n}", "func (d *Distance) Meters() (result int) {\n\tswitch d.Unit {\n\tcase M:\n\t\tresult = d.Value\n\tcase FT:\n\t\tresult = cnv.FtToM(d.Value)\n\tcase SM:\n\t\tresult = cnv.SMileToM(float64(d.Value) + d.FractionValue)\n\tdefault:\n\t\tresult = d.Value\n\t}\n\treturn\n}", "func init() {\n\tprometheus.MustRegister(uptime, reqCount, reqCountPerEndpoint, userCPU, systemCPU, memUsage, diskUsage)\n\tinitStat, err := stat.GetServerStat()\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tgo recordServerMetrics(initStat)\n}", "func init() {\n\tprometheus.MustRegister(logicTotal)\n\tprometheus.MustRegister(logicLatency)\n}", "func (site *Site) updateMeters() error {\n\tretryMeter := func(s string, m api.Meter, f *float64) error {\n\t\tif m == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\terr := retry.Do(func() error {\n\t\t\treturn site.updateMeter(s, m, f)\n\t\t}, retryOptions...)\n\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"updating %s meter: %v\", s, err)\n\t\t\tsite.log.ERROR.Println(err)\n\t\t}\n\n\t\treturn err\n\t}\n\n\t// pv meter is not critical for operation\n\t_ = retryMeter(\"pv\", site.pvMeter, &site.pvPower)\n\n\terr := retryMeter(\"grid\", site.gridMeter, &site.gridPower)\n\tif err == nil {\n\t\terr = retryMeter(\"battery\", site.batteryMeter, &site.batteryPower)\n\t}\n\n\t// currents\n\tif phaseMeter, ok := site.gridMeter.(api.MeterCurrent); err == nil && ok {\n\t\ti1, i2, i3, err := phaseMeter.Currents()\n\t\tif err == nil {\n\t\t\tsite.log.TRACE.Printf(\"grid currents: %vA\", []float64{i1, i2, i3})\n\t\t\tsite.publish(\"gridCurrents\", []float64{i1, i2, i3})\n\t\t}\n\t}\n\n\treturn err\n}", "func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) ListResult {\n\tvar res ListResult\n\turl := listURL(client)\n\n\tif opts != nil {\n\t\tquery, err := opts.ToMeterListQuery()\n\t\tif err != nil {\n\t\t\tres.Err = err\n\t\t\treturn res\n\t\t}\n\t\turl += query\n\t}\n\n\t_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})\n\treturn res\n}", "func (s *Stats) GetAllCPUInfo() {\n s.GetCPUInfo()\n s.GetCPUTimes()\n}", "func (s *Stream) Info() *StreamInfo {\n\ti := C.Pa_GetStreamInfo(s.paStream)\n\tif i == nil {\n\t\treturn nil\n\t}\n\treturn &StreamInfo{duration(i.inputLatency), duration(i.outputLatency), float64(i.sampleRate)}\n}", "func (client DDMetricsClient) GetInfo() (*DDInfo, error) {\n\tinfoURL := client.endpoint\n\tinfoURL.Path = \"/info\"\n\tresp, err := client.httpClient.Get(infoURL.String())\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := DDInfo{}\n\terr = json.NewDecoder(resp.Body).Decode(&info)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlogrus.Debugln(\"Received /info from Deepdetect :\", info)\n\treturn &info, nil\n}", "func (site *Site) updateMeter(name string, meter api.Meter, power *float64) error {\n\tvalue, err := meter.CurrentPower()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*power = value // update value if no error\n\n\tsite.log.DEBUG.Printf(\"%s power: %.0fW\", name, *power)\n\tsite.publish(name+\"Power\", *power)\n\n\treturn nil\n}", "func CollectProcessMetrics(refresh time.Duration) {\n\t// Short circuit if the metics system is disabled\n\tif !Enabled {\n\t\treturn\n\t}\n\t// Create the various data collectors\n\tmemstates := make([]*runtime.MemStats, 2)\n\tdiskstates := make([]*DiskStats, 2)\n\tfor i := 0; i < len(memstates); i++ {\n\t\tmemstates[i] = new(runtime.MemStats)\n\t\tdiskstates[i] = new(DiskStats)\n\t}\n\t// Define the various metics to collect\n\tmemAllocs := metics.GetOrRegisterMeter(\"system/memory/allocs\", metics.DefaultRegistry)\n\tmemFrees := metics.GetOrRegisterMeter(\"system/memory/frees\", metics.DefaultRegistry)\n\tmemInuse := metics.GetOrRegisterMeter(\"system/memory/inuse\", metics.DefaultRegistry)\n\tmemPauses := metics.GetOrRegisterMeter(\"system/memory/pauses\", metics.DefaultRegistry)\n\n\tvar diskReads, diskReadBytes, diskWrites, diskWriteBytes metics.Meter\n\tif err := ReadDiskStats(diskstates[0]); err == nil {\n\t\tdiskReads = metics.GetOrRegisterMeter(\"system/disk/readcount\", metics.DefaultRegistry)\n\t\tdiskReadBytes = metics.GetOrRegisterMeter(\"system/disk/readdata\", metics.DefaultRegistry)\n\t\tdiskWrites = metics.GetOrRegisterMeter(\"system/disk/writecount\", metics.DefaultRegistry)\n\t\tdiskWriteBytes = metics.GetOrRegisterMeter(\"system/disk/writedata\", metics.DefaultRegistry)\n\t} else {\n\t\tbgmlogs.Debug(\"Failed to read disk metics\", \"err\", err)\n\t}\n\t// Iterate loading the different states and updating the meters\n\tfor i := 1; ; i++ {\n\t\truntime.ReadMemStats(memstates[i%2])\n\t\tmemAllocs.Mark(int64(memstates[i%2].Mallocs - memstates[(i-1)%2].Mallocs))\n\t\tmemFrees.Mark(int64(memstates[i%2].Frees - memstates[(i-1)%2].Frees))\n\t\tmemInuse.Mark(int64(memstates[i%2].Alloc - memstates[(i-1)%2].Alloc))\n\t\tmemPauses.Mark(int64(memstates[i%2].PauseTotalNs - memstates[(i-1)%2].PauseTotalNs))\n\n\t\tif ReadDiskStats(diskstates[i%2]) == nil {\n\t\t\tdiskReads.Mark(diskstates[i%2].ReadCount - diskstates[(i-1)%2].ReadCount)\n\t\t\tdiskReadBytes.Mark(diskstates[i%2].ReadBytes - diskstates[(i-1)%2].ReadBytes)\n\t\t\tdiskWrites.Mark(diskstates[i%2].WriteCount - diskstates[(i-1)%2].WriteCount)\n\t\t\tdiskWriteBytes.Mark(diskstates[i%2].WriteBytes - diskstates[(i-1)%2].WriteBytes)\n\t\t}\n\t\ttime.Sleep(refresh)\n\t}\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"psoft\", \"stat\", New)\n}", "func (r *Reader) ReadMeter() (n int, d time.Duration) {\n\tr.Lock()\n\tdefer r.Unlock()\n\n\td = r.d\n\tn = r.n\n\tr.n = 0\n\tr.d = 0\n\treturn\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"mssql\", \"performance\", New,\n\t\tmb.DefaultMetricSet(),\n\t\tmb.WithHostParser(mssql.HostParser))\n}", "func APISFamily(sampler Sampler, size int) ([]float64, []float64) {\n\tmus, sigmas := make([]float64, size), make([]float64, size)\n\tfor i := range mus {\n\t\tmus[i] = sampler.Sample()\n\t\tsigmas[i] = sampler.Sample()\n\t\tif sigmas[i] < 0 {\n\t\t\tsigmas[i] *= -1\n\t\t}\n\t}\n\treturn mus, sigmas\n}", "func (m *Meter) MaybeStats() *MeterStats {\n\tnow := time.Now()\n\telapsedInIntervalMs := now.Sub(m.lastIntervalStart).Milliseconds()\n\tif elapsedInIntervalMs > m.printInterval.Milliseconds() {\n\t\tintervalCount := m.totalCount - m.lastCount\n\t\tintervalRatePerS := float64(intervalCount) / float64(elapsedInIntervalMs) * 1000.0\n\t\tm.lastCount = m.totalCount\n\t\tm.lastIntervalStart = now\n\n\t\telapsedTotalMs := now.Sub(m.start).Milliseconds()\n\t\ttotalRatePerS := float64(m.totalCount) / float64(elapsedTotalMs) * 1000.0\n\n\t\tm.lastStats = MeterStats{\n\t\t\tName: m.name,\n\t\t\tStart: m.start,\n\t\t\tTotalCount: m.totalCount,\n\t\t\tTotalRatePerS: totalRatePerS,\n\t\t\tIntervalCount: intervalCount,\n\t\t\tIntervalRatePerS: intervalRatePerS,\n\t\t}\n\t\treturn &m.lastStats\n\t}\n\treturn nil\n}", "func (obj *GenericMeasure) GetInfoRaw(ctx context.Context) (json.RawMessage, error) {\n\tresult := &struct {\n\t\tInfo json.RawMessage `json:\"qInfo\"`\n\t}{}\n\terr := obj.RPC(ctx, \"GetInfo\", result)\n\treturn result.Info, err\n}", "func (ooc *MockOpenoltClient) GetDeviceInfo(ctx context.Context, in *openolt.Empty, opts ...grpc.CallOption) (*openolt.DeviceInfo, error) {\n\tif ooc.counter == 0 {\n\t\tooc.counter++\n\t\tdeviceInfo := &openolt.DeviceInfo{Vendor: \"Openolt\", Model: \"1.0\", HardwareVersion: \"1.0\", FirmwareVersion: \"1.0\", DeviceId: \"olt\", DeviceSerialNumber: \"olt\"}\n\t\treturn deviceInfo, nil\n\t}\n\tif ooc.counter == 1 {\n\t\tooc.counter++\n\t\tdeviceInfo := &openolt.DeviceInfo{Vendor: \"Openolt\", Model: \"1.0\", HardwareVersion: \"1.0\", FirmwareVersion: \"1.0\", DeviceId: \"\", DeviceSerialNumber: \"olt\"}\n\t\treturn deviceInfo, nil\n\t}\n\tif ooc.counter == 2 {\n\t\tooc.counter++\n\t\treturn nil, nil\n\t}\n\n\treturn nil, errors.New(\"device info not found\")\n}", "func (mock *GpuInstanceMock) GetInfoCalls() []struct {\n} {\n\tvar calls []struct {\n\t}\n\tmock.lockGetInfo.RLock()\n\tcalls = mock.calls.GetInfo\n\tmock.lockGetInfo.RUnlock()\n\treturn calls\n}", "func (s *Stats) GetMemoryInfo(logMemory, logGoMemory bool) {\n\n if logGoMemory {\n if s.GoInfo == nil {\n s.initGoInfo()\n }\n\n runtime.ReadMemStats(s.GoInfo.Memory.mem)\n s.GoInfo.GoRoutines = runtime.NumGoroutine()\n s.GoInfo.Memory.Alloc = s.GoInfo.Memory.mem.Alloc\n s.GoInfo.Memory.HeapAlloc = s.GoInfo.Memory.mem.HeapAlloc\n s.GoInfo.Memory.HeapSys = s.GoInfo.Memory.mem.HeapSys\n\n if s.GoInfo.Memory.LastGC != s.GoInfo.Memory.mem.LastGC {\n s.GoInfo.Memory.LastGC = s.GoInfo.Memory.mem.LastGC\n s.GoInfo.Memory.NumGC = s.GoInfo.Memory.mem.NumGC - s.GoInfo.Memory.lastNumGC\n s.GoInfo.Memory.lastNumGC = s.GoInfo.Memory.mem.NumGC\n s.GoInfo.Memory.LastGCPauseDuration = s.GoInfo.Memory.mem.PauseNs[(s.GoInfo.Memory.mem.NumGC+255)%256]\n } else {\n s.GoInfo.Memory.NumGC = 0\n s.GoInfo.Memory.LastGCPauseDuration = 0\n }\n }\n\n if logMemory {\n\n if s.MemInfo == nil {\n s.MemInfo = new(MemInfo)\n }\n\n s.MemInfo.Memory, _ = mem.VirtualMemory()\n s.MemInfo.Swap, _ = mem.SwapMemory()\n }\n}", "func (s *Stats) GetCPUInfo() {\n\n if s.CPUInfo == nil {\n s.CPUInfo = new(CPUInfo)\n }\n\n s.CPUInfo.CPU, _ = cpu.Info()\n}", "func Init() {\n\tprometheus.MustRegister(\n\t\tHTTPRequestsCounter,\n\t\tHTTPRequestsDurationHistogram,\n\t\tDAOFindResultCounter,\n\t\tDAOOperationsCounter,\n\t\tDAOOperationsDurationHistogram,\n\t)\n}", "func initMetrics() *metrics.Manager {\n\treturn metrics.New(\"calert\")\n}", "func InitMetrics() error {\n\terr := view.Register(\n\t\tdiagUtils.NewMeasureView(sidecarInjectionRequestsTotal, noKeys, view.Count()),\n\t\tdiagUtils.NewMeasureView(succeededSidecarInjectedTotal, []tag.Key{appIDKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(failedSidecarInjectedTotal, []tag.Key{appIDKey, failedReasonKey}, view.Count()),\n\t)\n\n\treturn err\n}", "func (a API) GetMempoolInfo(cmd *None) (e error) {\n\tRPCHandlers[\"getmempoolinfo\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func (s MeterStats) String() string {\n\treturn fmt.Sprintf(\"Meter <%s>: %d since %v, rate: %.3f current, %.3f average\\n\",\n\t\ts.Name, s.TotalCount, s.Start.Format(timeFormat), s.IntervalRatePerS, s.TotalRatePerS)\n}", "func (p *StatsDParser) GetMetrics() pdata.Metrics {\n\tmetrics := pdata.NewMetrics()\n\trm := metrics.ResourceMetrics().AppendEmpty()\n\n\tfor _, metric := range p.gauges {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, metric := range p.counters {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, metric := range p.timersAndDistributions {\n\t\trm.InstrumentationLibraryMetrics().Append(metric)\n\t}\n\n\tfor _, summaryMetric := range p.summaries {\n\t\tmetrics.ResourceMetrics().At(0).InstrumentationLibraryMetrics().Append(buildSummaryMetric(summaryMetric))\n\t}\n\n\tp.gauges = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\n\tp.counters = make(map[statsDMetricdescription]pdata.InstrumentationLibraryMetrics)\n\tp.timersAndDistributions = make([]pdata.InstrumentationLibraryMetrics, 0)\n\tp.summaries = make(map[statsDMetricdescription]summaryMetric)\n\treturn metrics\n}", "func (g *Gatherer) Gather(ctx context.Context, gatherList []string, rec recorder.Interface) error {\n\tg.ctx = ctx\n\tvar errors []string\n\tvar gatherReport gatherMetadata\n\n\tif len(gatherList) == 0 {\n\t\terrors = append(errors, \"no gather functions are specified to run\")\n\t}\n\n\tif utils.StringInSlice(gatherAll, gatherList) {\n\t\tgatherList = fullGatherList()\n\t}\n\n\t// Starts the gathers in Go routines\n\tcases, starts, err := g.startGathering(gatherList, &errors)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Gets the info from the Go routines\n\tfor range gatherList {\n\t\tchosen, value, _ := reflect.Select(cases)\n\t\t// The chosen channel has been closed, so zero out the channel to disable the case\n\t\tcases[chosen].Chan = reflect.ValueOf(nil)\n\t\tgather := gatherList[chosen]\n\n\t\tgi := NewGatherInfo(gather, value)\n\t\tstatusReport, errorsReport := createStatusReport(gi, rec, starts[chosen])\n\n\t\tif len(errorsReport) > 0 {\n\t\t\terrors = append(errors, errorsReport...)\n\t\t}\n\t\tgatherReport.StatusReports = append(gatherReport.StatusReports, statusReport)\n\t}\n\n\t// if obfuscation is enabled, we want to know it from the archive\n\tgatherReport.IsGlobalObfuscationEnabled = g.anonymizer != nil\n\n\t// fill in performance related data to the report\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\tgatherReport.MemoryAlloc = m.HeapAlloc\n\tgatherReport.Uptime = time.Since(g.startTime).Truncate(time.Millisecond).Seconds()\n\n\t// records the report\n\tif err := recordGatherReport(rec, gatherReport); err != nil {\n\t\terrors = append(errors, fmt.Sprintf(\"unable to record io status reports: %v\", err))\n\t}\n\n\tif len(errors) > 0 {\n\t\treturn sumErrors(errors)\n\t}\n\n\treturn nil\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func Meter(m meter.Meter) Option {\n\treturn func(o *Options) {\n\t\to.Meter = m\n\t}\n}", "func init() {\n\tprometheus.MustRegister(duration)\n\tprometheus.MustRegister(counter)\n\tprometheus.MustRegister(requestsTotal)\n}", "func (p *Prometheus) Init() {\n\tp.fileApplyCount = prometheus.NewCounterVec(prometheus.CounterOpts{\n\t\tName: \"file_apply_count\",\n\t\tHelp: \"Success metric for every file applied\",\n\t},\n\t\t[]string{\n\t\t\t// Path of the file that was applied\n\t\t\t\"file\",\n\t\t\t// Result: true if the apply was successful, false otherwise\n\t\t\t\"success\",\n\t\t},\n\t)\n\tp.runLatency = prometheus.NewSummaryVec(prometheus.SummaryOpts{\n\t\tName: \"run_latency_seconds\",\n\t\tHelp: \"Latency for completed apply runs\",\n\t},\n\t\t[]string{\n\t\t\t// Result: true if the run was successful, false otherwise\n\t\t\t\"success\",\n\t\t},\n\t)\n\n\tprometheus.MustRegister(p.fileApplyCount)\n\tprometheus.MustRegister(p.runLatency)\n}", "func (systemd_units *SystemdUnits) Gather(acc telegraf.Accumulator) error {\n\tout, err := systemd_units.systemctl(systemd_units.Timeout, systemd_units.UnitType)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tscanner := bufio.NewScanner(out)\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tdata := strings.Fields(line)\n\t\tif len(data) < 4 {\n\t\t\tacc.AddError(fmt.Errorf(\"Error parsing line (expected at least 4 fields): %s\", line))\n\t\t\tcontinue\n\t\t}\n\t\ttags := map[string]string{\n\t\t\t\"name\": data[0],\n\t\t}\n\t\tload := load_map[data[1]] - 1\n\t\tactive := active_map[data[2]] - 1\n\t\tsub := sub_map[data[3]] - 1\n\n\t\tfields := map[string]interface{}{\n\t\t\t\"load\": load,\n\t\t\t\"active\": active,\n\t\t\t\"sub\": sub,\n\t\t}\n\t\tacc.AddCounter(measurement, fields, tags)\n\t}\n\n\treturn nil\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"connection\", \"load_stats\", New)\n}", "func (m *manager) AllStats() []*device.DeviceGroupStats {\n\t// Go through each plugin and collect stats\n\tvar stats []*device.DeviceGroupStats\n\tfor _, i := range m.instances {\n\t\tstats = append(stats, i.AllStats()...)\n\t}\n\n\treturn stats\n}", "func (g *Circle) Meters() float64 {\n\treturn g.meters\n}", "func NewMeter(options ...meterOption) *ProgressMeter {\n\tm := &ProgressMeter{\n\t\tlogger: &progressLogger{},\n\t\tstartTime: time.Now(),\n\t\tfileIndex: make(map[string]int64),\n\t\tfileIndexMutex: &sync.Mutex{},\n\t\tfinished: make(chan interface{}),\n\t}\n\n\tfor _, opt := range options {\n\t\topt(m)\n\t}\n\n\treturn m\n}", "func (ag *Aggregator) GetCollectedMeters() ([]*meter.Meter, error) {\n\tvar meters []*meter.Meter\n\tfor _, collector := range ag.GetCollectors() {\n\t\ttempMeters, err := collector.Collect()\n\t\tif err == nil {\n\t\t\tmeters = append(meters, tempMeters...)\n\t\t}\n\t}\n\treturn ag.getRequireMeters(meters), nil\n}", "func (e *HueEmulator) getDeviceInfo(w http.ResponseWriter, _ *http.Request, params httprouter.Params) {\n\tlightID := params.ByName(\"lightID\")\n\tfor _, v := range e.devices {\n\t\tif lightID == v.internalHash {\n\t\t\te.logger.Debug(\"Requested device state info\", common.LogIDToken, v.DeviceID)\n\t\t\te.sendJSON(w, getDevice(v))\n\t\t\treturn\n\t\t}\n\t}\n\n\te.logger.Warn(\"Requested unknown device state info\", common.LogIDToken, lightID)\n}", "func (fetcher *Fetcher) Init() {\n\tfetcher.cpuUsageUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + CPU_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n\tfetcher.memUsageUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + MEM_USAGE_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n\tfetcher.diskFreeUrl = TSDB_URL + \"start=\" + TIME_AGO + \"&m=\" + AGREGATOR + \":\" + DISK_FREE_METRIC + \"{host=\" + HOST + \",colo=\" + COLO + \"}&format=json\"\n}", "func Init() {\n\tglobalStats = make(map[Type]time.Duration)\n\tminMaxTimeStats = make(map[Type]minMaxTime)\n\tcountStats = make(map[Type]int)\n\tmutex = &sync.RWMutex{}\n}", "func (manager *MetricsCacheManager) GetSystemInfoMetrics() (*milvuspb.GetMetricsResponse, error) {\n\tretention := manager.GetRetention()\n\n\tmanager.systemInfoMetricsMtx.RLock()\n\tdefer manager.systemInfoMetricsMtx.RUnlock()\n\n\tif manager.systemInfoMetricsInvalid ||\n\t\tmanager.systemInfoMetrics == nil ||\n\t\ttime.Since(manager.systemInfoMetricsLastUpdatedTime) >= retention {\n\n\t\treturn nil, errInvalidSystemInfosMetricCache\n\t}\n\n\treturn manager.systemInfoMetrics, nil\n}", "func init() {\n\n\t// cpu\n\tRegistryMetricCreateInput(\"cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"mem\", \"Memory\", monitor.METRIC_RES_TYPE_HOST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_HOST, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\t// vm_cpu\n\tRegistryMetricCreateInput(\"vm_cpu\", \"Guest CPU usage\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_pcore\", \"CPU utilization rate per core\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"cpu_usage_idle_pcore\", \"CPU idle rate per core\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_system\", \"CPU system state time\", monitor.METRIC_UNIT_MS, 4),\n\t\t\tnewMetricFieldCreateInput(\"cpu_time_user\", \"CPU user state time\", monitor.METRIC_UNIT_MS, 5),\n\t\t\tnewMetricFieldCreateInput(\"thread_count\", \"The number of threads used by the process\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t})\n\n\t// vm_diskio\n\tRegistryMetricCreateInput(\"vm_diskio\", \"Guest disk traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BYTEPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BYTEPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\n\t// vm_mem\n\tRegistryMetricCreateInput(\"vm_mem\", \"Guest memory\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"vms\", \"Virtual memory consumption\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"rss\", \"Actual use of physical memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t})\n\n\t// vm_netio\n\tRegistryMetricCreateInput(\"vm_netio\", \"Guest network traffic\", monitor.METRIC_RES_TYPE_GUEST,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// oss_latency\n\tRegistryMetricCreateInput(\"oss_latency\", \"Object storage latency\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_late\", \"Request average E2E delay\", monitor.METRIC_UNIT_MS, 1),\n\t\t})\n\n\t// oss_netio\n\tRegistryMetricCreateInput(\"oss_netio\", \"Object storage network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_OSS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Receive byte\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send byte\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t})\n\n\t// oss_req\n\tRegistryMetricCreateInput(\"oss_req\", \"Object store request\", monitor.METRIC_RES_TYPE_OSS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"req_count\", \"request count\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// rds_conn\n\tRegistryMetricCreateInput(\"rds_conn\", \"Rds connect\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_cpu\n\tRegistryMetricCreateInput(\"rds_cpu\", \"Rds CPU usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t})\n\n\t// rds_mem\n\tRegistryMetricCreateInput(\"rds_mem\", \"Rds memory\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// rds_netio\n\tRegistryMetricCreateInput(\"rds_netio\", \"Rds network traffic\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// rds_disk\n\tRegistryMetricCreateInput(\"rds_disk\", \"Rds disk usage\", monitor.METRIC_RES_TYPE_RDS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_cpu\n\tRegistryMetricCreateInput(\"dcs_cpu\", \"Redis CPU usage\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_percent\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_mem\n\tRegistryMetricCreateInput(\"dcs_mem\", \"Redis memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_netio\n\tRegistryMetricCreateInput(\"dcs_netio\", \"Redis network traffic\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bps_recv\", \"Received traffic per second\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"bps_sent\", \"Send traffic per second\", monitor.METRIC_UNIT_BPS, 2),\n\t\t})\n\n\t// dcs_conn\n\tRegistryMetricCreateInput(\"dcs_conn\", \"Redis connect\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Connection usage\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t})\n\n\t// dcs_instantopt\n\tRegistryMetricCreateInput(\"dcs_instantopt\", \"Redis operator\",\n\t\tmonitor.METRIC_RES_TYPE_REDIS, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"opt_sec\", \"Number of commands processed per second\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_cachekeys\n\tRegistryMetricCreateInput(\"dcs_cachekeys\", \"Redis keys\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 6, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"key_count\", \"Number of cache keys\", monitor.METRIC_UNIT_COUNT, 1),\n\t\t})\n\n\t// dcs_datamem\n\tRegistryMetricCreateInput(\"dcs_datamem\", \"Redis data memory\", monitor.METRIC_RES_TYPE_REDIS,\n\t\tmonitor.METRIC_DATABASE_TELE, 3, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_byte\", \"Data node memory usage\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t})\n\n\t// cloudaccount_balance\n\tRegistryMetricCreateInput(\"cloudaccount_balance\", \"Cloud account balance\",\n\t\tmonitor.METRIC_RES_TYPE_CLOUDACCOUNT,\n\t\tmonitor.METRIC_DATABASE_METER, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"balance\", \"balance\", monitor.METRIC_UNIT_RMB, 1),\n\t\t})\n\n\t// cpu\n\tRegistryMetricCreateInput(\"agent_cpu\", \"CPU usage\", monitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 1,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"CPU active state utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"usage_idle\", \"CPU idle state utilization rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"usage_system\", \"CPU system state utilization rate\", monitor.METRIC_UNIT_PERCENT, 3),\n\t\t\tnewMetricFieldCreateInput(\"usage_user\", \"CPU user mode utilization rate\", monitor.METRIC_UNIT_PERCENT, 4),\n\t\t\tnewMetricFieldCreateInput(\"usage_iowait\", \"CPU IO usage\", monitor.METRIC_UNIT_PERCENT, 5),\n\t\t\tnewMetricFieldCreateInput(\"usage_irq\", \"CPU IRQ usage\", monitor.METRIC_UNIT_PERCENT, 6),\n\t\t\tnewMetricFieldCreateInput(\"usage_guest\", \"CPU guest usage\", monitor.METRIC_UNIT_PERCENT, 7),\n\t\t\tnewMetricFieldCreateInput(\"usage_nice\", \"CPU priority switch utilization\", monitor.METRIC_UNIT_PERCENT, 8),\n\t\t\tnewMetricFieldCreateInput(\"usage_softirq\", \"CPU softirq usage\", monitor.METRIC_UNIT_PERCENT, 9),\n\t\t})\n\n\t// disk\n\tRegistryMetricCreateInput(\"agent_disk\", \"Disk usage\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 3,\n\t\t[]monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Percentage of used disks\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free space size\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used disk size\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total disk size\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"inodes_free\", \"Available inode\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"inodes_used\", \"Number of inodes used\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"inodes_total\", \"Total inodes\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t})\n\n\t// diskio\n\tRegistryMetricCreateInput(\"agent_diskio\", \"Disk traffic and timing\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 4, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"read_bps\", \"Disk read rate\", monitor.METRIC_UNIT_BPS, 1),\n\t\t\tnewMetricFieldCreateInput(\"write_bps\", \"Disk write rate\", monitor.METRIC_UNIT_BPS, 2),\n\t\t\tnewMetricFieldCreateInput(\"read_iops\", \"Disk read operate rate\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"write_iops\", \"Disk write operate rate\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"reads\", \"Number of reads\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"writes\", \"Number of writes\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"read_bytes\", \"Bytes read\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"write_bytes\", \"Bytes write\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"write_time\", \"Time to wait for write\", monitor.METRIC_UNIT_MS, 9),\n\t\t\tnewMetricFieldCreateInput(\"io_time\", \"I / O request queuing time\", monitor.METRIC_UNIT_MS, 10),\n\t\t\tnewMetricFieldCreateInput(\"weighted_io_time\", \"I / O request waiting time\", monitor.METRIC_UNIT_MS, 11),\n\t\t\tnewMetricFieldCreateInput(\"iops_in_progress\", \"Number of I / O requests issued but not yet completed\", monitor.METRIC_UNIT_COUNT, 12),\n\t\t})\n\n\t// mem\n\tRegistryMetricCreateInput(\"agent_mem\", \"Memory\", monitor.METRIC_RES_TYPE_AGENT,\n\t\tmonitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"used_percent\", \"Used memory rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"available_percent\", \"Available memory rate\", monitor.METRIC_UNIT_PERCENT, 2),\n\t\t\tnewMetricFieldCreateInput(\"used\", \"Used memory\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free memory\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"active\", \"The amount of active memory\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"inactive\", \"The amount of inactive memory\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t\tnewMetricFieldCreateInput(\"cached\", \"Cache memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"buffered\", \"Buffer memory\", monitor.METRIC_UNIT_BYTE, 7),\n\t\t\tnewMetricFieldCreateInput(\"slab\", \"Number of kernel caches\", monitor.METRIC_UNIT_BYTE, 8),\n\t\t\tnewMetricFieldCreateInput(\"available\", \"Available memory\", monitor.METRIC_UNIT_BYTE, 9),\n\t\t\tnewMetricFieldCreateInput(\"total\", \"Total memory\", monitor.METRIC_UNIT_BYTE, 10),\n\t\t})\n\n\t// net\n\tRegistryMetricCreateInput(\"agent_net\", \"Network interface and protocol usage\",\n\t\tmonitor.METRIC_RES_TYPE_AGENT, monitor.METRIC_DATABASE_TELE, 5, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"bytes_sent\", \"The total number of bytes sent by the network interface\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"bytes_recv\", \"The total number of bytes received by the network interface\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"packets_sent\", \"The total number of packets sent by the network interface\", monitor.METRIC_UNIT_COUNT, 3),\n\t\t\tnewMetricFieldCreateInput(\"packets_recv\", \"The total number of packets received by the network interface\", monitor.METRIC_UNIT_COUNT, 4),\n\t\t\tnewMetricFieldCreateInput(\"err_in\", \"The total number of receive errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 5),\n\t\t\tnewMetricFieldCreateInput(\"err_out\", \"The total number of transmission errors detected by the network interface\", monitor.METRIC_UNIT_COUNT, 6),\n\t\t\tnewMetricFieldCreateInput(\"drop_in\", \"The total number of received packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 7),\n\t\t\tnewMetricFieldCreateInput(\"drop_out\", \"The total number of transmission packets dropped by the network interface\", monitor.METRIC_UNIT_COUNT, 8),\n\t\t})\n\n\tRegistryMetricCreateInput(\"storage\", \"Storage usage\",\n\t\tmonitor.METRIC_RES_TYPE_STORAGE, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"usage_active\", \"Storage utilization rate\", monitor.METRIC_UNIT_PERCENT, 1),\n\t\t\tnewMetricFieldCreateInput(\"free\", \"Free storage\", monitor.METRIC_UNIT_MB, 2),\n\t\t})\n\n\t//jenkins\n\tRegistryMetricCreateInput(\"jenkins_node\", \"jenkins node\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 1, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"disk_available\", \"disk_available\", monitor.METRIC_UNIT_BYTE, 1),\n\t\t\tnewMetricFieldCreateInput(\"temp_available\", \"temp_available\", monitor.METRIC_UNIT_BYTE, 2),\n\t\t\tnewMetricFieldCreateInput(\"memory_available\", \"memory_available\", monitor.METRIC_UNIT_BYTE, 3),\n\t\t\tnewMetricFieldCreateInput(\"memory_total\", \"memory_total\", monitor.METRIC_UNIT_BYTE, 4),\n\t\t\tnewMetricFieldCreateInput(\"swap_available\", \"swap_available\", monitor.METRIC_UNIT_BYTE, 5),\n\t\t\tnewMetricFieldCreateInput(\"swap_total\", \"swap_total\", monitor.METRIC_UNIT_BYTE, 6),\n\t\t})\n\tRegistryMetricCreateInput(\"jenkins_job\", \"jenkins job\",\n\t\tmonitor.METRIC_RES_TYPE_JENKINS, monitor.METRIC_DATABASE_TELE, 2, []monitor.MetricFieldCreateInput{\n\t\t\tnewMetricFieldCreateInput(\"duration\", \"duration\", monitor.METRIC_UNIT_MS, 1),\n\t\t\tnewMetricFieldCreateInput(\"number\", \"number\", monitor.METRIC_UNIT_COUNT, 2),\n\t\t})\n\n}", "func getMmStat(ctx context.Context) ([]float64, error) {\n\tout, err := testexec.CommandContext(ctx,\n\t\t\"cat\", zramMmStatPath).Output(testexec.DumpLogOnError)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to dump zram mm_stat\")\n\t}\n\n\tstatsRaw := strings.Fields(string(out))\n\tnumFields := len(statsRaw)\n\tstats := make([]float64, numFields)\n\tfor i := 0; i < numFields; i++ {\n\t\tstats[i], err = strconv.ParseFloat(statsRaw[i], 64)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to parse %s\", zramFieldNames[i])\n\t\t}\n\t}\n\treturn stats, nil\n}", "func (s SolrPlugin) FetchMetrics() (map[string]interface{}, error) {\n\tstat := make(map[string]interface{})\n\tfor core, stats := range s.Stats {\n\t\tfor k, v := range stats {\n\t\t\tstat[core+\"_\"+k] = v\n\t\t}\n\t}\n\treturn stat, nil\n}", "func (a *app) gatherStat() {\n\tabout, err := a.srv.About.Get().Fields(\"storageQuota\").Do()\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to execute an about request: %v\", err)\n\t}\n\n\ta.sq = about.StorageQuota\n}", "func (this *MCP342X) GetMeasurement() (int, error) {\n\tlog.Print(\"Starting polling for the result.\")\n\tresult := make([]byte, 3)\n\n\tfor {\n\t\terr := this.i2c.Read(result)\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\n\t\tif (result[2] & MCP342X_START) == 0x00 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// TODO: support all resolutions, it is only for 12 bit\n\tmeasurement := ((int(result[0]) & 0x3F) << 8) | int(result[1])\n\n\tif measurement > 2048-1 {\n\t\tmeasurement = measurement - 4096 - 1\n\t}\n\n\treturn measurement, nil\n}", "func (m *MeterSnapshot) Count() int64 { return m.count }", "func (s *Systemctl) Gather(acc telegraf.Accumulator) error {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\t// for each systemctl service being monitored\n\tfor _, aggregator := range s.Aggregators {\n\t\t// aggregate the data from the set of samples\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"InputPlugin\": \"systemctl\",\n\t\t\t\"ResourceName\": aggregator.ResourceName,\n\t\t}).Debug(\"Aggregating\")\n\t\terr := aggregator.Aggregate()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// create fields\n\t\tfields := map[string]interface{}{\n\t\t\t\"current_state_time\": aggregator.CurrentStateDuration,\n\t\t\t\"current_state\": aggregator.CurrentState,\n\t\t}\n\t\tfor k := range aggregator.AggState {\n\t\t\tfields[k] = aggregator.AggState[k]\n\t\t}\n\t\t// create tags\n\t\ttags := map[string]string{\"resource\": aggregator.ResourceName}\n\t\tacc.AddFields(\"service_config_state\", fields, tags)\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"InputPlugin\": \"systemctl\",\n\t\t\t\"ResourceName\": aggregator.ResourceName,\n\t\t}).Debug(\"Added fields\")\n\t}\n\treturn nil\n}", "func (m *RdmaDevPlugin) GetInfo(ctx context.Context, rqt *registerapi.InfoRequest) (*registerapi.PluginInfo, error) {\n\tpluginInfoResponse := &registerapi.PluginInfo{\n\t\tType: registerapi.DevicePlugin,\n\t\tName: m.resourceName,\n\t\tEndpoint: filepath.Join(sockDir, m.socketName),\n\t\tSupportedVersions: []string{\"v1alpha1\", \"v1beta1\"},\n\t}\n\treturn pluginInfoResponse, nil\n}", "func Stats(c *libvirt.Connect, uuid string) error {\n\t//Check exists\n\td, err := c.LookupDomainByUUIDString(uuid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to lookup: %s\", err)\n\t}\n\n\t//Check is running\n\ts, _, err := d.GetState()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed check state: %s\", err)\n\t}\n\tif s != libvirt.DOMAIN_RUNNING {\n\t\treturn fmt.Errorf(\"domain not running: %d\", s)\n\t}\n\n\tmemStats, err := memStats(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"STAT: %+v\\n\", memStats)\n\tfmt.Printf(\"STAT Used: %+v\\n\", memStats.Available-memStats.Unused)\n\tfmt.Printf(\"STAT Last: %s\\n\", time.Unix(int64(memStats.LastUpdate), 0))\n\n\tcpuStats, total, err := cpuStats(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"%+v\\n\", cpuStats)\n\tfmt.Printf(\"Total: %+#v\\n\", total)\n\n\tnetStats, err := netStats(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"NET: %+v\\n\", netStats)\n\n\t_, dTotal, err := diskStats(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"DISK: %+v\\n\", dTotal)\n\n\treturn nil\n}", "func init() {\n\tmb.Registry.MustAddMetricSet(\"kvm\", \"dommemstat\", New,\n\t\tmb.DefaultMetricSet(),\n\t)\n}", "func (p *hardwareProfiler) Start() error {\n\tif len(p.profilers) == 0 {\n\t\treturn ErrNoProfiler\n\t}\n\tvar err error\n\tfor _, profiler := range p.profilers {\n\t\terr = multierr.Append(err, profiler.Start())\n\t}\n\treturn err\n}", "func (f *FFS) Info(ctx context.Context) (api.InstanceInfo, error) {\n\tres, err := f.client.Info(ctx, &rpc.InfoRequest{})\n\tif err != nil {\n\t\treturn api.InstanceInfo{}, err\n\t}\n\n\tbalances := make([]api.BalanceInfo, len(res.Info.Balances))\n\tfor i, bal := range res.Info.Balances {\n\t\tbalances[i] = api.BalanceInfo{\n\t\t\tAddrInfo: api.AddrInfo{\n\t\t\t\tName: bal.Addr.Name,\n\t\t\t\tAddr: bal.Addr.Addr,\n\t\t\t\tType: bal.Addr.Type,\n\t\t\t},\n\t\t\tBalance: uint64(bal.Balance),\n\t\t}\n\t}\n\n\tpins := make([]cid.Cid, len(res.Info.Pins))\n\tfor i, pin := range res.Info.Pins {\n\t\tc, err := util.CidFromString(pin)\n\t\tif err != nil {\n\t\t\treturn api.InstanceInfo{}, err\n\t\t}\n\t\tpins[i] = c\n\t}\n\n\treturn api.InstanceInfo{\n\t\tID: ffs.APIID(res.Info.Id),\n\t\tDefaultStorageConfig: fromRPCStorageConfig(res.Info.DefaultStorageConfig),\n\t\tBalances: balances,\n\t\tPins: pins,\n\t}, nil\n}", "func (cpuCollector *CPUCollector) Init() {\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cpuTotal)\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cpuUtilization)\n\tprometheus.MustRegister(cpuCollector.cpuMetrics.cupIdle)\n}", "func (m *migdevice) GetProfile() (MigProfile, error) {\n\tif m.profile != nil {\n\t\treturn m.profile, nil\n\t}\n\n\tparent, ret := m.Device.GetDeviceHandleFromMigDeviceHandle()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting parent device handle: %v\", ret)\n\t}\n\n\tparentMemoryInfo, ret := parent.GetMemoryInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting parent memory info: %v\", ret)\n\t}\n\n\tattributes, ret := m.Device.GetAttributes()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device attributes: %v\", ret)\n\t}\n\n\tgiID, ret := m.Device.GetGpuInstanceId()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device GPU Instance ID: %v\", ret)\n\t}\n\n\tciID, ret := m.Device.GetComputeInstanceId()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting MIG device Compute Instance ID: %v\", ret)\n\t}\n\n\tgi, ret := parent.GetGpuInstanceById(giID)\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting GPU Instance: %v\", ret)\n\t}\n\n\tci, ret := gi.GetComputeInstanceById(ciID)\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting Compute Instance: %v\", ret)\n\t}\n\n\tgiInfo, ret := gi.GetInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting GPU Instance info: %v\", ret)\n\t}\n\n\tciInfo, ret := ci.GetInfo()\n\tif ret != nvml.SUCCESS {\n\t\treturn nil, fmt.Errorf(\"error getting Compute Instance info: %v\", ret)\n\t}\n\n\tfor i := 0; i < nvml.GPU_INSTANCE_PROFILE_COUNT; i++ {\n\t\tgiProfileInfo, ret := parent.GetGpuInstanceProfileInfo(i)\n\t\tif ret == nvml.ERROR_NOT_SUPPORTED {\n\t\t\tcontinue\n\t\t}\n\t\tif ret == nvml.ERROR_INVALID_ARGUMENT {\n\t\t\tcontinue\n\t\t}\n\t\tif ret != nvml.SUCCESS {\n\t\t\treturn nil, fmt.Errorf(\"error getting GPU Instance profile info: %v\", ret)\n\t\t}\n\n\t\tif giProfileInfo.Id != giInfo.ProfileId {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor j := 0; j < nvml.COMPUTE_INSTANCE_PROFILE_COUNT; j++ {\n\t\t\tfor k := 0; k < nvml.COMPUTE_INSTANCE_ENGINE_PROFILE_COUNT; k++ {\n\t\t\t\tciProfileInfo, ret := gi.GetComputeInstanceProfileInfo(j, k)\n\t\t\t\tif ret == nvml.ERROR_NOT_SUPPORTED {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif ret == nvml.ERROR_INVALID_ARGUMENT {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif ret != nvml.SUCCESS {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error getting Compute Instance profile info: %v\", ret)\n\n\t\t\t\t}\n\n\t\t\t\tif ciProfileInfo.Id != ciInfo.ProfileId {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tp, err := m.lib.NewMigProfile(i, j, k, attributes.MemorySizeMB, parentMemoryInfo.Total)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"error creating MIG profile: %v\", err)\n\t\t\t\t}\n\n\t\t\t\tm.profile = p\n\t\t\t\treturn p, nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"no matching profile IDs found\")\n}", "func (c *SystemCollector) Get(ch chan<- prometheus.Metric, target, user, pass string) (float64, error) {\n\n\tjsonSystem, err := getServerTechJSON(target, user, pass, \"system\")\n\tif err != nil {\n\t\ttotalSystemErrors++\n\t\treturn totalSystemErrors, fmt.Errorf(\"cannot get systems: %s\", err)\n\t}\n\n\tif err := processSystemStats(ch, jsonSystem); err != nil {\n\t\ttotalSystemErrors++\n\t\treturn totalSystemErrors, err\n\t}\n\treturn totalSystemErrors, nil\n\n}", "func (s *SplitStore) Info() map[string]interface{} {\n\tinfo := make(map[string]interface{})\n\tinfo[\"base epoch\"] = s.baseEpoch\n\tinfo[\"warmup epoch\"] = s.warmupEpoch.Load()\n\tinfo[\"compactions\"] = s.compactionIndex\n\tinfo[\"prunes\"] = s.pruneIndex\n\tinfo[\"compacting\"] = s.compacting == 1\n\n\tsizer, ok := s.hot.(bstore.BlockstoreSize)\n\tif ok {\n\t\tsize, err := sizer.Size()\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"error getting hotstore size: %s\", err)\n\t\t} else {\n\t\t\tinfo[\"hotstore size\"] = size\n\t\t}\n\t}\n\n\treturn info\n}", "func (am *Antman) GetGpusInfoFromEtcd(nodeName string) (gpuUtils []float64, gpuMems []float64) {\n\tklog.Infof(\"in GetGpusInfoFromEtcd for nodeName : %v\", nodeName)\n\tvar utils []float64\n\tvar mems []float64\n\tconst (\n\t\tPeriodInSeconds = 30\n\t)\n\tvar count, nowIndex, nowTime int\n\tvar err error\n\t// TODO # GPU from k8s api\n\tnodeInfo, err := am.frameworkHandle.SnapshotSharedLister().NodeInfos().Get(nodeName)\n\tnum_gpus := int(nodeInfo.AllocatableResource().ScalarResources[\"nvidia.com/gpu\"])\n\tfor gpu_id := 0; gpu_id < num_gpus; gpu_id++ {\n\t\t// the number of gpu statistics maintained\n\t\tcountKey := nodeName + \"/\" + strconv.Itoa(gpu_id) + \"/cnt\"\n\t\tcountStr := am.etcdWrapper.ReadEtcd(&countKey)\n\t\tif count, err = strconv.Atoi(*countStr); err == nil {\n\t\t\tklog.Infof(\"[%v] count: %v\", gpu_id, count)\n\t\t}\n\n\t\t// the index of the last statistic\n\t\tnowIndexKey := nodeName + \"/\" + strconv.Itoa(gpu_id) + \"/nowIndex\"\n\t\tnowIndexStr := am.etcdWrapper.ReadEtcd(&nowIndexKey)\n\t\tif nowIndex, err = strconv.Atoi(*nowIndexStr); err == nil {\n\t\t\tklog.Infof(\"[%v] nowIndex: %v\", gpu_id, nowIndex)\n\t\t}\n\n\t\t// the timestamp of the last index\n\t\tnowTimeKey := nodeName + \"/\" + strconv.Itoa(gpu_id) + \"/nowTime\"\n\t\tnowTimeStr := am.etcdWrapper.ReadEtcd(&nowTimeKey)\n\t\tif nowTime, err = strconv.Atoi(*nowTimeStr); err == nil {\n\t\t\tklog.Infof(\"[%v] nowTime: %v\", gpu_id, nowTime)\n\t\t}\n\n\t\t// the statistics are stored in [0, count) using a Circular Queue\n\t\t// make sure that PeriodInSeconds is smaller than count\n\t\tif PeriodInSeconds > count {\n\t\t\tklog.Errorf(\"PeriodInSeconds[%v] should smaller than count[%v]\", PeriodInSeconds, count)\n\t\t}\n\n\t\t// ave gpu util in PeriodInSeconds\n\t\t// peak gpu mem in PeriodInSeconds\n\t\taveUtil := 0.0\n\t\tpeakMem := 0.0\n\t\tfor index := 0; index < PeriodInSeconds; index++ {\n\t\t\ti := (index - (PeriodInSeconds - nowIndex) + count) % count\n\t\t\tutilKey := nodeName + \"/\" + strconv.Itoa(gpu_id) + \"/util\" + \"/\" + strconv.Itoa(i)\n\t\t\tmemKey := nodeName + \"/\" + strconv.Itoa(gpu_id) + \"/mem\" + \"/\" + strconv.Itoa(i)\n\t\t\tgpuUtilStr := am.etcdWrapper.ReadEtcd(&utilKey)\n\t\t\tgpuMemStr := am.etcdWrapper.ReadEtcd(&memKey)\n\t\t\tif gpuUtil, err := strconv.ParseFloat(*gpuUtilStr, 64); err == nil {\n\t\t\t\taveUtil += gpuUtil\n\t\t\t}\n\t\t\tif gpuMem, err := strconv.ParseFloat(*gpuMemStr, 64); err == nil {\n\t\t\t\tpeakMem = math.Max(peakMem, gpuMem)\n\t\t\t}\n\t\t}\n\t\taveUtil = aveUtil / PeriodInSeconds\n\n\t\tutils = append(utils, aveUtil)\n\t\tmems = append(mems, peakMem)\n\t}\n\treturn utils, mems\n}", "func InitMetrics() error {\n\terr := view.Register(\n\t\tdiagUtils.NewMeasureView(runtimesTotal, noKeys, view.LastValue()),\n\t\tdiagUtils.NewMeasureView(actorRuntimesTotal, noKeys, view.LastValue()),\n\t\tdiagUtils.NewMeasureView(actorHeartbeatTimestamp, []tag.Key{appIDKey, actorTypeKey, hostNameKey, podNameKey}, view.LastValue()),\n\t)\n\n\treturn err\n}", "func Init() {\n\tGlobalStats = make(map[Type]time.Duration)\n\tCountStats = make(map[Type]int)\n\tmutex = &sync.RWMutex{}\n}", "func GetAll() map[Type]time.Duration {\n\tmutex.RLock()\n\tdefer mutex.RUnlock()\n\treturn GlobalStats\n}", "func InitializeAll() {\n\t// TODO introduce isFanOut parameter to determine when to create fan-out controller/daemon metrics\n\tif haveInitialized {\n\t\tklog.Infof(\"metrics have already been initialized\")\n\t} else {\n\t\tinitializeDaemonMetrics()\n\t\tinitializeControllerMetrics()\n\t\t// TODO include dataplane health metrics:\n\t\t// num failures for apply ipsets, updating policies, deleting policies, and running periodic policy tasks, etc.\n\t\tlog.Logf(\"Finished initializing all Prometheus metrics\")\n\t\thaveInitialized = true\n\t}\n}", "func InitPrometheus() *Metrics {\n\tret := &Metrics{}\n\tret.CountTotal = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_total\",\n\t\tHelp: \"Total Requests\",\n\t})\n\n\tret.CountSSR = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_ssr\",\n\t\tHelp: \"SSR Requests\",\n\t})\n\n\tret.CountSSRCached = prometheus.NewCounter(prometheus.CounterOpts{\n\t\tName: \"rendora_requests_ssr_cached\",\n\t\tHelp: \"Cached SSR Requests\",\n\t})\n\n\tret.Duration = prometheus.NewHistogram(prometheus.HistogramOpts{\n\t\tName: \"rendora_latency_ssr\",\n\t\tHelp: \"SSR Latency\",\n\t\tBuckets: []float64{50, 100, 150, 200, 250, 300, 350, 400, 500},\n\t})\n\n\tprometheus.MustRegister(ret.CountTotal)\n\tprometheus.MustRegister(ret.CountSSR)\n\tprometheus.MustRegister(ret.Duration)\n\n\treturn ret\n}", "func (m *resiliencyMetrics) Init(id string) error {\n\tm.enabled = true\n\tm.appID = id\n\treturn view.Register(\n\t\tdiagUtils.NewMeasureView(m.policiesLoadCount, []tag.Key{appIDKey, resiliencyNameKey, namespaceKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(m.executionCount, []tag.Key{appIDKey, resiliencyNameKey, policyKey, namespaceKey, flowDirectionKey, targetKey, statusKey}, view.Count()),\n\t\tdiagUtils.NewMeasureView(m.activationsCount, []tag.Key{appIDKey, resiliencyNameKey, policyKey, namespaceKey, flowDirectionKey, targetKey, statusKey}, view.Count()),\n\t)\n}" ]
[ "0.5548705", "0.5365467", "0.52287626", "0.512273", "0.51192206", "0.5082145", "0.507905", "0.5076003", "0.5016304", "0.48349252", "0.48149756", "0.48085475", "0.47920698", "0.4763496", "0.4738158", "0.47250092", "0.46923137", "0.4688703", "0.46473172", "0.4640834", "0.46305916", "0.46232033", "0.4623091", "0.4586899", "0.45866975", "0.45818815", "0.45747572", "0.45747402", "0.45570606", "0.45422462", "0.45254445", "0.45076558", "0.45008865", "0.44957572", "0.4493149", "0.448109", "0.44769", "0.44702768", "0.44522676", "0.44475564", "0.44445047", "0.44405872", "0.44378477", "0.44318515", "0.44257513", "0.4402891", "0.43922743", "0.4391828", "0.43856636", "0.43793315", "0.437826", "0.43734628", "0.43671396", "0.43629646", "0.43621427", "0.43544388", "0.43538934", "0.43515494", "0.43312597", "0.4325084", "0.43246287", "0.43231776", "0.43147677", "0.43147677", "0.43147677", "0.43138093", "0.43056068", "0.42984065", "0.4298017", "0.42921424", "0.42898664", "0.4288338", "0.42858", "0.42842475", "0.4279289", "0.42738217", "0.4272006", "0.42636174", "0.42561796", "0.42499554", "0.42472294", "0.42383626", "0.42363188", "0.42306626", "0.42263868", "0.42258978", "0.422524", "0.422308", "0.42207542", "0.42074603", "0.42074317", "0.42041272", "0.42030138", "0.4202857", "0.42023906", "0.41907325", "0.41885716", "0.41869578", "0.41869366", "0.41854733" ]
0.55421275
1
TestGetMgmtPortsSortedCost covers both GetMgmtPortsSortedCost and GetAllPortsSortedCost.
func TestGetMgmtPortsSortedCost(t *testing.T) { testMatrix := map[string]struct { deviceNetworkStatus DeviceNetworkStatus rotate int expectedMgmtValue []string expectedAllValue []string }{ "Test single": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 0}, }, }, expectedMgmtValue: []string{"port1"}, expectedAllValue: []string{"port1"}, }, "Test single rotate": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 0}, }, }, rotate: 14, expectedMgmtValue: []string{"port1"}, expectedAllValue: []string{"port1"}, }, "Test empty": { deviceNetworkStatus: DeviceNetworkStatus{}, expectedMgmtValue: []string{}, expectedAllValue: []string{}, }, "Test no management": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: false, Cost: 0}, }, }, rotate: 14, expectedMgmtValue: []string{}, expectedAllValue: []string{"port1"}, }, "Test duplicates": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 17}, {IfName: "port2", IsMgmt: true, Cost: 1}, {IfName: "port3", IsMgmt: true, Cost: 17}, {IfName: "port4", IsMgmt: true, Cost: 1}, }, }, expectedMgmtValue: []string{"port2", "port4", "port1", "port3"}, expectedAllValue: []string{"port2", "port4", "port1", "port3"}, }, "Test duplicates rotate": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 17}, {IfName: "port2", IsMgmt: true, Cost: 1}, {IfName: "port3", IsMgmt: true, Cost: 17}, {IfName: "port4", IsMgmt: true, Cost: 1}, }, }, rotate: 1, expectedMgmtValue: []string{"port4", "port2", "port3", "port1"}, expectedAllValue: []string{"port4", "port2", "port3", "port1"}, }, "Test duplicates some management": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: false, Cost: 17}, {IfName: "port2", IsMgmt: false, Cost: 1}, {IfName: "port3", IsMgmt: true, Cost: 17}, {IfName: "port4", IsMgmt: true, Cost: 1}, }, }, expectedMgmtValue: []string{"port4", "port3"}, expectedAllValue: []string{"port2", "port4", "port1", "port3"}, }, "Test reverse": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 2}, {IfName: "port2", IsMgmt: true, Cost: 1}, {IfName: "port3", IsMgmt: true, Cost: 0}, }, }, expectedMgmtValue: []string{"port3", "port2", "port1"}, expectedAllValue: []string{"port3", "port2", "port1"}, }, "Test reverse some management": { deviceNetworkStatus: DeviceNetworkStatus{ Version: DPCIsMgmt, Ports: []NetworkPortStatus{ {IfName: "port1", IsMgmt: true, Cost: 2}, {IfName: "port2", IsMgmt: false, Cost: 1}, {IfName: "port3", IsMgmt: true, Cost: 0}, }, }, expectedMgmtValue: []string{"port3", "port1"}, expectedAllValue: []string{"port3", "port2", "port1"}, }, } for testname, test := range testMatrix { t.Logf("Running test case %s", testname) value := GetMgmtPortsSortedCost(test.deviceNetworkStatus, test.rotate) assert.Equal(t, test.expectedMgmtValue, value) value = GetAllPortsSortedCost(test.deviceNetworkStatus, test.rotate) assert.Equal(t, test.expectedAllValue, value) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockTCPRuleDao) GetUsedPortsByIP(ip string) ([]*model.TCPRule, error) {\n\tret := m.ctrl.Call(m, \"GetUsedPortsByIP\", ip)\n\tret0, _ := ret[0].([]*model.TCPRule)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (no *NetworkOverhead) sortNetworkTopologyCosts(networkTopology *ntv1alpha1.NetworkTopology) {\n\tif no.weightsName != ntv1alpha1.NetworkTopologyNetperfCosts { // Manual weights were selected\n\t\tfor _, w := range networkTopology.Spec.Weights {\n\t\t\t// Sort Costs by TopologyKey, might not be sorted since were manually defined\n\t\t\tsort.Sort(networkawareutil.ByTopologyKey(w.TopologyList))\n\t\t}\n\t}\n}", "func (m *MockTenantServiceLBMappingPortDao) GetLBPortsASC() ([]*model.TenantServiceLBMappingPort, error) {\n\tret := m.ctrl.Call(m, \"GetLBPortsASC\")\n\tret0, _ := ret[0].([]*model.TenantServiceLBMappingPort)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (r *Report) SortedUsersByTotalCost() UserList {\n\ttype tempUser struct {\n\t\tname string\n\t\ttotalCost float64\n\t\tdetailedCosts map[string]float64\n\t}\n\tuserMap := make(map[string]*tempUser)\n\t// Go through all ReportItems\n\tfor _, item := range r.Items {\n\t\t// Group by AccountId\n\t\tif user, ok := userMap[item.Owner]; ok {\n\t\t\tuser.totalCost += item.Cost\n\t\t\t// Group by Description\n\t\t\tif cost, ok := user.detailedCosts[item.Description]; ok {\n\t\t\t\tuser.detailedCosts[item.Description] = cost + item.Cost\n\t\t\t} else {\n\t\t\t\tuser.detailedCosts[item.Description] = item.Cost\n\t\t\t}\n\t\t} else {\n\t\t\tcosts := make(map[string]float64)\n\t\t\tcosts[item.Description] = item.Cost\n\t\t\tuserMap[item.Owner] = &tempUser{item.Owner, item.Cost, costs}\n\t\t}\n\t}\n\n\tuserList := make(UserList, 0, len(userMap))\n\tfor _, user := range userMap {\n\t\t// omit users with low TotalCost\n\t\tif user.totalCost < MinimumTotalCost {\n\t\t\tcontinue\n\t\t}\n\t\t// convert detailedCosts into sorted CostLists\n\t\tdetailedCostList := convertCostMapToSortedList(user.detailedCosts)\n\t\t// add generated User to userList\n\t\tuserList = append(userList, User{user.name, user.totalCost, detailedCostList})\n\t}\n\n\tsort.Sort(sort.Reverse(userList))\n\treturn userList\n}", "func calDataTransferOriginCost(region string, usagetype string, usage float64, blendedcost float64) float64{\n\t\n\tvar cost float64\n\n\tconst f = math.MaxFloat64\n\n/* Price version 20180305 */\n\taps1_dataout_pub_price := map[float64]float64{\n\t\t1: 0.000,\n\t\t10240: 0.120,\n\t\t40960: 0.085,\n\t\t102400: 0.082,\n\t\t358400: 0.080,\n\t\tf: 0.080,\n\t}\n\n\tus_can_eu_dataout_pub_price := map[float64]float64{\n\t\t1: 0.000,\n\t\t10240: 0.090,\n\t\t40960: 0.085,\n\t\t102400: 0.070,\n\t\t358400: 0.050,\n\t\tf: 0.050,\n\t}\n\n\tvar sortkey []float64\n\n\tswitch {\n\tcase (strings.Contains(\"USE1,USE2,USW1,USW2,CAN1,EUC1,EUW2,EU\",region) && strings.Contains(usagetype,\"DataTransfer-Out-Bytes\")): {\n\n\t\tfor key := range us_can_eu_dataout_pub_price {\n\t\tsortkey = append(sortkey, key)\n\t\t}\n\n\t\tsort.Float64s(sortkey)\n\n\t\tremain_usage := usage\n\n\t\tfor _, key := range sortkey {\n\t\t\tif remain_usage > key {\n\t\t\t\tcost = key * us_can_eu_dataout_pub_price[key]\n\t\t\t\tremain_usage = remain_usage - key \n\t\t\t} else {\n\t\t\t\tcost = remain_usage * us_can_eu_dataout_pub_price[key] + cost\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\tcase (strings.Contains(\"APS1\",region) && strings.Contains(usagetype,\"DataTransfer-Out-Bytes\")): {\n\n\t\tfor key := range aps1_dataout_pub_price {\n\t\tsortkey = append(sortkey, key)\n\t\t}\n\n\t\tsort.Float64s(sortkey)\n\n\t\tremain_usage := usage\n\n\t\tfor _, key := range sortkey {\n\t\t\tif remain_usage > key {\n\t\t\t\tcost = key * aps1_dataout_pub_price[key]\n\t\t\t\tremain_usage = remain_usage - key \n\t\t\t} else {\n\t\t\t\tcost = remain_usage * aps1_dataout_pub_price[key] + cost\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tcase (strings.Contains(\"USE1,USE2,USW1,USW2,CAN1,EUC1,EUW2,EU\",region) && strings.Contains(usagetype,\"DataTransfer-Regional-Bytes\")):\n\t\tcost = usage * 0.01\n\tdefault :\n\t\tcost = blendedcost\n\t}\t\n\treturn cost\n\n}", "func TestPortaniaGetPorts(t *testing.T) {\n\n\ttestSuite := map[string]struct {\n\t\tportRange string\n\t\tportList []string\n\t\terr string\n\t\tports []int\n\t}{\n\t\t\"getPorts should throw an error due to nil values\": {\n\t\t\terr: \"no ports found to parse\",\n\t\t},\n\t\t\"getPorts using portList should return the ports 80,443,8080\": {\n\t\t\tportList: []string{\"80\", \"443\", \"8080\"},\n\t\t\tports: []int{80, 443, 8080},\n\t\t},\n\t\t\"getPorts using portRange should return the ports 80-85\": {\n\t\t\tportRange: \"80-85\",\n\t\t\tports: []int{80, 81, 82, 83, 84, 85},\n\t\t},\n\t}\n\tfor testName, testCase := range testSuite {\n\n\t\tt.Logf(\"Running test %v\\n\", testName)\n\t\tports, err := getPorts(testCase.portList, testCase.portRange)\n\t\tif err != nil && err.Error() != testCase.err {\n\t\t\tt.Errorf(\"expected getPorts to fail with %v but received %v.\", testCase.err, err.Error())\n\t\t} else {\n\t\t\tt.Logf(\"received the expected error result %v\", testCase.err)\n\t\t}\n\n\t\tif len(testCase.ports) != 0 {\n\n\t\t\tfor _, p := range testCase.ports {\n\n\t\t\t\tmatch := false\n\t\t\t\tfor _, x := range ports {\n\t\t\t\t\tif p == x {\n\t\t\t\t\t\tmatch = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif match == false {\n\t\t\t\t\tt.Errorf(\"%v was not found in the returned slice from getPorts\", p)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func SortService(elements []int) {\n\tif len(elements) < 10000 {\n\t\tsortfunction.BubbleSort(elements)\n\t\treturn\n\t}\n\tsortfunction.PackageSort(elements)\n}", "func (a *BitlinksApiService) GetSortedBitlinks(ctx _context.Context, groupGuid string, sort string) ApiGetSortedBitlinksRequest {\n\treturn ApiGetSortedBitlinksRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tgroupGuid: groupGuid,\n\t\tsort: sort,\n\t}\n}", "func costexplorerCall(costexpl *(costexplorer.CostExplorer), start string, end string, metrics []*string) (*costexplorer.GetCostAndUsageOutput, error) {\n\t// truestring := \"true\"\n\n\t// prepare a GetCostAndUsageInput struct for the request\n\tinput := (&costexplorer.GetCostAndUsageInput{}).\n\t\tSetTimePeriod((&costexplorer.DateInterval{}).\n\t\t\tSetStart(start).\n\t\t\tSetEnd(end)).\n\t\tSetGranularity(\"MONTHLY\").\n\t\t// SetFilter((&costexplorer.Expression{}).\n\t\t// \tSetTags((&costexplorer.TagValues{}).\n\t\t// \t\tSetKey(\"isUserResource\").\n\t\t// \t\tSetValues([]*string{&truestring}))).\n\t\tSetGroupBy([]*costexplorer.GroupDefinition{(&costexplorer.GroupDefinition{}).\n\t\t\t// // Key can be AZ, INSTANCE_TYPE, LEGAL_ENTITY_NAME, LINKED_ACCOUNT, OPERATION, PLATFORM,\n\t\t\t// // PURCHASE_TYPE, SERVICE, TENANCY, and USAGE_TYPE, if type is DIMENSION.\n\t\t\t// // It can be the name of any cost explorer tag, if type is TAG\n\t\t\tSetKey(\"project-number\").\n\t\t\t// SetKey(\"INSTANCE_TYPE\").\n\t\t\t// // Type needs to be either DIMENSION or TAG\n\t\t\tSetType(\"TAG\")}).\n\t\t// SetType(\"DIMENSION\")}).\n\t\tSetMetrics(metrics)\n\n\toutput, err := costexpl.GetCostAndUsage(input)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlog.Println(output.String())\n\treturn output, nil\n}", "func (solver *MapSolver)GetMinCostAfterRegreting(node *data.MachineNode, regretArcList []int)(int, []int, []int, error){\n\tif regretArcList == nil || len(regretArcList) == 0{\n\t\tpanic(\"GetMinCostAfterRegreting's regretArcList can't be empty\")\n\t}\n\tcostSum := 0\n\tcostList := make([]int, len(regretArcList))\n\tscheduledMachineIdList := make([]int, len(regretArcList)) // store machineNode id for each preemted task finally schedulation\n\tscheduledMachineArcList := make([]int, len(regretArcList)) // store arc index of data.ArcList for every task's templateNode to machienNode\n\tfor i, _ := range scheduledMachineIdList{ // initial all task to -1 machine\n\t\tscheduledMachineIdList[i] = -1\n\t}\n\tfor i, _:= range regretArcList {\n\t\tnode := data.ArcList[regretArcList[i]].DstNode\n\t\ttemplateNode, err := node.(*data.TemplateNode)\n\t\tif !err {\n\t\t\tpanic(\"regretArc's dstNode must be templateNode\")\n\t\t}\n\t\ttask := templateNode.SourceTasks[0]\n\n\n\t\t// we only need to iterate by TaskMinCostArcIdList's order\n\t\t// TODO we only need to iterate by TaskMinCostArcIdList's order\n\t\tminCost := data.MAXINTVALUE\n\t\tfor _, arc := range data.TaskMinCostArcIdList[templateNode.SourceTasks[0].Index]{\n\t\t\t// the new machine can't be the old machine\n\t\t\tif(solver.HasScheduled(arc)){\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ttargetNode := arc.DstNode\n\t\t\ttargetMachineNode, err := targetNode.(*data.MachineNode)\n\t\t\tif !err {\n\t\t\t\tpanic(\"templateNode can only connect to machineNode on its right\")\n\t\t\t}\n\t\t\tj := targetMachineNode.Machine.Index\n\t\t\t// 1. the new machine has less cost\n\t\t\t// 2. the new machine has enough capacity\n\t\t\t// 3. the new machine can't be mutexed with task\n\t\t\t// check its capacity and its mutexed tag\n\t\t\thasEnoughCapacity := false\n\t\t\tisMutexed := false\n\n\t\t\ttoMachine := data.ClusterMachineList[j]\n\t\t\ttoMachineNode := toMachine.Node\n\n\t\t\t// check if mutexed\n\t\t\tfor _,tag := range task.ExclusiveTag{\n\t\t\t\tif _, isExsit := toMachineNode.ScheduledTasks[tag]; isExsit {\n\t\t\t\t\tisMutexed = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif isMutexed {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// check if has enough capacity\n\t\t\tarcToEnd := toMachineNode.GetRightOutArcs()[0]\n\t\t\tsumCapacity := make([]int, len(arcToEnd.Capacity))\n\t\t\tdata.ListAdd(sumCapacity, arcToEnd.Capacity)\n\t\t\tfor k:=0; k<i; k++ { // check if this machine has been used for previous task schedulation\n\t\t\t\tif arc.DstNode.GetID() == scheduledMachineIdList[k] {\n\t\t\t\t\tnode_ := data.ArcList[regretArcList[k]].DstNode\n\t\t\t\t\ttemplateNode_ := node_.(*data.TemplateNode)\n\t\t\t\t\ttask_ := templateNode_.SourceTasks[0]\n\t\t\t\t\tdata.ListSub(sumCapacity, task_.GetCapacity())\n\t\t\t\t}\n\t\t\t}\n\t\t\tif solver.HasEnoughCapacityForTask(sumCapacity, task){\n\t\t\t\thasEnoughCapacity = true\n\t\t\t}\n\t\t\tif !hasEnoughCapacity{\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// update minCost and scheduledMachineList\n\n\t\t\tscheduledMachineIdList[i] = arc.DstNode.GetID()\n\t\t\tscheduledMachineArcList[i] = arc.ID\n\t\t\tminCost = arc.Cost\n\t\t\tbreak\n\n\t\t}\n\t\tif minCost == data.MAXINTVALUE{ // there is no machine for this task to be scheduled, we droped this task(or we can get another preemptedArcList)\n\t\t\treturn 0, nil, nil, errors.New(\"no machine suitable for preempted task\")\n\t\t}\n\t\tcostList[i] = -minCost\n\n\t}\n\t// get sumCost\n\tfor i,_ := range regretArcList {\n\t\tcostSum += (data.ArcList[regretArcList[i]].Cost - costList[i])\n\t}\n\n\n\treturn costSum, costList, scheduledMachineArcList, nil\n}", "func (no *NetworkOverhead) getAccumulatedCost(scheduledList networkawareutil.ScheduledList, dependencyList []agv1alpha1.DependenciesInfo, nodeName string, region string,\n\tzone string, costMap map[networkawareutil.CostKey]int64) (int64, error) {\n\n\t// keep track of the accumulated cost\n\tvar cost int64 = 0\n\n\t// calculate accumulated shortest path\n\tfor _, podAllocated := range scheduledList { // For each pod already allocated\n\t\tfor _, d := range dependencyList { // For each pod dependency\n\t\t\t// If the pod allocated is not an established dependency, continue.\n\t\t\tif podAllocated.Selector != d.Workload.Selector {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif podAllocated.Hostname == nodeName { // If the Pod hostname is the node being scored\n\t\t\t\tcost += SameHostname\n\t\t\t} else { // If Nodes are not the same\n\t\t\t\t// Get NodeInfo from pod Hostname\n\t\t\t\tpodNodeInfo, err := no.handle.SnapshotSharedLister().NodeInfos().Get(podAllocated.Hostname)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.ErrorS(nil, \"getting pod hostname %q from Snapshot: %v\", podNodeInfo, err)\n\t\t\t\t\treturn cost, err\n\t\t\t\t}\n\t\t\t\t// Get zone and region from Pod Hostname\n\t\t\t\tregionPodNodeInfo := networkawareutil.GetNodeRegion(podNodeInfo.Node())\n\t\t\t\tzonePodNodeInfo := networkawareutil.GetNodeZone(podNodeInfo.Node())\n\n\t\t\t\tif regionPodNodeInfo == \"\" && zonePodNodeInfo == \"\" { // Node has no zone and region defined\n\t\t\t\t\tcost += MaxCost\n\t\t\t\t} else if region == regionPodNodeInfo { // If Nodes belong to the same region\n\t\t\t\t\tif zone == zonePodNodeInfo { // If Nodes belong to the same zone\n\t\t\t\t\t\tcost += SameZone\n\t\t\t\t\t} else { // belong to a different zone\n\t\t\t\t\t\tvalue, ok := costMap[networkawareutil.CostKey{ // Retrieve the cost from the map (origin: zone, destination: pod zoneHostname)\n\t\t\t\t\t\t\tOrigin: zone, // Time Complexity: O(1)\n\t\t\t\t\t\t\tDestination: zonePodNodeInfo,\n\t\t\t\t\t\t}]\n\t\t\t\t\t\tif ok {\n\t\t\t\t\t\t\tcost += value // Add the cost to the sum\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcost += MaxCost\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else { // belong to a different region\n\t\t\t\t\tvalue, ok := costMap[networkawareutil.CostKey{ // Retrieve the cost from the map (origin: region, destination: pod regionHostname)\n\t\t\t\t\t\tOrigin: region, // Time Complexity: O(1)\n\t\t\t\t\t\tDestination: regionPodNodeInfo,\n\t\t\t\t\t}]\n\t\t\t\t\tif ok {\n\t\t\t\t\t\tcost += value // Add the cost to the sum\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcost += MaxCost\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn cost, nil\n}", "func (no *NetworkOverhead) populateCostMap(costMap map[networkawareutil.CostKey]int64, networkTopology *ntv1alpha1.NetworkTopology, region string, zone string) {\n\tfor _, w := range networkTopology.Spec.Weights { // Check the weights List\n\t\tif w.Name != no.weightsName { // If it is not the Preferred algorithm, continue\n\t\t\tcontinue\n\t\t}\n\n\t\tif region != \"\" { // Add Region Costs\n\t\t\t// Binary search through CostList: find the Topology Key for region\n\t\t\ttopologyList := networkawareutil.FindTopologyKey(w.TopologyList, ntv1alpha1.NetworkTopologyRegion)\n\n\t\t\tif no.weightsName != ntv1alpha1.NetworkTopologyNetperfCosts {\n\t\t\t\t// Sort Costs by origin, might not be sorted since were manually defined\n\t\t\t\tsort.Sort(networkawareutil.ByOrigin(topologyList))\n\t\t\t}\n\n\t\t\t// Binary search through TopologyList: find the costs for the given Region\n\t\t\tcosts := networkawareutil.FindOriginCosts(topologyList, region)\n\n\t\t\t// Add Region Costs\n\t\t\tfor _, c := range costs {\n\t\t\t\tcostMap[networkawareutil.CostKey{ // Add the cost to the map\n\t\t\t\t\tOrigin: region,\n\t\t\t\t\tDestination: c.Destination}] = c.NetworkCost\n\t\t\t}\n\t\t}\n\t\tif zone != \"\" { // Add Zone Costs\n\t\t\t// Binary search through CostList: find the Topology Key for zone\n\t\t\ttopologyList := networkawareutil.FindTopologyKey(w.TopologyList, ntv1alpha1.NetworkTopologyZone)\n\n\t\t\tif no.weightsName != ntv1alpha1.NetworkTopologyNetperfCosts {\n\t\t\t\t// Sort Costs by origin, might not be sorted since were manually defined\n\t\t\t\tsort.Sort(networkawareutil.ByOrigin(topologyList))\n\t\t\t}\n\n\t\t\t// Binary search through TopologyList: find the costs for the given Region\n\t\t\tcosts := networkawareutil.FindOriginCosts(topologyList, zone)\n\n\t\t\t// Add Zone Costs\n\t\t\tfor _, c := range costs {\n\t\t\t\tcostMap[networkawareutil.CostKey{ // Add the cost to the map\n\t\t\t\t\tOrigin: zone,\n\t\t\t\t\tDestination: c.Destination}] = c.NetworkCost\n\t\t\t}\n\t\t}\n\t}\n}", "func (m *MockTenantServicesPortDao) GetDepUDPPort(serviceID string) ([]*model.TenantServicesPort, error) {\n\tret := m.ctrl.Call(m, \"GetDepUDPPort\", serviceID)\n\tret0, _ := ret[0].([]*model.TenantServicesPort)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (client *HammerspaceClient) GetDataPortals(nodeID string) ([]common.DataPortal, error) {\n req, err := client.generateRequest(\"GET\", \"/data-portals/\", \"\")\n statusCode, respBody, _, err := client.doRequest(*req)\n\n if err != nil {\n log.Error(err)\n return nil, err\n }\n if statusCode != 200 {\n return nil, errors.New(fmt.Sprintf(common.UnexpectedHSStatusCode, statusCode, 200))\n }\n\n var portals []common.DataPortal\n err = json.Unmarshal([]byte(respBody), &portals)\n if err != nil {\n log.Error(\"Error parsing JSON response: \" + err.Error())\n return nil, err\n }\n\n // filter dataportals\n var filteredPortals []common.DataPortal\n for _, p := range portals {\n if p.OperState == \"UP\" && p.AdminState == \"UP\" && p.DataPortalType == \"NFS_V3\" {\n filteredPortals = append(filteredPortals, p)\n }\n }\n\n // sort dataportals\n var colocatedPortals []common.DataPortal\n var otherPortals []common.DataPortal\n //// Find colocated node portals\n for _, p := range filteredPortals {\n if p.Node.Name == nodeID {\n colocatedPortals = append(colocatedPortals, p)\n log.Infof(\"Found co-located data-portal, %s, with node name, %s\", p.Uoid[\"uuid\"], p.Node.Name)\n } else {\n otherPortals = append(otherPortals, p)\n }\n }\n\n sortedPortals := append(colocatedPortals, otherPortals...)\n\n return sortedPortals, nil\n}", "func (solver *MapSolver)GetCostByRegretting(regretArcList []int, machineNode *data.MachineNode, cost int)(int, []int, []int, error){\n\t// defer solver.timeCost(\"GetCostByRegretting\", time.Now())\n\tregrettingCost, costForReverseArcList, machineTargerList, err := solver.GetMinCostAfterRegreting(machineNode, regretArcList)\n\tcost += regrettingCost\n\treturn cost, costForReverseArcList, machineTargerList, err\n}", "func ShowCalcDurationBySort(sortable Sortable, target []int) {\n\t_, duration := SortWithDuration(sortable, target)\n\tfmt.Printf(\"call took %v to run by %v\\n\", duration, reflect.TypeOf(sortable))\n}", "func (test *Test) GetPorts(projectName string, ip string) ([]models.Port, error) {\n\treturn tests.NormalPorts, nil\n}", "func (cs *COSTMetricSource) getCOSTMetrics(namespace, metricName string, query prom.Selector) (values []external_metrics.ExternalMetricValue, err error) {\n\tclient, err := prometheusProvider.GlobalConfig.MakePromClient()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to create prometheus client,because of %v\", err)\n\t\treturn values, err\n\t}\n\tklog.V(4).Infof(\"externalquery :%+v\", query)\n\tqueryResult, err := client.Query(context.TODO(), pmodel.Now(), query)\n\tif err != nil {\n\t\tklog.Errorf(\"unable to fetch metrics from prometheus: %v\", err)\n\t\treturn nil, apierr.NewInternalError(fmt.Errorf(\"unable to fetch metrics\"))\n\t}\n\n\treturn cs.convertVector(metricName, queryResult)\n}", "func GetFreeTCPPorts(n int, offset ...int) (PortList, error) {\n\tlist := make([]string, 0, n)\n\tstart := PortStartingNumber\n\tif len(offset) != 0 {\n\t\tstart = offset[0]\n\t}\n\tfor i := start; i < start+n; i++ {\n\t\tlist = append(list, strconv.Itoa(i))\n\t}\n\treturn PortList{ports: list}, nil\n}", "func (c IpRemoteHost_getTcpPort) AllocResults() (IpRemoteHost_getTcpPort_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1})\n\treturn IpRemoteHost_getTcpPort_Results{Struct: r}, err\n}", "func (m *MockTCPRuleDao) GetTCPRuleByServiceIDAndContainerPort(serviceID string, containerPort int) ([]*model.TCPRule, error) {\n\tret := m.ctrl.Call(m, \"GetTCPRuleByServiceIDAndContainerPort\", serviceID, containerPort)\n\tret0, _ := ret[0].([]*model.TCPRule)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func SortServicePorts(ports []corev1.ServicePort) []corev1.ServicePort {\n\tsorted := make([]corev1.ServicePort, len(ports))\n\tcopy(sorted, ports)\n\tsort.Slice(sorted, func(i, j int) bool { return sorted[i].Port < sorted[j].Port })\n\treturn sorted\n}", "func (m *MockDB) ListCompilationTasks(userID, limit, offset uint, kind string) ([]CompilationTask, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListCompilationTasks\", userID, limit, offset, kind)\n\tret0, _ := ret[0].([]CompilationTask)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func getIPPermsForSG(isAllow bool, sg secGroup, myIP, sshUser string) (ipPerms []*ec2.IpPermission) {\n\tvar portsToChange []int64\n\tif isAllow {\n\t\tportsToChange = sg.ports\n\t} else {\n\t\tfor port := range sg.portToMyIPs {\n\t\t\tportsToChange = append(portsToChange, port)\n\t\t}\n\t}\n\tfor _, port := range portsToChange {\n\t\tipRanges := getIPRangesForPort(isAllow, sg, myIP, sshUser, port)\n\t\tif len(ipRanges) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tipPerms = append(ipPerms, &ec2.IpPermission{\n\t\t\tIpProtocol: aws.String(\"tcp\"),\n\t\t\tFromPort: aws.Int64(port),\n\t\t\tToPort: aws.Int64(port),\n\t\t\tIpRanges: ipRanges,\n\t\t})\n\t}\n\treturn ipPerms\n}", "func (m *MockLocalConfigProvider) GetComponentPorts() ([]string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetComponentPorts\")\n\tret0, _ := ret[0].([]string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func getIPPermsForSG(isAllow bool, sg secGroup, myIP string, userName *string) (ipPerms []*ec2.IpPermission) {\n\tvar portsToChange []int64\n\tif isAllow {\n\t\tportsToChange = sg.ports\n\t} else {\n\t\tfor port := range sg.portToMyIPs {\n\t\t\tportsToChange = append(portsToChange, port)\n\t\t}\n\t}\n\tfor _, port := range portsToChange {\n\t\tipRanges := getIPRangesForPort(isAllow, sg, myIP, userName, port)\n\t\tif len(ipRanges) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tipPerms = append(ipPerms, &ec2.IpPermission{\n\t\t\tIpProtocol: aws.String(\"tcp\"),\n\t\t\tFromPort: aws.Int64(port),\n\t\t\tToPort: aws.Int64(port),\n\t\t\tIpRanges: ipRanges,\n\t\t})\n\t}\n\treturn ipPerms\n}", "func (m *MockTenantServicesPortDao) GetPortsByServiceID(serviceID string) ([]*model.TenantServicesPort, error) {\n\tret := m.ctrl.Call(m, \"GetPortsByServiceID\", serviceID)\n\tret0, _ := ret[0].([]*model.TenantServicesPort)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (p *Provider) CapacityGet() (*structs.Capacity, error) {\n\tlog := Logger.At(\"CapacityGet\").Start()\n\n\tcapacity := &structs.Capacity{}\n\n\tires, err := p.listAndDescribeContainerInstances()\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tfor _, instance := range ires.ContainerInstances {\n\t\tif *instance.Status == \"DRAINING\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, resource := range instance.RegisteredResources {\n\t\t\tif *resource.Name == \"MEMORY\" {\n\t\t\t\tcapacity.InstanceMemory = *resource.IntegerValue\n\t\t\t\tcapacity.ClusterMemory += *resource.IntegerValue\n\t\t\t}\n\t\t\tif *resource.Name == \"CPU\" {\n\t\t\t\tcapacity.InstanceCPU = *resource.IntegerValue\n\t\t\t\tcapacity.ClusterCPU += *resource.IntegerValue\n\t\t\t}\n\t\t}\n\t}\n\n\tservices, err := p.clusterServices()\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tportWidth := map[int64]int64{}\n\n\tfor _, service := range services {\n\t\tservicePortWidth := map[int64]int64{}\n\n\t\tif service.LaunchType != nil && *service.LaunchType != \"EC2\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(service.LoadBalancers) > 0 {\n\t\t\tfor _, deployment := range service.Deployments {\n\t\t\t\tres, err := p.describeTaskDefinition(&ecs.DescribeTaskDefinitionInput{\n\t\t\t\t\tTaskDefinition: deployment.TaskDefinition,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err)\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\ttdPorts := map[string]int64{}\n\n\t\t\t\tfor _, cd := range res.TaskDefinition.ContainerDefinitions {\n\t\t\t\t\tif g := cd.DockerLabels[\"convox.generation\"]; g == nil || *g != \"2\" {\n\t\t\t\t\t\tfor _, pm := range cd.PortMappings {\n\t\t\t\t\t\t\ttdPorts[fmt.Sprintf(\"%s.%d\", *cd.Name, *pm.ContainerPort)] = *pm.HostPort\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor _, lb := range service.LoadBalancers {\n\t\t\t\t\tif port, ok := tdPorts[fmt.Sprintf(\"%s.%d\", *lb.ContainerName, *lb.ContainerPort)]; ok {\n\t\t\t\t\t\tservicePortWidth[port] += *deployment.DesiredCount\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// take deploymentconfiguration into account during deploys\n\t\tif len(service.Deployments) > 1 {\n\t\t\tif dc := service.DeploymentConfiguration; dc != nil {\n\t\t\t\tif mp := dc.MinimumHealthyPercent; mp != nil {\n\t\t\t\t\tmult := float64(*mp) / float64(100)\n\n\t\t\t\t\tfor port, width := range servicePortWidth {\n\t\t\t\t\t\tservicePortWidth[port] = int64(math.Ceil(float64(width) * mult))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor port, width := range servicePortWidth {\n\t\t\tportWidth[port] += width\n\t\t}\n\n\t\tres, err := p.describeTaskDefinition(&ecs.DescribeTaskDefinitionInput{\n\t\t\tTaskDefinition: service.TaskDefinition,\n\t\t})\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif service.DesiredCount == nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid DesiredCount\")\n\t\t}\n\n\t\tminCount := *service.DesiredCount\n\n\t\tfor _, cd := range res.TaskDefinition.ContainerDefinitions {\n\t\t\tcapacity.ProcessCount += minCount\n\n\t\t\tif cd.Memory != nil {\n\t\t\t\tcapacity.ProcessMemory += (minCount * *cd.Memory)\n\t\t\t}\n\n\t\t\tif cd.Cpu != nil {\n\t\t\t\tcapacity.ProcessCPU += (minCount * *cd.Cpu)\n\t\t\t}\n\t\t}\n\t}\n\n\tmax := int64(0)\n\n\tfor _, n := range portWidth {\n\t\tif n > max {\n\t\t\tmax = n\n\t\t}\n\t}\n\n\tcapacity.ProcessWidth = max\n\n\tlog.Success()\n\t// \"cluster.cpu=%d cluster.memory=%d instance.cpu=%d instance.memory=%d process.count=%d process.cpu=%d process.memory=%d process.width=%d\", capacity.ClusterCPU, capacity.ClusterMemory, capacity.InstanceCPU, capacity.InstanceMemory, capacity.ProcessCount, capacity.ProcessCPU, capacity.ProcessMemory, capacity.ProcessWidth)\n\treturn capacity, nil\n}", "func TestServiceRegistryExternalTrafficHealthCheckNodePortUserAllocationBeta(t *testing.T) {\n\trandomNodePort := generateRandomNodePort()\n\tctx := genericapirequest.NewDefaultContext()\n\tstorage, _, server := NewTestREST(t, nil)\n\tdefer server.Terminate(t)\n\tsvc := &api.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"external-lb-esipp\",\n\t\t\tAnnotations: map[string]string{\n\t\t\t\tapi.BetaAnnotationExternalTraffic: api.AnnotationValueExternalTrafficLocal,\n\t\t\t\tapi.BetaAnnotationHealthCheckNodePort: fmt.Sprintf(\"%v\", randomNodePort),\n\t\t\t},\n\t\t},\n\t\tSpec: api.ServiceSpec{\n\t\t\tSelector: map[string]string{\"bar\": \"baz\"},\n\t\t\tSessionAffinity: api.ServiceAffinityNone,\n\t\t\tType: api.ServiceTypeLoadBalancer,\n\t\t\tPorts: []api.ServicePort{{\n\t\t\t\tPort: 6502,\n\t\t\t\tProtocol: api.ProtocolTCP,\n\t\t\t\tTargetPort: intstr.FromInt(6502),\n\t\t\t}},\n\t\t},\n\t}\n\tcreated_svc, err := storage.Create(ctx, svc, false)\n\tif created_svc == nil || err != nil {\n\t\tt.Fatalf(\"Unexpected failure creating service :%v\", err)\n\t}\n\tcreated_service := created_svc.(*api.Service)\n\tif !service.NeedsHealthCheck(created_service) {\n\t\tt.Errorf(\"Expecting health check needed, returned health check not needed instead\")\n\t}\n\tport := service.GetServiceHealthCheckNodePort(created_service)\n\tif port == 0 {\n\t\tt.Errorf(\"Failed to allocate health check node port and set the HealthCheckNodePort\")\n\t}\n\tif port != randomNodePort {\n\t\tt.Errorf(\"Failed to allocate requested nodePort expected %d, got %d\", randomNodePort, port)\n\t}\n}", "func TestPortGrabber(t *testing.T) {\n\tports := make([]int, portGrabberMax-portGrabberStart)\n\n\tvar wg sync.WaitGroup\n\twg.Add(len(ports))\n\tfor i := 0; i < len(ports); i++ {\n\t\tgo func(i int) {\n\t\t\tports[i] = uiPortGrabber.grabPort()\n\t\t\tif ports[i] == 0 {\n\t\t\t\tt.Error(\"Expected grabPort to return non zero value\")\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(i)\n\t}\n\twg.Wait()\n\n\tif len(uiPortGrabber.free) != 0 {\n\t\tt.Error(\"Expected all ports to be allocated\")\n\t}\n\n\tif uiPortGrabber.grabPort() != 0 {\n\t\tt.Error(\"Expected grabPort to return 0\")\n\t}\n\n\twg.Add(len(ports))\n\tfor i := 0; i < len(ports); i++ {\n\t\tgo func(port int) {\n\t\t\tuiPortGrabber.releasePort(port)\n\t\t\twg.Done()\n\t\t}(ports[i])\n\t}\n\twg.Wait()\n\n\tif len(uiPortGrabber.free) != len(ports) {\n\t\tt.Error(\"Expected no ports to be allocated\")\n\t}\n}", "func GetGroupDetails(group *crd.Group) (*metrics.GroupMetrics, *metrics.GroupMetrics, *Cost) {\n\t// TODO: include storage in group details\n\tprice := GetUserCosts()\n\n\tcurrentTime := getCurrentTime()\n\tmonthStartTime := getCurrentMonthStartTime()\n\n\tpodsDetails := group.Spec.PodsDetails\n\tvar totalCPURequest, totalCPULimit, totalMemoryRequest, totalMemoryLimit, totalStorageClaimed float64\n\t// [PIT] Point In Time metrics for the group\n\tvar pitCPURequest, pitCPULimit, pitMemoryRequest, pitMemoryLimit, pitStorageClaimed float64\n\tfor _, podDetails := range podsDetails {\n\t\tstartTime := podDetails.StartTime\n\t\tendTime := podDetails.EndTime\n\n\t\tpodActiveHours := currentMonthActiveTimeInHoursMulti(startTime, endTime, currentTime, monthStartTime)\n\n\t\tpodComputeMetrics := getPodComputeMetrics(podDetails)\n\t\tpodStorageAllocatedInGBHours, podActiveStorageAllocated := getPodStorageMetrics(podDetails)\n\n\t\tpodCPURequest := float64(podComputeMetrics.CPURequest.Value())\n\t\tpodMemRequest := bytesToGB(podComputeMetrics.MemoryRequest.Value())\n\t\tpodCPULimit := float64(podComputeMetrics.CPULimit.Value())\n\t\tpodMemLimit := bytesToGB(podComputeMetrics.MemoryLimit.Value())\n\n\t\t// Pod is alive\n\t\tif endTime.IsZero() {\n\t\t\tpitCPULimit += podCPULimit\n\t\t\tpitCPURequest += podCPURequest\n\t\t\tpitMemoryLimit += podMemLimit\n\t\t\tpitMemoryRequest += podMemRequest\n\t\t\tpitStorageClaimed += podActiveStorageAllocated\n\t\t}\n\n\t\ttotalCPURequest += podCPURequest * podActiveHours\n\t\ttotalMemoryRequest += podMemRequest * podActiveHours\n\t\ttotalCPULimit += podCPULimit * podActiveHours\n\t\ttotalMemoryLimit += podMemLimit * podActiveHours\n\n\t\ttotalStorageClaimed += podStorageAllocatedInGBHours\n\t}\n\n\ttotalCPUCost := price.CPU * totalCPURequest\n\ttotalMemoryCost := price.Memory * totalMemoryRequest\n\ttotalStorageCost := price.Storage * totalStorageClaimed\n\n\ttotalCumulativeCost := totalCPUCost + totalMemoryCost + totalStorageCost\n\n\tmtdGroupMetrics := &metrics.GroupMetrics{\n\t\tCPULimit: totalCPULimit,\n\t\tMemoryLimit: totalMemoryLimit,\n\t\tCPURequest: totalCPURequest,\n\t\tMemoryRequest: totalMemoryRequest,\n\t\tStorageClaimed: totalStorageClaimed,\n\t}\n\n\tpitGroupMetrics := &metrics.GroupMetrics{\n\t\tCPULimit: pitCPULimit,\n\t\tMemoryLimit: pitMemoryLimit,\n\t\tCPURequest: pitCPURequest,\n\t\tMemoryRequest: pitMemoryRequest,\n\t\tStorageClaimed: pitStorageClaimed,\n\t}\n\n\tcost := &Cost{\n\t\tTotalCost: totalCumulativeCost,\n\t\tCPUCost: totalCPUCost,\n\t\tMemoryCost: totalMemoryCost,\n\t\tStorageCost: totalStorageCost,\n\t}\n\n\treturn pitGroupMetrics, mtdGroupMetrics, cost\n}", "func TestOrderedWorkerPoolSmallNumberOfTasks(t *testing.T) {\n\ttaskCount := 5\n\tresults := make([]int, taskCount)\n\n\ttasksCh, resultCh := New(runtime.NumCPU() * 2)\n\tgo dispatchTasks(tasksCh, taskCount)\n\n\t// Cache the results in order they are received\n\ti := 0\n\tfor result := range resultCh {\n\t\tresults[i] = result.Value.(int)\n\t\ti++\n\t}\n\n\t// Verify that results arrived in correct order.\n\tfor i := 0; i < taskCount; i++ {\n\t\tif results[i] != i {\n\t\t\tt.Error(\"Results out of order\", results)\n\t\t}\n\t}\n}", "func (s *SortSuite) TestSortPortNetworkPolicyRules(c *C) {\n\tvar slice, expected []*cilium.PortNetworkPolicyRule\n\n\tslice = []*cilium.PortNetworkPolicyRule{\n\t\tPortNetworkPolicyRule7,\n\t\tPortNetworkPolicyRule6,\n\t\tPortNetworkPolicyRule5,\n\t\tPortNetworkPolicyRule4,\n\t\tPortNetworkPolicyRule3,\n\t\tPortNetworkPolicyRule2,\n\t\tPortNetworkPolicyRule1,\n\t}\n\texpected = []*cilium.PortNetworkPolicyRule{\n\t\tPortNetworkPolicyRule1,\n\t\tPortNetworkPolicyRule2,\n\t\tPortNetworkPolicyRule3,\n\t\tPortNetworkPolicyRule4,\n\t\tPortNetworkPolicyRule5,\n\t\tPortNetworkPolicyRule6,\n\t\tPortNetworkPolicyRule7,\n\t}\n\tSortPortNetworkPolicyRules(slice)\n\tc.Assert(slice, checker.DeepEquals, expected)\n}", "func TestServiceRegistryExternalTrafficHealthCheckNodePortUserAllocation(t *testing.T) {\n\trandomNodePort := generateRandomNodePort()\n\tctx := genericapirequest.NewDefaultContext()\n\tstorage, _, server := NewTestREST(t, nil)\n\tdefer server.Terminate(t)\n\tsvc := &api.Service{\n\t\tObjectMeta: metav1.ObjectMeta{Name: \"external-lb-esipp\"},\n\t\tSpec: api.ServiceSpec{\n\t\t\tSelector: map[string]string{\"bar\": \"baz\"},\n\t\t\tSessionAffinity: api.ServiceAffinityNone,\n\t\t\tType: api.ServiceTypeLoadBalancer,\n\t\t\tPorts: []api.ServicePort{{\n\t\t\t\tPort: 6502,\n\t\t\t\tProtocol: api.ProtocolTCP,\n\t\t\t\tTargetPort: intstr.FromInt(6502),\n\t\t\t}},\n\t\t\tExternalTrafficPolicy: api.ServiceExternalTrafficPolicyTypeLocal,\n\t\t\tHealthCheckNodePort: randomNodePort,\n\t\t},\n\t}\n\tcreated_svc, err := storage.Create(ctx, svc, false)\n\tif created_svc == nil || err != nil {\n\t\tt.Fatalf(\"Unexpected failure creating service :%v\", err)\n\t}\n\tcreated_service := created_svc.(*api.Service)\n\tif !service.NeedsHealthCheck(created_service) {\n\t\tt.Errorf(\"Expecting health check needed, returned health check not needed instead\")\n\t}\n\tport := service.GetServiceHealthCheckNodePort(created_service)\n\tif port == 0 {\n\t\tt.Errorf(\"Failed to allocate health check node port and set the HealthCheckNodePort\")\n\t}\n\tif port != randomNodePort {\n\t\tt.Errorf(\"Failed to allocate requested nodePort expected %d, got %d\", randomNodePort, port)\n\t}\n}", "func costsMonthlyAWS(month time.Time) (apiCallResult, error) {\n\n\tamortizedCost := \"AmortizedCost\"\n\tmetrics := []*string{&amortizedCost}\n\n\tstart, end := splitIntoBounds(month)\n\n\toutput, err := costexplorerCall(costexplorer.New(awsSess), start, end, metrics)\n\tif err != nil {\n\t\treturn apiCallResult{}, err\n\t}\n\n\t// reserve space for the queried month\n\tentries := make([]apiCallResultEntry, len(output.ResultsByTime[0].Groups))\n\n\t// Retrieve the required information for csvEntries from the output.\n\t// As we queried only for a single month, we don't have to iterate and simply look at [0]\n\telement := output.ResultsByTime[0]\n\tfor i, group := range element.Groups {\n\t\tamount, err := strconv.ParseFloat(*group.Metrics[amortizedCost].Amount, 64)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Unable to decode AWS cost amount as float64\")\n\t\t\treturn apiCallResult{}, err\n\t\t}\n\n\t\tentries[i] = apiCallResultEntry{\n\t\t\tProjectID: strings.Replace(*group.Keys[0], \"project-number$\", \"\", 1),\n\t\t\tAmount: amount,\n\t\t\tCurrency: *(group.Metrics[amortizedCost].Unit),\n\t\t}\n\t}\n\tresult := apiCallResult{\n\t\tTimestamp: time.Now(),\n\t\tResponseString: output.String(),\n\t\tEntries: entries,\n\t}\n\n\treturn result, nil\n}", "func (qs SysDBQuerySet) OrderDescByPort() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"port DESC\"))\n}", "func (m *MockNetwork) ListPorts(arg0 ports.ListOptsBuilder) ([]ports.Port, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListPorts\", arg0)\n\tret0, _ := ret[0].([]ports.Port)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func testCheckDDCloudPortListMatches(name string, expected compute.PortList) resource.TestCheckFunc {\n\tname = ensureResourceTypePrefix(name, \"ddcloud_port_list\")\n\n\treturn func(state *terraform.State) error {\n\t\tres, ok := state.RootModule().Resources[name]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"not found: %s\", name)\n\t\t}\n\n\t\tportListID := res.Primary.ID\n\n\t\tclient := testAccProvider.Meta().(*providerState).Client()\n\t\tportList, err := client.GetPortList(portListID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"bad: get port list: %s\", err)\n\t\t}\n\t\tif portList == nil {\n\t\t\treturn fmt.Errorf(\"bad: port list not found with Id '%s'\", portListID)\n\t\t}\n\n\t\tif portList.Name != expected.Name {\n\t\t\treturn fmt.Errorf(\"bad: port list '%s' has name '%s' (expected '%s')\", portListID, portList.Name, expected.Name)\n\t\t}\n\n\t\tif portList.Description != expected.Description {\n\t\t\treturn fmt.Errorf(\"bad: port list '%s' has description '%s' (expected '%s')\", portListID, portList.Description, expected.Description)\n\t\t}\n\n\t\tif len(portList.Ports) != len(expected.Ports) {\n\t\t\treturn fmt.Errorf(\"bad: port list '%s' has %d ports or port ranges (expected '%d')\", portListID, len(portList.Ports), len(expected.Ports))\n\t\t}\n\n\t\terr = comparePortListEntries(expected, *portList)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif len(portList.ChildLists) != len(expected.ChildLists) {\n\t\t\treturn fmt.Errorf(\"bad: port list '%s' has %d child lists (expected '%d')\", portListID, len(portList.ChildLists), len(expected.ChildLists))\n\t\t}\n\n\t\tfor index := range portList.ChildLists {\n\t\t\texpectedChildListID := expected.ChildLists[index].ID\n\t\t\tactualChildListID := portList.ChildLists[index].ID\n\n\t\t\tif actualChildListID != expectedChildListID {\n\t\t\t\treturn fmt.Errorf(\"bad: port list '%s' has child list at index %d with Id %s (expected '%s')\",\n\t\t\t\t\tportListID, index, actualChildListID, expectedChildListID,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func checkMaxNetworkCostRequirements(scheduledList networkawareutil.ScheduledList, dependencyList []agv1alpha1.DependenciesInfo, nodeInfo *framework.NodeInfo, region string,\n\tzone string, costMap map[networkawareutil.CostKey]int64, no *NetworkOverhead) (int64, int64, error) {\n\n\tvar satisfied int64 = 0\n\tvar violated int64 = 0\n\n\t// check if maxNetworkCost fits\n\tfor _, podAllocated := range scheduledList { // For each pod already allocated\n\t\tif podAllocated.Hostname != \"\" { // if hostname not empty...\n\t\t\tfor _, d := range dependencyList { // For each pod dependency\n\t\t\t\t// If the pod allocated is not an established dependency, continue.\n\t\t\t\tif podAllocated.Selector != d.Workload.Selector {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// If the Pod hostname is the node being filtered, requirements are checked via extended resources\n\t\t\t\tif podAllocated.Hostname == nodeInfo.Node().Name {\n\t\t\t\t\tsatisfied += 1\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// If Nodes are not the same, get NodeInfo from pod Hostname\n\t\t\t\tpodNodeInfo, err := no.handle.SnapshotSharedLister().NodeInfos().Get(podAllocated.Hostname)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.ErrorS(nil, \"getting pod nodeInfo %q from Snapshot: %v\", podNodeInfo, err)\n\t\t\t\t\treturn satisfied, violated, err\n\t\t\t\t}\n\n\t\t\t\t// Get zone and region from Pod Hostname\n\t\t\t\tregionPodNodeInfo := networkawareutil.GetNodeRegion(podNodeInfo.Node())\n\t\t\t\tzonePodNodeInfo := networkawareutil.GetNodeZone(podNodeInfo.Node())\n\n\t\t\t\tif regionPodNodeInfo == \"\" && zonePodNodeInfo == \"\" { // Node has no zone and region defined\n\t\t\t\t\tviolated += 1\n\t\t\t\t} else if region == regionPodNodeInfo { // If Nodes belong to the same region\n\t\t\t\t\tif zone == zonePodNodeInfo { // If Nodes belong to the same zone\n\t\t\t\t\t\tsatisfied += 1\n\t\t\t\t\t} else { // belong to a different zone, check maxNetworkCost\n\t\t\t\t\t\tcost, costOK := costMap[networkawareutil.CostKey{ // Retrieve the cost from the map (origin: zone, destination: pod zoneHostname)\n\t\t\t\t\t\t\tOrigin: zone, // Time Complexity: O(1)\n\t\t\t\t\t\t\tDestination: zonePodNodeInfo,\n\t\t\t\t\t\t}]\n\t\t\t\t\t\tif costOK {\n\t\t\t\t\t\t\tif cost <= d.MaxNetworkCost {\n\t\t\t\t\t\t\t\tsatisfied += 1\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tviolated += 1\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} else { // belong to a different region\n\t\t\t\t\tcost, costOK := costMap[networkawareutil.CostKey{ // Retrieve the cost from the map (origin: zone, destination: pod zoneHostname)\n\t\t\t\t\t\tOrigin: region, // Time Complexity: O(1)\n\t\t\t\t\t\tDestination: regionPodNodeInfo,\n\t\t\t\t\t}]\n\t\t\t\t\tif costOK {\n\t\t\t\t\t\tif cost <= d.MaxNetworkCost {\n\t\t\t\t\t\t\tsatisfied += 1\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tviolated += 1\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\treturn satisfied, violated, nil\n}", "func ListRealmNodePoolPlansMocked(\n\tt *testing.T, nodePoolPlansIn []*types.NodePoolPlan, realmID string,\n) []*types.NodePoolPlan {\n\n\tassert := assert.New(t)\n\n\t// wire up\n\tcs := &utils.MockConcertoService{}\n\tds, err := NewRealmService(cs)\n\tassert.Nil(err, \"Couldn't load realm service\")\n\tassert.NotNil(ds, \"Realm service not instanced\")\n\n\t// to json\n\tdIn, err := json.Marshal(nodePoolPlansIn)\n\tassert.Nil(err, \"NodePoolPlans test data corrupted\")\n\n\t// call service\n\tcs.On(\"Get\", fmt.Sprintf(APIPathCloudRealmNodePoolPlans, realmID)).Return(dIn, 200, nil)\n\tnodePoolPlansOut, err := ds.ListRealmNodePoolPlans(realmID)\n\n\tassert.Nil(err, \"Error getting node pool plan list\")\n\tassert.Equal(nodePoolPlansIn, nodePoolPlansOut, \"ListRealmNodePoolPlans returned different node pool plans\")\n\n\treturn nodePoolPlansOut\n}", "func fakeHostPorts(fromHost, toHost, fromPort, toPort int) []string {\n\tvar hostports []string\n\tfor h := fromHost; h <= toHost; h++ {\n\t\tfor p := fromPort; p <= toPort; p++ {\n\t\t\thostports = append(hostports, fmt.Sprintf(\"192.0.2.%v:%v\", h, p))\n\t\t}\n\t}\n\treturn hostports\n}", "func (c IpRemoteHost_getUdpPort) AllocResults() (IpRemoteHost_getUdpPort_Results, error) {\n\tr, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1})\n\treturn IpRemoteHost_getUdpPort_Results{Struct: r}, err\n}", "func checkNodeAllocatableTest(f *framework.Framework) {\n\n\tnodeMem := getNodeMemory(f)\n\tframework.Logf(\"nodeMem says: %+v\", nodeMem)\n\n\t// calculate the allocatable mem based on capacity - reserved amounts\n\tcalculatedNodeAlloc := nodeMem.capacity.Copy()\n\tcalculatedNodeAlloc.Sub(nodeMem.systemReserve)\n\tcalculatedNodeAlloc.Sub(nodeMem.kubeReserve)\n\tcalculatedNodeAlloc.Sub(nodeMem.softEviction)\n\tcalculatedNodeAlloc.Sub(nodeMem.hardEviction)\n\n\tginkgo.By(fmt.Sprintf(\"Checking stated allocatable memory %v against calculated allocatable memory %v\", &nodeMem.allocatable, calculatedNodeAlloc))\n\n\t// sanity check against stated allocatable\n\tgomega.Expect(calculatedNodeAlloc.Cmp(nodeMem.allocatable)).To(gomega.Equal(0))\n}", "func (s *UtilizationAllocatorSuite) TestCalcScheduledTasksDuration() {\n\tqueue := []model.TaskQueueItem{\n\t\t{\n\t\t\tExpectedDuration: 5 * time.Minute,\n\t\t},\n\t\t{\n\t\t\tExpectedDuration: 15 * time.Minute,\n\t\t},\n\t\t{\n\t\t\tExpectedDuration: 2 * time.Hour,\n\t\t},\n\t}\n\ts.Equal(140*time.Minute, calcScheduledTasksDuration(queue))\n}", "func sortNodesByUsage(nodes []NodeUsage) {\n\tsort.Slice(nodes, func(i, j int) bool {\n\t\tti := nodes[i].usage[v1.ResourceMemory].Value() + nodes[i].usage[v1.ResourceCPU].MilliValue() + nodes[i].usage[v1.ResourcePods].Value()\n\t\ttj := nodes[j].usage[v1.ResourceMemory].Value() + nodes[j].usage[v1.ResourceCPU].MilliValue() + nodes[j].usage[v1.ResourcePods].Value()\n\n\t\t// extended resources\n\t\tfor name := range nodes[i].usage {\n\t\t\tif !isBasicResource(name) {\n\t\t\t\tti = ti + nodes[i].usage[name].Value()\n\t\t\t\ttj = tj + nodes[j].usage[name].Value()\n\t\t\t}\n\t\t}\n\n\t\t// To return sorted in descending order\n\t\treturn ti > tj\n\t})\n}", "func (mdc *MockDistroConnector) FindCostByDistroId(distroId string,\n\tstarttime time.Time, duration time.Duration) (*task.DistroCost, error) {\n\tdc := task.DistroCost{}\n\tvar provider string\n\tvar settings map[string]interface{}\n\n\t// Find the distro.\n\tfor _, d := range mdc.CachedDistros {\n\t\tif d.Id == distroId {\n\t\t\tdc.DistroId = distroId\n\t\t\tprovider = d.Provider\n\t\t\tsettings = *d.ProviderSettings\n\t\t}\n\t}\n\n\t// Throw an error when no task with the given distro ID is found.\n\tif dc.DistroId == \"\" {\n\t\treturn nil, fmt.Errorf(\"no task with distro_id %s has been found\", distroId)\n\t}\n\n\t// Simulate aggregation\n\tfor _, t := range mdc.CachedTasks {\n\t\tif t.DistroId == distroId && (t.FinishTime.Sub(starttime) >= 0) &&\n\t\t\t(starttime.Add(duration).Sub(t.FinishTime) >= 0) {\n\t\t\tdc.SumTimeTaken += t.TimeTaken\n\t\t}\n\t}\n\n\tif dc.SumTimeTaken != time.Duration(0) {\n\t\tdc.Provider = provider\n\t\tdc.ProviderSettings = settings\n\t}\n\n\treturn &dc, nil\n}", "func (suite *ServiceTestSuite) TestHostsService_ReserveHosts() {\n\tdefer suite.mockCtrl.Finish()\n\tctx := context.Background()\n\n\terr := suite.hostService.ReserveHost(ctx, nil, nil)\n\trequire.Error(suite.T(), err)\n\tsuite.Equal(err.Error(), errNoValidHosts.Error())\n\n\terr = suite.hostService.ReserveHost(\n\t\tctx,\n\t\t[]*models_v0.Host{{Host: &hostsvc.HostInfo{}}},\n\t\tnil)\n\trequire.Error(suite.T(), err)\n\tsuite.Equal(err.Error(), errNoValidTask.Error())\n\n\tsuite.hostMgrClient.EXPECT().ReserveHosts(\n\t\tgomock.Any(), gomock.Any()).\n\t\tReturn(nil, errReturn)\n\terr = suite.hostService.ReserveHost(\n\t\tctx,\n\t\t[]*models_v0.Host{{Host: &hostsvc.HostInfo{}}},\n\t\t&resmgr.Task{})\n\trequire.Error(suite.T(), err)\n\tsuite.Equal(err.Error(), errReturn.Error())\n\n\tsuite.hostMgrClient.EXPECT().ReserveHosts(\n\t\tgomock.Any(), gomock.Any()).\n\t\tReturn(\n\t\t\t&hostsvc.ReserveHostsResponse{\n\t\t\t\tError: &hostsvc.ReserveHostsResponse_Error{\n\t\t\t\t\tFailed: &hostsvc.ReservationFailed{\n\t\t\t\t\t\tMessage: \"failed\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}, nil,\n\t\t)\n\terr = suite.hostService.ReserveHost(\n\t\tctx,\n\t\t[]*models_v0.Host{{Host: &hostsvc.HostInfo{}}},\n\t\t&resmgr.Task{})\n\trequire.Error(suite.T(), err)\n\n\tsuite.hostMgrClient.EXPECT().ReserveHosts(\n\t\tgomock.Any(), gomock.Any()).\n\t\tReturn(\n\t\t\t&hostsvc.ReserveHostsResponse{}, nil,\n\t\t)\n\terr = suite.hostService.ReserveHost(\n\t\tctx,\n\t\t[]*models_v0.Host{{Host: &hostsvc.HostInfo{}}},\n\t\t&resmgr.Task{})\n\trequire.NoError(suite.T(), err)\n}", "func ListPools(ctx context.Context, rpcClient UnaryInvoker, req *ListPoolsReq) (*ListPoolsResp, error) {\n\treq.setRPC(func(ctx context.Context, conn *grpc.ClientConn) (proto.Message, error) {\n\t\treturn mgmtpb.NewMgmtSvcClient(conn).ListPools(ctx, &mgmtpb.ListPoolsReq{\n\t\t\tSys: req.getSystem(rpcClient),\n\t\t})\n\t})\n\trpcClient.Debugf(\"DAOS system list-pools request: %+v\", req)\n\n\tur, err := rpcClient.InvokeUnaryRPC(ctx, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp := new(ListPoolsResp)\n\tif err := convertMSResponse(ur, resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif req.NoQuery {\n\t\treturn resp, nil\n\t}\n\n\t// issue query request and populate usage statistics for each pool\n\tfor _, p := range resp.Pools {\n\t\trpcClient.Debugf(\"Fetching details for discovered pool: %v\", p)\n\n\t\tresp, err := PoolQuery(ctx, rpcClient, &PoolQueryReq{ID: p.UUID})\n\t\tif err != nil {\n\t\t\tp.QueryErrorMsg = err.Error()\n\t\t\tif p.QueryErrorMsg == \"\" {\n\t\t\t\tp.QueryErrorMsg = \"unknown error\"\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif resp.Status != 0 {\n\t\t\tp.QueryStatusMsg = drpc.DaosStatus(resp.Status).Error()\n\t\t\tif p.QueryStatusMsg == \"\" {\n\t\t\t\tp.QueryStatusMsg = \"unknown error\"\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif p.UUID != resp.UUID {\n\t\t\treturn nil, errors.New(\"pool query response uuid does not match request\")\n\t\t}\n\n\t\tp.TargetsTotal = resp.TotalTargets\n\t\tp.TargetsDisabled = resp.DisabledTargets\n\t\tp.setUsage(resp)\n\t}\n\n\tfor _, p := range resp.Pools {\n\t\trpcClient.Debugf(\"DAOS system pool in list-pools response: %+v\", p)\n\t}\n\n\treturn resp, nil\n}", "func TestCostsSearch(t *testing.T) {\n\tfor _, target := range []time.Duration{\n\t\t100 * time.Millisecond,\n\t\t200 * time.Millisecond,\n\t\t500 * time.Millisecond,\n\t} {\n\t\tcosts, err := getHashingCosts(target)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\tactual, err := timeHashingCosts(costs)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\n\t\tif actual*3 < target {\n\t\t\tt.Errorf(\"actual=%v is too small (target=%v)\", actual, target)\n\t\t}\n\t\tif target*3 < actual {\n\t\t\tt.Errorf(\"actual=%v is too big (target=%v)\", actual, target)\n\t\t}\n\t}\n}", "func (a *cpuAccumulator) freeCPUs() []int {\n\treturn a.sortAvailableCPUs()\n}", "func ports(servicePorts []swarmtypes.PortConfig) string {\n\tif servicePorts == nil {\n\t\treturn \"\"\n\t}\n\n\tpr := portRange{}\n\tports := []string{}\n\n\tsort.Slice(servicePorts, func(i, j int) bool {\n\t\tif servicePorts[i].Protocol == servicePorts[j].Protocol {\n\t\t\treturn servicePorts[i].PublishedPort < servicePorts[j].PublishedPort\n\t\t}\n\t\treturn servicePorts[i].Protocol < servicePorts[j].Protocol\n\t})\n\n\tfor _, p := range servicePorts {\n\t\tif p.PublishMode == swarmtypes.PortConfigPublishModeIngress {\n\t\t\tprIsRange := pr.tEnd != pr.tStart\n\t\t\ttOverlaps := p.TargetPort <= pr.tEnd\n\n\t\t\t// Start a new port-range if:\n\t\t\t// - the protocol is different from the current port-range\n\t\t\t// - published or target port are not consecutive to the current port-range\n\t\t\t// - the current port-range is a _range_, and the target port overlaps with the current range's target-ports\n\t\t\tif p.Protocol != pr.protocol || p.PublishedPort-pr.pEnd > 1 || p.TargetPort-pr.tEnd > 1 || prIsRange && tOverlaps {\n\t\t\t\t// start a new port-range, and print the previous port-range (if any)\n\t\t\t\tif pr.pStart > 0 {\n\t\t\t\t\tports = append(ports, pr.String())\n\t\t\t\t}\n\t\t\t\tpr = portRange{\n\t\t\t\t\tpStart: p.PublishedPort,\n\t\t\t\t\tpEnd: p.PublishedPort,\n\t\t\t\t\ttStart: p.TargetPort,\n\t\t\t\t\ttEnd: p.TargetPort,\n\t\t\t\t\tprotocol: p.Protocol,\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpr.pEnd = p.PublishedPort\n\t\t\tpr.tEnd = p.TargetPort\n\t\t}\n\t}\n\tif pr.pStart > 0 {\n\t\tports = append(ports, pr.String())\n\t}\n\treturn strings.Join(ports, \", \")\n}", "func TestServiceRegistryExternalTrafficHealthCheckNodePortAllocation(t *testing.T) {\n\tctx := genericapirequest.NewDefaultContext()\n\tstorage, _, server := NewTestREST(t, nil)\n\tdefer server.Terminate(t)\n\tsvc := &api.Service{\n\t\tObjectMeta: metav1.ObjectMeta{Name: \"external-lb-esipp\"},\n\t\tSpec: api.ServiceSpec{\n\t\t\tSelector: map[string]string{\"bar\": \"baz\"},\n\t\t\tSessionAffinity: api.ServiceAffinityNone,\n\t\t\tType: api.ServiceTypeLoadBalancer,\n\t\t\tPorts: []api.ServicePort{{\n\t\t\t\tPort: 6502,\n\t\t\t\tProtocol: api.ProtocolTCP,\n\t\t\t\tTargetPort: intstr.FromInt(6502),\n\t\t\t}},\n\t\t\tExternalTrafficPolicy: api.ServiceExternalTrafficPolicyTypeLocal,\n\t\t},\n\t}\n\tcreated_svc, err := storage.Create(ctx, svc, false)\n\tif created_svc == nil || err != nil {\n\t\tt.Errorf(\"Unexpected failure creating service %v\", err)\n\t}\n\tcreated_service := created_svc.(*api.Service)\n\tif !service.NeedsHealthCheck(created_service) {\n\t\tt.Errorf(\"Expecting health check needed, returned health check not needed instead\")\n\t}\n\tport := service.GetServiceHealthCheckNodePort(created_service)\n\tif port == 0 {\n\t\tt.Errorf(\"Failed to allocate health check node port and set the HealthCheckNodePort\")\n\t}\n\n}", "func TestOrderedWorkerPool(t *testing.T) {\n\ttaskCount := 100000\n\tresults := make([]int, taskCount)\n\n\ttasksCh, resultCh := New(runtime.NumCPU() * 2)\n\tgo dispatchTasks(tasksCh, taskCount)\n\n\t// Cache the results in order they are received\n\ti := 0\n\tfor result := range resultCh {\n\t\tresults[i] = result.Value.(int)\n\t\ti++\n\t}\n\n\t// Verify that results arrived in correct order.\n\tfor i := 0; i < taskCount; i++ {\n\t\tif results[i] != i {\n\t\t\tt.Error(\"Results out of order\", results)\n\t\t}\n\t}\n}", "func GetResTransactionCost()int{\n return 1 // TODO: tune later\n}", "func getUsageData(start, stop string) UsageData {\n\n\tutils.Logger.Println(\"Get usage from: \", start, \" to: \", stop)\n\n\tvar total string\n\tvar usageData UsageData\n\n\terr := utils.DbCon.QueryRow(\"select sum(cost) as cost from bsms_smsrecipient where time_sent>=? and time_sent<=?\", start, stop).Scan(&total)\n\n\tif err != nil {\n\t\tutils.Logger.Println(\"get total error: \", err)\n\t\treturn usageData\n\t}\n\n\tusageData.Total = total\n\n\tstmt, err := utils.DbCon.Prepare(\"select u.username, sum(r.cost) as cost from auth_user u join bsms_smsrecipient r on u.id=r.user_id where r.time_sent > ? and r.time_sent < ? group by u.username order by cost desc\")\n\n\tif err != nil {\n\t\tutils.Logger.Println(\"slect costs error: \", err)\n\t\treturn usageData\n\t}\n\n\tdefer stmt.Close()\n\n\trows, err := stmt.Query(start, stop)\n\n\tif err != nil {\n\t\tutils.Logger.Println(\"exec costs error: \", err)\n\t\treturn usageData\n\t}\n\n\tdefer rows.Close()\n\n\tvar costs []CostData\n\tfor rows.Next() {\n\t\tvar usage CostData\n\t\terr := rows.Scan(&usage.Username, &usage.Amount)\n\t\tif err != nil {\n\t\t\tutils.Logger.Println(\"scan costs error: \", err)\n\t\t\treturn usageData\n\t\t}\n\t\tcosts = append(costs, usage)\n\t}\n\n\tusageData.Costs = costs\n\n\treturn usageData\n}", "func (taskService TaskService) GetByPartnerAndManagedEndpointID(w http.ResponseWriter, r *http.Request) {\n\tendpointID, err := common.ExtractUUID(\"TaskService.GetByPartnerAndManagedEndpointID\", w, r, \"managedEndpointID\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpartnerID := mux.Vars(r)[partnerIDKey]\n\tcurrentUser := taskService.userService.GetUser(r, taskService.httpClient)\n\n\tlistOfInternalTasksByTarget, err := taskService.taskPersistence.GetByPartnerAndManagedEndpointID(r.Context(), partnerID, endpointID, common.UnlimitedCount)\n\tif err != nil {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetListOfTasksByManagedEndpoint, \"TaskService.GetByPartnerAndManagedEndpointID: can not get list of Tasks by ManagedEndpointID. err=%v\", err)\n\t\tcommon.SendInternalServerError(w, r, errorcode.ErrorCantGetListOfTasksByManagedEndpoint)\n\t\treturn\n\t}\n\n\ttaskIDs := make([]gocql.UUID, len(listOfInternalTasksByTarget))\n\tfor i, internalTask := range listOfInternalTasksByTarget {\n\t\ttaskIDs[i] = internalTask.ID\n\t}\n\n\tlistOfInternalTasksByIDs, err := taskService.taskPersistence.GetByIDs(r.Context(), nil, partnerID, false, taskIDs...)\n\tif err != nil {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetListOfTasksByManagedEndpoint, \"TaskService.GetByPartnerAndManagedEndpointID: can not get list of Tasks by IDs(%v). err=%v\", taskIDs, err)\n\t\tcommon.SendInternalServerError(w, r, errorcode.ErrorCantGetListOfTasksByManagedEndpoint)\n\t\treturn\n\t}\n\n\t// Filter by NOC\n\tfilteredTaskGroup := filterTasksByNOCAccsess(listOfInternalTasksByIDs, currentUser.HasNOCAccess())\n\n\t// Group tasks by taskIDs\n\ttasksGroup := make(map[gocql.UUID][]models.Task)\n\tfor _, task := range filteredTaskGroup {\n\t\ttasksGroup[task.ID] = append(tasksGroup[task.ID], task)\n\t}\n\n\tlistOfOutputTasks := make([]models.Task, 0)\n\tfor _, internalTaskGroup := range tasksGroup {\n\t\ttaskOutputPtr, err := models.NewTaskOutput(r.Context(), internalTaskGroup)\n\t\tif err != nil {\n\t\t\tlogger.Log.WarnfCtx(\n\t\t\t\tr.Context(),\n\t\t\t\t\"TaskService.GetByPartnerAndManagedEndpointID: failed to build task output from internal tasks %v. Err: %s\",\n\t\t\t\tinternalTaskGroup,\n\t\t\t\terr,\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tlistOfOutputTasks = append(listOfOutputTasks, *taskOutputPtr)\n\t}\n\n\tlogger.Log.DebugfCtx(r.Context(), \"TaskService.GetByPartnerAndManagedEndpointID: successfully returned list of Tasks by ManagedEndpointID.\")\n\tcommon.RenderJSON(w, listOfOutputTasks)\n}", "func TestServiceRegistryExternalTrafficHealthCheckNodePortAllocationBeta(t *testing.T) {\n\tctx := genericapirequest.NewDefaultContext()\n\tstorage, _, server := NewTestREST(t, nil)\n\tdefer server.Terminate(t)\n\tsvc := &api.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"external-lb-esipp\",\n\t\t\tAnnotations: map[string]string{\n\t\t\t\tapi.BetaAnnotationExternalTraffic: api.AnnotationValueExternalTrafficLocal,\n\t\t\t},\n\t\t},\n\t\tSpec: api.ServiceSpec{\n\t\t\tSelector: map[string]string{\"bar\": \"baz\"},\n\t\t\tSessionAffinity: api.ServiceAffinityNone,\n\t\t\tType: api.ServiceTypeLoadBalancer,\n\t\t\tPorts: []api.ServicePort{{\n\t\t\t\tPort: 6502,\n\t\t\t\tProtocol: api.ProtocolTCP,\n\t\t\t\tTargetPort: intstr.FromInt(6502),\n\t\t\t}},\n\t\t},\n\t}\n\tcreated_svc, err := storage.Create(ctx, svc, false)\n\tif created_svc == nil || err != nil {\n\t\tt.Errorf(\"Unexpected failure creating service %v\", err)\n\t}\n\tcreated_service := created_svc.(*api.Service)\n\tif !service.NeedsHealthCheck(created_service) {\n\t\tt.Errorf(\"Expecting health check needed, returned health check not needed instead\")\n\t}\n\tport := service.GetServiceHealthCheckNodePort(created_service)\n\tif port == 0 {\n\t\tt.Errorf(\"Failed to allocate health check node port and set the HealthCheckNodePort\")\n\t}\n\n}", "func portRangeConnectivityTest(t *testing.T, getAddresses func(validPort int) []string, portsToTryBefore int, portsToTryAfter int) {\n\tit.TesterWithConfigBuilder(t, func(config *hz.Config) {\n\t\tclusterAddress := config.Cluster.Network.Addresses[0]\n\t\t_, port, err := internal.ParseAddr(clusterAddress)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t\tconfig.Cluster.Network.SetAddresses(getAddresses(port)...)\n\t\tconfig.Cluster.Network.SetPortRange(port-portsToTryBefore, port+portsToTryAfter)\n\t},\n\t\tfunc(t *testing.T, client *hz.Client) {\n\t\t\tassert.True(t, client.Running())\n\t\t\tif err := client.Shutdown(context.Background()); err != nil {\n\t\t\t\tt.Fatal(err)\n\t\t\t}\n\t\t\tassert.False(t, client.Running())\n\t\t})\n}", "func (m *MockICompilationTask) ListCompilationTasks(userID, limit, offset uint, kind string) ([]CompilationTask, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"ListCompilationTasks\", userID, limit, offset, kind)\n\tret0, _ := ret[0].([]CompilationTask)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockTenantServicesPortDao) GetOpenedPorts(serviceID string) ([]*model.TenantServicesPort, error) {\n\tret := m.ctrl.Call(m, \"GetOpenedPorts\", serviceID)\n\tret0, _ := ret[0].([]*model.TenantServicesPort)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (s NetworkTrafficBillingTablePrinter) Print(data *models.V1NetworkUsageResponse) {\n\ts.wideHeader = []string{\"Tenant\", \"From\", \"To\", \"ProjectID\", \"ProjectName\", \"Partition\", \"ClusterID\", \"ClusterName\", \"Device\", \"In (Gi)\", \"Out (Gi)\", \"Total (Gi)\", \"Lifetime\", \"Warnings\"}\n\ts.shortHeader = []string{\"Tenant\", \"ProjectID\", \"Partition\", \"ClusterName\", \"Device\", \"In (Gi)\", \"Out (Gi)\", \"Total (Gi)\", \"Lifetime\"}\n\ts.Order(data.Usage)\n\tfor _, u := range data.Usage {\n\t\tvar from string\n\t\tif data.From != nil {\n\t\t\tfrom = data.From.String()\n\t\t}\n\t\tvar to string\n\t\tif !time.Time(data.To).IsZero() {\n\t\t\tto = data.To.String()\n\t\t}\n\t\tvar tenant string\n\t\tif u.Tenant != nil {\n\t\t\ttenant = *u.Tenant\n\t\t}\n\t\tvar projectID string\n\t\tif u.Projectid != nil {\n\t\t\tprojectID = *u.Projectid\n\t\t}\n\t\tvar projectName string\n\t\tif u.Projectname != nil {\n\t\t\tprojectName = *u.Projectname\n\t\t}\n\t\tvar partition string\n\t\tif u.Partition != nil {\n\t\t\tpartition = *u.Partition\n\t\t}\n\t\tvar clusterID string\n\t\tif u.Clusterid != nil {\n\t\t\tclusterID = *u.Clusterid\n\t\t}\n\t\tvar clusterName string\n\t\tif u.Clustername != nil {\n\t\t\tclusterName = *u.Clustername\n\t\t}\n\t\tvar device string\n\t\tif u.Device != nil {\n\t\t\tdevice = *u.Device\n\t\t}\n\t\tvar in string\n\t\tif u.In != nil {\n\t\t\tin = humanizeBytesToGi(*u.In)\n\t\t}\n\t\tvar out string\n\t\tif u.Out != nil {\n\t\t\tout = humanizeBytesToGi(*u.Out)\n\t\t}\n\t\tvar total string\n\t\tif u.Total != nil {\n\t\t\ttotal = humanizeBytesToGi(*u.Total)\n\t\t}\n\t\tvar lifetime time.Duration\n\t\tif u.Lifetime != nil {\n\t\t\tlifetime = time.Duration(*u.Lifetime)\n\t\t}\n\t\tvar warnings string\n\t\tif u.Warnings != nil {\n\t\t\twarnings = strings.Join(u.Warnings, \", \")\n\t\t}\n\t\twide := []string{\n\t\t\ttenant,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tprojectID,\n\t\t\tprojectName,\n\t\t\tpartition,\n\t\t\tclusterID,\n\t\t\tclusterName,\n\t\t\tdevice,\n\t\t\tin,\n\t\t\tout,\n\t\t\ttotal,\n\t\t\thumanizeDuration(lifetime),\n\t\t\twarnings,\n\t\t}\n\t\tshort := []string{\n\t\t\ttenant,\n\t\t\tprojectID,\n\t\t\tpartition,\n\t\t\tclusterName,\n\t\t\tdevice,\n\t\t\tin,\n\t\t\tout,\n\t\t\ttotal,\n\t\t\thumanizeDuration(lifetime),\n\t\t}\n\n\t\ts.addWideData(wide, data)\n\t\ts.addShortData(short, data)\n\t}\n\n\tvar in string\n\tif data.Accumulatedusage.In != nil {\n\t\tin = humanizeBytesToGi(*data.Accumulatedusage.In) + giCosts(*data.Accumulatedusage.In, viper.GetFloat64(\"costs-incoming-network-traffic-gi\"))\n\t}\n\tvar out string\n\tif data.Accumulatedusage.Out != nil {\n\t\tout = humanizeBytesToGi(*data.Accumulatedusage.Out) + giCosts(*data.Accumulatedusage.Out, viper.GetFloat64(\"costs-outgoing-network-traffic-gi\"))\n\t}\n\tvar total string\n\tif data.Accumulatedusage.Total != nil {\n\t\ttotal = humanizeBytesToGi(*data.Accumulatedusage.Total) + giCosts(*data.Accumulatedusage.Total, viper.GetFloat64(\"costs-total-network-traffic-gi\"))\n\t}\n\tvar lifetime string\n\tif data.Accumulatedusage.Lifetime != nil {\n\t\tlifetime = humanizeDuration(time.Duration(*data.Accumulatedusage.Lifetime))\n\t}\n\tfooter := []string{\"Total\",\n\t\tin,\n\t\tout,\n\t\ttotal,\n\t\tlifetime,\n\t}\n\tshortFooter := make([]string, len(s.shortHeader)-len(footer))\n\twideFooter := make([]string, len(s.wideHeader)-len(footer))\n\ts.addWideData(append(wideFooter, footer...), data) // nolint:makezero\n\ts.addShortData(append(shortFooter, footer...), data) // nolint:makezero\n\ts.render()\n}", "func TwoCitySchedCost(costs [][]int) int {\n\treturn twoCitySchedCost(costs)\n}", "func (suite *TestCompountReportSuite) TestCompareForHostOfTargets(c *C) {\n\ttestCases := []*struct {\n\t\tleftHost string\n\t\trightHost string\n\t\texpected int\n\t}{\n\t\t{\"22.20.30.40\", \"103.20.30.40\", utils.SeqHigher},\n\t\t{\"10.20.30.40\", \"google.com\", utils.SeqHigher},\n\t\t{\"10.20.30.40\", \"10.20.30.40\", utils.SeqEqual},\n\t\t{\"wine.com.cn\", \"wine.com.cn\", utils.SeqEqual},\n\t}\n\n\tfor i, testCase := range testCases {\n\t\tcomment := ocheck.TestCaseComment(i)\n\t\tocheck.LogTestCase(c, testCase)\n\n\t\ttestedResult := CompareFunctions[\"target_host\"](\n\t\t\t&DynamicRecord{\n\t\t\t\tTarget: &DynamicTargetProps{\n\t\t\t\t\tHost: testCase.leftHost,\n\t\t\t\t},\n\t\t\t},\n\t\t\t&DynamicRecord{\n\t\t\t\tTarget: &DynamicTargetProps{\n\t\t\t\t\tHost: testCase.rightHost,\n\t\t\t\t},\n\t\t\t},\n\t\t\tutils.Ascending,\n\t\t)\n\t\tc.Assert(testedResult, Equals, testCase.expected, comment)\n\t}\n}", "func (_CraftingI *CraftingICaller) GetItemCost(opts *bind.CallOpts, _base_type *big.Int, _item_type *big.Int) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _CraftingI.contract.Call(opts, &out, \"get_item_cost\", _base_type, _item_type)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (suite *HostCacheTestSuite) TestMesosHostSummarySetAvailable() {\n\ttestTable := map[string]struct {\n\t\tcapacity scalar.Resources\n\t\tavailable scalar.Resources\n\t\texpectedAllocated scalar.Resources\n\t}{\n\t\t\"normal-test-case-1\": {\n\t\t\tcapacity: scalar.Resources{\n\t\t\t\tCPU: 4.0,\n\t\t\t\tMem: 100.0,\n\t\t\t},\n\t\t\tavailable: scalar.Resources{\n\t\t\t\tCPU: 1.0,\n\t\t\t\tMem: 20.0,\n\t\t\t},\n\t\t\texpectedAllocated: scalar.Resources{\n\t\t\t\tCPU: 3.0,\n\t\t\t\tMem: 80.0,\n\t\t\t},\n\t\t},\n\t\t\"normal-test-case-2\": {\n\t\t\tcapacity: scalar.Resources{\n\t\t\t\tCPU: 4.0,\n\t\t\t\tMem: 100.0,\n\t\t\t},\n\t\t\tavailable: scalar.Resources{\n\t\t\t\tCPU: 3.0,\n\t\t\t\tMem: 10.0,\n\t\t\t},\n\t\t\texpectedAllocated: scalar.Resources{\n\t\t\t\tCPU: 1.0,\n\t\t\t\tMem: 90.0,\n\t\t\t},\n\t\t},\n\t\t\"all-capacity-allocated\": {\n\t\t\tcapacity: scalar.Resources{\n\t\t\t\tCPU: 4.0,\n\t\t\t\tMem: 100.0,\n\t\t\t},\n\t\t\tavailable: scalar.Resources{\n\t\t\t\tCPU: 4.0,\n\t\t\t\tMem: 100.0,\n\t\t\t},\n\t\t\texpectedAllocated: scalar.Resources{\n\t\t\t\tCPU: 0.0,\n\t\t\t\tMem: 0.0,\n\t\t\t},\n\t\t},\n\t\t\"more-available-than-capacity\": {\n\t\t\tcapacity: scalar.Resources{\n\t\t\t\tCPU: 4.0,\n\t\t\t\tMem: 100.0,\n\t\t\t},\n\t\t\tavailable: scalar.Resources{\n\t\t\t\tCPU: 5.0,\n\t\t\t\tMem: 200.0,\n\t\t\t},\n\t\t\texpectedAllocated: scalar.Resources{\n\t\t\t\tCPU: 0.0,\n\t\t\t\tMem: 0.0,\n\t\t\t},\n\t\t},\n\t}\n\n\tfor msg, test := range testTable {\n\t\tms := newMesosHostSummary(_hostname, _version).(*mesosHostSummary)\n\t\tms.capacity = test.capacity\n\t\tms.SetAvailable(test.available)\n\t\tsuite.Equal(ms.GetCapacity(), test.capacity, msg)\n\t\tsuite.Equal(ms.GetAvailable(), test.available, msg)\n\t\tsuite.Equal(ms.GetAllocated(), test.expectedAllocated, msg)\n\t}\n}", "func sortTasksHelper(tasks map[string]task.Task, idToDisplayName map[string]string) []task.Task {\n\tlayers := layerTasks(tasks)\n\tsortedTasks := make([]task.Task, 0, len(tasks))\n\tfor _, layer := range layers {\n\t\tsortedTasks = append(sortedTasks, sortLayer(layer, idToDisplayName)...)\n\t}\n\treturn sortedTasks\n}", "func TestLeastUsedSched(t *testing.T) {\n\t// create a resource manager instance\n\trm := newRsrcmgr(t, t.Name())\n\n\trsrc := &rproto.Resource{\n\t\tResourceType: \"type1\",\n\t\tResourceKind: rproto.ResourceKind_Scalar,\n\t\tScalar: &rproto.ScalarResource{\n\t\t\tTotalResource: 10,\n\t\t\tAvailableResource: 10,\n\t\t},\n\t}\n\n\t// add some providers\n\terr := rm.AddProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov1\"})\n\tAssertOk(t, err, \"AddProvider failed\")\n\terr = rm.AddProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov2\"})\n\tAssertOk(t, err, \"AddProvider failed\")\n\terr = rm.AddProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov3\"})\n\tAssertOk(t, err, \"AddProvider failed\")\n\n\t// resource request\n\treq := &rproto.ResourceRequest{\n\t\tResourceType: \"type1\",\n\t\tAllocType: rproto.AllocType_Any,\n\t\tScheduler: \"leastUsed\",\n\t\tQuantity: 4,\n\t\tConsumerID: \"consumer1\",\n\t}\n\n\t// request some resources\n\tc1, err := rm.RequestResource(req)\n\tAssertOk(t, err, \"RequestResource failed to get a resource for c1\")\n\tAssert(t, c1.ResourceType == \"type1\", \"Returned resource type did not match\", c1)\n\tAssert(t, c1.Values[0] == 4, \"Returned resource value was incorrect\", c1)\n\tAssert(t, strings.Contains(c1.ProviderID, \"prov\"), \"Returned provider was incorrect\", c1)\n\n\t// request some more resources and verify they come from different providers\n\treq.ConsumerID = \"consumer2\"\n\tc2, err := rm.RequestResource(req)\n\tAssertOk(t, err, \"RequestResource failed to get a resource for c2\")\n\tAssert(t, c1.ProviderID != c2.ProviderID, \"did not get least used resource\", []*rproto.ResourceConsumer{c1, c2})\n\treq.ConsumerID = \"consumer3\"\n\tc3, err := rm.RequestResource(req)\n\tAssertOk(t, err, \"RequestResource failed to get a resource for c3\")\n\tAssert(t, (c1.ProviderID != c3.ProviderID && c2.ProviderID != c3.ProviderID), \"did not get least used resource\", []*rproto.ResourceConsumer{c1, c2, c3})\n\n\t// verify we request more resource than available, we get an error\n\treq.ConsumerID = \"consumer4\"\n\treq.Quantity = 8\n\tc4, err := rm.RequestResource(req)\n\tAssert(t, err != nil, \"Resource allocation succeeded while expecting it to fail\", c4)\n\n\t// try deleting a provider and verify it fails\n\terr = rm.DelProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov1\"})\n\tAssert(t, err != nil, \"Provider delete succeeded while expecting it to fail\", err)\n\n\t// release one of the resources\n\terr = rm.ReleaseResource(c1)\n\tAssertOk(t, err, \"ReleaseResource failed\")\n\n\t// retry allocating resource which should go thru\n\tc4, err = rm.RequestResource(req)\n\tAssertOk(t, err, \"RequestResource failed to get a resource for c4\")\n\n\t// release all resources\n\terr = rm.ReleaseResource(c2)\n\tAssertOk(t, err, \"ReleaseResource failed\")\n\terr = rm.ReleaseResource(c3)\n\tAssertOk(t, err, \"ReleaseResource failed\")\n\terr = rm.ReleaseResource(c4)\n\tAssertOk(t, err, \"ReleaseResource failed\")\n\n\t// delete all providers\n\terr = rm.DelProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov1\"})\n\tAssertOk(t, err, \"DelProvider failed\")\n\terr = rm.DelProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov2\"})\n\tAssertOk(t, err, \"DelProvider failed\")\n\terr = rm.DelProvider(&rproto.ResourceProvide{Resource: rsrc, ProviderID: \"prov3\"})\n\tAssertOk(t, err, \"DelProvider failed\")\n}", "func (m *MockTenantServicesPortDao) ListByK8sServiceNames(serviceIDs []string) ([]*model.TenantServicesPort, error) {\n\tret := m.ctrl.Call(m, \"ListByK8sServiceNames\", serviceIDs)\n\tret0, _ := ret[0].([]*model.TenantServicesPort)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockProduct) TotalCostOfEachScope(arg0 context.Context, arg1 []string) ([]db.TotalCostOfEachScopeRow, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"TotalCostOfEachScope\", arg0, arg1)\n\tret0, _ := ret[0].([]db.TotalCostOfEachScopeRow)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (rcsw *RemoteClusterServiceWatcher) getEndpointsPorts(service *corev1.Service, gatewayPort int32) []corev1.EndpointPort {\n\tvar endpointsPorts []corev1.EndpointPort\n\tfor _, remotePort := range service.Spec.Ports {\n\t\tendpointsPorts = append(endpointsPorts, corev1.EndpointPort{\n\t\t\tName: remotePort.Name,\n\t\t\tProtocol: remotePort.Protocol,\n\t\t\tPort: gatewayPort,\n\t\t})\n\t}\n\treturn endpointsPorts\n}", "func getPaymentCreditsTest(t *testing.T, c *TestContext) {\n\ttcc := []TestCase{\n\t\t*c.UserCheckTestCase,\n\t\t{\n\t\t\tToken: c.Config.Users.User.Token,\n\t\t\tStatusCode: http.StatusBadRequest,\n\t\t\tParams: \"a\",\n\t\t\tRespContains: []string{`Liste des enveloppes de crédits, décodage : `}},\n\t\t{\n\t\t\tToken: c.Config.Users.User.Token,\n\t\t\tStatusCode: http.StatusOK,\n\t\t\tParams: \"2019\",\n\t\t\tRespContains: []string{`{\"PaymentCredit\":[`}},\n\t}\n\tf := func(tc TestCase) *httpexpect.Response {\n\t\treturn c.E.GET(\"/api/payment_credits\").WithHeader(\"Authorization\", \"Bearer \"+tc.Token).\n\t\t\tWithQuery(\"Year\", tc.Params).Expect()\n\t}\n\tfor _, r := range chkFactory(tcc, f, \"GetPaymentCredits\") {\n\t\tt.Error(r)\n\t}\n}", "func getIPRangesForPort(isAllow bool, sg secGroup, myIP string, userName *string, port int64) (ipr []*ec2.IpRange) {\n\tif isAllow {\n\t\tif !strings.Contains(myIP, \"/\") {\n\t\t\tmyIP += \"/32\"\n\t\t}\n\t\tfor _, cidr := range sg.portToMyIPs[port] {\n\t\t\tif cidr == myIP {\n\t\t\t\tout.Highlight(out.WARN, \"skipping existing access for %s - IP %s to port %s in SG %s (%s)\", *userName, cidr, strconv.Itoa(int(port)), sg.name, sg.id)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tipr = append(ipr, &ec2.IpRange{\n\t\t\tCidrIp: aws.String(myIP),\n\t\t\tDescription: aws.String(*userName),\n\t\t})\n\t} else {\n\t\tfor _, cidr := range sg.portToMyIPs[port] {\n\t\t\tipr = append(ipr, &ec2.IpRange{\n\t\t\t\tCidrIp: aws.String(cidr),\n\t\t\t\tDescription: aws.String(*userName),\n\t\t\t})\n\t\t}\n\t}\n\treturn\n}", "func (f *TaskFinder) getPortForTask(t *ecs.Task, service string) (int, error) {\n\tvar c *ecs.Container\n\tif len(t.Containers) == 0 {\n\t\treturn 0, fmt.Errorf(\"no containers configured\")\n\t} else if len(t.Containers) == 1 {\n\t\tc = t.Containers[0]\n\t} else {\n\t\tfor _, cc := range t.Containers {\n\t\t\tif *cc.Name == service {\n\t\t\t\tc = cc\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif c == nil {\n\t\t\treturn 0, fmt.Errorf(\"ambiguous, multi-container task, one container should match service name\")\n\t\t}\n\t}\n\tif c.NetworkBindings == nil || len(c.NetworkBindings) == 0 {\n\t\t// Pending tasks don't yet have network bindings.\n\t\treturn 0, nil\n\t}\n\t// Take the first port binding.\n\treturn int(*c.NetworkBindings[0].HostPort), nil\n}", "func getPodsInfoFromTask(cluster *imec_db.DB_INFRASTRUCTURE_CLUSTER, result map[string]interface{}, appPort int, appProtocol string) []structs.DB_TASK_POD {\n\tlog.Println(pathLOG + \"COMPSs [getPodsInfoFromTask] Getting info from pods ...\")\n\n\t// items\n\titems := result[\"items\"].([]interface{})\n\tlog.Println(pathLOG + \"COMPSs [getPodsInfoFromTask] Total pods = \" + strconv.Itoa(len(items)))\n\n\t// final res\n\tvar lres []structs.DB_TASK_POD\n\n\t// iterate json (response)\n\tfor _, item := range items { // \"items\" element ==> PODS INFO\n\t\t/* DB_TASK_POD:\n\t\t{\n\t\t\tName string `json:\"name,omitempty\"`\n\t\t\tIP string `json:\"ip,omitempty\"` // IP accessed by external apps\n\t\t\tHostIP string `json:\"hostIp,omitempty\"` // node IP\n\t\t\tPodIP string `json:\"podIp,omitempty\"` // internal IP created by Kubernetes / Openshift\n\t\t\tStatus string `json:\"status,omitempty\"` // running, unknown\n\t\t\tPort int `json:\"port,omitempty\"` // port exposed in Kubernetes / Openshift\n\t\t\tTargetPort int `json:\"targetPort,omitempty\"` // application port\n\t\t}\n\t\t*/\n\t\tpodData := &structs.DB_TASK_POD{}\n\t\tpodData.IP = urls.GetHostIP(cluster) // cfg.Config.Clusters[clusterIndex].HostIP\n\t\tpodData.Port = adapt_common.NewRPort()\n\t\tpodData.TargetPort = appPort\n\t\tpodData.Protocol = appProtocol\n\n\t\t// \"metadata\" element\n\t\tfor key1, value1 := range item.(map[string]interface{}) {\n\t\t\tif key1 == \"metadata\" {\n\t\t\t\tfor key2, value2 := range value1.(map[string]interface{}) {\n\t\t\t\t\tif key2 == \"name\" {\n\t\t\t\t\t\tpodData.Name = value2.(string) // Pod name\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if key1 == \"status\" {\n\t\t\t\tfor key2, value2 := range value1.(map[string]interface{}) {\n\t\t\t\t\tif key2 == \"podIP\" {\n\t\t\t\t\t\tpodData.PodIP = value2.(string) // IP address from pod\n\t\t\t\t\t} else if key2 == \"hostIP\" {\n\t\t\t\t\t\tpodData.HostIP = urls.GetHostIP(cluster) // value2.(string) // IP address from node\n\t\t\t\t\t} else if key2 == \"phase\" {\n\t\t\t\t\t\tpodData.Status = value2.(string) // Status / Phase from pod\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] POD \" + podData.Name)\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] - PodIP: \" + podData.PodIP)\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] - HostIP: \" + podData.HostIP)\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] - Status: \" + podData.Status)\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] - Port: \" + strconv.Itoa(podData.Port))\n\t\tlog.Debug(pathLOG + \"COMPSs [getPodsInfoFromTask] - TargetPort: \" + strconv.Itoa(podData.TargetPort))\n\n\t\tlres = append(lres, *podData)\n\t}\n\n\tlog.Println(pathLOG + \"COMPSs [getPodsInfoFromTask] Total pods response = \" + strconv.Itoa(len(lres)))\n\n\treturn lres\n}", "func (d USBDriver) GrabAndSortScanData(scans uint, timeout uint) (uint, []driver.RplidarResponseMeasurementNode) {\n\tif d.verbose {\n\t\tlog.Printf(\"%s GrabAndSortScanData()\", moduleName)\n\t}\n\tvar cscans = C.uint(scans)\n\tif d.verbose {\n\t\tlog.Printf(\"%s GrabAndSortScanData(): got %d scans\\n\", moduleName, uint(cscans))\n\t}\n\n\tvar cresults *C.rplidar_scan_results_unpacked = C.ProxyDriverGrabAndSortScanData(d.driver, cscans, C.uint(timeout))\n\topResult := uint(cresults.op_result)\n\tif driver.IsFail(opResult) {\n\t\treturn opResult, nil\n\t}\n\t// success\n\treturnedScans := int(cresults.scans)\n\tif d.verbose {\n\t\tlog.Printf(\"%s GrabAndSortScanData(): got %d scans\", moduleName, returnedScans)\n\t}\n\tresults := make([]driver.RplidarResponseMeasurementNode, returnedScans)\n\tfor i := 0; i < returnedScans; i++ {\n\t\tcnode := C.ProxyDriverGetRplidarResponseMeasurementNode(d.driver, cresults, C.uint(i))\n\t\tresults[i].AngleQ6Checkbit = uint16(cnode.angle_q6_checkbit)\n\t\tresults[i].SyncQuality = uint8(cnode.sync_quality)\n\t\tresults[i].DistanceQ2 = uint16(cnode.distance_q2)\n\t\tif d.verbose {\n\t\t\ts := \"F\"\n\t\t\tif results[i].SyncBit() {\n\t\t\t\ts = \"T\"\n\t\t\t}\n\t\t\tc := \"F\"\n\t\t\tif results[i].CheckBit() {\n\t\t\t\tc = \"T\"\n\t\t\t}\n\t\t\tlog.Printf(\"%s GrabAndSortScanData(): S %s C %s Q %d A %4.1f D %6.1f\\n\",\n\t\t\t\tmoduleName, s, c, results[i].Quality(), results[i].AngleAsFloat32(), results[i].DistanceAsFloat32())\n\t\t}\n\t}\n\t// Free the space malloced by the C++ proxy\n\tC.ProxyDriverFreeRplidarScanResultsUnpacked(d.driver, cresults)\n\n\tif d.verbose {\n\t\tlog.Printf(\"%s GrabAndSortScanData(): returning %d nodes\\n\", moduleName, len(results))\n\t}\n\treturn opResult, results\n}", "func CustomSortDispatcher(a []int, maxMem int, maxCPU int, delay time.Duration) []int {\n\t// Best case\n\tif sort.IntsAreSorted(a) {\n\t\treturn a\n\t}\n\t// Realistic Case\n\tresult := make(chan []int, 1)\n\tfor len(result) != 1 {\n\t\tif currMemoryAlloc() > maxMem || currCPUUse() > maxCPU {\n\t\t\ttime.Sleep(delay)\n\t\t\truntime.GC()\n\t\t\truntime.Gosched()\n\t\t} else {\n\t\t\tgo Sort(append([]int{}, a...), result)\n\t\t}\n\t}\n\treturn <-result\n}", "func (qs SysDBQuerySet) OrderAscByPort() SysDBQuerySet {\n\treturn qs.w(qs.db.Order(\"port ASC\"))\n}", "func (router Router) getPeerSortDist(refPeer Peer) []PeerSort {\n\tvar peerList []Peer\n\tfor buckIdx, bucket := range router.tree.buckets {\n\t\t// Skip bucket 0\n\t\tif buckIdx != 0 {\n\t\t\tpeerList = append(peerList[:], bucket.entries[:]...)\n\t\t}\n\t}\n\tvar peerListSort []PeerSort\n\tfor _, peer := range peerList {\n\t\t// We don't want to return the Peer struct of the Peer\n\t\t// that is the reference.\n\t\tif peer != refPeer {\n\t\t\tpeerListSort = append(peerListSort[:],\n\t\t\t\tPeerSort{\n\t\t\t\t\tip: peer.ip,\n\t\t\t\t\tport: peer.port,\n\t\t\t\t\tid: peer.id,\n\t\t\t\t\txorMyPeer: xor(refPeer.id, peer.id),\n\t\t\t\t})\n\t\t}\n\t}\n\treturn peerListSort\n}", "func (d *portworx) GetPoolsUsedSize(n *node.Node) (map[string]string, error) {\n\tcmd := fmt.Sprintf(\"%s sv pool show -j | grep -e uuid -e '\\\"Used\\\"'\", d.getPxctlPath(*n))\n\n\tout, err := d.nodeDriver.RunCommandWithNoRetry(*n, cmd, node.ConnectionOpts{\n\t\tTimeout: 2 * time.Minute,\n\t\tTimeBeforeRetry: 10 * time.Second,\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\toutLines := strings.Split(out, \"\\n\")\n\n\tpoolsData := make(map[string]string)\n\tvar poolId string\n\tvar usedSize string\n\tfor _, l := range outLines {\n\t\tline := strings.Trim(l, \" \")\n\t\tline = strings.Trim(line, \",\")\n\t\tif strings.Contains(line, \"uuid\") {\n\t\t\tpoolId = strings.Split(line, \":\")[1]\n\t\t\tpoolId = strings.Trim(poolId, \" \")\n\t\t\tpoolId = strings.ReplaceAll(poolId, \"\\\"\", \"\")\n\t\t}\n\t\tif strings.Contains(line, \"Used\") {\n\t\t\tusedSize = strings.Split(line, \":\")[1]\n\t\t\tusedSize = strings.Trim(usedSize, \" \")\n\t\t\tusedSize = strings.ReplaceAll(usedSize, \"\\\"\", \"\")\n\t\t}\n\t\tif poolId != \"\" && usedSize != \"\" {\n\t\t\tpoolsData[poolId] = usedSize\n\t\t\tpoolId = \"\"\n\t\t\tusedSize = \"\"\n\t\t}\n\t}\n\treturn poolsData, nil\n}", "func test_case_2() {\n\tvar pfs []rdma_hardware_info.PF = make([]rdma_hardware_info.PF, 2)\n\tpfs[0].UsedTxRate = 0\n\tpfs[0].CapacityTxRate = 9\n\tpfs[0].UsedVFs = 1\n\tpfs[0].CapacityVFs = 120\n\tpfs[1].UsedTxRate = 0\n\tpfs[1].CapacityTxRate = 6\n\tpfs[1].UsedVFs = 119\n\tpfs[1].CapacityVFs = 120\n\n\tvar req []knapsack_pod_placement.RdmaInterfaceRequest = make([]knapsack_pod_placement.RdmaInterfaceRequest, 3)\n\treq[0].MinTxRate = 3\n\treq[1].MinTxRate = 3\n\treq[2].MinTxRate = 8\n\n\tallocation, possible := knapsack_pod_placement.PlacePod(req, pfs, true)\n\n\tlog.Println(\"Possible: \", possible)\n\tlog.Println(\"Allocation: \", allocation)\n}", "func getIPRangesForPort(isAllow bool, sg secGroup, myIP, sshUser string, port int64) (ipr []*ec2.IpRange) {\n\tif isAllow {\n\t\tif !strings.Contains(myIP, \"/\") {\n\t\t\tmyIP += \"/32\"\n\t\t}\n\t\tfor _, cidr := range sg.portToMyIPs[port] {\n\t\t\tif cidr == myIP {\n\t\t\t\tout.Highlight(out.WARN, \"skipping existing access for %s - IP %s to port %s in SG %s (%s)\", sshUser, cidr, strconv.Itoa(int(port)), sg.name, sg.id)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tipr = append(ipr, &ec2.IpRange{\n\t\t\tCidrIp: aws.String(myIP),\n\t\t\tDescription: aws.String(sshUser),\n\t\t})\n\t} else {\n\t\tfor _, cidr := range sg.portToMyIPs[port] {\n\t\t\tipr = append(ipr, &ec2.IpRange{\n\t\t\t\tCidrIp: aws.String(cidr),\n\t\t\t\tDescription: aws.String(sshUser),\n\t\t\t})\n\t\t}\n\t}\n\treturn\n}", "func getCostEstimationLogs(ctx context.Context, client *tfe.Client, r *tfe.Run) error {\n\tif r.CostEstimate == nil {\n\t\treturn nil\n\t}\n\tmsgPrefix := \"Cost estimation\"\n\tstarted := time.Now()\n\tupdated := started\n\tfor i := 0; ; i++ {\n\t\t// select {\n\t\t// case <-stopCtx.Done():\n\t\t// \treturn stopCtx.Err()\n\t\t// case <-cancelCtx.Done():\n\t\t// \treturn cancelCtx.Err()\n\t\t// case <-time.After(backoff(backoffMin, backoffMax, i)):\n\t\t// }\n\n\t\t// Retrieve the cost estimate to get its current status.\n\t\tce, err := client.CostEstimates.Read(ctx, r.CostEstimate.ID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// If the run is canceled or errored, but the cost-estimate still has\n\t\t// no result, there is nothing further to render.\n\t\tif ce.Status != tfe.CostEstimateFinished {\n\t\t\tif r.Status == tfe.RunCanceled || r.Status == tfe.RunErrored {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\n\t\t// checking if i == 0 so as to avoid printing this starting horizontal-rule\n\t\t// every retry, and that it only prints it on the first (i=0) attempt.\n\t\tif i == 0 {\n\t\t\tfmt.Println(\"------------------------------------------------------------------------\")\n\t\t}\n\n\t\tswitch ce.Status {\n\t\tcase tfe.CostEstimateFinished:\n\t\t\tdelta, err := strconv.ParseFloat(ce.DeltaMonthlyCost, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tsign := \"+\"\n\t\t\tif delta < 0 {\n\t\t\t\tsign = \"-\"\n\t\t\t}\n\n\t\t\tdeltaRepr := strings.Replace(ce.DeltaMonthlyCost, \"-\", \"\", 1)\n\n\t\t\tfmt.Println(msgPrefix + \":\")\n\t\t\tfmt.Printf(\"Resources: %d of %d estimated\", ce.MatchedResourcesCount, ce.ResourcesCount)\n\t\t\tfmt.Printf(\" $%s/mo %s$%s\", ce.ProposedMonthlyCost, sign, deltaRepr)\n\n\t\t\tif len(r.PolicyChecks) == 0 && r.HasChanges {\n\t\t\t\tfmt.Println(\"------------------------------------------------------------------------\")\n\t\t\t}\n\n\t\t\t// if b.CLI != nil {\n\t\t\t// \tb.CLI.Output(b.Colorize().Color(msgPrefix + \":\"))\n\t\t\t// \tb.CLI.Output(b.Colorize().Color(fmt.Sprintf(\"Resources: %d of %d estimated\", ce.MatchedResourcesCount, ce.ResourcesCount)))\n\t\t\t// \tb.CLI.Output(b.Colorize().Color(fmt.Sprintf(\" $%s/mo %s$%s\", ce.ProposedMonthlyCost, sign, deltaRepr)))\n\n\t\t\t// \tif len(r.PolicyChecks) == 0 && r.HasChanges && op.Type == backend.OperationTypeApply {\n\t\t\t// \t\tb.CLI.Output(\"------------------------------------------------------------------------\")\n\t\t\t// \t}\n\t\t\t// }\n\n\t\t\treturn nil\n\t\tcase tfe.CostEstimatePending, tfe.CostEstimateQueued:\n\t\t\t// Check if 30 seconds have passed since the last update.\n\t\t\tcurrent := time.Now()\n\t\t\tif i == 0 || current.Sub(updated).Seconds() > 30 {\n\t\t\t\tupdated = current\n\t\t\t\telapsed := \"\"\n\n\t\t\t\t// Calculate and set the elapsed time.\n\t\t\t\tif i > 0 {\n\t\t\t\t\telapsed = fmt.Sprintf(\n\t\t\t\t\t\t\" (%s elapsed)\", current.Sub(started).Truncate(30*time.Second))\n\t\t\t\t}\n\t\t\t\tfmt.Println(msgPrefix + \":\")\n\t\t\t\tfmt.Println(\"Waiting for cost estimate to complete...\" + elapsed)\n\t\t\t}\n\t\t\tcontinue\n\t\tcase tfe.CostEstimateSkippedDueToTargeting:\n\t\t\tfmt.Println(msgPrefix + \":\")\n\t\t\tfmt.Println(\"Not available for this plan, because it was created with the -target option.\")\n\t\t\tfmt.Println(\"------------------------------------------------------------------------\")\n\t\t\treturn nil\n\t\tcase tfe.CostEstimateErrored:\n\t\t\tfmt.Println(msgPrefix + \" errored.\")\n\t\t\tfmt.Println(\"------------------------------------------------------------------------\")\n\t\t\treturn nil\n\t\tcase tfe.CostEstimateCanceled:\n\t\t\treturn errors.New(msgPrefix + \" canceled.\")\n\t\tdefault:\n\t\t\treturn errors.New(\"Unknown or unexpected cost estimate state: \" + string(ce.Status))\n\t\t}\n\t}\n}", "func GetCost(client elevator.LocalClient, btn elevator.Button) int {\n\tcost := 0\n\t// Because of bug in elevator cant take order in own floor\n\tif client.Floor == btn.Floor {\n\t\tcost += 10\n\t\treturn cost\n\t}\n\t\n\tif client.CurrentDir == elevator.NONE{\n\t\tcost = client.Floor-btn.Floor\n\t\tif cost < 0 {\n\t\t\tcost = cost * -1\n\t\t}\t\n\t\tcost += 1\n\t\treturn cost\n\t}\n\t// If elevator is on its way to ordered floor\n\tif client.CurrentDir == elevator.UP && btn.Dir == elevator.UP && btn.Floor >= client.Floor {\n\t\tcost = btn.Floor - client.Floor\n\t\treturn cost\n\t}\n\tif client.CurrentDir == elevator.DOWN && btn.Dir == elevator.DOWN && btn.Floor <= client.Floor {\n\t\tcost = client.Floor - btn.Floor\n\t\treturn cost\n\t}\n\t// If elevator is driving in oposite direction\n\tif client.CurrentDir != btn.Dir {\n\t\tcost = client.Floor-btn.Floor\n\t\tif cost < 0 {\n\t\t\tcost = cost * -1\n\t\t}\t\n\t\tcost += 3\n\t\treturn cost\n\t}else{\n\t\tcost = 2\n\t\treturn cost\n\t}\n\t\n}", "func ProcTCP(c *gin.Context) {\n\tres := CmdExec(\"cat /proc/net/tcp | wc -l\")\n\ttcpV4Links, _ := strconv.Atoi(res[0])\n\tres = CmdExec(\"cat /proc/net/tcp6 | wc -l\")\n\ttcpV6Links, _ := strconv.Atoi(res[0])\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"tcpV4Links\": NonNegative(tcpV4Links - 2),\n\t\t\"tcpV6Links\": NonNegative(tcpV6Links - 2),\n\t})\n}", "func TestStatsConnTopoGet(t *testing.T) {\n\tconn := &fakeConn{}\n\tstatsConn := NewStatsConn(\"global\", conn)\n\tctx := context.Background()\n\n\tstatsConn.Get(ctx, \"\")\n\ttimingCounts := topoStatsConnTimings.Counts()[\"Get.global\"]\n\tif got, want := timingCounts, int64(1); got != want {\n\t\tt.Errorf(\"stats were not properly recorded: got = %d, want = %d\", got, want)\n\t}\n\n\t// error is zero before getting an error\n\terrorCount := topoStatsConnErrors.Counts()[\"Get.global\"]\n\tif got, want := errorCount, int64(0); got != want {\n\t\tt.Errorf(\"stats were not properly recorded: got = %d, want = %d\", got, want)\n\t}\n\n\tstatsConn.Get(ctx, \"error\")\n\n\t// error stats gets emitted\n\terrorCount = topoStatsConnErrors.Counts()[\"Get.global\"]\n\tif got, want := errorCount, int64(1); got != want {\n\t\tt.Errorf(\"stats were not properly recorded: got = %d, want = %d\", got, want)\n\t}\n}", "func (a *BitlinksApiService) GetSortedBitlinksExecute(r ApiGetSortedBitlinksRequest) (SortedLinks, *_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 SortedLinks\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"BitlinksApiService.GetSortedBitlinks\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/groups/{group_guid}/bitlinks/{sort}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"group_guid\"+\"}\", _neturl.PathEscape(parameterToString(r.groupGuid, \"\")), -1)\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"sort\"+\"}\", _neturl.PathEscape(parameterToString(r.sort, \"\")), -1)\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\tif r.unit != nil {\n\t\tlocalVarQueryParams.Add(\"unit\", parameterToString(*r.unit, \"\"))\n\t}\n\tif r.units != nil {\n\t\tlocalVarQueryParams.Add(\"units\", parameterToString(*r.units, \"\"))\n\t}\n\tif r.unitReference != nil {\n\t\tlocalVarQueryParams.Add(\"unit_reference\", parameterToString(*r.unitReference, \"\"))\n\t}\n\tif r.size != nil {\n\t\tlocalVarQueryParams.Add(\"size\", parameterToString(*r.size, \"\"))\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\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\tif localVarHTTPResponse.StatusCode == 404 {\n\t\t\tvar v NotFound\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 Forbidden\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 == 500 {\n\t\t\tvar v InternalError\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 == 503 {\n\t\t\tvar v TemporarilyUnavailable\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 exposedPorts(node *parser.Node) [][]string {\n\tvar allPorts [][]string\n\tvar ports []string\n\tfroms := FindAll(node, command.From)\n\texposes := FindAll(node, command.Expose)\n\tfor i, j := len(froms)-1, len(exposes)-1; i >= 0; i-- {\n\t\tfor ; j >= 0 && exposes[j] > froms[i]; j-- {\n\t\t\tports = append(nextValues(node.Children[exposes[j]]), ports...)\n\t\t}\n\t\tallPorts = append([][]string{ports}, allPorts...)\n\t\tports = nil\n\t}\n\treturn allPorts\n}", "func handleGetNetTotals(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {\n\ttotalBytesRecv, totalBytesSent := s.cfg.ConnMgr.NetTotals()\n\treply := &rpcmodel.GetNetTotalsResult{\n\t\tTotalBytesRecv: totalBytesRecv,\n\t\tTotalBytesSent: totalBytesSent,\n\t\tTimeMillis: time.Now().UTC().UnixNano() / int64(time.Millisecond),\n\t}\n\treturn reply, nil\n}", "func (suite *ServiceTestSuite) TestHostsService_AcquireHosts() {\n\tdefer suite.mockCtrl.Finish()\n\n\tctx := context.Background()\n\tfilter := &hostsvc.HostFilter{}\n\thosts := &hostsvc.GetHostsResponse{\n\t\tHosts: []*hostsvc.HostInfo{\n\t\t\t{\n\t\t\t\tHostname: _hostname,\n\t\t\t},\n\t\t},\n\t}\n\ttask := createResMgrTask()\n\n\tgomock.InOrder(\n\t\tsuite.hostMgrClient.EXPECT().\n\t\t\tGetHosts(\n\t\t\t\tgomock.Any(),\n\t\t\t\tgetHostRequest(filter),\n\t\t\t).Return(hosts, nil),\n\t\tsuite.resmgrClient.EXPECT().\n\t\t\tGetTasksByHosts(gomock.Any(),\n\t\t\t\t&resmgrsvc.GetTasksByHostsRequest{\n\t\t\t\t\tType: resmgr.TaskType_UNKNOWN,\n\t\t\t\t\tHostnames: []string{_hostname},\n\t\t\t\t},\n\t\t\t).Return(\n\t\t\t&resmgrsvc.GetTasksByHostsResponse{\n\t\t\t\tHostTasksMap: map[string]*resmgrsvc.TaskList{\n\t\t\t\t\t_hostname: {\n\t\t\t\t\t\tTasks: []*resmgr.Task{\n\t\t\t\t\t\t\ttask,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tError: nil,\n\t\t\t}, nil),\n\t)\n\n\thostsRet, err := suite.hostService.GetHosts(ctx, task, filter)\n\t//validating the same out which we are passing in the mock calls\n\tsuite.NoError(err)\n\tsuite.Equal(1, len(hostsRet))\n\tsuite.Equal(_hostname, hostsRet[0].GetHost().Hostname)\n\tsuite.Equal(1, len(hostsRet[0].Tasks))\n}", "func (_Mcapscontroller *McapscontrollerCaller) GetInitialTokensAndBalances(opts *bind.CallOpts, categoryID *big.Int, indexSize *big.Int, wethValue *big.Int) (struct {\n\tTokens []common.Address\n\tBalances []*big.Int\n}, error) {\n\tvar out []interface{}\n\terr := _Mcapscontroller.contract.Call(opts, &out, \"getInitialTokensAndBalances\", categoryID, indexSize, wethValue)\n\n\toutstruct := new(struct {\n\t\tTokens []common.Address\n\t\tBalances []*big.Int\n\t})\n\tif err != nil {\n\t\treturn *outstruct, err\n\t}\n\n\toutstruct.Tokens = out[0].([]common.Address)\n\toutstruct.Balances = out[1].([]*big.Int)\n\n\treturn *outstruct, err\n\n}", "func (r *RemoteList) unlockedSort(preferredRanges []*net.IPNet) {\n\tn := len(r.addrs)\n\tif n < 2 {\n\t\treturn\n\t}\n\n\tlessFunc := func(i, j int) bool {\n\t\ta := r.addrs[i]\n\t\tb := r.addrs[j]\n\t\t// Preferred addresses first\n\n\t\taPref := isPreferred(a.IP, preferredRanges)\n\t\tbPref := isPreferred(b.IP, preferredRanges)\n\t\tswitch {\n\t\tcase aPref && !bPref:\n\t\t\t// If i is preferred and j is not, i is less than j\n\t\t\treturn true\n\n\t\tcase !aPref && bPref:\n\t\t\t// If j is preferred then i is not due to the else, i is not less than j\n\t\t\treturn false\n\n\t\tdefault:\n\t\t\t// Both i an j are either preferred or not, sort within that\n\t\t}\n\n\t\t// ipv6 addresses 2nd\n\t\ta4 := a.IP.To4()\n\t\tb4 := b.IP.To4()\n\t\tswitch {\n\t\tcase a4 == nil && b4 != nil:\n\t\t\t// If i is v6 and j is v4, i is less than j\n\t\t\treturn true\n\n\t\tcase a4 != nil && b4 == nil:\n\t\t\t// If j is v6 and i is v4, i is not less than j\n\t\t\treturn false\n\n\t\tcase a4 != nil && b4 != nil:\n\t\t\t// Special case for ipv4, a4 and b4 are not nil\n\t\t\taPrivate := isPrivateIP(a4)\n\t\t\tbPrivate := isPrivateIP(b4)\n\t\t\tswitch {\n\t\t\tcase !aPrivate && bPrivate:\n\t\t\t\t// If i is a public ip (not private) and j is a private ip, i is less then j\n\t\t\t\treturn true\n\n\t\t\tcase aPrivate && !bPrivate:\n\t\t\t\t// If j is public (not private) then i is private due to the else, i is not less than j\n\t\t\t\treturn false\n\n\t\t\tdefault:\n\t\t\t\t// Both i an j are either public or private, sort within that\n\t\t\t}\n\n\t\tdefault:\n\t\t\t// Both i an j are either ipv4 or ipv6, sort within that\n\t\t}\n\n\t\t// lexical order of ips 3rd\n\t\tc := bytes.Compare(a.IP, b.IP)\n\t\tif c == 0 {\n\t\t\t// Ips are the same, Lexical order of ports 4th\n\t\t\treturn a.Port < b.Port\n\t\t}\n\n\t\t// Ip wasn't the same\n\t\treturn c < 0\n\t}\n\n\t// Sort it\n\tsort.Slice(r.addrs, lessFunc)\n\n\t// Deduplicate\n\ta, b := 0, 1\n\tfor b < n {\n\t\tif !r.addrs[a].Equals(r.addrs[b]) {\n\t\t\ta++\n\t\t\tif a != b {\n\t\t\t\tr.addrs[a], r.addrs[b] = r.addrs[b], r.addrs[a]\n\t\t\t}\n\t\t}\n\t\tb++\n\t}\n\n\tr.addrs = r.addrs[:a+1]\n\treturn\n}", "func addKbps(dsStats Stats, lastKbpsStats StatsLastKbps, dsStatsTime time.Time, cacheOutbytes map[enum.CacheName]int64) (Stats, StatsLastKbps, error) {\n\tfor dsName, iStat := range dsStats.DeliveryService {\n\t\tif _, ok := iStat.(*StatDNS); ok {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := iStat.(*StatHTTP); !ok {\n\t\t\tfmt.Printf(\"WARNING: addKbps got unknown stat type %T\\n\", iStat)\n\t\t\tcontinue\n\t\t}\n\t\tstat := iStat.(*StatHTTP)\n\n\t\tlastKbpsStat, lastKbpsStatExists := lastKbpsStats.DeliveryServices[dsName]\n\t\tif !lastKbpsStatExists {\n\t\t\tlastKbpsStat = newStatLastKbps()\n\t\t}\n\n\t\tfor cgName, cacheStats := range stat.CacheGroups {\n\t\t\tlastKbpsData, _ := lastKbpsStat.CacheGroups[cgName]\n\n\t\t\tif cacheStats.OutBytes.Value == lastKbpsData.Bytes {\n\t\t\t\tcacheStats.Kbps.Value = lastKbpsData.Kbps\n\t\t\t\tstat.CacheGroups[cgName] = cacheStats\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif lastKbpsStatExists {\n\t\t\t\tcacheStats.Kbps.Value = float64(cacheStats.OutBytes.Value-lastKbpsData.Bytes) / dsStatsTime.Sub(lastKbpsData.Time).Seconds()\n\t\t\t}\n\n\t\t\tlastKbpsStat.CacheGroups[cgName] = LastKbpsData{Time: dsStatsTime, Bytes: cacheStats.OutBytes.Value, Kbps: cacheStats.Kbps.Value}\n\t\t\tstat.CacheGroups[cgName] = cacheStats\n\t\t}\n\n\t\tfor cacheType, cacheStats := range stat.Type {\n\t\t\tlastKbpsData, _ := lastKbpsStat.Type[cacheType]\n\t\t\tif cacheStats.OutBytes.Value == lastKbpsData.Bytes {\n\t\t\t\tif cacheStats.OutBytes.Value == lastKbpsData.Bytes {\n\t\t\t\t\tcacheStats.Kbps.Value = lastKbpsData.Kbps\n\t\t\t\t\tstat.Type[cacheType] = cacheStats\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif lastKbpsStatExists {\n\t\t\t\t\tcacheStats.Kbps.Value = float64(cacheStats.OutBytes.Value-lastKbpsData.Bytes) / dsStatsTime.Sub(lastKbpsData.Time).Seconds()\n\t\t\t\t}\n\t\t\t\tlastKbpsStat.Type[cacheType] = LastKbpsData{Time: dsStatsTime, Bytes: cacheStats.OutBytes.Value, Kbps: cacheStats.Kbps.Value}\n\t\t\t\tstat.Type[cacheType] = cacheStats\n\t\t\t}\n\t\t}\n\t\tif lastKbpsStatExists {\n\t\t\tstat.Total.Kbps.Value = float64(stat.Total.OutBytes.Value-lastKbpsStat.Total.Bytes) / dsStatsTime.Sub(lastKbpsStat.Total.Time).Seconds()\n\t\t} else {\n\t\t\tstat.Total.Kbps.Value = lastKbpsStat.Total.Kbps\n\t\t}\n\t\tlastKbpsStat.Total = LastKbpsData{Time: dsStatsTime, Bytes: stat.Total.OutBytes.Value, Kbps: stat.Total.Kbps.Value}\n\n\t\tlastKbpsStats.DeliveryServices[dsName] = lastKbpsStat\n\t}\n\n\tfor cacheName, outBytes := range cacheOutbytes { // map[enum.CacheName]int64\n\t\tlastCacheKbpsData, ok := lastKbpsStats.Caches[cacheName]\n\t\tif !ok {\n\t\t\tlastKbpsStats.Caches[cacheName] = LastKbpsData{Time: dsStatsTime, Bytes: outBytes, Kbps: 0}\n\t\t\tcontinue\n\t\t}\n\n\t\tif lastCacheKbpsData.Bytes == outBytes {\n\t\t\tcontinue // don't try to kbps, and importantly don't change the time of the last change, if Traffic Server hasn't updated\n\t\t}\n\n\t\tkbps := float64(outBytes-lastCacheKbpsData.Bytes) / dsStatsTime.Sub(lastCacheKbpsData.Time).Seconds()\n\t\tlastKbpsStats.Caches[cacheName] = LastKbpsData{Time: dsStatsTime, Bytes: outBytes, Kbps: kbps}\n\t}\n\n\treturn dsStats, lastKbpsStats, nil\n}", "func (solver *MapSolver)GetCost(cost int, newFlow []int) int{\n\tsum := 0\n\tfor i, _ := range newFlow{\n\t\tsum += cost*newFlow[i]\n\t}\n\treturn sum\n}", "func AllocateIpPortRangeforservice(c client.Client, portInuse map[string][]aciv1.NodePortRange,\n\tpodList *corev1.PodList, snatPolicy *aciv1.SnatPolicy, snatip string) bool {\n\tupdated := false\n\tvisited := make(map[string]bool)\n\tfor _, pod := range podList.Items {\n\t\tif visited[pod.Spec.NodeName] {\n\t\t\tcontinue\n\t\t}\n\t\tportrange, exists := GetPortRangeForServiceIP(c, pod.Spec.NodeName, snatPolicy, snatip)\n\t\tif reflect.DeepEqual(portrange, aciv1.PortRange{}) {\n\t\t\treturn updated\n\t\t}\n\t\tif exists == false && pod.GetObjectMeta().GetDeletionTimestamp() == nil {\n\t\t\tvar nodePortRnage aciv1.NodePortRange\n\t\t\tnodePortRnage.NodeName = pod.Spec.NodeName\n\t\t\tnodePortRnage.PortRange = portrange\n\t\t\tportInuse[snatip] = append(portInuse[snatip], nodePortRnage)\n\t\t\tupdated = true\n\t\t\tvisited[pod.Spec.NodeName] = true\n\t\t}\n\t}\n\treturn updated\n}", "func GetPorts(lookupPids bool) map[string]GOnetstat.Process {\n\tports := make(map[string]GOnetstat.Process)\n\tnetstat, _ := GOnetstat.Tcp(lookupPids)\n\tvar net string\n\t//netPorts := make(map[string]GOnetstat.Process)\n\t//ports[\"tcp\"] = netPorts\n\tnet = \"tcp\"\n\tfor _, entry := range netstat {\n\t\tif entry.State == \"LISTEN\" {\n\t\t\tport := strconv.FormatInt(entry.Port, 10)\n\t\t\tports[net+\":\"+port] = entry\n\t\t}\n\t}\n\tnetstat, _ = GOnetstat.Tcp6(lookupPids)\n\t//netPorts = make(map[string]GOnetstat.Process)\n\t//ports[\"tcp6\"] = netPorts\n\tnet = \"tcp6\"\n\tfor _, entry := range netstat {\n\t\tif entry.State == \"LISTEN\" {\n\t\t\tport := strconv.FormatInt(entry.Port, 10)\n\t\t\tports[net+\":\"+port] = entry\n\t\t}\n\t}\n\tnetstat, _ = GOnetstat.Udp(lookupPids)\n\t//netPorts = make(map[string]GOnetstat.Process)\n\t//ports[\"udp\"] = netPorts\n\tnet = \"udp\"\n\tfor _, entry := range netstat {\n\t\tport := strconv.FormatInt(entry.Port, 10)\n\t\tports[net+\":\"+port] = entry\n\t}\n\tnetstat, _ = GOnetstat.Udp6(lookupPids)\n\t//netPorts = make(map[string]GOnetstat.Process)\n\t//ports[\"udp6\"] = netPorts\n\tnet = \"udp6\"\n\tfor _, entry := range netstat {\n\t\tport := strconv.FormatInt(entry.Port, 10)\n\t\tports[net+\":\"+port] = entry\n\t}\n\treturn ports\n}", "func (m *MockHTTPRuleDao) GetHTTPRuleByServiceIDAndContainerPort(serviceID string, containerPort int) ([]*model.HTTPRule, error) {\n\tret := m.ctrl.Call(m, \"GetHTTPRuleByServiceIDAndContainerPort\", serviceID, containerPort)\n\tret0, _ := ret[0].([]*model.HTTPRule)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func explainQueryCost(transaction *model.DbTransaction, withAnalyze bool, query string, args ...interface{}) (int64, error) {\r\n\tvar planStr string\r\n\texplainTpl := \"EXPLAIN (FORMAT JSON) %s\"\r\n\tif withAnalyze {\r\n\t\texplainTpl = \"EXPLAIN ANALYZE (FORMAT JSON) %s\"\r\n\t}\r\n\terr := model.GetDB(transaction).Raw(fmt.Sprintf(explainTpl, query), args...).Row().Scan(&planStr)\r\n\tswitch {\r\n\tcase err == sql.ErrNoRows:\r\n\t\tlog.WithFields(log.Fields{\"type\": consts.DBError, \"error\": err, \"query\": query}).Error(\"no rows while explaining query\")\r\n\t\treturn 0, errors.New(\"No rows\")\r\n\tcase err != nil:\r\n\t\tlog.WithFields(log.Fields{\"type\": consts.DBError, \"error\": err, \"query\": query}).Error(\"error explaining query\")\r\n\t\treturn 0, err\r\n\t}\r\n\tvar queryPlan []map[string]interface{}\r\n\tdec := json.NewDecoder(strings.NewReader(planStr))\r\n\tdec.UseNumber()\r\n\tif err := dec.Decode(&queryPlan); err != nil {\r\n\t\tlog.WithFields(log.Fields{\"type\": consts.JSONUnmarshallError, \"error\": err}).Error(\"decoding query plan from JSON\")\r\n\t\treturn 0, err\r\n\t}\r\n\tif len(queryPlan) == 0 {\r\n\t\tlog.Error(\"Query plan is empty\")\r\n\t\treturn 0, errors.New(\"Query plan is empty\")\r\n\t}\r\n\tfirstNode := queryPlan[0]\r\n\tvar plan interface{}\r\n\tvar ok bool\r\n\tif plan, ok = firstNode[\"Plan\"]; !ok {\r\n\t\tlog.Error(\"No Plan key in result\")\r\n\t\treturn 0, errors.New(\"No Plan key in result\")\r\n\t}\r\n\r\n\tplanMap, ok := plan.(map[string]interface{})\r\n\tif !ok {\r\n\t\tlog.Error(\"Plan is not map[string]interface{}\")\r\n\t\treturn 0, errors.New(\"Plan is not map[string]interface{}\")\r\n\t}\r\n\r\n\ttotalCost, ok := planMap[\"Total Cost\"]\r\n\tif !ok {\r\n\t\treturn 0, errors.New(\"PlanMap has no TotalCost\")\r\n\t}\r\n\r\n\t}", "func TestPlan(t *testing.T) {\n\tt.Parallel()\n\n\tctx := context.Background()\n\n\tg := testGateway.Plan()\n\tplans, err := g.All(ctx)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif len(plans) == 0 {\n\t\tt.Fatal(plans)\n\t}\n\n\tvar plan *Plan\n\tfor _, p := range plans {\n\t\tif p.Id == \"test_plan\" {\n\t\t\tplan = p\n\t\t\tbreak\n\t\t}\n\t}\n\n\tt.Log(plan)\n\n\tif plan == nil {\n\t\tt.Fatal(\"plan not found\")\n\t}\n\tif x := plan.Id; x != \"test_plan\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.MerchantId; x == \"\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.BillingFrequency; x == nil || *x != 1 {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.CurrencyISOCode; x != \"USD\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.Description; x != \"test_plan_desc\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.Name; x != \"test_plan_name\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.NumberOfBillingCycles; x == nil || *x != 2 {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.Price; x.Cmp(NewDecimal(1000, 2)) != 0 {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.TrialDuration; x == nil || *x != 14 {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.TrialDurationUnit; x != \"day\" {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.TrialPeriod; !x {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.CreatedAt; x == nil {\n\t\tt.Fatal(x)\n\t}\n\tif x := plan.UpdatedAt; x == nil {\n\t\tt.Fatal(x)\n\t}\n\n\t// Add Ons\n\tif len(plan.AddOns.AddOns) == 0 {\n\t\tt.Fatal(plan.AddOns)\n\t}\n\taddOn := plan.AddOns.AddOns[0]\n\tt.Log(addOn)\n\tif addOn.Id != \"test_add_on\" {\n\t\tt.Fatalf(\"expected Id to be %s, was %s\", \"test_add_on\", addOn.Id)\n\t} else if addOn.Amount.Cmp(NewDecimal(1000, 2)) != 0 {\n\t\tt.Fatalf(\"expected Amount to be %s, was %s\", NewDecimal(1000, 2), addOn.Amount)\n\t} else if addOn.Kind != ModificationKindAddOn {\n\t\tt.Fatalf(\"expected Kind to be %s, was %s\", ModificationKindAddOn, addOn.Kind)\n\t} else if addOn.Name != \"test_add_on_name\" {\n\t\tt.Fatalf(\"expected Name to be %s, was %s\", \"test_add_on_name\", addOn.Name)\n\t} else if addOn.NeverExpires != true {\n\t\tt.Fatalf(\"expected NeverExpires to be %v, was %v\", true, addOn.NeverExpires)\n\t} else if addOn.Description != \"A test add-on\" {\n\t\tt.Fatalf(\"expected Description to be %s, was %s\", \"A test add-on\", addOn.Description)\n\t} else if addOn.NumberOfBillingCycles != 0 {\n\t\tt.Fatalf(\"expected NumberOfBillingCycles to be %d, was %d\", 0, addOn.NumberOfBillingCycles)\n\t}\n\n\t// Discounts\n\tif len(plan.Discounts.Discounts) == 0 {\n\t\tt.Fatal(plan.Discounts)\n\t}\n\tdiscount := plan.Discounts.Discounts[0]\n\tt.Log(discount)\n\tif discount.Id != \"test_discount\" {\n\t\tt.Fatalf(\"expected Id to be %s, was %s\", \"test_discount\", discount.Id)\n\t} else if discount.Amount.Cmp(NewDecimal(1000, 2)) != 0 {\n\t\tt.Fatalf(\"expected Amount to be %s, was %s\", NewDecimal(1000, 2), discount.Amount)\n\t} else if discount.Kind != ModificationKindDiscount {\n\t\tt.Fatalf(\"expected Kind to be %s, was %s\", ModificationKindDiscount, discount.Kind)\n\t} else if discount.Name != \"test_discount_name\" {\n\t\tt.Fatalf(\"expected Name to be %s, was %s\", \"test_discount_name\", discount.Name)\n\t} else if discount.NeverExpires != true {\n\t\tt.Fatalf(\"expected NeverExpires to be %v, was %v\", true, discount.NeverExpires)\n\t} else if discount.Description != \"A test discount\" {\n\t\tt.Fatalf(\"expected Description to be %s, was %s\", \"A test discount\", discount.Description)\n\t} else if discount.NumberOfBillingCycles != 0 {\n\t\tt.Fatalf(\"expected NumberOfBillingCycles to be %d, was %d\", 0, discount.NumberOfBillingCycles)\n\t}\n\n\t// Find\n\tplan2, err := g.Find(ctx, \"test_plan_2\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif plan2.Id != \"test_plan_2\" {\n\t\tt.Fatal(plan2)\n\t}\n\tif len(plan2.AddOns.AddOns) != 0 {\n\t\tt.Fatal(plan2.AddOns)\n\t}\n\tif len(plan2.Discounts.Discounts) != 0 {\n\t\tt.Fatal(plan2.Discounts)\n\t}\n}", "func GetPortRangeForServiceIP(c client.Client, NodeName string,\n\tsnatpolicy *aciv1.SnatPolicy, snatIp string) (aciv1.PortRange, bool) {\n\tsnatPortsAllocated := snatpolicy.Status.SnatPortsAllocated\n\tportRange, portsPerNode := getPortRangeFromConfigMap(c)\n\tvar currPortRange []aciv1.PortRange\n\tcurrPortRange = append(currPortRange, portRange)\n\texpandedsnatports := ExpandPortRanges(currPortRange, portsPerNode)\n\tif _, ok := snatPortsAllocated[snatIp]; ok {\n\t\tnodePortRange := snatPortsAllocated[snatIp]\n\t\tif len(nodePortRange) == 0 {\n\t\t\treturn expandedsnatports[0], false\n\t\t}\n\t\tfor _, val := range nodePortRange {\n\t\t\tif val.NodeName == NodeName {\n\t\t\t\tlog.V(1).Info(\"Snat port range exists for\", \"Service ip: \", \"NodeName: \", snatIp, NodeName)\n\t\t\t\treturn val.PortRange, true\n\t\t\t}\n\t\t}\n\t\tm := map[int]int{}\n\t\tfor _, Val1 := range snatPortsAllocated[snatIp] {\n\n\t\t\tm[Val1.PortRange.Start] = Val1.PortRange.End\n\t\t}\n\t\tfor i, Val2 := range expandedsnatports {\n\t\t\tif _, ok := m[Val2.Start]; !ok {\n\t\t\t\tlog.V(1).Info(\"Created new snat port range for\", \"Service ip: \", \"New nodename: \", snatIp, NodeName)\n\t\t\t\treturn expandedsnatports[i], false\n\t\t\t}\n\t\t}\n\t\treturn aciv1.PortRange{}, false\n\t}\n\treturn expandedsnatports[0], false\n}", "func TestQosCpuBT_Manage(t *testing.T) {\n\tif !cgroup.CPUOfflineSupported() {\n\t\tt.Skipf(\"cpu qos bt test skipped for not supported\")\n\t}\n\ttotal, err := getTotalCpus()\n\tif err != nil {\n\t\tt.Skipf(\"cpu qos bt test skipped for get total cpus err: %v\", err)\n\t}\n\n\t// recover origin value\n\tprocOffline := \"/proc/offline/\"\n\tvar originValues = make(map[string]string)\n\tcpus, err := ioutil.ReadDir(procOffline)\n\tif err != nil {\n\t\tt.Skipf(\"read offline path(%s) failed: %v\", procOffline, err)\n\t}\n\tfor _, f := range cpus {\n\t\tp := path.Join(procOffline, f.Name())\n\t\tvalue, err := ioutil.ReadFile(p)\n\t\tif err != nil {\n\t\t\tt.Skipf(\"read offline file(%s) err: %v\", p, err)\n\t\t\treturn\n\t\t}\n\t\toriginValues[p] = string(value)\n\t}\n\tdefer func() {\n\t\tfor p, v := range originValues {\n\t\t\tioutil.WriteFile(p, []byte(v), 0664)\n\t\t}\n\t}()\n\n\tminCpuBtPercent = 50\n\ttestCases := []cpuBtTestData{\n\t\t{\n\t\t\tdescribe: \"normal test\",\n\t\t\tcpuStatic: false,\n\t\t\tcpusetRecovered: true,\n\t\t\tlimitCores: total,\n\t\t\texpectPercent: \"100\",\n\t\t},\n\t\t{\n\t\t\tdescribe: \"min limit test\",\n\t\t\tcpuStatic: false,\n\t\t\tcpusetRecovered: true,\n\t\t\tlimitCores: 1,\n\t\t\texpectPercent: fmt.Sprintf(\"%d\", minCpuBtPercent),\n\t\t},\n\t\t{\n\t\t\tdescribe: \"static test\",\n\t\t\tcpuStatic: true,\n\t\t\tcpusetRecovered: true,\n\t\t\tlimitCores: total,\n\t\t\texpectPercent: \"100\",\n\t\t},\n\t\t{\n\t\t\tdescribe: \"cpuset recovered\",\n\t\t\tcpuStatic: false,\n\t\t\tcpusetRecovered: false,\n\t\t\tlimitCores: total,\n\t\t\texpectPercent: \"100\",\n\t\t},\n\t}\n\n\tofflineCg := \"/sys/fs/cgroup/cpu,cpuacct\" + types.CgroupOffline\n\t// offlineCpusetCg should be under the offlineCg path, we not creates it as this just for test\n\tofflineCpusetCg := \"/sys/fs/cgroup/cpuset/offlinetest\"\n\tofflineCpusetCgInRoot := \"/offlinetest\"\n\n\tfor _, tc := range testCases {\n\t\tbtQos := &qosCpuBT{\n\t\t\tkubeletStatic: tc.cpuStatic,\n\t\t}\n\t\tcpusetRecovered = tc.cpusetRecovered\n\n\t\tfunc() {\n\t\t\texisted, err := mkdirCgPath(offlineCg)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"mkdir offline cgroup %s err: %v\", offlineCg, err)\n\t\t\t}\n\t\t\tif !existed {\n\t\t\t\tdefer os.RemoveAll(offlineCg)\n\t\t\t}\n\n\t\t\texisted, err = mkdirCgPath(offlineCpusetCg)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"mkdir offline cgroup %s err: %v\", offlineCpusetCg, err)\n\t\t\t}\n\t\t\tif !existed {\n\t\t\t\tdefer os.RemoveAll(offlineCpusetCg)\n\t\t\t}\n\n\t\t\tbtQos.Manage(&CgroupResourceConfig{\n\t\t\t\tResources: v1.ResourceList{\n\t\t\t\t\tv1.ResourceCPU: *resource.NewMilliQuantity(tc.limitCores*1000, resource.DecimalSI),\n\t\t\t\t},\n\t\t\t\tOfflineCgroups: []string{\n\t\t\t\t\tofflineCpusetCgInRoot,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tvalueBytes, err := ioutil.ReadFile(path.Join(offlineCg, \"cpu.offline\"))\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"read offline cgroup %s err: %v\", offlineCg, err)\n\t\t\t}\n\t\t\tif strings.Trim(string(valueBytes), \"\\n\") != \"1\" {\n\t\t\t\tt.Fatalf(\"cpu qos bt test case(%s) failed, offline(%s) not enabled\", tc.describe, offlineCg)\n\t\t\t}\n\n\t\t\tfor p := range originValues {\n\t\t\t\tvByts, err := ioutil.ReadFile(p)\n\t\t\t\tif err != nil {\n\t\t\t\t\tt.Fatalf(\"read cpu offline file(%s) err: %v\", p, err)\n\t\t\t\t}\n\t\t\t\tif strings.Trim(string(vByts), \"\\n\") != tc.expectPercent {\n\t\t\t\t\tt.Fatalf(\"cpu qos bt test case(%s) unexpect result, expect %s, got %s\",\n\t\t\t\t\t\ttc.describe, tc.expectPercent, string(vByts))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcpusetStr, err := readCpuSetCgroup(offlineCpusetCg)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"read cpuset cgroup %s err: %v\", offlineCpusetCg, err)\n\t\t\t}\n\t\t\tif (!tc.cpuStatic && tc.cpusetRecovered) && len(cpusetStr) != 0 {\n\t\t\t\tt.Fatalf(\"cpu qos bt test case(%s) failed, static is false, should not set cpusets: %s\",\n\t\t\t\t\ttc.describe, cpusetStr)\n\t\t\t}\n\t\t\tif (tc.cpuStatic || !tc.cpusetRecovered) && len(cpusetStr) == 0 {\n\t\t\t\tt.Fatalf(\"cpu qos bt test case(%s) failed, static is true, should set cpusets, got null\",\n\t\t\t\t\ttc.describe)\n\t\t\t}\n\t\t}()\n\t}\n}" ]
[ "0.519822", "0.49126178", "0.48835254", "0.48608983", "0.48415226", "0.47969556", "0.4731509", "0.47084606", "0.4685272", "0.46802023", "0.4675119", "0.46535274", "0.4619654", "0.46005216", "0.45628616", "0.45617744", "0.45382494", "0.45167297", "0.4492512", "0.4472494", "0.44720653", "0.44659784", "0.44633818", "0.44592702", "0.4439586", "0.44138247", "0.4413763", "0.44014785", "0.43863136", "0.43858916", "0.4381165", "0.43791226", "0.43759552", "0.43707007", "0.4365189", "0.43473703", "0.43380234", "0.43330678", "0.4320964", "0.4312855", "0.42849162", "0.428033", "0.42782158", "0.42733452", "0.42731404", "0.42679083", "0.426687", "0.42469737", "0.42405552", "0.42347798", "0.4234529", "0.42325", "0.42319122", "0.4222484", "0.42198354", "0.4215063", "0.4213188", "0.421007", "0.42085192", "0.41908604", "0.4190832", "0.41798386", "0.41773736", "0.41766298", "0.4174588", "0.41657645", "0.41657606", "0.4164914", "0.41615388", "0.41594025", "0.4148421", "0.41413504", "0.4136441", "0.41290835", "0.4126893", "0.41258112", "0.41250122", "0.4121569", "0.41180885", "0.41130924", "0.41125745", "0.41117573", "0.41092208", "0.40988046", "0.4094594", "0.40927264", "0.40918887", "0.40801826", "0.40778214", "0.40756848", "0.40755668", "0.40737513", "0.40734068", "0.40732995", "0.40705046", "0.40690777", "0.40687922", "0.40671226", "0.4062776", "0.40560967" ]
0.7060136
0
NewBuildClient creates a new BuildClient instance that is set to the initial state (i.e., being idle).
func NewBuildClient(scheduler remoteworker.OperationQueueClient, buildExecutor BuildExecutor, filePool filesystem.FilePool, clock clock.Clock, workerID map[string]string, instanceNamePrefix digest.InstanceName, platform *remoteexecution.Platform, sizeClass uint32) *BuildClient { return &BuildClient{ scheduler: scheduler, buildExecutor: buildExecutor, filePool: filePool, clock: clock, instanceNamePrefix: instanceNamePrefix, instanceNamePatcher: digest.NewInstanceNamePatcher(digest.EmptyInstanceName, instanceNamePrefix), request: remoteworker.SynchronizeRequest{ WorkerId: workerID, InstanceNamePrefix: instanceNamePrefix.String(), Platform: platform, SizeClass: sizeClass, CurrentState: &remoteworker.CurrentState{ WorkerState: &remoteworker.CurrentState_Idle{ Idle: &emptypb.Empty{}, }, }, }, nextSynchronizationAt: clock.Now(), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewBuild(state *builder.Dispatcher, log logrus.FieldLogger, ghIntClient *ghIntegr.Client) *Build {\n\treturn &Build{\n\t\tstate: state,\n\t\tlog: log,\n\t\tgithubIntegrationClient: ghIntClient,\n\t}\n}", "func (bc Client) Build(id string) types.BuildClientV1 {\n\treturn newBuildClient(bc.client, id)\n}", "func (c *cookRun) newBuildUpdater() (*buildUpdater, error) {\n\thttpClient, err := c.systemAuth.Authenticator().Client()\n\tif err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to create a system-auth HTTP client for updating build state on the server\").Err()\n\t}\n\treturn &buildUpdater{\n\t\tannAddr: &c.AnnotationURL,\n\t\tbuildID: c.BuildbucketBuildID,\n\t\tbuildToken: c.buildSecrets.BuildToken,\n\t\tclient: buildbucketpb.NewBuildsPRPCClient(&prpc.Client{\n\t\t\tHost: c.BuildbucketHostname,\n\t\t\tC: httpClient,\n\t\t}),\n\t\tannotations: make(chan []byte),\n\t}, nil\n}", "func BuildClient(creds *config.CircleConfiguration) *circleci.Client {\n\treturn &circleci.Client{Token: creds.Token}\n}", "func NewOSClientBuildClient(client osclient.Interface) *OSClientBuildClient {\n\treturn &OSClientBuildClient{Client: client}\n}", "func NewBuildVersionClient() *BuildVersionClient {\n\treturn &BuildVersionClient{\n\t\tjobCacheClient: &defaultJobCacheClient{},\n\t\tgithubClient: &defaultGithubClient{},\n\t\ttestGridClient: &defaultTestGridClient{},\n\t}\n}", "func (o *OAuth) BuildClient(accessToken *AccessToken) *http.Client {\n\treturn &http.Client{\n\t\tTransport: &RoundTripper{\n\t\t\tdebug: utils.IsDebug(),\n\t\t\toauth: o,\n\t\t\ttoken: accessToken,\n\t\t},\n\t}\n}", "func (c *Client) Build(params map[string]interface{}) (api.ClientAPI, error) {\n\t// tenantName, _ := params[\"name\"].(string)\n\n\tidentity, _ := params[\"identity\"].(map[string]interface{})\n\tcompute, _ := params[\"compute\"].(map[string]interface{})\n\t// network, _ := params[\"network\"].(map[string]interface{})\n\n\tusername, _ := identity[\"Username\"].(string)\n\tpassword, _ := identity[\"Password\"].(string)\n\tdomainName, _ := identity[\"UserDomainName\"].(string)\n\n\tregion, _ := compute[\"Region\"].(string)\n\tprojectName, _ := compute[\"ProjectName\"].(string)\n\tprojectID, _ := compute[\"ProjectID\"].(string)\n\tdefaultImage, _ := compute[\"DefaultImage\"].(string)\n\n\treturn AuthenticatedClient(\n\t\tAuthOptions{\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t\tRegion: region,\n\t\t\tDomainName: domainName,\n\t\t\tProjectName: projectName,\n\t\t\tProjectID: projectID,\n\t\t},\n\t\topenstack.CfgOptions{\n\t\t\tDefaultImage: defaultImage,\n\t\t},\n\t)\n}", "func BuildClient() (*buildv1.BuildV1Client, error) {\n\tif buildClient == nil && buildClientError == nil {\n\t\tbuildClient, buildClientError = newBuildClient()\n\t}\n\treturn buildClient, buildClientError\n}", "func BuildClient(path string) (*Client, error) {\n\tdata, err := ioutil.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tscheme := defaultScheme\n\tif os.Getenv(\"SCHEME\") != \"\" {\n\t\tscheme = os.Getenv(\"SCHEME\")\n\t}\n\n\thost := defaultHost\n\tif os.Getenv(\"HOST\") != \"\" {\n\t\thost = os.Getenv(\"HOST\")\n\t}\n\n\tidHeader := defaultIDHeader\n\tif os.Getenv(\"IDENTITY\") != \"\" {\n\t\tidHeader = os.Getenv(\"IDENTITY\")\n\t}\n\n\tport := defaultPort\n\tif os.Getenv(\"PORT\") != \"\" {\n\t\tvar err error\n\t\tport, err = strconv.Atoi(os.Getenv(\"PORT\"))\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Invalid Port '%s'.\\n\", os.Getenv(\"PORT\"))\n\t\t\tport = defaultPort\n\t\t}\n\t}\n\n\t// Timeout should be an integer in milliseconds.\n\ttimeout := defaultTimeout\n\tif os.Getenv(\"TIMEOUT\") != \"\" {\n\t\tvar err error\n\t\ttimeout, err = strconv.Atoi(os.Getenv(\"TIMEOUT\"))\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Invalid Timeout '%s'.\\n\", os.Getenv(\"TIMEOUT\"))\n\t\t\ttimeout = defaultTimeout\n\t\t}\n\t}\n\n\tsc := Client{}\n\tsc.Scheme = scheme\n\tsc.Hostname = host\n\tsc.IdentityHeader = idHeader\n\tsc.Port = port\n\tsc.Timeout = timeout\n\n\tsc.Client = &http.Client{\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\tif sc.FollowRedirects {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn http.ErrUseLastResponse\n\t\t},\n\t\tTimeout: time.Duration(sc.Timeout) * time.Millisecond,\n\t}\n\n\tsc.load(data)\n\n\treturn &sc, nil\n}", "func (c *Client) Build(params map[string]interface{}) (api.ClientAPI, error) {\n\tUsername, _ := params[\"Username\"].(string)\n\tPassword, _ := params[\"Password\"].(string)\n\tTenantName, _ := params[\"TenantName\"].(string)\n\tRegion, _ := params[\"Region\"].(string)\n\treturn AuthenticatedClient(AuthOptions{\n\t\tUsername: Username,\n\t\tPassword: Password,\n\t\tTenantName: TenantName,\n\t\tRegion: Region,\n\t})\n}", "func NewBuildingClient(c config) *BuildingClient {\n\treturn &BuildingClient{config: c}\n}", "func newClient() (client *Client) {\n\n\tclient = new(Client)\n\n\tid := <-uuidBuilder\n\tclient.Id = id.String()\n\tclient.subscriptions = make(map[string]bool)\n\n\tclients[client.Id] = client\n\n\tlog.WithField(\"clientID\", id.String()).Info(\"Created new Client\")\n\treturn\n}", "func NewBuildServiceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BuildServiceClient, error) {\n\tcl, err := arm.NewClient(moduleName+\".BuildServiceClient\", moduleVersion, credential, options)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := &BuildServiceClient{\n\t\tsubscriptionID: subscriptionID,\n\t\tinternal: cl,\n\t}\n\treturn client, nil\n}", "func GetBuildMockClient() MockClient {\n\tmc := NewMockClient()\n\n\tmc.AddData(buildHead)\n\tmc.AddData(buildPost)\n\tmc.AddData(buildGet1)\n\tmc.AddData(buildGet2)\n\tmc.AddData(buildGetTasks)\n\tmc.AddData(buildGetTask0Logs)\n\tmc.AddData(buildGetTask1Logs)\n\tmc.AddData(buildGetTask2Logs)\n\tmc.AddData(buildGetTask3Logs)\n\tmc.AddData(buildGetTask4Logs)\n\tmc.AddData(buildGetTask5Logs)\n\tmc.AddData(buildGetTask6Logs)\n\tmc.AddData(buildGetTask7Logs)\n\tmc.AddData(buildGetTask8Logs)\n\tmc.AddData(buildGetTask9Logs)\n\tmc.AddData(buildGetTask10Logs)\n\tmc.AddData(buildGetTask11Logs)\n\tmc.AddData(buildGetTask12Logs)\n\tmc.AddData(buildGetTask0Result)\n\tmc.AddData(buildGetTask1Result)\n\tmc.AddData(buildGetTask2Result)\n\tmc.AddData(buildGetTask3Result)\n\tmc.AddData(buildGetTask4Result)\n\tmc.AddData(buildGetTask5Result)\n\tmc.AddData(buildGetTask6Result)\n\tmc.AddData(buildGetTask7Result)\n\tmc.AddData(buildGetTask8Result)\n\tmc.AddData(buildGetTask9Result)\n\tmc.AddData(buildGetTask10Result)\n\tmc.AddData(buildGetTask11Result)\n\tmc.AddData(buildGetTask12Result)\n\tmc.AddData(buildGetTask11ResultMedia)\n\tmc.AddData(buildGetValues)\n\n\treturn mc\n}", "func NewBuild(\n\tui cli.Ui,\n\tgocmd gocmd.Command,\n\tworkspace deptfile.Workspacer,\n\ttoolcacher toolcacher.Cacher,\n) cli.Command {\n\treturn &buildCommand{\n\t\tf: newBuildFlagSet(),\n\t\tui: ui,\n\t\tgocmd: gocmd,\n\t\tworkspace: workspace,\n\t\ttoolcacher: toolcacher,\n\t}\n}", "func newClient(ctx context.Context, cfg v1.Github) *client {\n\tgithubToken := os.Getenv(cfg.AccessTokenEnvVar)\n\t// Setup the token for github authentication\n\tts := oauth2.StaticTokenSource(\n\t\t&oauth2.Token{AccessToken: githubToken},\n\t)\n\ttc := oauth2.NewClient(context.Background(), ts)\n\n\t// Return a client instance from github\n\tc := github.NewClient(tc)\n\treturn &client{\n\t\tctx: ctx,\n\t\tClient: c,\n\t\towner: cfg.Owner,\n\t\trepo: cfg.Repo,\n\t\tbotName: cfg.BotName,\n\t}\n}", "func New(inConf *config.Config) Client {\n\turl := OrgRepoUrl\n\n\tspecifiedUrl := os.Getenv(\"GHCLI_GITHUB_URL\")\n\tif specifiedUrl != \"\" {\n\t\turl = specifiedUrl\n\t}\n\n\treturn Client{\n\t\tconf: inConf,\n\t\tgithubUrl: url,\n\t\tclient: &http.Client{},\n\t}\n}", "func (cb *ClientBuilder) Build() *Client {\n\treturn cb.client\n}", "func (cb *ClientBuilder) Build() *Client {\n\treturn cb.client\n}", "func (app *ClientApplication) Build(context string, makisuArgs []string) error {\n\ttarget, err := prepContext(app.LocalSharedPath, app.WorkerSharedPath, context)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to prepare context: %v\", err)\n\t}\n\tlocalPath := filepath.Join(app.LocalSharedPath, target)\n\tdefer os.RemoveAll(localPath)\n\tworkerPath := filepath.Join(app.WorkerSharedPath, target)\n\n\tstart := time.Now()\n\tfor time.Since(start) < app.WaitDuration {\n\t\tif err = app.client().Build(makisuArgs, workerPath); err == client.ErrWorkerBusy {\n\t\t\ttime.Sleep(250 * time.Millisecond)\n\t\t\tcontinue\n\t\t} else if err != nil {\n\t\t\treturn fmt.Errorf(\"build failed: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\treturn err\n}", "func (c *client) newClient() *gitea.Client {\n\treturn c.newClientToken(\"\")\n}", "func GetBuildClient(config config.BuildConfig) (pb.BuildClient, error) {\n\tconn, err := grpc.Dial(\n\t\tconfig.Remote,\n\t\tgrpc.WithInsecure(),\n\t\tgrpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*50)), // Avoid this using Stream API\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn pb.NewBuildClient(conn), nil\n}", "func New(g *godo.Client) Client {\n\tc := &client{\n\t\tg: g,\n\t}\n\treturn c\n}", "func createBuildService() *Service {\n\treturn &Service{\n\t\tList: map[string]string{\n\t\t\t\"all\": ListBuilds,\n\t\t\t\"repo\": ListRepoBuilds,\n\t\t\t\"repoByEvent\": ListRepoBuildsByEvent,\n\t\t\t\"org\": ListOrgBuilds,\n\t\t\t\"orgByEvent\": ListOrgBuildsByEvent,\n\t\t},\n\t\tSelect: map[string]string{\n\t\t\t\"repo\": SelectRepoBuild,\n\t\t\t\"last\": SelectLastRepoBuild,\n\t\t\t\"lastByBranch\": SelectLastRepoBuildByBranch,\n\t\t\t\"count\": SelectBuildsCount,\n\t\t\t\"countByStatus\": SelectBuildsCountByStatus,\n\t\t\t\"countByRepo\": SelectRepoBuildCount,\n\t\t\t\"countByRepoAndEvent\": SelectRepoBuildCountByEvent,\n\t\t\t\"countByOrg\": SelectOrgBuildCount,\n\t\t\t\"countByOrgAndEvent\": SelectOrgBuildCountByEvent,\n\t\t},\n\t\tDelete: DeleteBuild,\n\t}\n}", "func newClient(cfg Config) *Client {\n\treturn &Client{bitclient: bitclient.NewBitClient(cfg.Bitbucket.Host, cfg.Bitbucket.User, cfg.Bitbucket.Password)}\n}", "func NewClient(\n\tctx context.Context,\n\tappID int64,\n\tinstallationID int64,\n\tkeyPEM []byte,\n) (*github.Client, error) {\n\tinstallationToken, err := getInstallationToken(\n\t\tctx,\n\t\tappID,\n\t\tinstallationID,\n\t\tkeyPEM,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to negotiate an installation token: %s\", err)\n\t}\n\treturn github.NewClient(\n\t\toauth2.NewClient(\n\t\t\tctx,\n\t\t\toauth2.StaticTokenSource(\n\t\t\t\t&oauth2.Token{\n\t\t\t\t\tTokenType: \"token\", // This type indicates an installation token\n\t\t\t\t\tAccessToken: installationToken,\n\t\t\t\t},\n\t\t\t),\n\t\t),\n\t), nil\n}", "func newClient(conf Config) (*github.Client, error) {\n\tctx := context.Background()\n\n\tvar ts oauth2.TokenSource\n\tswitch {\n\tcase conf.HasAPIToken():\n\t\tts = oauth2.StaticTokenSource(\n\t\t\t&oauth2.Token{AccessToken: conf.GetAPIToken()},\n\t\t)\n\tdefault:\n\t\treturn nil, errors.New(\"Cannot find GitHub credentials\")\n\t}\n\n\ttc := oauth2.NewClient(ctx, ts)\n\treturn github.NewClient(tc), nil\n}", "func (s *Syncer) buildClient(name string, clientConfig ClientConfig, metricsHandle *sqmetrics.SquareMetrics) (*syncerEntry, error) {\n\tclientLogger := s.logger.WithField(\"client\", name)\n\tclient, err := NewClient(&clientConfig, s.config.CaFile, s.server, clientLogger, metricsHandle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toutput, err := s.outputCollection.NewOutput(clientConfig, clientLogger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &syncerEntry{client, clientConfig, output, map[string]secretState{}}, nil\n}", "func NewClient() *client.Client {\n\t// No need to test docker connection if AppMaker and DbMaker are not deployed\n\tif !configs.ServiceConfig.AppMaker.Deploy && !configs.ServiceConfig.DbMaker.Deploy {\n\t\treturn nil\n\t}\n\tcli, err := client.NewEnvClient()\n\tif err != nil {\n\t\tutils.Log(\"Docker-Connection-1\", \"Failed creating Docker Client\", utils.ErrorTAG)\n\t\tutils.LogError(\"Docker-Connection-2\", err)\n\t\tos.Exit(1)\n\t}\n\t_, err = cli.Ping(context.Background())\n\tif err != nil {\n\t\tutils.Log(\"Docker-Connection-3\", \"Connection with Docker Daemon was not established\", utils.ErrorTAG)\n\t\tutils.LogError(\"Docker-Connection-4\", err)\n\t\tos.Exit(1)\n\t}\n\tutils.LogInfo(\"Docker-Connection-5\", \"Docker Daemon Connection Established\")\n\treturn cli\n}", "func newClient(project string) (*client, error) {\n\tctx := context.Background()\n\tcl, err := pubsub.NewClient(ctx, project)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &client{\n\t\tclient: cl,\n\t}, nil\n}", "func newClient(cs ConnectionSettings) *client {\n\treturn &client{\n\t\tConnectionSettings: cs,\n\t}\n}", "func newBuild(rev buildgo.BuilderRev, detail commitDetail) (*buildStatus, error) {\n\t// Note: can't acquire statusMu in newBuild, as this is called\n\t// from findTryWork -> newTrySet, which holds statusMu.\n\n\tconf, ok := dashboard.Builders[rev.Name]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unknown builder type %q\", rev.Name)\n\t}\n\tif rev.Rev == \"\" {\n\t\treturn nil, fmt.Errorf(\"required field Rev is empty; got %+v\", rev)\n\t}\n\tif detail.RevBranch == \"\" {\n\t\treturn nil, fmt.Errorf(\"required field RevBranch is empty; got %+v\", detail)\n\t}\n\tif rev.SubRev != \"\" && detail.SubRevBranch == \"\" {\n\t\treturn nil, fmt.Errorf(\"field SubRevBranch is empty, required because SubRev is present; got %+v\", detail)\n\t}\n\n\tctx, cancel := context.WithCancel(context.Background())\n\treturn &buildStatus{\n\t\tbuildID: \"B\" + randHex(9),\n\t\tBuilderRev: rev,\n\t\tcommitDetail: detail,\n\t\tconf: conf,\n\t\tstartTime: time.Now(),\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t}, nil\n}", "func BuildReleaseClient(rootLogger logrus.FieldLogger, patProvider vstspat.PATProvider, org string, project string) (ReleaseClient, error) {\n\tlogger := rootLogger.WithFields(logrus.Fields{\n\t\t\"organization\": org,\n\t\t\"project\": project,\n\t})\n\n\treturn &releaseClient{\n\t\tpatProvider: patProvider,\n\t\torganization: org,\n\t\tproject: project,\n\t\tlogger: logger,\n\t}, nil\n}", "func NewClient() Golib {\r\n\treturn &golib{}\r\n}", "func NewClient(domain, apikey string, l *log.Logger) (c *Client, err error) {\n\tc = &Client{}\n\tc.l = l\n\tc.httpclient = &http.Client{Timeout: 5 * time.Second} // TODO: provide ability to configure\n\tc.domain = domain\n\tc.apikey = apikey\n\tc.baseURL, err = url.Parse(fmt.Sprintf(\"https://%s.canary.tools/api/v1/\", domain))\n\tif err != nil {\n\t\treturn\n\t}\n\n\tc.l.Debug(\"pinging console...\")\n\terr = c.Ping()\n\treturn\n}", "func NewClient(key, secret string) (cl *Client, err error) {\n\tcl = &Client{\n\t\tconn: &http.Client{},\n\t\tenv: newEnvironment(),\n\t}\n\n\tif key != \"\" {\n\t\tcl.env.apiKey = key\n\t\tcl.env.apiSecret = secret\n\t}\n\treturn cl, nil\n}", "func New(cred Credential, cfg Config) Client {\n\treturn clientImpl{\n\t\tapi: newAPI(cfg.env),\n\t\tcred: cred,\n\t\tjwt: newJWT(cfg.issuer, cfg.keyID),\n\t}\n}", "func NewGitClient(t mockConstructorTestingTNewGitClient) *GitClient {\n\tmock := &GitClient{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func buildClient(user string, keyfile string, baseurl string) *chef.Client {\n\tkey := clientKey(keyfile)\n\tclient, err := chef.NewClient(&chef.Config{\n\t\tName: user,\n\t\tKey: string(key),\n\t\tBaseURL: baseurl,\n\t\t// goiardi is on port 4545 by default, chef-zero is 8889, chef-server is on 443\n\t})\n\tif err != nil {\n\t\tfmt.Println(\"Issue setting up client:\", err)\n\t\tos.Exit(1)\n\t}\n\treturn client\n}", "func newClient(id int) *client {\n\treturn &client{\n\t\tID: id,\n\t\tmsg: make(chan string),\n\t}\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(\n\tb cbuild.BuildV1alpha1Interface,\n\timageFetcher RemoteImageFetcher,\n) Client {\n\treturn &client{\n\t\tbuild: b,\n\t\timageFetcher: imageFetcher,\n\t}\n}", "func newClient(hub *Hub, conn *websocket.Conn, queue chan<- command.Command) *client {\n\treturn &client{\n\t\tuuid: uuid.NewV4().String(),\n\t\thub: hub,\n\t\tconn: conn,\n\t\tsend: make(chan []byte, sendBufSize),\n\t\tcommandQueue: queue,\n\t}\n}", "func New(conf *Configuration) *Client {\n\tcli = &Client{\n\t\tConf: conf,\n\t\tsigs: make(chan os.Signal, 1),\n\t}\n\n\treturn cli\n}", "func newClient(httpClient *http.Client) (c *Client) {\n\tc = &Client{httpClient: httpClient}\n\tc.service.client = c\n\tc.Auth = (*AuthService)(&c.service)\n\tc.Providers = (*ProvidersService)(&c.service)\n\tc.Projects = (*ProjectsService)(&c.service)\n\tc.Releases = (*ReleasesService)(&c.service)\n\tc.SlackChannels = (*SlackChannelsService)(&c.service)\n\tc.TelegramChats = (*TelegramChatsService)(&c.service)\n\tc.DiscordChannels = (*DiscordChannelsService)(&c.service)\n\tc.HangoutsChatWebhooks = (*HangoutsChatWebhooksService)(&c.service)\n\tc.MicrosoftTeamsWebhooks = (*MicrosoftTeamsWebhooksService)(&c.service)\n\tc.MattermostWebhooks = (*MattermostWebhooksService)(&c.service)\n\tc.RocketchatWebhooks = (*RocketchatWebhooksService)(&c.service)\n\tc.MatrixRooms = (*MatrixRoomsService)(&c.service)\n\tc.Webhooks = (*WebhooksService)(&c.service)\n\tc.Tags = (*TagsService)(&c.service)\n\treturn c\n}", "func Build(mongoClient *mongo.Client) *App {\n\treturn &App{\n\t\tmongoClient: mongoClient,\n\t}\n}", "func (s *Surf) buildClient(param *DownloadParam) *http.Client {\n\tclient := &http.Client{\n\t\tCheckRedirect: param.CheckRedirect,\n\t}\n\n\tif param.IsEnableCookie() {\n\t\tclient.Jar = s.CookieJar\n\t}\n\n\ttransport := &http.Transport{\n\t\tDial: func(network, addr string) (net.Conn, error) {\n\t\t\tvar (\n\t\t\t\tc net.Conn\n\t\t\t\terr error\n\t\t\t\tipPort, ok = globalDnsCache.Query(addr)\n\t\t\t)\n\t\t\tif !ok {\n\t\t\t\tipPort = addr\n\t\t\t\tdefer func() {\n\t\t\t\t\tif err == nil {\n\t\t\t\t\t\tglobalDnsCache.Reg(addr, c.RemoteAddr().String())\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t} else {\n\t\t\t\tdefer func() {\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tglobalDnsCache.Del(addr)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t}\n\t\t\tc, err = net.DialTimeout(network, ipPort, param.GetDialTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif param.GetConnTimeout() > 0 {\n\t\t\t\tc.SetDeadline(time.Now().Add(param.GetConnTimeout()))\n\t\t\t}\n\t\t\treturn c, nil\n\t\t},\n\t}\n\n\tif param.GetProxy() != nil {\n\t\ttransport.Proxy = http.ProxyURL(param.GetProxy())\n\t}\n\n\tif strings.ToLower(param.GetUrl().Scheme) == \"https\" {\n\t\ttransport.TLSClientConfig = &tls.Config{RootCAs: nil, InsecureSkipVerify: true}\n\t\ttransport.DisableCompression = true\n\t}\n\tclient.Transport = transport\n\treturn client\n}", "func NewBuilder(watcher Watcher, buildCommand, runCommand string) *Builder {\n\treturn &Builder{\n\t\twatcher: watcher,\n\t\tstartChannel: make(chan bool),\n\t\tstopChannel: make(chan bool),\n\t\tbuildCommand: buildCommand,\n\t\trunCommand: runCommand,\n\t}\n}", "func newClient(token string) *Client {\n\treturn &Client{\n\t\tToken: token,\n\t}\n}", "func newClient(opts *ClientOpts) (*Client, error) {\n\tbaseClient, err := newAPIClient(opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &Client{\n\t\tAPIClient: *baseClient,\n\t}\n\n\t// init base operator\n\tclient.Node = newNodeClient(client)\n\tclient.Namespace = newNameSpaceClient(client)\n\tclient.ConfigMap = newConfigMapClient(client)\n\tclient.Service = newServiceClient(client)\n\tclient.Pod = newPodClient(client)\n\tclient.ReplicationController = newReplicationControllerClient(client)\n\tclient.StatefulSet = newStatefulSetClient(client)\n\tclient.DaemonSet = newDaemonSetClient(client)\n\tclient.Deployment = newDeploymentClient(client)\n\tclient.ReplicaSet = newReplicaSetClient(client)\n\n\treturn client, nil\n}", "func NewCmdControllerBuild(commonOpts *opts.CommonOptions) *cobra.Command {\n\toptions := &ControllerBuildOptions{\n\t\tControllerOptions: ControllerOptions{\n\t\t\tCommonOptions: commonOpts,\n\t\t},\n\t}\n\n\tcmd := &cobra.Command{\n\t\tUse: \"build\",\n\t\tShort: \"Runs the build controller\",\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\toptions.Cmd = cmd\n\t\t\toptions.Args = args\n\t\t\terr := options.Run()\n\t\t\thelper.CheckErr(err)\n\t\t},\n\t\tAliases: []string{\"builds\"},\n\t}\n\n\tcmd.Flags().StringVarP(&options.Namespace, \"namespace\", \"n\", \"\", \"The namespace to watch or defaults to the current namespace\")\n\tcmd.Flags().BoolVarP(&options.InitGitCredentials, \"git-credentials\", \"\", false, \"If enable then lets run the 'jx step git credentials' step to initialise git credentials\")\n\tcmd.Flags().BoolVarP(&options.FailIfNoGitProvider, \"fail-on-git-provider-error\", \"\", false, \"If enable then lets terminate quickly if we cannot create a git provider\")\n\n\t// optional git reporting flags\n\tcmd.Flags().StringVarP(&options.TargetURLTemplate, \"target-url-template\", \"\", \"\", \"The Go template for generating the target URL of pipeline logs/views if git reporting is enabled. If unspecified, a default will be used based on `--job-url-base`.\")\n\tcmd.Flags().BoolVarP(&options.GitReporting, \"git-reporting\", \"\", false, \"If enabled then lets report pipeline success/failures to the git provider. Note this is purely tactical until we can do this natively inside tekton\")\n\tcmd.Flags().StringVarP(&options.JobURLBase, \"job-url-base\", \"\", \"\", \"The base URL, such as 'https://dashboard.jenkins-x.live', for generating the target URL for pipeline logs if git reporting is enabled.\")\n\treturn cmd\n}", "func NewClient() *Client {\n\tclient := &Client{\n\t\tapi: C.Create(),\n\t\tVariables: map[SettableVariable]string{},\n\t\tTrim: true,\n\t\tshouldInit: true,\n\t\tLanguages: []string{\"eng\"},\n\t}\n\treturn client\n}", "func New(apiKey string, secretKey string, opts ...ClientOption) (*client, error) {\n\tc := &client{\n\t\tidGenerator: &id.Generator{},\n\t\tsignatureGenerator: &auth.Generator{},\n\t\tclock: clockwork.NewRealClock(),\n\t\trequester: api.Requester{\n\t\t\tClient: http.DefaultClient,\n\t\t\tBaseURL: productionBaseURL,\n\t\t},\n\t}\n\n\tif err := c.UpdateConfig(apiKey, secretKey, opts...); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func New(masterUrl,kubeconfig string)(*Client,error){\n // use the current context in kubeconfig\n config, err := clientcmd.BuildConfigFromFlags(masterUrl, kubeconfig)\n if err != nil {\n\t return nil,err\n }\n\n // create the clientset\n clientset, err := kubernetes.NewForConfig(config)\n if err!=nil{\n\t\treturn nil,err\n }\n return &Client{cset:clientset},nil\n}", "func NewBuild(sha string) *Build {\n\treturn &Build{\n\t\tsha: sha,\n\t\truns: make(map[string]*github.CheckRun),\n\t}\n}", "func NewClient(token string) *Client {\n\treturn &Client{\n\t\tclient: &http.Client{},\n\t\ttoken: token,\n\t\tbase: githubBase,\n\t\tdry: false,\n\t}\n}", "func New() Client {\n\treturn &client{\n\t\tControllerParams: nil,\n\t\tCloud: nil,\n\t\tServiceEngineGroup: nil,\n\t\tNetwork: nil,\n\t}\n}", "func NewClient(cfg *Config) (*Client, error) {\r\n\tBaseURL := new(url.URL)\r\n\tvar err error\r\n\r\n\tviper.SetEnvPrefix(\"TS\")\r\n\tviper.BindEnv(\"LOG\")\r\n\r\n\tswitch l := viper.Get(\"LOG\"); l {\r\n\tcase \"trace\":\r\n\t\tlog.SetLevel(log.TraceLevel)\r\n\tcase \"debug\":\r\n\t\tlog.SetLevel(log.DebugLevel)\r\n\tcase \"info\":\r\n\t\tlog.SetLevel(log.InfoLevel)\r\n\tcase \"warn\":\r\n\t\tlog.SetLevel(log.WarnLevel)\r\n\tcase \"fatal\":\r\n\t\tlog.SetLevel(log.FatalLevel)\r\n\tcase \"panic\":\r\n\t\tlog.SetLevel(log.PanicLevel)\r\n\t}\r\n\r\n\tif cfg.BaseURL != \"\" {\r\n\t\tBaseURL, err = url.Parse(cfg.BaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t} else {\r\n\t\tBaseURL, err = url.Parse(defaultBaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t}\r\n\r\n\tnewClient := &Client{\r\n\t\tBaseURL: BaseURL,\r\n\t\tclient: http.DefaultClient,\r\n\t\tcreds: &Credentials{\r\n\t\t\tAPIKey: cfg.APIKey,\r\n\t\t\tOrganizationID: cfg.OrganizationID,\r\n\t\t\tUserID: cfg.UserID,\r\n\t\t},\r\n\t}\r\n\r\n\tnewClient.Rulesets = &RulesetService{newClient}\r\n\tnewClient.Rules = &RuleService{newClient}\r\n\r\n\treturn newClient, nil\r\n}", "func New() (client *Client) {\n\thttpClient := &http.Client{}\n\treturn &Client{\n\t\thttpClient: httpClient,\n\t\tTimeout: 0,\n\t\tDisableKeepAlives: true,\n\t\tIdleConnectionTimeout: 0,\n\t\ttransport: &http.Transport{},\n\t\tMaxRetriesOnError: 1,\n\t}\n}", "func MakeClient(ctx context.Context) *Client {\n\n\t// get project ID\n\tp, err := project.GetID()\n\tif err != nil {\n\t\tlogger.Fatalf(\"Error while getting project ID: %v\", err)\n\t}\n\n\t// create metric client\n\tmc, err := monitoring.NewMetricClient(ctx)\n\tif err != nil {\n\t\tlogger.Fatalf(\"Error creating metric client with NewClient: %v\", err)\n\t}\n\n\treturn &Client{\n\t\tprojectID: p,\n\t\tmetricClient: mc,\n\t}\n\n}", "func NewClient(config *config.Config) Client {\n\treturn &releaseClient{\n\t\tconfig: config,\n\t}\n}", "func NewClient(authToken string) Client {\n\treturn Client{AuthToken: authToken, BaseURL: defaultBaseURL}\n}", "func (client *BuildServiceClient) getBuildCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, buildServiceName string, buildName string, options *BuildServiceClientGetBuildOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/buildServices/{buildServiceName}/builds/{buildName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif serviceName == \"\" {\n\t\treturn nil, errors.New(\"parameter serviceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{serviceName}\", url.PathEscape(serviceName))\n\tif buildServiceName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildServiceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildServiceName}\", url.PathEscape(buildServiceName))\n\tif buildName == \"\" {\n\t\treturn nil, errors.New(\"parameter buildName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{buildName}\", url.PathEscape(buildName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2023-01-01-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func NewClient(ctx context.Context, auth *repository.Auth) (repository.Client, error) {\n\tif auth == nil {\n\t\treturn nil, fmt.Errorf(\"Must provide authentication\")\n\t}\n\tif auth.Type() != repository.TokenAuthType {\n\t\treturn nil, fmt.Errorf(\"Unsupported auth type: %s\", auth.Type())\n\t}\n\n\tsts := oauth2.StaticTokenSource(\n\t\t&oauth2.Token{AccessToken: auth.Token},\n\t)\n\thttpClient := oauth2.NewClient(ctx, sts)\n\trtw := newRoundTripperWrapper(httpClient.Transport)\n\thttpClient.Transport = rtw\n\treturn &client{\n\t\tghClient: githubv4.NewClient(httpClient),\n\t}, nil\n}", "func newCloudlyckeClient() *http.Client {\n\treturn &http.Client{}\n}", "func New(cfg client.Config) (client.Client, error) {\n\treturn client.New(cfg)\n}", "func New(client *client.Client, properties ClientProperties) *Client {\n\treturn &Client{\n\t\tclient: client,\n\n\t\tflowSid: properties.FlowSid,\n\t\tsid: properties.Sid,\n\n\t\tContext: func() *context.Client {\n\t\t\treturn context.New(client, context.ClientProperties{\n\t\t\t\tExecutionSid: properties.Sid,\n\t\t\t\tFlowSid: properties.FlowSid,\n\t\t\t})\n\t\t},\n\t\tStep: func(stepSid string) *step.Client {\n\t\t\treturn step.New(client, step.ClientProperties{\n\t\t\t\tExecutionSid: properties.Sid,\n\t\t\t\tFlowSid: properties.FlowSid,\n\t\t\t\tSid: stepSid,\n\t\t\t})\n\t\t},\n\t\tSteps: steps.New(client, steps.ClientProperties{\n\t\t\tExecutionSid: properties.Sid,\n\t\t\tFlowSid: properties.FlowSid,\n\t\t}),\n\t}\n}", "func GetBuildMockClientToRun2Times() MockClient {\n\tmc := NewMockClient()\n\n\tmc.AddData(buildHead)\n\tmc.AddData(buildHead)\n\n\tmc.AddData(buildPost)\n\tmc.AddData(buildPost)\n\n\tmc.AddData(buildGet1)\n\tmc.AddData(buildGet2)\n\tmc.AddData(buildGet1)\n\tmc.AddData(buildGet2)\n\n\tmc.AddData(buildGetTasks)\n\tmc.AddData(buildGetTasks)\n\n\tmc.AddData(buildGetTask0Logs)\n\tmc.AddData(buildGetTask1Logs)\n\tmc.AddData(buildGetTask2Logs)\n\tmc.AddData(buildGetTask3Logs)\n\tmc.AddData(buildGetTask4Logs)\n\tmc.AddData(buildGetTask5Logs)\n\tmc.AddData(buildGetTask6Logs)\n\tmc.AddData(buildGetTask7Logs)\n\tmc.AddData(buildGetTask8Logs)\n\tmc.AddData(buildGetTask9Logs)\n\tmc.AddData(buildGetTask10Logs)\n\tmc.AddData(buildGetTask11Logs)\n\tmc.AddData(buildGetTask12Logs)\n\n\tmc.AddData(buildGetTask0Logs)\n\tmc.AddData(buildGetTask1Logs)\n\tmc.AddData(buildGetTask2Logs)\n\tmc.AddData(buildGetTask3Logs)\n\tmc.AddData(buildGetTask4Logs)\n\tmc.AddData(buildGetTask5Logs)\n\tmc.AddData(buildGetTask6Logs)\n\tmc.AddData(buildGetTask7Logs)\n\tmc.AddData(buildGetTask8Logs)\n\tmc.AddData(buildGetTask9Logs)\n\tmc.AddData(buildGetTask10Logs)\n\tmc.AddData(buildGetTask11Logs)\n\tmc.AddData(buildGetTask12Logs)\n\n\tmc.AddData(buildGetTask0Result)\n\tmc.AddData(buildGetTask1Result)\n\tmc.AddData(buildGetTask2Result)\n\tmc.AddData(buildGetTask3Result)\n\tmc.AddData(buildGetTask4Result)\n\tmc.AddData(buildGetTask5Result)\n\tmc.AddData(buildGetTask6Result)\n\tmc.AddData(buildGetTask7Result)\n\tmc.AddData(buildGetTask8Result)\n\tmc.AddData(buildGetTask9Result)\n\tmc.AddData(buildGetTask10Result)\n\tmc.AddData(buildGetTask11Result)\n\tmc.AddData(buildGetTask12Result)\n\n\tmc.AddData(buildGetTask0Result)\n\tmc.AddData(buildGetTask1Result)\n\tmc.AddData(buildGetTask2Result)\n\tmc.AddData(buildGetTask3Result)\n\tmc.AddData(buildGetTask4Result)\n\tmc.AddData(buildGetTask5Result)\n\tmc.AddData(buildGetTask6Result)\n\tmc.AddData(buildGetTask7Result)\n\tmc.AddData(buildGetTask8Result)\n\tmc.AddData(buildGetTask9Result)\n\tmc.AddData(buildGetTask10Result)\n\tmc.AddData(buildGetTask11Result)\n\tmc.AddData(buildGetTask12Result)\n\n\tmc.AddData(buildGetTask11ResultMedia)\n\tmc.AddData(buildGetTask11ResultMedia)\n\n\tmc.AddData(buildGetValues)\n\tmc.AddData(buildGetValues)\n\n\treturn mc\n}", "func newClient() (*client, error) {\n\tc, err := genetlink.Dial(nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Make a best effort to apply the strict options set to provide better\n\t// errors and validation. We don't apply Strict in the constructor because\n\t// this library is widely used on a range of kernels and we can't guarantee\n\t// it will always work on older kernels.\n\tfor _, o := range []netlink.ConnOption{\n\t\tnetlink.ExtendedAcknowledge,\n\t\tnetlink.GetStrictCheck,\n\t} {\n\t\t_ = c.SetOption(o, true)\n\t}\n\n\treturn initClient(c)\n}", "func NewClient() (Client, error) {\n\tc, err := client.NewEnvClient()\n\treturn Client{cli: c}, err\n}", "func NewClient(accessToken string) *Client {\n\treturn &Client{\n\t\ttoken: accessToken,\n\t\tunmarshal: json.Unmarshal,\n\t\tmarshal: json.Marshal,\n\t\tclient: &http.Client{},\n\t\tdebug: utils.GetEnv(envDebug, \"false\") == \"true\",\n\t\tlog: log.New(os.Stderr, \"slackapi\", log.LstdFlags|log.Lshortfile),\n\t}\n}", "func (cli *KodderClient) Build(flags []string, context string) error {\n\targs := append(flags, context)\n\tcontent, _ := json.Marshal(args)\n\tlog.Infof(\"Sending build request to kodderd with args %v\", args)\n\n\treader := bytes.NewBuffer(content)\n\treq, err := http.NewRequest(\"POST\", \"http://localhost/build\", reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := cli.HTTPDo(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := cli.readLines(resp.Body); err != nil {\n\t\treturn err\n\t} else if resp.StatusCode == http.StatusOK {\n\t\treturn nil\n\t} else if resp.StatusCode == http.StatusConflict {\n\t\treturn ErrWorkerBusy\n\t}\n\treturn fmt.Errorf(\"bad http status code from Kodder worker: %v\", resp.StatusCode)\n}", "func (r *Request) newClient() *http.Client {\n\treturn &http.Client{Timeout: r.timeout}\n}", "func NewClient(key, secretKey string) (*Client, error) {\n\tif key == \"\" || secretKey == \"\" {\n\t\treturn &Client{}, errors.New(\"key is missing\")\n\t}\n\n\tbaseurl, _ := url.Parse(defalutBaseURL)\n\tclient := &http.Client{Timeout: time.Duration(10) * time.Second}\n\n\tcli := &Client{accessKey: key, secretAccessKey: secretKey, BaseURL: baseurl, HTTPClient: client}\n\n\treturn cli, nil\n}", "func NewClient(config *Config) (c *Client, err error) {\n\tif config == nil {\n\t\treturn nil, errClientConfigNil\n\t}\n\n\tc = &Client{\n\t\trevocationTransport: http.DefaultTransport,\n\t}\n\n\tif c.transport, err = ghinstallation.NewAppsTransport(\n\t\thttp.DefaultTransport,\n\t\tint64(config.AppID),\n\t\t[]byte(config.PrvKey),\n\t); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.url, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/app/installations/%v/access_tokens\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t\tconfig.InsID,\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif c.revocationURL, err = url.ParseRequestURI(fmt.Sprintf(\n\t\t\"%s/installation/token\",\n\t\tstrings.TrimSuffix(fmt.Sprint(config.BaseURL), \"/\"),\n\t)); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func newClient() *sts.STS {\n\tsess := session.Must(session.NewSessionWithOptions(session.Options{\n\t\tSharedConfigState: session.SharedConfigEnable,\n\t}))\n\tconfig := aws.NewConfig()\n\tif debug {\n\t\tconfig.WithLogLevel(aws.LogDebugWithHTTPBody)\n\t}\n\treturn sts.New(sess, config)\n}", "func NewClient(httpClient *http.Client) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tc := &Client{}\n\n\tbaseURL, _ := url.Parse(DefaultBaseURL)\n\tvsspsBaseURL, _ := url.Parse(DefaultVsspsBaseURL)\n\tvsaexBaseURL, _ := url.Parse(DefaultVsaexBaseURL)\n\n\tc.client = httpClient\n\tc.BaseURL = *baseURL\n\tc.VsspsBaseURL = *vsspsBaseURL\n\tc.VsaexBaseURL = *vsaexBaseURL\n\tc.UserAgent = userAgent\n\n\tc.Boards = &BoardsService{client: c}\n\tc.BuildDefinitions = &BuildDefinitionsService{client: c}\n\tc.Builds = &BuildsService{client: c}\n\tc.DeliveryPlans = &DeliveryPlansService{client: c}\n\tc.Favourites = &FavouritesService{client: c}\n\tc.Git = &GitService{client: c}\n\tc.Iterations = &IterationsService{client: c}\n\tc.PolicyEvaluations = &PolicyEvaluationsService{client: c}\n\tc.PullRequests = &PullRequestsService{client: c}\n\tc.Teams = &TeamsService{client: c}\n\tc.Tests = &TestsService{client: c}\n\tc.Users = &UsersService{client: c}\n\tc.UserEntitlements = &UserEntitlementsService{client: c}\n\tc.WorkItems = &WorkItemsService{client: c}\n\n\treturn c, nil\n}", "func New() *Client {\n return &Client{&API{}}\n}", "func NewClient() *Client {\n baseURL, _ := url.Parse(defaultBaseURL)\n return &Client{client: http.DefaultClient, BaseURL: baseURL, UserAgent: userAgent}\n}", "func (gp Provider) Build(config config.Credentials) provider.Provider {\n\tclient := NewClient()\n\n\treturn &Provider{\n\t\tVerifier: provider.NewVerifierBasket(\n\t\t\tNewTeamVerifier(teamConfigsToTeam(config.Github.Teams), client),\n\t\t\tNewOrganizationVerifier(config.Github.Organizations, client),\n\t\t),\n\t}\n}", "func New() Client {\n\treturn &client{}\n}", "func (c *config) newClient(u *model.User) *internal.Client {\n\treturn c.newClientToken(u.Token, u.Secret)\n}", "func NewBuild(jenkins *gojenkins.Jenkins, regex string) *Build {\n\treturn &Build{jenkins, regex}\n}", "func NewClient(ctx context.Context, cfg *Config, bc *bclient.Client, db *db.Database) (*Client, error) {\n\twg := &sync.WaitGroup{}\n\n\tfor _, watcher := range cfg.Watchers {\n\t\twg.Add(1)\n\t\tgo func(discToken, token0, token1 string) {\n\t\t\tdefer wg.Done()\n\t\t\tdg, err := discordgo.New(\"Bot \" + discToken)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"failed to start watcher: \", err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif err := dg.Open(); err != nil {\n\t\t\t\tlog.Println(\"failed to start watcher: \", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}(watcher.DiscordToken, watcher.Token0Address, watcher.Token1Address)\n\t}\n\n\tclient := &Client{bc: bc, wg: wg, db: db}\n\n\tlog.Println(\"bot is now running\")\n\treturn client, nil\n}", "func New(consumerID string, cli *http.Client) *Client {\n\treturn &Client{\n\t\tconsumerID: consumerID,\n\t\tclient: cli,\n\t}\n}", "func (c OSClientBuildConfigInstantiatorClient) Instantiate(namespace string, request *buildapi.BuildRequest) (*buildapi.Build, error) {\n\treturn c.Client.BuildConfigs(namespace).Instantiate(request)\n}", "func (tmpl *APIClientTemplate) Build() APIClient {\n\treturn tmpl.BuildWithAuthorization(tmpl.Authorization)\n}", "func New(ctx context.Context, config Config) *Client {\n\tclient := &Client{\n\t\tid: generateClientID(\"C\"),\n\t\tvalues: make(map[string]interface{}),\n\t\tevents: make(chan *Event, 64),\n\t\tsends: make(chan string, 64),\n\t\tcapEnabled: make(map[string]bool),\n\t\tcapData: make(map[string]string),\n\t\tconfig: config.WithDefaults(),\n\t\tstatus: &Status{id: generateClientID(\"T\")},\n\t}\n\n\tclient.ctx, client.cancel = context.WithCancel(ctx)\n\n\t_ = client.AddTarget(client.status)\n\n\tgo client.handleEventLoop()\n\tgo client.handleSendLoop()\n\n\tclient.EmitNonBlocking(NewEvent(\"client\", \"create\"))\n\n\treturn client\n}", "func New() *Client {\n\treturn &Client{\n\t\tClientInfo: ClientInfo{\n\t\t\t// api defaults\n\t\t\tdatatype: &defaultDatatype,\n\t\t\toutputsize: &defaultOutputsize,\n\t\t},\n\t}\n}", "func (p *Pool) newClient() (*ClientConn, error) {\n\t// client pool already close\n\tif p == nil {\n\t\treturn nil, ErrClosed\n\t}\n\n\t// check if the pool already full\n\tif p.poolSize >= p.opt.PoolSize {\n\t\treturn nil, ErrFullPool\n\t}\n\n\t// create new conn\n\tconn, err := p.opt.Factory()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ClientConn{\n\t\tClientConn: conn,\n\t\tpool: p,\n\t\tinUse: 0,\n\t\ttimeUsed: time.Now(),\n\t\ttimeInitiated: time.Now(),\n\t}, nil\n}", "func New(key string) *Client {\n\treturn &Client{\n\t\tClient: &http.Client{Timeout: defaultTimeout},\n\t\tBaseURL: defaultBaseURL,\n\t\tUserAgent: defaultUserAgent,\n\t\tkey: key,\n\t}\n}", "func Create() *ConnectedClient {\n client := ConnectedClient {}\n\n client.ClientSecret = generateClientSecret();\n client.ClientToken = generateClientIdentifier();\n client.ClientName = generateClientName();\n client.VoteHistory = make([]Vote, 0);\n client.QueueHistory = make([]QueueEntry, 0);\n client.ConnectionTime = time.Now();\n client.LastCommunicated = time.Now();\n\n currentClients[client.ClientToken] = &client\n\n return &client\n}", "func NewClient(apiKey string, httpClient HTTPClient) *Client {\n\treturn &Client{\n\t\tapiKey: apiKey,\n\t\tclient: httpClient,\n\t\tLanguage: \"en-us\", // change after creating a new client\n\t}\n}", "func NewClient(httpClient *http.Client, space string, apiKey string) *Client {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tbaseURL, _ := url.Parse(\"https://\" + space + \".backlog.com/api/v2/\")\n\tc := &Client{client: httpClient, BaseURL: baseURL, apiKey: apiKey}\n\tc.common.client = c\n\tc.Space = (*SpaceService)(&c.common)\n\tc.Projects = (*ProjectsService)(&c.common)\n\tc.Issues = (*IssuesService)(&c.common)\n\treturn c\n}", "func (c *Config) Build() *Godim {\n\tif c.appProfile == nil {\n\t\tc.appProfile = newAppProfile()\n\t}\n\tc.appProfile.lock()\n\tif c.activateES {\n\t\tc.eventSwitch = NewEventSwitch(c.bufferSize)\n\t}\n\treturn NewGodim(c)\n}", "func New() *Client {\n\treturn &Client{repeat: false}\n}" ]
[ "0.66642916", "0.65855694", "0.6529739", "0.6344639", "0.62326384", "0.6230642", "0.6222423", "0.61396587", "0.61195105", "0.60379076", "0.6036955", "0.59917134", "0.59914863", "0.5910789", "0.5893504", "0.5862307", "0.58469456", "0.58261406", "0.5815292", "0.5815292", "0.5726841", "0.56984687", "0.56855506", "0.5657369", "0.5651807", "0.5615112", "0.5593324", "0.555978", "0.55574393", "0.55518955", "0.55509794", "0.5546623", "0.55258244", "0.55194396", "0.55188924", "0.5488479", "0.5485695", "0.5472036", "0.5464221", "0.5458197", "0.5453941", "0.5446276", "0.5446276", "0.5446276", "0.5446276", "0.544402", "0.5435598", "0.5420705", "0.54198366", "0.5410319", "0.5406001", "0.54034853", "0.5402364", "0.5396125", "0.5391916", "0.5388654", "0.5386425", "0.538274", "0.53807914", "0.5380014", "0.5375799", "0.53681123", "0.5366086", "0.5360743", "0.53596616", "0.53472", "0.53468984", "0.533929", "0.53281933", "0.5322782", "0.5319955", "0.5315811", "0.53146875", "0.5310501", "0.5308993", "0.5303779", "0.5289184", "0.52886736", "0.52880645", "0.52740765", "0.52708715", "0.5267588", "0.5254534", "0.5253076", "0.52530557", "0.52505636", "0.5239743", "0.52386045", "0.5232983", "0.5232448", "0.52315253", "0.52310675", "0.52310365", "0.52205306", "0.5215482", "0.52091885", "0.5208079", "0.52055264", "0.5200497", "0.5198108" ]
0.6985224
0
Run a iteration of the Remote Worker client, by performing a single synchronization against the scheduler.
func (bc *BuildClient) Run() error { // When executing an action, see if there are any updates on the // execution state. if bc.executionCancellation != nil { timer, timerChannel := bc.clock.NewTimer(bc.nextSynchronizationAt.Sub(bc.clock.Now())) select { case <-timerChannel: // No meaningful updates. Send the last update // once again. case update := <-bc.executionUpdates: // One or more execution updates available. Send // a new update with the latest state. timer.Stop() bc.applyExecutionUpdate(update) bc.consumeExecutionUpdatesNonBlocking() bc.nextSynchronizationAt = bc.clock.Now() } } // Inform scheduler of current worker state, potentially // requesting new work. response, err := bc.scheduler.Synchronize(context.Background(), &bc.request) if err != nil { return util.StatusWrap(err, "Failed to synchronize with scheduler") } // Determine when we should contact the scheduler again in case // of no activity. nextSynchronizationAt := response.NextSynchronizationAt if err := nextSynchronizationAt.CheckValid(); err != nil { return util.StatusWrap(err, "Scheduler response contained invalid synchronization timestamp") } bc.nextSynchronizationAt = nextSynchronizationAt.AsTime() // Apply desired state changes provided by the scheduler. if desiredState := response.DesiredState; desiredState != nil { switch workerState := desiredState.WorkerState.(type) { case *remoteworker.DesiredState_Executing_: // Scheduler is requesting us to execute the // next action, maybe forcing us to to stop // execution of the current build action. if err := bc.startExecution(workerState.Executing); err != nil { return err } case *remoteworker.DesiredState_Idle: // Scheduler is forcing us to go back to idle. bc.stopExecution() default: return status.Error(codes.Internal, "Scheduler provided an unknown desired state") } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (sc *SchedulerController) runWorker() {\n\tfor sc.processNextWorkItem() {\n\t}\n}", "func (c *DedicatedGameServerCollectionController) runWorker() {\n\t// hot loop until we're told to stop. processNextWorkItem will\n\t// automatically wait until there's work available, so we don't worry\n\t// about secondary waits\n\tlog.Info(\"Starting loop for DedicatedGameServerCollection controller\")\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (fc *FederatedController) worker() {\n\tfor fc.processNextWorkItem() {\n\t}\n}", "func (self *APIRequestManager) RunWorker() {\n\tfor {\n\t\titem := <-self.queue\n\n\t\tdata, err := FetchWeatherData(item.ctx, item.city)\n\t\tif err != nil {\n\t\t\tclose(item.outChannel)\n\t\t\tcontinue\n\t\t}\n\n\t\titem.outChannel <- data\n\t}\n}", "func (m *cloudResourceSyncManager) Run(stopCh <-chan struct{}) {\n\twait.Until(m.syncNodeAddresses, m.syncPeriod, stopCh)\n}", "func (client *TimeClient) Run() {\n\tgo client.worker()\n}", "func (m *SGController) runWorker() {\n\tfor m.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (s *GenericSync) Run() (chan struct{}, error) {\n\n\tclient, err := dynamic.NewForConfig(s.kubeconfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tquit := make(chan struct{})\n\tgo s.loop(client, quit)\n\treturn quit, nil\n}", "func (m *MaintenanceScheduler) Run() {\n\trc := m.rclt.gconn()\n\tpsc := redis.PubSubConn{\n\t\tConn: rc,\n\t}\n\tkey := fmt.Sprintf(\"%s_channel\", m.hkey)\n\tif err := psc.PSubscribe(key); err != nil {\n\t\tm.echan <- err\n\t\treturn\n\t}\n\tfor {\n\t\tselect {\n\t\tcase <-m.schan:\n\t\t\trc.Close()\n\t\t\tpsc.Close()\n\t\t\treturn\n\t\tdefault:\n\t\t\tswitch msg := psc.Receive().(type) {\n\t\t\tcase redis.Message:\n\t\t\t\tgo m.process(msg.Data)\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem(c.ctx) {\n\t}\n}", "func (ssc *StatefulSetController) worker() {\n\tfor ssc.processNextWorkItem() {\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextItem() {\n\t}\n}", "func (c *Controller) RunWorker(stopCh <-chan struct{}) {\n\n\tgo c.waitForShutdown(stopCh)\n\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *CaddyController) runWorker() {\n\tfor c.processNextItem() {\n\t}\n}", "func (s *Scheduler) Run(client *clientv3.Client) error {\n\ts.client = client\n\ts.queue = recipe.NewPriorityQueue(client, common.QueuePrefix)\n\n\ts.logger.Infof(\"starting main scheduler\")\n\n\tgo s.watchDone()\n\n\tfor {\n\t\tselect {\n\t\tcase <-s.ready:\n\t\t\ts.process()\n\t\tcase <-s.ctx.Done():\n\t\t\treturn s.ctx.Err()\n\t\tcase <-s.done:\n\t\t\treturn nil\n\t\t}\n\t}\n}", "func (c *MultiClusterController) worker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) worker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) worker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) worker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func worker(clients <-chan api.Client) {\n\tfor c := range clients {\n\t\tlog.Printf(\"Fetching metrics from %s\", c.GetHost())\n\t\terr := c.FetchInventoryMetrics()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error updating %s: %v\", c.GetHost(), err)\n\t\t}\n\t}\n}", "func (w *worker) runWorker() {\n\tfor w.processNextItem() {\n\t}\n}", "func (r *Cluster) Run() {\n\tif features.RemoteClusterTimeout > 0 {\n\t\ttime.AfterFunc(features.RemoteClusterTimeout, func() {\n\t\t\tif !r.initialSync.Load() {\n\t\t\t\tlog.Errorf(\"remote cluster %s failed to sync after %v\", r.ID, features.RemoteClusterTimeout)\n\t\t\t\ttimeouts.With(clusterLabel.Value(string(r.ID))).Increment()\n\t\t\t}\n\t\t\tr.initialSyncTimeout.Store(true)\n\t\t})\n\t}\n\n\tr.Client.RunAndWait(r.stop)\n\tr.initialSync.Store(true)\n}", "func (c *Controller) runWorker() {\n\t// hot loop until we're told to stop. processNextWorkItem will\n\t// automatically wait until there's work available, so we don't worry\n\t// about secondary waits\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (c *Controller) RunWorker(stopCh <-chan struct{}, doneCh chan<- struct{}) {\n\n\tgo c.waitForShutdown(stopCh)\n\n\tfor c.processNextItem() {\n\t}\n\n\tlog.Debug(\"pgcluster Contoller: worker queue has been shutdown, writing to the done channel\")\n\tdoneCh <- struct{}{}\n}", "func (mgr *WatchController) worker() {\n\tfor mgr.processNextWorkItem() {\n\t}\n}", "func (c *Client) RunDispatch() {\n for {\n time.Sleep(pollInterval)\n c.SendRequests()\n c.RecvResponses()\n }\n}", "func Run(workerCount int, refreshInterval time.Duration) {\n\tfor w := 0; w < workerCount; w++ {\n\t\tgo worker(clients)\n\t}\n\tfor {\n\t\tcfg := config.GetConfig()\n\t\tfor i, _ := range cfg.PlatformManagements {\n\t\t\tswitch pm := cfg.PlatformManagements[i].Type; pm {\n\t\t\tcase \"IDRAC\":\n\t\t\t\tfallthrough\n\t\t\tcase \"IDRAC9\":\n\t\t\t\tfallthrough\n\t\t\tcase \"IDRAC8\":\n\t\t\t\tclient := api.NewRedfishAPI(cfg.PlatformManagements[i].Host)\n\t\t\t\tclient.SetUser(cfg.PlatformManagements[i].Username, cfg.PlatformManagements[i].Password)\n\t\t\t\tclients <- client\n\t\t\tcase \"ILO5\":\n\t\t\t\tclient := api.NewHpeApi(cfg.PlatformManagements[i].Host)\n\t\t\t\tclient.SetUser(cfg.PlatformManagements[i].Username, cfg.PlatformManagements[i].Password)\n\t\t\t\tclients <- client\n\t\t\t\tcontinue\n\t\t\tdefault:\n\t\t\t\tlog.Printf(\"Error fetching inventory for %v - type unknown (%v)\\n\", cfg.PlatformManagements[i].Host, cfg.PlatformManagements[i].Type)\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(refreshInterval)\n\t}\n}", "func (c *Controller) runWorker() {\n\tlog.Info(\"Starting worker\")\n\n\t// invoke processNextItem to fetch and consume the next change\n\t// to a watched resource\n\tfor c.processNextItem() {\n\t\tlog.Info(\"Processing next item from the queue\")\n\t}\n\n\tlog.Info(\"Worker completed processing items\")\n}", "func (d *Deployer) runWorker() {\n\tlog.Debug(\"Deployer: starting\")\n\n\t// invoke processNextItem to fetch and consume the next change\n\t// to a watched or listed resource\n\tfor d.processNextItem() {\n\t\tlog.Debug(\"Deployer.runWorker: processing next item\")\n\t}\n\n\tlog.Debug(\"Deployer.runWorker: completed\")\n}", "func (c *MetricsController) runWorker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (s *Slot) Run() {\n\tcanInteract := true\n\tfor _, worker := range s.workers {\n\t\titem, didInteract := worker.Run(s.item, canInteract)\n\t\tif didInteract {\n\t\t\ts.item = item\n\t\t\tcanInteract = false\n\t\t}\n\t}\n}", "func (s *Syncer) Run() error {\n\tfor {\n\t\terrors := s.RunOnce()\n\t\tvar err error\n\t\tif len(errors) != 0 {\n\t\t\tif len(errors) == 1 {\n\t\t\t\terr = errors[0]\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"Errors: %v\", errors)\n\t\t\t}\n\t\t\ts.logger.WithError(err).Error(\"Failed running sync\")\n\t\t} else {\n\t\t\ts.logger.Debug(\"Updating success timestamp\")\n\t\t\ts.updateSuccessTimestamp()\n\t\t}\n\n\t\t// No poll interval configured, so return now\n\t\tif s.pollInterval == 0 {\n\t\t\ts.logger.Info(\"No poll configured\")\n\t\t\treturn err\n\t\t}\n\t\tsleep := randomize(s.pollInterval)\n\t\ts.logger.WithField(\"duration\", sleep).Info(\"Sleeping\")\n\t\ttime.Sleep(sleep)\n\t}\n}", "func (b *QuerySnipBroadcaster) Run() {\n\tfor {\n\t\ts := <-b.in\n\t\tfor _, recipient := range b.recipients {\n\t\t\trecipient <- s\n\t\t}\n\t}\n}", "func (c *Coordinator) run(ctx context.Context) error {\n\tminRemoteClientsPerGame := 1\n\tmaxRemoteClientsPerGame := 10\n\tfor {\n\t\tclients, err := c.awaitRemoteClients(ctx, minRemoteClientsPerGame, maxRemoteClientsPerGame)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error awaiting remote clients\")\n\t\t}\n\n\t\t// Add a couple of AI clients.\n\t\tnumAIClients := 4 - len(clients)\n\t\tif numAIClients <= 0 {\n\t\t\tnumAIClients = 1\n\t\t}\n\t\tfor i := 0; i < numAIClients; i++ {\n\t\t\tvar aiClient *ai.Client\n\t\t\tvar err error\n\t\t\tif i%3 == 2 {\n\t\t\t\taiClient, err = ai.NewClient(c.logEntry.Logger, ai.RandomStrategy(rand.Int63n(30)+2))\n\t\t\t} else {\n\t\t\t\taiClient, err = ai.NewClient(c.logEntry.Logger, ai.OpportunisticStrategy())\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"error creating ai client\")\n\t\t\t}\n\t\t\tclients = append(clients, aiClient)\n\t\t}\n\n\t\tc.logEntry.Debug(\"Starting a new game\")\n\t\terr = c.startGame(ctx, clients)\n\t\tif err != nil {\n\t\t\t// As we still own the clients here, make sure we stop them\n\t\t\t// before quiting ourselves.\n\t\t\tdisconnectAll(clients)\n\t\t\treturn errors.Wrap(err, \"Error starting game\")\n\t\t}\n\t}\n}", "func (w *Worker) Run(done <-chan interface{}) error {\n\tdefer close(w.resultStream)\n\tfor {\n\t\tselect {\n\t\tcase <-done:\n\t\t\tlog.Println(\n\t\t\t\t\"level\", \"INFO\",\n\t\t\t\t\"object\", \"workers.worker\",\n\t\t\t\t\"method\", \"Run\",\n\t\t\t\t\"msg\", \"terminating operations by application request\",\n\t\t\t)\n\t\t\treturn nil\n\t\tcase order, ok := <-w.orderStream:\n\t\t\tif !ok {\n\t\t\t\tlog.Println(\"level\", \"INFO\",\n\t\t\t\t\t\"object\", \"workers.worker\",\n\t\t\t\t\t\"method\", \"Run\",\n\t\t\t\t\t\"msg\", \"terminating operations because order stream was closed\",\n\t\t\t\t)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tw.processOrder(order)\n\t\t}\n\t}\n}", "func (c *Controller) runWorker() {\n\tfor c.processNextWorkItem(c.workqueue, false) {\n\t}\n}", "func (h *Hub) run() {\n\tfor {\n\t\tselect {\n\t\t// register a new client to a specific ws connection\n\t\tcase client := <-h.register:\n\t\t\th.clients[client] = true\n\t\t\tclient.send <- &Message{\n\t\t\t\tbroadcast: []byte(fmt.Sprintf(`{\"id\": \"%s\"}`, client.key)),\n\t\t\t}\n\t\t// de-register existing client\n\t\tcase client := <-h.unregister:\n\t\t\tif _, ok := h.clients[client]; ok {\n\t\t\t\tdelete(h.clients, client)\n\t\t\t\tclose(client.send)\n\t\t\t}\n\t\t// send message to each client\n\t\tcase message := <-h.broadcast:\n\t\t\tfor client := range h.clients {\n\t\t\t\t// don't send to creator of the broadcast\n\t\t\t\tif client.key == message.senderKey {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase client.send <- message:\n\t\t\t\tdefault:\n\t\t\t\t\tclose(client.send)\n\t\t\t\t\tdelete(h.clients, client)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func Run(concurrent int, round int, interval int) {\n\tsenders := pickupPeersButMyself(peer.ID(\"\"), concurrent, mnet.Peers())\n\tlog.Info(senders)\n\tvar wg sync.WaitGroup\n\twg.Add(len(senders))\n\tfor _, pid := range senders {\n\t\t// 随机化开始时间\n\t\ttime.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)\n\t\tgo Work(&wg, pid, round, interval)\n\t}\n\twg.Wait()\n\tlog.Info(\"run ok\")\n}", "func (reporter *RedisReporter) Run() {\n\treporter.running = true\n\n\tfor {\n\t\tselect {\n\t\tcase t := <-reporter.channel.Channel():\n\t\t\treceivers, err := report(reporter.client, t)\n\n\t\t\tif err != nil {\n\t\t\t\treporter.running = false\n\n\t\t\t\t_, ok := err.(*retryingRedis.ClientClosedError)\n\t\t\t\tif ok {\n\t\t\t\t\tlog.Println(\"retry client was closed\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// TODO proper error handling\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tif receivers == 0 {\n\t\t\t\t// TODO: if there are no subscribers, we could pause this ticker for X seconds and try again\n\t\t\t}\n\t\tcase <-reporter.stopChan:\n\t\t\treporter.running = false\n\t\t\treturn\n\t\t}\n\t}\n}", "func runWorker(ch <-chan func()) {\n\tfor {\n\t\tf := <-ch\n\t\tf()\n\t}\n}", "func (c *EgressController) worker() {\n\tfor c.processNextWorkItem() {\n\t}\n}", "func (t *Tester) runWorkers() {\n\n\twg := sync.WaitGroup{}\n\n\tfor i, item := range t.items {\n\t\ti := i\n\t\titem := item\n\n\t\ttr := &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{\n\t\t\t\tInsecureSkipVerify: true,\n\t\t\t\tServerName: item.Host,\n\t\t\t},\n\t\t\tMaxIdleConnsPerHost: t.conf.MaxIdleConnPerHost,\n\t\t\tDisableCompression: t.conf.DisableCompression,\n\t\t\tDisableKeepAlives: t.conf.DisableKeepAlive,\n\t\t}\n\n\t\tif t.conf.UseHTTP2 {\n\t\t\t_ = http2.ConfigureTransport(tr)\n\t\t} else {\n\t\t\ttr.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)\n\t\t}\n\n\t\tclient := &http.Client{\n\t\t\tTransport: tr,\n\t\t\tTimeout: httpClientTimeout,\n\t\t}\n\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tt.runWorker(i, client, item)\n\t\t\twg.Done()\n\t\t}()\n\t}\n\n\twg.Wait()\n}", "func (pc *PolicyController) worker() {\n\tfor pc.processNextWorkItem() {\n\t}\n}", "func (pm *PipelineManager) runWorker() {\n\tfor pm.processNextWorkItem() {\n\t}\n}", "func (c *Operator) worker() {\n\tfor {\n\t\tp, ok := c.queue.pop()\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tif err := c.reconcile(p); err != nil {\n\t\t\tutilruntime.HandleError(logger.LogError(\"reconciliation failed: %v\", err))\n\t\t}\n\t}\n}", "func Worker() {\n\tlog.Println(\"Starting listening for messages to publish to datawarehouse\")\n\tfor {\n\t\tdataToPublish := <- DatawarehouseChannel\n\t\tpublishToDW(dataToPublish.TopicId, dataToPublish.Data, dataToPublish.Info)\n\t\ttime.Sleep(300*time.Second)\n\t}\n}", "func (w *worker) run() {\n\tw.a.V(2).S().P()\n\tdefer w.a.V(2).E().P()\n\n\tfor {\n\t\t// Get() blocks until it can return an item\n\t\titem, shutdown := w.queue.Get()\n\t\tif shutdown {\n\t\t\tw.a.Info(\"shutdown request\")\n\t\t\treturn\n\t\t}\n\n\t\tif err := w.processItem(item); err != nil {\n\t\t\t// Item not processed\n\t\t\t// this code cannot return an error and needs to indicate error has been ignored\n\t\t\tutilruntime.HandleError(err)\n\t\t}\n\n\t\t// Forget indicates that an item is finished being retried. Doesn't matter whether its for perm failing\n\t\t// or for success, we'll stop the rate limiter from tracking it. This only clears the `rateLimiter`, you\n\t\t// still have to call `Done` on the queue.\n\t\tw.queue.Forget(item)\n\n\t\t// Remove item from processing set when processing completed\n\t\tw.queue.Done(item)\n\t}\n}", "func (c Client) Run() {\n\terr := c.createRetryDir()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tc.mainChannels = make(map[string]chan string)\n\tc.monChannels = make(map[string]chan string)\n\n\tfor _, carbonAddr := range c.Conf.CarbonAddrs {\n\t\tchanLock.Lock()\n\t\tc.mainChannels[carbonAddr] = make(chan string, cap(c.Lc.mainChannel))\n\t\tc.monChannels[carbonAddr] = make(chan string, cap(c.Lc.monitoringChannel))\n\t\tchanLock.Unlock()\n\t\tgo c.runBackend(carbonAddr)\n\t}\n\n\tsup := supervisor(c.Conf.Supervisor)\n\tfor ; ; time.Sleep(time.Second) {\n\t\t// Notify watchdog about aliveness of Client routine\n\t\tsup.notify()\n\n\t\t// write metrics from monitoring and main channels to the server specific channels\n\t\tfor i := 0; i < len(c.Lc.mainChannel); i++ {\n\t\t\tmetric := <-c.Lc.mainChannel\n\t\t\tfor _, carbonAddr := range c.Conf.CarbonAddrs {\n\t\t\t\tselect {\n\t\t\t\tcase c.mainChannels[carbonAddr] <- metric:\n\t\t\t\tdefault:\n\t\t\t\t\tc.Mon.Increase(&c.Mon.clientStat[carbonAddr].dropped, 1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < len(c.Lc.monitoringChannel); i++ {\n\t\t\tmetric := <-c.Lc.monitoringChannel\n\t\t\tfor _, carbonAddr := range c.Conf.CarbonAddrs {\n\t\t\t\tselect {\n\t\t\t\tcase c.monChannels[carbonAddr] <- metric:\n\t\t\t\tdefault:\n\t\t\t\t\tc.Mon.Increase(&c.Mon.clientStat[carbonAddr].dropped, 1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (sc *SchedulerController) Run(workers int, stopCh <-chan struct{}) error {\n\tdefer runtime.HandleCrash()\n\tdefer sc.workqueue.ShutDown()\n\n\t// Start the informer factories to begin populating the informer caches\n\tklog.Info(\"Starting Scheduler control loop\")\n\n\t// Wait for the caches to be synced before starting workers\n\tklog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, sc.schedulerSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tklog.Infof(\"Starting %d workers\", workers)\n\tfor i := 0; i < workers; i++ {\n\t\tgo wait.Until(sc.runWorker, time.Second, stopCh)\n\t}\n\n\tklog.Info(\"Started workers\")\n\t<-stopCh\n\tklog.Info(\"Shutting down workers\")\n\n\treturn nil\n}", "func (e *Executor) Run() { e.loop() }", "func (c *Controller) Run(ctx context.Context) {\n\tlog.Info(\"Starting main control loop.\")\n\n\t// Start the update workers\n\tfor i := uint(0); i < c.concurrentUpdates; i++ {\n\t\tgo c.processWorkerLoop(ctx, i+1)\n\t}\n\n\tvar interval time.Duration\n\n\t// Start the refresh loop\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(interval):\n\t\t\tinterval = c.interval\n\t\t\terr := c.refresh()\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed to refresh cluster list: %s\", err)\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\tlog.Info(\"Terminating main controller loop.\")\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *Controller) runWorker() {\n\tdefer utilruntime.HandleCrash()\n\tfor c.processNextItem() {\n\t}\n}", "func (c *Converter) workerLoop() {\n\tdefer c.wg.Done()\n\n\tvar (\n\t\tbuff = bytes.Buffer{}\n\t\tencoder = json.NewEncoder(&buff)\n\t)\n\n\tfor {\n\n\t\tselect {\n\t\tcase <-c.stopChan:\n\t\t\treturn\n\n\t\tcase e, ok := <-c.workerChan:\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tbuff.Reset()\n\t\t\tlr := convert(e)\n\n\t\t\tif err := encoder.Encode(e.Resource); err != nil {\n\t\t\t\tc.logger.Debug(\"Failed marshaling entry.Resource to JSON\",\n\t\t\t\t\tzap.Any(\"resource\", e.Resource),\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tselect {\n\t\t\tcase c.batchChan <- &workerItem{\n\t\t\t\tResource: e.Resource,\n\t\t\t\tResourceString: buff.String(),\n\t\t\t\tLogRecord: lr,\n\t\t\t}:\n\t\t\tcase <-c.stopChan:\n\t\t\t}\n\t\t}\n\t}\n}", "func (trd *trxDispatcher) run() {\n\t// make sure we are orchestrated\n\tif trd.mgr == nil {\n\t\tpanic(fmt.Errorf(\"no svc manager set on %s\", trd.name()))\n\t}\n\n\t// start the block observer ticker\n\ttrd.bot = time.NewTicker(trxDispatchBlockUpdateTicker)\n\n\t// signal orchestrator we started and go\n\ttrd.mgr.started(trd)\n\tgo trd.execute()\n}", "func (r *gatewayOneDotOne) Run() {\n\tr.state = RstateRunning\n\n\tgo func() {\n\t\tfor r.state == RstateRunning {\n\t\t\tr.send()\n\t\t\ttime.Sleep(time.Microsecond * 100)\n\t\t}\n\t\tr.closeTxChannels()\n\t}()\n}", "func (this *RpcObject) Loop() {\n\tfor this.IsRun {\n\t\tstart := time.Now()\n\t\tthis.ExecuteEvent()\n\t\tdelta := MAX_SLEEP_TIME - time.Now().Sub(start)\n\t\tif delta > 0 {\n\t\t\ttime.Sleep(delta)\n\t\t} else {\n\t\t\truntime.Gosched()\n\t\t}\n\t}\n}", "func (s *Server) Run() {\n\tfor {\n\t\tselect {\n\t\tcase msg := <-s.broadcast:\n\t\t\tfor conn, m := range s.clients {\n\t\t\t\tm.Lock()\n\t\t\t\tconn.WriteMessage(websocket.TextMessage, msg)\n\t\t\t\tm.Unlock()\n\t\t\t}\n\t\tcase conn := <-s.add:\n\t\t\ts.clients[conn] = new(sync.Mutex)\n\t\t\tgo s.listen(conn)\n\t\tcase conn := <-s.del:\n\t\t\tif _, ok := s.clients[conn]; ok {\n\t\t\t\tdelete(s.clients, conn)\n\t\t\t}\n\t\t}\n\t}\n}", "func (k *KubeBoot) RunSyncLoop() {\n\tctx := context.Background()\n\n\tif k.Master {\n\t\tclient, err := k.Kubernetes.KubernetesClient()\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"could not create kubernetes client: %v\", err))\n\t\t}\n\n\t\tklog.Info(\"polling for apiserver readiness\")\n\t\tfor {\n\t\t\t_, err = client.CoreV1().Namespaces().Get(ctx, \"kube-system\", metav1.GetOptions{})\n\t\t\tif err == nil {\n\t\t\t\tklog.Info(\"successfully connected to the apiserver\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tklog.Infof(\"failed to connect to the apiserver (will sleep and retry): %v\", err)\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t}\n\t}\n\n\tfor {\n\t\tif err := k.syncOnce(ctx); err != nil {\n\t\t\tklog.Warningf(\"error during attempt to bootstrap (will sleep and retry): %v\", err)\n\t\t}\n\n\t\ttime.Sleep(1 * time.Minute)\n\t}\n}", "func (c *Connection) Worker() {\n\n\tfor {\n\t\tselect {\n\t\tcase _ = <-c.workerctx.Done():\n\t\t\treturn\n\t\tcase inData := <-c.In:\n\t\t\theader, _ := wire.GetHeader(inData)\n\n\t\t\tif header.CmdType == wire.CMD_EXIT {\n\t\t\t\tos.Exit(0)\n\t\t\t}\n\n\t\t\tlogg.Debug(\"processing server cmd\")\n\n\t\t\tcmdFunc, ok := cmd.CommandBuffer[header.CmdType]\n\t\t\tif !ok {\n\t\t\t\tlogg.Log(\"Command not implemented\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tnewctx1, _ := context.WithCancel(c.workerctx)\n\t\t\tgo cmdFunc(inData, c.Out, newctx1)\n\t\t}\n\t}\n\n}", "func RunPhabricatorRepositorySyncWorker(ctx context.Context, s Store) {\n\tcf := NewHTTPClientFactory()\n\n\tfor {\n\t\tphabs, err := s.ListExternalServices(ctx, StoreListExternalServicesArgs{\n\t\t\tKinds: []string{\"PHABRICATOR\"},\n\t\t})\n\n\t\tif err != nil {\n\t\t\tlog15.Error(\"unable to fetch Phabricator connections\", \"err\", err)\n\t\t}\n\n\t\tfor _, phab := range phabs {\n\t\t\tsrc, err := NewPhabricatorSource(phab, cf)\n\t\t\tif err != nil {\n\t\t\t\tlog15.Error(\"failed to instantiate PhabricatorSource\", \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\trepos, err := src.ListRepos(ctx)\n\t\t\tif err != nil {\n\t\t\t\tlog15.Error(\"Error fetching Phabricator repos\", \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\terr = updatePhabRepos(ctx, repos)\n\t\t\tif err != nil {\n\t\t\t\tlog15.Error(\"Error updating Phabricator repos\", \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tcfg, err := phab.Configuration()\n\t\t\tif err != nil {\n\t\t\t\tlog15.Error(\"failed to parse Phabricator config\", \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tphabricatorUpdateTime.WithLabelValues(\n\t\t\t\tcfg.(*schema.PhabricatorConnection).Url,\n\t\t\t).Set(float64(time.Now().Unix()))\n\t\t}\n\n\t\ttime.Sleep(GetUpdateInterval())\n\t}\n}", "func (c *Client) Run() {\n\tctx, cancel := context.WithCancel(context.Background())\n\t// TODO: Possibly switch these to prioritize select statements\n\t// to handle case where backupper returns an error\n\t// https://stackoverflow.com/questions/46200343/force-priority-of-go-select-statement/46202533#46202533\n\tgo func() {\n\t\tc.Backupper.Run(ctx)\n\t}()\n\n\tgo func() {\n\t\tfor msg := range c.Conn.Read() {\n\t\t\tc.Broadcaster.Broadcast() <- &broker.Message{Payload: msg}\n\n\t\t\tc.Backupper.Hold(msg)\n\t\t}\n\t\tc.Broadcaster.Unregister() <- c.Receive // shutdown the client because the connection was closed\n\t}()\n\n\tgo func() {\n\t\tfor bmsg := range c.Receive {\n\t\t\tc.Conn.Write() <- bmsg.Payload.(*Message)\n\t\t}\n\t\tcancel()\n\t}()\n}", "func (t *TestRun) Run() {\n\tstartedAt := time.Now()\n\n\tlog.Printf(\"Spawning %d clients\", t.ConcurrencyLevel)\n\tt.waiting.Add(t.ConcurrencyLevel)\n\tfor i := 0; i < t.ConcurrencyLevel; i++ {\n\t\tgo t.startWorker(i)\n\t}\n\tt.waiting.Wait()\n\n\tduration := time.Since(startedAt)\n\tlog.Printf(\"TESTRUN - FINISHED (took %dms %v)\", durationInMillis(duration), duration)\n}", "func (r *ReconciliationLoop) Run() error {\n\t/*\n\t* Ensure node state\n\t*\n\t* - Run prechecks to make sure the redis node is configured in cluster mode.\n\t* - Record cluster state\n\t* - Report state to manager\n\t* - Ask for optimal state\n\t* - Try to execute\n\t* - Go to record cluster state\n\t */\n\n\tvar precheckDone = make(chan bool)\n\n\tgo func() {\n\t\tif !r.skipPrechecks {\n\t\t\tr.prechecks()\n\t\t}\n\t\tprecheckDone <- true\n\t}()\n\n\tselect {\n\tcase <-r.done:\n\t\treturn nil\n\tcase <-time.After(pkg.PrecheckWaitDelay):\n\t\tlog.Warnf(\"Prechecks did not complete within %v\", pkg.PrecheckWaitDelay)\n\t\treturn nil\n\tcase <-precheckDone:\n\t\tlog.Infof(\"Prechecks passed, starting reconciler\")\n\t}\n\n\tgo r.collectScrape()\n\n\tfunc() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-r.done:\n\t\t\t\treturn\n\t\t\tcase <-time.After(pkg.ReconciliationLoopInterval):\n\t\t\t\terr := r.iteration()\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Warnf(\"ReconciliationLoop iteration error: %v\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn nil\n}", "func SendWorker(ch chan RemoteCommandMessage, broadlink broadlinkrm.Broadlink, wg *sync.WaitGroup) {\n\tfor msg := range ch {\n\t\tfor _, cmd := range msg.commands {\n\t\t\tswitch cmd.commandType {\n\t\t\tcase SendCommand:\n\t\t\t\terr := broadlink.Execute(cmd.target, cmd.data)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"Error executing command: %v\", err)\n\t\t\t\t}\n\t\t\tcase Pause:\n\t\t\t\tinterval, err := strconv.Atoi(cmd.data)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"Error processing pause interval (%v): %v\", cmd.data, err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\ttime.Sleep(time.Duration(interval) * time.Millisecond)\n\t\t\tcase shutdown:\n\t\t\t\twg.Done()\n\t\t\t\tlog.Print(\"SendWorker terminated\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (obj *Client) Run() {\n\tobj.SendAdminsAboutMe(dataKeys.KeyOnline)\n\tfor {\n\t\tst := dataKeys.Keys{}\n\t\terr := obj.Conn.ReadJSON(&st)\n\t\tif err != nil {\n\t\t\tlog.Println(\"stop from run\")\n\t\t\tobj.Stop(err)\n\t\t\tbreak\n\t\t}\n\t\tlog.Printf(\"%+v\", st)\n\t}\n}", "func (lbc *loadBalancerController) worker() {\n\tfor {\n\t\tkey, _ := lbc.queue.Get()\n\t\tglog.Infof(\"Sync triggered by service %v\", key)\n\t\tif err := lbc.sync(false); err != nil {\n\t\t\tglog.Infof(\"Requeuing %v because of error: %v\", key, err)\n\t\t\tlbc.queue.Add(key)\n\t\t} else {\n\t\t\tlbc.queue.Done(key)\n\t\t}\n\t}\n}", "func Worker(mapf MapF, reducef ReduceF) {\n\tfor {\n\t\treply := GetWorkReply{}\n\t\tif !call(\"Coordinator.GetWork\", &GetWorkArgs{}, &reply) {\n\t\t\ttime.Sleep(ERROR_TIMEOUT)\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch reply.Type {\n\t\tcase Map:\n\t\t\terr := runMap(mapf, reply.MapWorkload)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\targs := WorkDoneArgs{\n\t\t\t\tType: Map,\n\t\t\t\tId: reply.MapWorkload.Id,\n\t\t\t}\n\t\t\tif !call(\"Coordinator.WorkDone\", &args, &WorkDoneReply{}) {\n\t\t\t\ttime.Sleep(ERROR_TIMEOUT)\n\t\t\t}\n\t\tcase Reduce:\n\t\t\terr := runReduce(reducef, reply.ReduceWorkload)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\targs := WorkDoneArgs{\n\t\t\t\tType: Reduce,\n\t\t\t\tId: reply.ReduceWorkload.Hash,\n\t\t\t}\n\t\t\tif !call(\"Coordinator.WorkDone\", &args, &WorkDoneReply{}) {\n\t\t\t\ttime.Sleep(ERROR_TIMEOUT)\n\t\t\t}\n\t\tcase Saturated:\n\t\t\ttime.Sleep(SATURATED_TIMEOUT)\n\t\tcase None:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (r *serverThree) Run() {\n\tr.state = RstateRunning\n\n\t// event handling is a NOP in this model\n\trxcallback := func(ev EventInterface) int {\n\t\tassert(r == ev.GetTarget())\n\t\tlog(LogV, \"rxcallback\", r.String(), ev.String())\n\n\t\trealevent, ok := ev.(*TimedUniqueEvent)\n\t\tassert(ok)\n\n\t\t// send the response\n\t\tgwysrc := ev.GetSource()\n\t\tat := clusterTripPlusRandom()\n\t\tevresponse := newTimedUniqueEvent(r, at, gwysrc, realevent.id)\n\t\tr.Send(evresponse, SmethodWait)\n\t\treturn 0\n\t}\n\n\tgo func() {\n\t\tfor r.state == RstateRunning {\n\t\t\tr.receiveEnqueue()\n\t\t\ttime.Sleep(time.Microsecond)\n\t\t\tr.processPendingEvents(rxcallback)\n\t\t}\n\t}()\n}", "func (c *Client) Run() {\n\tfor {\n\t\tselect {\n\t\tcase conn := <-c.register:\n\t\t\tc.connections[conn] = true\n\t\t\tgo conn.writePump()\n\t\t\tgo conn.readPump()\n\t\tcase conn := <-c.unregister:\n\t\t\tif _, ok := c.connections[conn]; ok {\n\t\t\t\tdelete(c.connections, conn)\n\t\t\t\tclose(conn.send)\n\t\t\t\tif len(c.connections) <= 0 {\n\t\t\t\t\tc.hub.unregister <- c.id\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\tcase incomingMessage := <-c.outbox:\n\t\t\tc.hub.messages <- incomingMessage\n\t\tcase outcomingMessage := <-c.inbox:\n\t\t\tfor conn := range c.connections {\n\t\t\t\tmsgBytes, err := outcomingMessage.GetData()\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"invalid message data\")\n\t\t\t\t} else {\n\t\t\t\t\tconn.send <- msgBytes\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (r *serverOneDotOne) Run() {\n\tr.state = RstateRunning\n\n\t// event handling is a NOP in this model\n\trxcallback := func(ev EventInterface) int {\n\t\tassert(r == ev.GetTarget())\n\t\tlog(LogVV, \"proc-ed\", ev.String())\n\t\treturn 0\n\t}\n\n\tgo func() {\n\t\tfor r.state == RstateRunning {\n\t\t\tr.receiveEnqueue()\n\t\t\ttime.Sleep(time.Microsecond)\n\t\t\tr.processPendingEvents(rxcallback)\n\t\t}\n\t}()\n}", "func (gen *Generator) Run(workers int, stopCh <-chan struct{}) {\n\tlogger := gen.log\n\tdefer utilruntime.HandleCrash()\n\tlogger.Info(\"start\")\n\tdefer logger.Info(\"shutting down\")\n\n\tif !cache.WaitForCacheSync(stopCh, gen.reportReqSynced, gen.clusterReportReqSynced, gen.cpolListerSynced, gen.polListerSynced) {\n\t\tlogger.Info(\"failed to sync informer cache\")\n\t}\n\n\tfor i := 0; i < workers; i++ {\n\t\tgo wait.Until(gen.runWorker, time.Second, stopCh)\n\t}\n\n\tgo gen.requestCreator.run(stopCh)\n\n\t<-stopCh\n}", "func (m *etcdMinion) periodicRunner() {\n\tschedule := time.Minute * 5\n\tticker := time.NewTicker(schedule)\n\tlog.Printf(\"Periodic scheduler set to run every %s\\n\", schedule)\n\n\tfor {\n\t\tselect {\n\t\tcase <-m.done:\n\t\t\tbreak\n\t\tcase now := <-ticker.C:\n\t\t\t// Run periodic jobs\n\t\t\tm.classify()\n\t\t\tm.checkQueue()\n\t\t\tm.SetLastseen(now.Unix())\n\t\t}\n\t}\n}", "func (p *Pool) Run(w Worker) {\n p.job <- w\n}", "func (s *Server) Worker(queue *Queue, srv Server_SubscribeServer) {\n\t// temp imitate unsibscribe\n\tvar exit = make(chan (struct{}))\n\ttime.AfterFunc(time.Second*10, func() { exit <- struct{}{} })\n\n\tfor {\n\t\tselect {\n\t\tcase <-exit:\n\t\t\tfmt.Println(\"Exit\")\n\t\t\ts.wg.Done()\n\t\t\treturn\n\t\tdefault:\n\t\t\tif queue.messages.Len() > 0 {\n\t\t\t\tel := queue.messages.Back()\n\t\t\t\tval := el.Value\n\n\t\t\t\tmessage, ok := val.(*Message)\n\t\t\t\tif ok {\n\t\t\t\t\tresp := &SubscribeResponse{QueueName: queue.queueName, Message: message}\n\n\t\t\t\t\tif err := srv.Send(resp); err != nil {\n\t\t\t\t\t\tfmt.Println(err)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tqueue.messages.Remove(el)\n\t\t\t}\n\t\t}\n\t}\n\n}", "func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer utilruntime.HandleCrash()\n\tdefer c.queue.ShutDown()\n\n\tif ok := cache.WaitForCacheSync(stopCh, c.synced, c.synced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\t<-stopCh\n\n\treturn nil\n}", "func Worker(mapf func(string, string) []KeyValue,\n\treducef func(string, []string) string) {\n\n\t// Your worker implementation here.\n\n\t// uncomment to send the Example RPC to the master.\n\t// CallExample()\n\n\tcallSuccess, taskSuccess, taskType, taskNumber := GetTask(mapf, reducef)\n\ttime.Sleep(time.Second)\n\tnotifySuccess := NotifyTaskStatus(taskSuccess, taskType, taskNumber)\n\n\tfor (callSuccess && notifySuccess) {\n\t\tcallSuccess, taskSuccess, taskType, taskNumber = GetTask(mapf, reducef)\n\t\ttime.Sleep(time.Second)\n\t\tnotifySuccess = NotifyTaskStatus(taskSuccess, taskType, taskNumber)\n\t}\n}", "func Worker(mapf func(string, string) []KeyValue,\n\treducef func(string, []string) string) {\n\n\t// Your worker implementation here.\n\tfor {\n\t\ttime.Sleep(time.Second)\n\n\t\treq := GetTaskReq{}\n\t\treq.No = 1\n\t\trsp := GetTaskRsp{}\n\t\tok := call(\"Master.GetTask\", &req, &rsp)\n\t\tif ok {\n\t\t\tfmt.Println(rsp.Status, rsp.TaskID, len(rsp.Filename) > 0)\n\t\t\tif rsp.Status == \"Wait\" {\n\t\t\t\t// do nothing\n\t\t\t} else if rsp.Status == \"Task\" {\n\t\t\t\tdoTask(&req, &rsp, mapf, reducef)\n\t\t\t} else if rsp.Status == \"Exit\" {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"unknow status\\n\")\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(\"rpc error\")\n\t\t}\n\n\t}\n\t// uncomment to send the Example RPC to the master.\n\tCallExample()\n\n}", "func (client *TimeClient) worker() {\n\tclient.locker.Lock()\n\tif client.running {\n\t\tclient.locker.Unlock()\n\t\treturn\n\t}\n\tclient.running = true\n\tclient.locker.Unlock()\n\ttimeout := time.Duration(1)\n\n\tfor {\n\t\tselect {\n\t\tcase <-client.stopChannel:\n\t\t\tbreak\n\t\tcase <-time.After(timeout):\n\t\t\t// run the client\n\t\t\terr, errcode, timeresp := client.getTime()\n\t\t\ttimeout = client.checkTimeInterval\n\t\t\tif err != nil {\n\t\t\t\tif client.backingOff {\n\t\t\t\t\tclient.backoff = client.backoff * time.Duration(2)\n\t\t\t\t} else {\n\t\t\t\t\tclient.backoff = initialBackoff\n\t\t\t\t}\n\t\t\t\tif client.backoff > maxBackoff {\n\t\t\t\t\tclient.backoff = maxBackoff\n\t\t\t\t}\n\t\t\t\tclient.backingOff = true\n\t\t\t\ttimeout = client.backoff\n\t\t\t\t// analyze errors and send to status channel\n\t\t\t\tclient.sendToStatusChannel(errcode)\n\t\t\t} else {\n\t\t\t\tclient.backingOff = false\n\t\t\t\tclient.backoff = 0\n\t\t\t\tclient.locker.Lock()\n\t\t\t\ttimeout = client.checkTimeInterval\n\t\t\t\tclient.locker.Unlock()\n\n\t\t\t\t// set the time\n\t\t\t\tif timeresp.Time > recentTime {\n\t\t\t\t\ttimespec := timeToTimeval(timeresp.Time)\n\t\t\t\t\tnow := time.Now().UnixNano() / 1000000\n\t\t\t\t\tlog.MaestroInfof(\"Time: time being adjusted. Skew is %d ms\\n\", now-timeresp.Time)\n\t\t\t\t\tif client.pretend {\n\t\t\t\t\t\tlog.MaestroInfof(\"Time: time would be set to %d s %d us - but prentending only.\\n\", timespec.Sec, timespec.Usec)\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrno := syscall.Settimeofday(&timespec)\n\t\t\t\t\t\tif errno != nil {\n\t\t\t\t\t\t\tlog.MaestroErrorf(\"Time: settimeofday failed: %s\\n\", errno.Error())\n\t\t\t\t\t\t\tclient.sendToStatusChannel(SycallFailed)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tlog.MaestroSuccess(\"Time: time of day updated.\")\n\t\t\t\t\t\t\tclient.sendToStatusChannel(SetTimeOk)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlog.MaestroErrorf(\"Time server reported INSANE time value (%ld) - ignoring.\\n\", timeresp.Time)\n\t\t\t\t\tclient.sendToStatusChannel(InsaneResponse)\n\t\t\t\t}\n\t\t\t\t// send to status channel\n\t\t\t}\n\t\t}\n\t}\n\n\tclient.locker.Lock()\n\tclient.running = false\n\tclient.locker.Unlock()\n}", "func (c *ClusterQuotaReconcilationController) Run(workers int, stopCh <-chan struct{}) {\n\tdefer utilruntime.HandleCrash()\n\n\t// Wait for the stores to sync before starting any work in this controller.\n\tready := make(chan struct{})\n\tgo c.waitForSyncedStores(ready, stopCh)\n\tselect {\n\tcase <-ready:\n\tcase <-stopCh:\n\t\treturn\n\t}\n\tglog.V(4).Infof(\"Starting the cluster quota reconcilation controller workers\")\n\n\t// the controllers that replenish other resources to respond rapidly to state changes\n\tfor _, replenishmentController := range c.replenishmentControllers {\n\t\tgo replenishmentController.Run(stopCh)\n\t}\n\n\t// the workers that chug through the quota calculation backlog\n\tfor i := 0; i < workers; i++ {\n\t\tgo wait.Until(c.worker, time.Second, stopCh)\n\t}\n\n\t// the timer for how often we do a full recalculation across all quotas\n\tgo wait.Until(func() { c.calculateAll() }, c.resyncPeriod, stopCh)\n\n\t<-stopCh\n\tglog.Infof(\"Shutting down ClusterQuotaReconcilationController\")\n\tc.queue.ShutDown()\n}", "func (c *Controller) Run(stop <-chan struct{}) {\n\t// Catch crash and log an error.\n\tdefer runtime.HandleCrash()\n\t// Shutdown after all goroutines have finished handling\n\t// existing items.\n\tdefer c.queue.ShutDown()\n\n\t// Start listing and watching resource changes.\n\tgo c.informer.Run(stop)\n\n\t// Do a cache sync.\n\tif !cache.WaitForCacheSync(stop, c.HasSynced) {\n\t\truntime.HandleError(fmt.Errorf(\"error syncing cached\"))\n\t\treturn\n\t}\n\n\twait.Until(c.runWorker, time.Second, stop)\n}", "func (c *Controller) Run(workers int, stopCh <-chan struct{}) error {\n\t// Start the informer factories to begin populating the informer caches\n\tlog.Info(\"Starting collector controller\")\n\tdefer log.Info(\"Shutting down collector controller\")\n\n\tif len(c.remoteClient.InfluxDB) > 0 {\n\t\t// Check if database for project existed, if not, just create\n\t\tquery := influxapi.Query{\n\t\t\tCommand: \"create database \" + monitorutil.ProjectDatabaseName,\n\t\t\tDatabase: monitorutil.ProjectDatabaseName,\n\t\t}\n\t\t// Wait unitl influxdb is OK\n\t\t_ = wait.PollImmediateInfinite(10*time.Second, func() (bool, error) {\n\t\t\tfor _, client := range c.remoteClient.InfluxDB {\n\t\t\t\tlog.Debugf(\"Query sql: %s\", query.Command)\n\t\t\t\tresp, err := client.Client.Query(query)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Errorf(\"Create database %s for %s failed: %v\", monitorutil.ProjectDatabaseName, client.Address, err)\n\t\t\t\t\treturn false, nil\n\t\t\t\t} else if resp.Error() != nil {\n\t\t\t\t\tlog.Errorf(\"Create database %s for %s failed: %v\", monitorutil.ProjectDatabaseName, client.Address, resp.Error())\n\t\t\t\t\treturn false, nil\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.Info(\"Created database projects in influxdb\")\n\t\t\treturn true, nil\n\t\t})\n\t}\n\n\tdefer runtime.HandleCrash()\n\tdefer c.queue.ShutDown()\n\n\tif ok := cache.WaitForCacheSync(stopCh, c.listerSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for cluster caches to sync\")\n\t}\n\n\tc.stopCh = stopCh\n\n\tfor i := 0; i < workers; i++ {\n\t\tgo wait.Until(c.worker, time.Second, stopCh)\n\t}\n\n\t<-stopCh\n\treturn nil\n}", "func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer runtime.HandleCrash()\n\tdefer c.workqueue.ShutDown()\n\n\tglog.Info(\"start network control loop\")\n\tglog.Info(\"waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.networksSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\tglog.Info(\"start workers\")\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\tglog.Info(\"started workers\")\n\t<-stopCh\n\tglog.Info(\"shutting down workers\")\n\treturn nil\n}" ]
[ "0.65198463", "0.6371653", "0.63588005", "0.6302773", "0.62866783", "0.6262516", "0.62587476", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6237947", "0.6199254", "0.61887556", "0.61864537", "0.617542", "0.6147252", "0.6136679", "0.61069155", "0.6077725", "0.60722476", "0.606775", "0.606775", "0.606775", "0.6066505", "0.5999045", "0.599792", "0.5976905", "0.59720725", "0.5963125", "0.5885706", "0.58835775", "0.5879048", "0.58746785", "0.5857544", "0.5834955", "0.58311087", "0.58036107", "0.577514", "0.5768521", "0.57522494", "0.5751829", "0.57501704", "0.573471", "0.5734271", "0.57131314", "0.57001907", "0.56967545", "0.5668737", "0.56590563", "0.5657571", "0.56547135", "0.5651659", "0.5646965", "0.5640806", "0.5616188", "0.5604004", "0.56023586", "0.560073", "0.55950814", "0.5593053", "0.55887663", "0.5586947", "0.5574272", "0.5562839", "0.55624294", "0.5545554", "0.5543963", "0.5542316", "0.5539397", "0.5538003", "0.55286276", "0.55272675", "0.55248135", "0.5522407", "0.5517578", "0.5511746", "0.5491858", "0.5479861", "0.5475854", "0.5464606", "0.54632366", "0.54555637", "0.5454278", "0.54516727", "0.54499733", "0.54493165" ]
0.58920133
43
InExecutingState returns true if the worker is executing an action, or still needs to successfully synchronize against the scheduler to communicate the completion of an action. If this function returns false, it is safe for the worker to stop synchronizing against the scheduler without causing any operations to fail.
func (bc *BuildClient) InExecutingState() bool { return bc.inExecutingState }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (i *invocation) isActive() bool {\n\treturn i.queuedOperations.Len() > 0 || i.executingWorkersCount > 0\n}", "func (state *State) Running() bool {\n\treturn *(*uint32)(state) == 1\n}", "func (s *Scheduler) Running() bool {\n\ts.mutex.RLock()\n\tdefer s.mutex.RUnlock()\n\treturn s.running\n}", "func (co *CompositeOperator) IsSuspended(ctx context.Context, obj client.Object) bool {\n\tctx, span, _, _ := co.inst.Start(ctx, \"IsSuspended\")\n\tdefer span.End()\n\n\treturn co.isSuspended(ctx, obj)\n}", "func (t *task) IsRunning() bool {\n\treturn t.running\n}", "func (t ResolvedPipelineRunTask) IsRunning() bool {\n\tif t.IsCustomTask() {\n\t\tif t.Run == nil {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\tif t.TaskRun == nil {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn !t.IsSuccessful() && !t.IsFailure() && !t.IsCancelled()\n}", "func (s *scheduler) IsRunning() bool {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\n\treturn s.isRunning\n}", "func (w *worker) isRunning() bool {\n\treturn atomic.LoadInt32(&w.running) == 1\n}", "func (s *SegmentUpdateWorker) IsRunning() bool {\n\treturn s.lifecycle.IsRunning()\n}", "func (sc *ConditionsScraper) Running() bool {\n\treturn sc.running\n}", "func (o *Outbound) IsRunning() bool {\n\treturn o.once.IsRunning()\n}", "func (e *executor) IsCompleted() bool {\n\tif len(e.executables) < 1 {\n\t\treturn false\n\t}\n\n\tfor _, exec := range e.executables {\n\t\tif exec.IsCompleted() {\n\t\t\tcontinue\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}", "func (n *Node) Running() bool {\n\tn.opMx.RLock()\n\tdefer n.opMx.RUnlock()\n\treturn n.running\n}", "func (r *VmwareMapper) RunningState() bool {\n\treturn false\n}", "func (m *WebsocketRoutineManager) IsRunning() bool {\n\tif m == nil {\n\t\treturn false\n\t}\n\treturn atomic.LoadInt32(&m.state) == readyState\n}", "func (s *server) Running() bool {\n\ts.mutex.RLock()\n\tdefer s.mutex.RUnlock()\n\treturn (s.state != Stopped && s.state != Initialized)\n}", "func (s StackStatus) InProgress() bool {\n\treturn strings.HasSuffix(string(s), \"IN_PROGRESS\")\n}", "func (r *RecordStream) Running() bool { return r.state == running }", "func (task Task) IsStarted() bool {\n\treturn task.Status != TaskScheduled\n}", "func (b *Build) IsRunning() bool {\n\treturn (b.Status == StatusStarted || b.Status == StatusEnqueue)\n}", "func (p *adapter) Running() bool {\n\tif p.cmd == nil || p.cmd.Process == nil || p.cmd.Process.Pid == 0 || p.state() != nil {\n\t\treturn false\n\t}\n\treturn true\n}", "func (b *Bar) InProgress() bool {\n\treturn !isClosed(b.done)\n}", "func (m *Machine) IsRunningSwarmingTask() bool {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\treturn m.runningTask\n}", "func (bc *BotCommand) isRunning() bool {\n\tbc.Lock()\n\tdefer bc.Unlock()\n\treturn bc.running\n}", "func (i *Inbound) IsRunning() bool {\n\treturn i.once.IsRunning()\n}", "func IsTaskRunning() bool {\n\treturn persist.HasValue(taskPayloadKey)\n}", "func (c *Consumer) IsRunning() bool {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\n\treturn c.running\n}", "func (c *Collection) Running() bool {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\n\treturn c.running\n}", "func (t ResolvedPipelineRunTask) IsStarted() bool {\n\tif t.IsCustomTask() {\n\t\treturn t.Run != nil && t.Run.Status.GetCondition(apis.ConditionSucceeded) != nil\n\n\t}\n\treturn t.TaskRun != nil && t.TaskRun.Status.GetCondition(apis.ConditionSucceeded) != nil\n}", "func (wf *Workflow) IsRunning() bool {\n\treturn wf.running\n}", "func (s *Service) Running() bool {\n\tif m := s.mgr; m == nil {\n\t\treturn false\n\t} else {\n\t\tm.lock()\n\t\trv := s.running && !s.stopping\n\t\tm.unlock()\n\t\treturn rv\n\t}\n}", "func (b *Backtest) IsRunning() (ret bool) {\n\treturn b.running\n}", "func (o DrillStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v DrillStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (scheduler *Scheduler) IsRunning() bool {\n\treturn atomic.LoadInt32(&scheduler.isRunning) == 1\n}", "func (t *Task) IsStatusProcessing() bool {\n\treturn t.Status == taskStatusProcessing\n}", "func (w *worker) isRunningCorrectTask(actionDigest *remoteexecution.Digest) bool {\n\tt := w.currentTask\n\tif t == nil {\n\t\treturn false\n\t}\n\tdesiredDigest := t.desiredState.ActionDigest\n\treturn proto.Equal(actionDigest, desiredDigest)\n}", "func (db *Database) CompactionRunning() bool {\n\tif db.compactionRunningFunc == nil {\n\t\treturn false\n\t}\n\n\treturn db.compactionRunningFunc()\n}", "func (s *Streamer) IsRunning() bool {\n\ts.mu.Lock()\n\tisRunning := s.state == stateRunning\n\ts.mu.Unlock()\n\n\treturn isRunning\n}", "func (s *Scanner) IsRunning() bool {\n\treturn s.state == running\n}", "func (o PgbenchStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v PgbenchStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (n *Node) IsTransactionQueued(ctx context.Context, id hash.Hash) (bool, error) {\n\t// Check if we are a leader. Note that we may be in the middle of a\n\t// transition, but this shouldn't matter as the client will retry.\n\tif !n.commonNode.Group.GetEpochSnapshot().IsTransactionSchedulerLeader() {\n\t\treturn false, api.ErrNotLeader\n\t}\n\n\tn.algorithmMutex.RLock()\n\tdefer n.algorithmMutex.RUnlock()\n\n\tif n.algorithm == nil || !n.algorithm.IsInitialized() {\n\t\treturn false, api.ErrNotReady\n\t}\n\treturn n.algorithm.IsQueued(id), nil\n}", "func (task *Task) IsScheduled() bool {\n\tif task.State != statuses.TaskStateActive {\n\t\treturn false\n\t}\n\treturn task.IsRecurringlyScheduled() || task.Schedule.Regularity == apiModels.OneTime\n}", "func (t ResolvedPipelineRunTask) IsCancelled() bool {\n\tif t.IsCustomTask() {\n\t\tif t.Run == nil {\n\t\t\treturn false\n\t\t}\n\t\tc := t.Run.Status.GetCondition(apis.ConditionSucceeded)\n\t\treturn c != nil && c.IsFalse() && c.Reason == v1alpha1.RunReasonCancelled\n\t}\n\tif t.TaskRun == nil {\n\t\treturn false\n\t}\n\tc := t.TaskRun.Status.GetCondition(apis.ConditionSucceeded)\n\treturn c != nil && c.IsFalse() && c.Reason == v1beta1.TaskRunReasonCancelled.String()\n}", "func (o *ChannelOutbound) IsRunning() bool {\n\treturn o.once.IsRunning()\n}", "func (q *ExecutionBroker) notConfirmedPending() bool {\n\treturn q.pending == insolar.InPending && !q.PendingConfirmed\n}", "func (m *TimerMutation) IsRunning() (r bool, exists bool) {\n\tv := m._IsRunning\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func IsDone(s State) bool {\n\treturn s != State_PENDING && s != State_RUNNING\n}", "func isStackSetOperationInProgress(s string) bool {\n\treturn strings.Contains(s, cloudformation.ErrCodeOperationInProgressException)\n}", "func (p *AbstractRunProvider) IsRunning() bool {\n\treturn p.running\n}", "func (transmuxer *Transmuxer) IsRunning() bool {\n\treturn transmuxer.running\n}", "func running() bool {\n\treturn runCalled.Load() != 0\n}", "func (o Iperf3StatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v Iperf3Status) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (t *DeferredRecordingTaskImpl) IsRunning() bool {\n\treturn t.task.IsRunning()\n}", "func (o IopingStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v IopingStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (w *Worker) Online() bool {\n\treturn w.s != nil\n}", "func (r *Runner) IsRunning(id string) bool {\n\tr.rw.RLock()\n\tdefer r.rw.RUnlock()\n\t_, ok := r.jobsCancel[id]\n\n\treturn ok\n}", "func (p *promise) IsDelivered() bool {\n\treturn p.result.Load() != nil\n}", "func (o SysbenchStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v SysbenchStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (o QperfStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v QperfStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (i *Intel8080) Running() bool {\n\treturn !i.halted\n}", "func (async *async) isPending() bool {\n\tstate := atomic.LoadUint32(&async.state)\n\treturn state == pending\n}", "func (self *BaseActor) IsRunning() bool {\n\tself.mu.RLock()\n\tdefer self.mu.RUnlock()\n\n\treturn self.isRunning\n}", "func (b *base) IsRunning() bool {\n\treturn b.isRunning\n}", "func (p *procBase) Running() bool {\n\treturn p.cmd != nil\n}", "func (r *Router) IsRunning() bool {\n\tselect {\n\tcase <-r.running:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (th *transitionHandler) IsPreparingTimedOut(sw stateswitch.StateSwitch, args stateswitch.TransitionArgs) (bool, error) {\n\tsCluster, ok := sw.(*stateCluster)\n\tif !ok {\n\t\treturn false, errors.New(\"IsPreparingTimedOut incompatible type of StateSwitch\")\n\t}\n\t// can happen if the service was rebooted or somehow the async part crashed.\n\tif time.Since(time.Time(sCluster.cluster.StatusUpdatedAt)) > th.prepareConfig.InstallationTimeout {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (task *Task) IsRunAsUserApplied() bool {\n\treturn nil != task.Credentials\n}", "func (th *transitionHandler) IsPreparingTimedOut(sw stateswitch.StateSwitch, args stateswitch.TransitionArgs) (bool, error) {\n\tsCluster, ok := sw.(*stateCluster)\n\tif !ok {\n\t\treturn false, errors.New(\"IsPreparingTimedOut incompatible type of StateSwitch\")\n\t}\n\t// can happen if the service was rebooted or somehow the async part crashed.\n\tif time.Since(time.Time(sCluster.cluster.StatusUpdatedAt)) > th.prepareConfig.PrepareForInstallationTimeout {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (e *Engine) Running() bool {\n\treturn e.running\n}", "func (s *Sync) IsInterrupted() bool {\n\tselect {\n\tcase <-s.grp.Ch():\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func (internal *mInternal) IsCommitted() bool {\n\tinternal.mu.Lock()\n\tdefer internal.mu.Unlock()\n\treturn internal.committed\n}", "func (e *ProgramChangeEvent) RunningStatus() bool {\n\treturn e.runningStatus\n}", "func (ti TaskInstance) IsScheduled() bool {\n\tvar disabledCount int\n\n\tfor _, status := range ti.Statuses {\n\t\tif status == statuses.TaskInstanceDisabled {\n\t\t\tdisabledCount++\n\t\t\tcontinue\n\t\t}\n\n\t\tif status == statuses.TaskInstanceScheduled {\n\t\t\t// FIX: RMM-36676\n\t\t\treturn true\n\t\t}\n\t\tbreak\n\t}\n\treturn len(ti.Statuses) == disabledCount\n}", "func (s *Syncer) Called() bool {\n\treturn s.called\n}", "func (o Outcome) IsFinished() bool { return o.Reason != notCompleted }", "func (c *CleanupStatusTracker) InProgress(bdName string) bool {\n\treturn c.JobController.IsCleaningJobRunning(bdName)\n}", "func (o FioStatusOutput) Running() pulumi.BoolOutput {\n\treturn o.ApplyT(func(v FioStatus) bool { return v.Running }).(pulumi.BoolOutput)\n}", "func (r *Radio) IsRunning() bool {\n\tr.Lock()\n\trunning := r.running\n\tr.Unlock()\n\treturn running\n}", "func (async *async) isCompleted() bool {\n\tstate := atomic.LoadUint32(&async.state)\n\treturn state == completed\n}", "func (ms *StatusImpl) IsCommitted() bool {\n\tms.mutex.Lock()\n\tdefer ms.mutex.Unlock()\n\n\tif ms.systemChannel {\n\t\treturn ms.state == orderer.ConsensusType_MIG_STATE_COMMIT\n\t}\n\n\treturn false\n}", "func (obj *trans) IsAtomic() bool {\n\treturn obj.isAtomic\n}", "func (cs cmdStatus) isDone() bool {\n\treturn cs&(1<<12 /*busy*/) == 0\n}", "func (h *Module) IsRunning()bool{\n\treturn h.running\n}", "func isEligibleForExecution(sensor *v1alpha1.Sensor, logger *logrus.Logger) (bool, error) {\n\tif sensor.Spec.ErrorOnFailedRound && sensor.Status.TriggerCycleStatus == v1alpha1.TriggerCycleFailure {\n\t\treturn false, errors.Errorf(\"last trigger cycle was a failure and sensor policy is set to ErrorOnFailedRound, so won't process the triggers\")\n\t}\n\tif sensor.Spec.Circuit != \"\" && sensor.Spec.DependencyGroups != nil {\n\t\treturn dependencies.ResolveCircuit(sensor, logger)\n\t}\n\tif ok := sensor.AreAllNodesSuccess(v1alpha1.NodeTypeEventDependency); ok {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (c *Concurrent) isExecutable(e interface{}) bool {\n\treturn reflect.TypeOf(e).Kind() == reflect.Func\n}", "func InTheFuture(ctx context.Context, t time.Time) bool {\n\tnow, err := BlockTime(ctx)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"%+v\", err))\n\t}\n\treturn t.After(now)\n}", "func (wce WaitingChaosEvent) AsExecutingFaultsChaosEvent() (*ExecutingFaultsChaosEvent, bool) {\n\treturn nil, false\n}", "func (t NodeType) IsExecutable() bool {\n\treturn t > execBegin && t < execEnd\n}", "func (m *TrxMgr) isProcessingTrx(trx *prototype.SignedTransaction) *TrxEntry {\n\tm.waitingLock.RLock()\n\tdefer m.waitingLock.RUnlock()\n\tm.fetchedLock.RLock()\n\tdefer m.fetchedLock.RUnlock()\n\treturn m.isProcessingNoLock(trx)\n}", "func IsStalled(from Getter) bool {\n\treturn !IsTrue(from, meta.ReconcilingCondition) && IsTrue(from, meta.StalledCondition)\n}", "func (bc *BuildClient) Run() error {\n\t// When executing an action, see if there are any updates on the\n\t// execution state.\n\tif bc.executionCancellation != nil {\n\t\ttimer, timerChannel := bc.clock.NewTimer(bc.nextSynchronizationAt.Sub(bc.clock.Now()))\n\t\tselect {\n\t\tcase <-timerChannel:\n\t\t\t// No meaningful updates. Send the last update\n\t\t\t// once again.\n\t\tcase update := <-bc.executionUpdates:\n\t\t\t// One or more execution updates available. Send\n\t\t\t// a new update with the latest state.\n\t\t\ttimer.Stop()\n\t\t\tbc.applyExecutionUpdate(update)\n\t\t\tbc.consumeExecutionUpdatesNonBlocking()\n\t\t\tbc.nextSynchronizationAt = bc.clock.Now()\n\t\t}\n\t}\n\n\t// Inform scheduler of current worker state, potentially\n\t// requesting new work.\n\tresponse, err := bc.scheduler.Synchronize(context.Background(), &bc.request)\n\tif err != nil {\n\t\treturn util.StatusWrap(err, \"Failed to synchronize with scheduler\")\n\t}\n\n\t// Determine when we should contact the scheduler again in case\n\t// of no activity.\n\tnextSynchronizationAt := response.NextSynchronizationAt\n\tif err := nextSynchronizationAt.CheckValid(); err != nil {\n\t\treturn util.StatusWrap(err, \"Scheduler response contained invalid synchronization timestamp\")\n\t}\n\tbc.nextSynchronizationAt = nextSynchronizationAt.AsTime()\n\n\t// Apply desired state changes provided by the scheduler.\n\tif desiredState := response.DesiredState; desiredState != nil {\n\t\tswitch workerState := desiredState.WorkerState.(type) {\n\t\tcase *remoteworker.DesiredState_Executing_:\n\t\t\t// Scheduler is requesting us to execute the\n\t\t\t// next action, maybe forcing us to to stop\n\t\t\t// execution of the current build action.\n\t\t\tif err := bc.startExecution(workerState.Executing); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase *remoteworker.DesiredState_Idle:\n\t\t\t// Scheduler is forcing us to go back to idle.\n\t\t\tbc.stopExecution()\n\t\tdefault:\n\t\t\treturn status.Error(codes.Internal, \"Scheduler provided an unknown desired state\")\n\t\t}\n\t}\n\treturn nil\n}", "func IsReconciling(from Getter) bool {\n\treturn !IsTrue(from, meta.StalledCondition) && IsTrue(from, meta.ReconcilingCondition)\n}", "func (task *Task) IsWaiting() bool {\n\treturn task.status == TaskStatusWaiting\n}", "func (task *Task) IsActivatedTrigger() bool {\n\tnow := time.Now().UTC()\n\tif task.Schedule.EndRunTime.IsZero() { // its 'Never' task trigger\n\t\treturn task.RunTimeUTC.After(now)\n\t}\n\treturn task.Schedule.EndRunTime.Equal(task.RunTimeUTC) // when trigger is activated they are equal\n}", "func (i *Interval) IsRunning() bool {\n\treturn i.latch.IsRunning()\n}", "func (q *priorityLocalQueue) Started() bool {\n\treturn q.channel != nil\n}", "func (m *CPUMiner) IsMining() bool {\n\tm.Lock()\n\tdefer m.Unlock()\n\n\treturn m.started\n}", "func (j *isolatedJob) Execute(ctx context.Context) {\n\tif wasRunning := j.isRunning.Swap(true); wasRunning != nil && wasRunning.(bool) {\n\t\treturn\n\t}\n\tdefer j.isRunning.Store(false)\n\n\tj.Job.Execute(ctx)\n}", "func (a *Recorder) IsRunning() bool {\n\treturn atomic.LoadUint32(&a.isRunning) != 0\n}", "func (task Task) IsPaused() bool {\n\treturn task.Status != TaskPaused\n}" ]
[ "0.5905961", "0.5734211", "0.56579614", "0.5495739", "0.5458313", "0.53582", "0.53134084", "0.5310453", "0.53033215", "0.52937394", "0.52794194", "0.5269087", "0.5233215", "0.5215061", "0.5157463", "0.5146507", "0.5138153", "0.5115511", "0.5109179", "0.50924224", "0.5081532", "0.50744146", "0.5072365", "0.50688845", "0.5067532", "0.50551337", "0.50456023", "0.50199753", "0.5012038", "0.50011", "0.4999996", "0.49993414", "0.49792153", "0.4975111", "0.49738878", "0.49684873", "0.49680462", "0.49598518", "0.49437425", "0.49406132", "0.4939234", "0.49344048", "0.49241182", "0.4921515", "0.4920835", "0.49185613", "0.4915271", "0.4910508", "0.48846638", "0.4880473", "0.48799646", "0.48766923", "0.48735377", "0.48658577", "0.48589668", "0.48556864", "0.48520604", "0.4848412", "0.48464403", "0.48461083", "0.48448706", "0.48350078", "0.48349234", "0.48302606", "0.48282784", "0.48174143", "0.4807585", "0.48042735", "0.48024353", "0.48016232", "0.47961673", "0.47810102", "0.47792327", "0.47761357", "0.47757417", "0.47733328", "0.4757827", "0.47565463", "0.47451183", "0.47447747", "0.47360185", "0.47324234", "0.47286513", "0.47272152", "0.4726637", "0.47204885", "0.47197634", "0.47174916", "0.47050086", "0.47049037", "0.47001168", "0.4692659", "0.4692219", "0.4691578", "0.4686225", "0.46812886", "0.46768427", "0.4674723", "0.46744826", "0.46739087" ]
0.76145965
0
NewGetDeviceHealthParams creates a new GetDeviceHealthParams object with the default values initialized.
func NewGetDeviceHealthParams() *GetDeviceHealthParams { var () return &GetDeviceHealthParams{ timeout: cr.DefaultTimeout, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDeviceHealth()(*DeviceHealth) {\n m := &DeviceHealth{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func MockDeviceHealth(ctrlr *Controller) DeviceHealth {\n\th := MockDeviceHealthPB()\n\treturn DeviceHealth{\n\t\tTemp: h.Temp,\n\t\tTempWarnTime: h.Tempwarn,\n\t\tTempCritTime: h.Tempcrit,\n\t\tCtrlBusyTime: h.Ctrlbusy,\n\t\tPowerCycles: h.Powercycles,\n\t\tPowerOnHours: h.Poweronhours,\n\t\tUnsafeShutdowns: h.Unsafeshutdowns,\n\t\tMediaErrors: h.Mediaerrors,\n\t\tErrorLogEntries: h.Errorlogs,\n\t\tTempWarn: h.Tempwarning,\n\t\tAvailSpareWarn: h.Availspare,\n\t\tReliabilityWarn: h.Reliability,\n\t\tReadOnlyWarn: h.Readonly,\n\t\tVolatileWarn: h.Volatilemem,\n\t}\n}", "func NewDeviceHealthAttestationState()(*DeviceHealthAttestationState) {\n m := &DeviceHealthAttestationState{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func NewHealth() *Health {\n\treturn NewHealthOnPort(healthPort)\n}", "func New() *Health {\n\treturn &Health{\n\t\tStatus: StatusUnknown,\n\t\tDetails: make(map[string]interface{}),\n\t}\n}", "func NewHealth() *Health {\n\treturn &Health{\n\t\tcomponents: map[interface{}]*HealthComponentStatus{},\n\t}\n}", "func NewHealth(r router) *Health {\n\treturn &Health{\n\t\trouter: r,\n\t}\n}", "func NewHealth(\n\tstate Status,\n\tmessage string,\n) Health {\n\treturn Health{\n\t\tStatus: state,\n\t\tUrgency: UNKNOWN, // set by the owning Monitor\n\t\tTime: time.Now(),\n\t\tMessage: Message(message),\n\t\tDuration: 0,\n\t}\n}", "func NewHealth() Health {\n\treturn &health{\n\t\tlogger: logging.NewLogger(),\n\t}\n}", "func NewHealthGetOK() *HealthGetOK {\n\n\treturn &HealthGetOK{}\n}", "func NewGetDevicesAllParams() *GetDevicesAllParams {\n\tvar ()\n\treturn &GetDevicesAllParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetDeviceHealthParams) WithDeviceID(deviceID string) *GetDeviceHealthParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (a *HealthApiService) GetHealth(ctx _context.Context) ApiGetHealthRequest {\n\treturn ApiGetHealthRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "func New(opts ...Option) (*Health, error) {\n\th := &Health{\n\t\tchecks: make(map[string]Config),\n\t\ttp: trace.NewNoopTracerProvider(),\n\t\tmaxConcurrent: runtime.NumCPU(),\n\t}\n\n\tfor _, o := range opts {\n\t\tif err := o(h); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn h, nil\n}", "func NewHealthCheck(opt ...Option) *HealthCheck {\n\topts := GetOpts(opt...)\n\n\th := &HealthCheck{\n\t\tstatus: &healthStatus{},\n\t}\n\tif e, ok := opts[optionWithEngine].(*gin.Engine); ok {\n\t\th.Engine = e\n\t}\n\tif path, ok := opts[optionWithHealthPath].(string); ok {\n\t\th.HealthPath = path\n\t} else {\n\t\th.HealthPath = \"/ready\"\n\t}\n\tif handler, ok := opts[optionWithHealthHandler].(gin.HandlerFunc); ok {\n\t\th.Handler = handler\n\t} else {\n\t\th.Handler = h.DefaultHealthHandler()\n\t}\n\n\tif ticker, ok := opts[optionHealthTicker].(*time.Ticker); ok {\n\t\th.metricTicker = ticker\n\t} else {\n\t\th.metricTicker = time.NewTicker(DefaultHealthTickerDuration)\n\t}\n\n\treturn h\n}", "func NewTeamworkSoftwareUpdateHealth()(*TeamworkSoftwareUpdateHealth) {\n m := &TeamworkSoftwareUpdateHealth{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func NewGetPropertyDescriptorParams() *GetPropertyDescriptorParams {\n\treturn &GetPropertyDescriptorParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewManagedDeviceOverview()(*ManagedDeviceOverview) {\n m := &ManagedDeviceOverview{\n Entity: *NewEntity(),\n }\n return m\n}", "func getHealthParams(now time.Time, tg *structs.TaskGroup, isDeploy bool) (deadline time.Time, useChecks bool, minHealthyTime time.Duration) {\n\tif isDeploy {\n\t\tdeadline = now.Add(tg.Update.HealthyDeadline)\n\t\tminHealthyTime = tg.Update.MinHealthyTime\n\t\tuseChecks = tg.Update.HealthCheck == structs.UpdateStrategyHealthCheck_Checks\n\t} else {\n\t\tstrategy := tg.Migrate\n\t\tif strategy == nil {\n\t\t\t// For backwards compat with pre-0.8 allocations that\n\t\t\t// don't have a migrate strategy set.\n\t\t\tstrategy = structs.DefaultMigrateStrategy()\n\t\t}\n\n\t\tdeadline = now.Add(strategy.HealthyDeadline)\n\t\tminHealthyTime = strategy.MinHealthyTime\n\t\tuseChecks = strategy.HealthCheck == structs.MigrateStrategyHealthChecks\n\t}\n\treturn\n}", "func NewGetDevicesUnknownParams() *GetDevicesUnknownParams {\n\treturn &GetDevicesUnknownParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewDevicesGetModuleComponentCommandHistoryParams() *DevicesGetModuleComponentCommandHistoryParams {\n\tvar ()\n\treturn &DevicesGetModuleComponentCommandHistoryParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewHealthGetDefault(code int) *HealthGetDefault {\n\tif code <= 0 {\n\t\tcode = 500\n\t}\n\n\treturn &HealthGetDefault{\n\t\t_statusCode: code,\n\t}\n}", "func NewDeviceCreateParams() DeviceCreateParams {\n\n\treturn DeviceCreateParams{}\n}", "func NewHealth() *Health {\n\tconst vertexShader = `\n\t\t#version 410\n\n\t\tin vec4 coord;\n\t\tout vec2 tcoord;\n\n\t\tvoid main(void) {\n\t\t\tgl_Position = vec4(coord.xy, 0, 1);\n\t\t\ttcoord = coord.zw;\n\t\t}\n\t`\n\n\tconst fragmentShader = `\n\t\t#version 410\n\n\t\tin vec2 tcoord;\n\t\tuniform sampler2D tex;\n\t\tout vec4 frag_color;\n\n\t\tvoid main(void) {\n\t\t\tvec4 texel = texture(tex, tcoord);\n\t\t\tfrag_color = texel;\n\t\t}\n\t`\n\n\th := Health{}\n\n\th.program = createProgram(vertexShader, fragmentShader)\n\tbindAttribute(h.program, 0, \"coord\")\n\n\th.textureUniform = uniformLocation(h.program, \"tex\")\n\th.pointsVBO = newVBO()\n\th.drawableVAO = newPointsVAO(h.pointsVBO, 4)\n\n\trgba, _ := LoadImages([]string{\"textures/health.png\", \"textures/health-empty.png\"}, 16)\n\th.textureUnit = 4\n\tgl.ActiveTexture(uint32(gl.TEXTURE0 + h.textureUnit))\n\tgl.GenTextures(1, &h.texture)\n\tgl.BindTexture(gl.TEXTURE_2D, h.texture)\n\n\tgl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)\n\tgl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)\n\tgl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)\n\tgl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n\tgl.TexImage2D(\n\t\tgl.TEXTURE_2D,\n\t\t0,\n\t\tgl.RGBA,\n\t\tint32(rgba.Rect.Size().X),\n\t\tint32(rgba.Rect.Size().Y),\n\t\t0,\n\t\tgl.RGBA,\n\t\tgl.UNSIGNED_BYTE,\n\t\tgl.Ptr(rgba.Pix),\n\t)\n\n\tgl.GenerateMipmap(gl.TEXTURE_2D)\n\treturn &h\n}", "func (o *GetDeviceHealthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", o.DeviceID); 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 GetHealth(c *gin.Context) {\n\tservicer := c.MustGet(registry.ServiceKey).(registry.Servicer)\n\thealthCheckSearvice := servicer.NewHealthCheck()\n\n\tvar input model.HealthCheckSearchInput\n\n\terr := c.ShouldBindQuery(&input)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\toutput, err := healthCheckSearvice.GetHealth(input.ID)\n\tif err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, output)\n}", "func NewHealthFilter() Filter {\n\treturn &healthFilter{}\n}", "func NewHealthHealthContext(ctx context.Context, r *http.Request, service *goa.Service) (*HealthHealthContext, error) {\n\tvar err error\n\tresp := goa.ContextResponse(ctx)\n\tresp.Service = service\n\treq := goa.ContextRequest(ctx)\n\treq.Request = r\n\trctx := HealthHealthContext{Context: ctx, ResponseData: resp, RequestData: req}\n\treturn &rctx, err\n}", "func NewHealth(logger *log.Logger) health.Service {\n\treturn &healthsrvc{logger}\n}", "func NewHealthController(router *mux.Router, r *render.Render) *HealthController {\n\tctrl := &HealthController{router, r}\n\tctrl.Register()\n\treturn ctrl\n}", "func MockNvmeDeviceHealth(varIdx ...int32) *ctlpb.NvmeController_Health {\n\tnative := storage.MockNvmeDeviceHealth(varIdx...)\n\tpb := new(NvmeDeviceHealth)\n\n\tif err := pb.FromNative(native); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn pb.AsProto()\n}", "func (a *HyperflexApiService) GetHyperflexHealthList(ctx context.Context) ApiGetHyperflexHealthListRequest {\n\treturn ApiGetHyperflexHealthListRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "func NewGetProxiesHealthParams() *GetProxiesHealthParams {\n\treturn &GetProxiesHealthParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewDeviceHealthScriptBooleanParameter()(*DeviceHealthScriptBooleanParameter) {\n m := &DeviceHealthScriptBooleanParameter{\n DeviceHealthScriptParameter: *NewDeviceHealthScriptParameter(),\n }\n odataTypeValue := \"#microsoft.graph.deviceHealthScriptBooleanParameter\"\n m.SetOdataType(&odataTypeValue)\n return m\n}", "func NewUpdateDeviceParams() *UpdateDeviceParams {\n\tvar ()\n\treturn &UpdateDeviceParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewHealthController(service *goa.Service, zapi_list ZAPIStructure) *HealthController {\n\treturn &HealthController{\n\t\tController: service.NewController(\"HealthController\"),\n\t\tzapi_list: zapi_list,\n\t}\n}", "func (a *HyperflexApiService) GetHyperflexHealthByMoid(ctx context.Context, moid string) ApiGetHyperflexHealthByMoidRequest {\n\treturn ApiGetHyperflexHealthByMoidRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t\tmoid: moid,\n\t}\n}", "func GetHealth(c echo.Context) error {\n\tu := int(time.Since(helpers.StartTime).Seconds())\n\tuptime := &Health{\n\t\tStatus: \"ok\",\n\t\tUptime: u,\n\t}\n\n\treturn c.JSON(http.StatusOK, uptime)\n}", "func NewGetParams() *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewHealthCheck(rt *permissions.Runtime) operations.HealthCheckHandler {\n\treturn &healthCheck{}\n}", "func NewHealthCheck() jrpc2.Handler {\n\treturn handler.New(func(context.Context) HealthCheckResult {\n\t\treturn HealthCheckResult{Status: \"healthy\"}\n\t})\n}", "func NewGetDashboardConfigurationParams() *GetDashboardConfigurationParams {\n\n\treturn &GetDashboardConfigurationParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewHealthController(service *goa.Service) *HealthController {\n\treturn &HealthController{Controller: service.NewController(\"HealthController\")}\n}", "func New(transport runtime.ClientTransport, formats strfmt.Registry) *CiliumHealthAPI {\n\t// ensure nullable parameters have default\n\tif formats == nil {\n\t\tformats = strfmt.Default\n\t}\n\n\tcli := new(CiliumHealthAPI)\n\tcli.Transport = transport\n\tcli.Connectivity = connectivity.New(transport, formats)\n\tcli.Restapi = restapi.New(transport, formats)\n\treturn cli\n}", "func NewGetDevicesAllParamsWithTimeout(timeout time.Duration) *GetDevicesAllParams {\n\tvar ()\n\treturn &GetDevicesAllParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetHistogramStatByParams() *GetHistogramStatByParams {\n\tvar ()\n\treturn &GetHistogramStatByParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetMetricsParams() *GetMetricsParams {\n\tvar (\n\t\tgranularityDefault = string(\"AUTO\")\n\t\tgroupByDefault = string(\"NONE\")\n\t\tsiteTypeFilterDefault = string(\"ALL\")\n\t)\n\treturn &GetMetricsParams{\n\t\tGranularity: &granularityDefault,\n\t\tGroupBy: &groupByDefault,\n\t\tSiteTypeFilter: &siteTypeFilterDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetDevicesAllParamsWithHTTPClient(client *http.Client) *GetDevicesAllParams {\n\tvar ()\n\treturn &GetDevicesAllParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewHealthCheck(rt *app.Runtime) operations.HealthCheckHandler {\n\treturn &healthCheck{}\n}", "func CreateDeviceHealthFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {\n return NewDeviceHealth(), nil\n}", "func NewGetHealthContext(ctx context.Context, r *http.Request, service *goa.Service) (*GetHealthContext, error) {\n\tvar err error\n\tresp := goa.ContextResponse(ctx)\n\tresp.Service = service\n\treq := goa.ContextRequest(ctx)\n\treq.Request = r\n\trctx := GetHealthContext{Context: ctx, ResponseData: resp, RequestData: req}\n\treturn &rctx, err\n}", "func GetHealth(w http.ResponseWriter, r *http.Request) {\n\tjson.NewEncoder(w).Encode(health)\n}", "func CreateHealthRequest() *Message {\n\treturn &Message{\n\t\tSchemaVersion: SchemaVersion,\n\t\tTopic: GetWorkerHealthRequest,\n\t}\n}", "func NewGetUserUsageParams() *GetUserUsageParams {\n\tvar ()\n\treturn &GetUserUsageParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewMockHealthReporter() *MockHealthReporter {\n\treturn &MockHealthReporter{\n\t\tnotify: make(chan Update),\n\t}\n}", "func NewHealthController() *HealthController {\n\treturn &HealthController{}\n}", "func NewHealthHandler(appCtx appcontext.AppContext, redisPool *redis.Pool, gitBranch string, gitCommit string) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\tdata := map[string]interface{}{\n\t\t\t\"gitBranch\": gitBranch,\n\t\t\t\"gitCommit\": gitCommit,\n\t\t}\n\t\t// Check and see if we should disable DB query with '?database=false'\n\t\t// Disabling the DB is useful for Route53 health checks which require the TLS\n\t\t// handshake be less than 4 seconds and the status code return in less than\n\t\t// two seconds. https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-determining-health-of-endpoints.html\n\t\tshowDB, ok := r.URL.Query()[\"database\"]\n\n\t\tvar dbID string\n\t\tvar dbURL string\n\t\t// Always show DB unless key set to \"false\"\n\t\tif !ok || (ok && showDB[0] != \"false\") {\n\t\t\tappCtx.Logger().Info(\"Health check connecting to the DB\")\n\t\t\t// include the request context for helpful tracing\n\t\t\tdb := appCtx.DB().WithContext(r.Context())\n\t\t\tdbID = db.ID\n\t\t\tdbURL = db.Dialect.Details().URL\n\t\t\tdbErr := db.RawQuery(\"SELECT 1;\").Exec()\n\t\t\tif dbErr != nil {\n\t\t\t\tappCtx.Logger().Error(\"Failed database health check\",\n\t\t\t\t\tzap.String(\"dbID\", dbID),\n\t\t\t\t\tzap.String(\"dbURL\", dbURL),\n\t\t\t\t\tzap.Error(dbErr))\n\t\t\t\tdata[\"database\"] = false\n\t\t\t\thealthCheckError(appCtx, w, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdata[\"database\"] = true\n\t\t\tif redisPool != nil {\n\t\t\t\tredisErr := redisHealthCheck(redisPool, appCtx.Logger())\n\t\t\t\tif redisErr != nil {\n\t\t\t\t\tdata[\"redis\"] = false\n\t\t\t\t\thealthCheckError(appCtx, w, data)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tdata[\"redis\"] = true\n\t\t\t}\n\t\t}\n\n\t\tnewEncoderErr := json.NewEncoder(w).Encode(data)\n\t\tif newEncoderErr != nil {\n\t\t\tappCtx.Logger().Error(\"Failed encoding health check response\", zap.Error(newEncoderErr))\n\t\t\thttp.Error(w, \"failed health check\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tappCtx.Logger().Info(\"Request health ok\",\n\t\t\tzap.String(\"dbID\", dbID),\n\t\t\tzap.String(\"dbURL\", dbURL))\n\t}\n}", "func NewGetTreeParams() *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewDeviceMetricsAllOfWithDefaults() *DeviceMetricsAllOf {\n\tthis := DeviceMetricsAllOf{}\n\treturn &this\n}", "func NewMockHealthCheck(ctrl *gomock.Controller) *MockHealthCheck {\n\tmock := &MockHealthCheck{ctrl: ctrl}\n\tmock.recorder = &MockHealthCheckMockRecorder{mock}\n\treturn mock\n}", "func NewMockHealthCheck(ctrl *gomock.Controller) *MockHealthCheck {\n\tmock := &MockHealthCheck{ctrl: ctrl}\n\tmock.recorder = &MockHealthCheckMockRecorder{mock}\n\treturn mock\n}", "func newDevice(title string, x, y, width, height int) *device {\n\td := &device{}\n\td.os = newNativeOs()\n\td.os.createDisplay(title, x, y, width, height)\n\td.os.createShell()\n\tdepthBufferBits, alphaBits := 24, 8 // resonable defaults\n\td.os.createContext(depthBufferBits, alphaBits)\n\td.pressed = newInput(d.os)\n\treturn d\n}", "func (r *DeviceConfigurationDeviceOverviewRequest) Get(ctx context.Context) (resObj *DeviceConfigurationDeviceOverview, 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 NewGetDistrictForSchoolParams() *GetDistrictForSchoolParams {\n\treturn &GetDistrictForSchoolParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (c *UPHostClient) NewDescribePHostRequest() *DescribePHostRequest {\n\treq := &DescribePHostRequest{}\n\n\t// setup request with client config\n\tc.Client.SetupRequest(req)\n\n\t// setup retryable with default retry policy (retry for non-create action and common error)\n\treq.SetRetryable(true)\n\treturn req\n}", "func NewQueryEntitlementsParams() *QueryEntitlementsParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t\tlimitDefault = int32(20)\n\t\toffsetDefault = int32(0)\n\t)\n\treturn &QueryEntitlementsParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func New(title string, x, y, width, height int) Device { return newDevice(title, x, y, width, height) }", "func NewDeviceWeight() DeviceWeight {\n\treturn DeviceWeight{\n\t\tMajor: -1,\n\t\tMinor: -1,\n\t\tWeight: -1,\n\t}\n}", "func GetHealthHandler(ghp probe.GetHealthParams) middleware.Responder {\n\treturn probe.NewGetHealthOK()\n}", "func NewFieldHistogramKeywordParams() *FieldHistogramKeywordParams {\n\tvar ()\n\treturn &FieldHistogramKeywordParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetWormDomainParams() *GetWormDomainParams {\n\tvar ()\n\treturn &GetWormDomainParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewDevice(info IDeviceInfo, commandProcessor CommandProcessor, eventProcessor EventProcessor, queryProcessor QueryProcessor) *Device {\n instance := new(Device)\n agent.SetupAgent(&instance.Agent, info, 0, 0, agent.DEFAULT_BUFFER_SIZE, true)\n instance.info = info\n instance.commandProcessor = commandProcessor\n instance.eventProcessor = eventProcessor\n instance.queryProcessor = queryProcessor\n return instance\n}", "func NewMonitoringParameters(clientHandle uint32, samplingInterval float64, filter ExtensionObject, queueSize uint32, discardOldest bool) *_MonitoringParameters {\n\t_result := &_MonitoringParameters{\n\t\tClientHandle: clientHandle,\n\t\tSamplingInterval: samplingInterval,\n\t\tFilter: filter,\n\t\tQueueSize: queueSize,\n\t\tDiscardOldest: discardOldest,\n\t\t_ExtensionObjectDefinition: NewExtensionObjectDefinition(),\n\t}\n\t_result._ExtensionObjectDefinition._ExtensionObjectDefinitionChildRequirements = _result\n\treturn _result\n}", "func (client IotHubResourceClient) GetEndpointHealthPreparer(ctx context.Context, resourceGroupName string, iotHubName string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"iotHubName\": autorest.Encode(\"path\", iotHubName),\n\t\t\"resourceGroupName\": autorest.Encode(\"path\", resourceGroupName),\n\t\t\"subscriptionId\": autorest.Encode(\"path\", client.SubscriptionID),\n\t}\n\n\tconst APIVersion = \"2022-04-30-preview\"\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(\"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (m *MockHealthCheck) GetTabletHealth(arg0 discovery.KeyspaceShardTabletType, arg1 *topodata.TabletAlias) (*discovery.TabletHealth, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetTabletHealth\", arg0, arg1)\n\tret0, _ := ret[0].(*discovery.TabletHealth)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func NewGetBuildPropertiesParams() *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewHealthRecord() *HealthRecord {\n\tr := &HealthRecord{}\n\n\treturn r\n}", "func NewDeviceManagementSettings()(*DeviceManagementSettings) {\n m := &DeviceManagementSettings{\n }\n m.backingStore = ie8677ce2c7e1b4c22e9c3827ecd078d41185424dd9eeb92b7d971ed2d49a392e.BackingStoreFactoryInstance();\n m.SetAdditionalData(make(map[string]any))\n return m\n}", "func NewHealthcheck(name string, metric metrics.Healthcheck) interface {\n\tprometheus.Collector\n\tmetrics.Healthcheck\n} {\n\treturn healthcheck{\n\t\tHealthcheck: metric,\n\t\tgaugeAdapter: gaugeAdapter{\n\t\t\tmetric: func(snapshot interface{}) float64 {\n\t\t\t\tif snapshot.(metrics.Healthcheck).Error() != nil {\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t\treturn 1\n\t\t\t},\n\t\t\tsnapshot: func() interface{} {\n\t\t\t\treturn metric\n\t\t\t},\n\t\t\tdescription: newDescriptionFrom(name),\n\t\t},\n\t}\n}", "func NewHealthchecker(log *logrus.Logger, hostname string) Healthchecker {\n\treturn &healthchecker{\n\t\tlog: log.WithField(\"service\", \"lookup\"),\n\t\thostname: hostname,\n\t}\n}", "func NewHealthController() *HealthController {\n\treturn new(HealthController)\n}", "func NewDeviceManagementConfigurationSetting()(*DeviceManagementConfigurationSetting) {\n m := &DeviceManagementConfigurationSetting{\n Entity: *NewEntity(),\n }\n return m\n}", "func NewHealthHandler(user *user.User) *HealthHandler {\n\tdlog.Server.Debug(user, \"Creating new server health handler\")\n\th := HealthHandler{\n\t\tbaseHandler: baseHandler{\n\t\t\tdone: internal.NewDone(),\n\t\t\tlines: make(chan *line.Line, 100),\n\t\t\tserverMessages: make(chan string, 10),\n\t\t\tmaprMessages: make(chan string, 10),\n\t\t\tackCloseReceived: make(chan struct{}),\n\t\t\tuser: user,\n\t\t},\n\t}\n\th.handleCommandCb = h.handleHealthCommand\n\n\tfqdn, err := config.Hostname()\n\tif err != nil {\n\t\tdlog.Server.FatalPanic(err)\n\t}\n\ts := strings.Split(fqdn, \".\")\n\th.hostname = s[0]\n\treturn &h\n}", "func NewDeviceHealthScriptRunSummary()(*DeviceHealthScriptRunSummary) {\n m := &DeviceHealthScriptRunSummary{\n Entity: *NewEntity(),\n }\n return m\n}", "func NewGetLogicalPortParams() *GetLogicalPortParams {\n\tvar ()\n\treturn &GetLogicalPortParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewThrottleDevice(major, minor int64, rate uint64) *ThrottleDevice {\n\ttd := &ThrottleDevice{}\n\ttd.Major = major\n\ttd.Minor = minor\n\ttd.Rate = rate\n\treturn td\n}", "func NewWeightDevice(major, minor int64, weight, leafWeight uint16) *WeightDevice {\n\twd := &WeightDevice{}\n\twd.Major = major\n\twd.Minor = minor\n\twd.Weight = weight\n\twd.LeafWeight = leafWeight\n\treturn wd\n}", "func GetHelp(w http.ResponseWriter, r *http.Request) {\n\toptions := map[string]string{\n\t\t\"GET /health/v1\": \"This help message\",\n\t\t\"GET /health/v1/health\": \"Get data from health table\",\n\t\t\"GET /health/v1/health/id/{ id }\": \"Get health data by id\",\n\t\t\"GET /health/v1/health/ts/{ ts }\": \"Get health data by ts\",\n\t\t\"GET /health/v1/health/variable/{ variable }\": \"Get health data by variable\",\n\t\t\"GET /health/v1/logged_in\": \"Get login status (username)\",\n\t\t\"GET /health/v1/ref_variables\": \"Get data from ref_variables table\",\n\t\t\"GET /health/v1/ref_variables/id/{ id }\": \"Get ref_variables data by id\",\n\t\t\"GET /health/v1/ref_variables/variable/{ variable }\": \"Get ref_variables data by variable\",\n\t\t\"POST /health/v1/login\": \"Log in\",\n\t\t\"POST /health/v1/logout\": \"Log out\",\n\t\t\"POST /health/v1/health/keys/u\": \"Post data to health table using unique key for insert/update\",\n\t\t\"POST /health/v1/health/keys/p\": \"Post data to health table using primary key for insert/update\",\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.WriteHeader(http.StatusOK)\n\n\tif err := json.NewEncoder(w).Encode(options); err != nil {\n\t\tpanic(err)\n\t}\n\n\tlogRequest(r)\n}", "func NewGetHardwareDefault(code int) *GetHardwareDefault {\n\treturn &GetHardwareDefault{\n\t\t_statusCode: code,\n\t}\n}", "func NewGetHardwareOK() *GetHardwareOK {\n\treturn &GetHardwareOK{}\n}", "func NewDevicesGetModuleComponentCommandHistoryParamsWithTimeout(timeout time.Duration) *DevicesGetModuleComponentCommandHistoryParams {\n\tvar ()\n\treturn &DevicesGetModuleComponentCommandHistoryParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func newDHT(r *Router) *dht {\n\td := &dht{\n\t\tr: r,\n\t\tfinger: make(map[types.PublicKey]dhtEntry),\n\t}\n\treturn d\n}", "func GetHealth(w http.ResponseWriter, r *http.Request, db *sqlx.DB) {\n\tparams := mux.Vars(r)\n\n\thealth := []Health{}\n\n\tvar err error\n\n\tsession, err := store.Get(r, \"auth\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Convert our session data into an instance of User\n\tuser := User{}\n\tuser, _ = session.Values[\"user\"].(User)\n\n\tif user.Username != \"\" && user.AccessLevel == \"admin\" {\n\t\tif _, ok := params[\"id\"]; ok {\n\t\t\terr = db.Select(&health, \"SELECT id, username, ts, variable, value \"+\n\t\t\t\t\"FROM public.health \"+\n\t\t\t\t\"WHERE id = $1 \", params[\"id\"])\n\t\t} else if _, ok = params[\"ts\"]; ok {\n\t\t\terr = db.Select(&health, \"SELECT id, username, ts, variable, value \"+\n\t\t\t\t\"FROM public.health \"+\n\t\t\t\t\"WHERE ts = $1 \", params[\"ts\"])\n\t\t} else if _, ok = params[\"variable\"]; ok {\n\t\t\terr = db.Select(&health, \"SELECT id, username, ts, variable, value \"+\n\t\t\t\t\"FROM public.health \"+\n\t\t\t\t\"WHERE variable = $1 \", params[\"variable\"])\n\t\t} else {\n\t\t\terr = db.Select(&health, \"SELECT id, username, ts, variable, value \"+\n\t\t\t\t\"FROM public.health \")\n\t\t}\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\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(health); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t} else {\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(\"access denied\"); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tlogRequest(r)\n}", "func NewGetDrgParams() *GetDrgParams {\n\tvar ()\n\treturn &GetDrgParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func newHCDummy(logPrefix string, json JSONMap) *HCDummy {\n\thc := new(HCDummy)\n\thc.HCBase = &HCBase{}\n\thc.hcType = json[\"type\"].(string)\n\n\tif result, ok := json[\"result\"].(HCResult); ok {\n\t\thc.result = result\n\t}\n\n\thc.logPrefix = logPrefix + fmt.Sprintf(\"healthcheck: %s response: %s \", hc.hcType, hc.result)\n\n\tlogger.Info.Printf(hc.logPrefix + \"created\")\n\treturn hc\n}", "func NewHealthHandler(e *empire.Empire) *HealthHandler {\n\treturn &HealthHandler{\n\t\tIsHealthy: e.IsHealthy,\n\t}\n}", "func newDevice(cdevice C.nvmlDevice_t) (*Device, error) {\n\tdevice := Device{\n\t\tnvmldevice: cdevice,\n\t}\n\n\tuuid, err := device.UUID()\n\tif err != nil {\n\t\treturn nil, errors.New(\"Cannot retrieve UUID property\")\n\t}\n\tdevice.uuid = uuid\n\n\tname, err := device.Name()\n\tif err != nil {\n\t\treturn nil, errors.New(\"Cannot retrieve Name property\")\n\t}\n\tdevice.name = name\n\n\tindex, err := device.Index()\n\tif err != nil {\n\t\treturn nil, errors.New(\"Cannot retrieve Index property\")\n\t}\n\tdevice.index = index\n\n\tdevice.bus = device.BusID()\n\n\treturn &device, nil\n}", "func New(config HealthCheckConfig) *HealthCheck {\n\treturn &HealthCheck{\n\t\tbroker: &kafkaBrokerConnection{},\n\t\tzookeeper: &zkConnection{},\n\t\trandSrc: rand.NewSource(time.Now().UnixNano()),\n\t\tconfig: config,\n\t}\n}", "func NewHealthHandler() HealthHandler {\n\treturn HealthHandler{}\n}", "func (m *DeviceManagementRequestBuilder) ManagedDeviceOverview()(*i2eb7d01d7645dcb50edbcee3c098f918d1036928f83217ac1ac02f2fd20a2c72.ManagedDeviceOverviewRequestBuilder) {\n return i2eb7d01d7645dcb50edbcee3c098f918d1036928f83217ac1ac02f2fd20a2c72.NewManagedDeviceOverviewRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}" ]
[ "0.6771214", "0.56535894", "0.5605594", "0.5478605", "0.5244152", "0.522956", "0.5224426", "0.5197208", "0.5125405", "0.50955284", "0.50763583", "0.5020125", "0.49859306", "0.49729276", "0.49534455", "0.49006212", "0.48718244", "0.47930813", "0.47829595", "0.47705016", "0.47638848", "0.47593614", "0.4739287", "0.47344372", "0.47092676", "0.4620843", "0.45887458", "0.45870912", "0.458241", "0.45818806", "0.4573155", "0.45679107", "0.45421937", "0.45405418", "0.4483625", "0.44833478", "0.44799027", "0.4448815", "0.44466016", "0.4430312", "0.44023204", "0.43964982", "0.43958467", "0.43942928", "0.43870205", "0.43743306", "0.43621525", "0.4358059", "0.4349759", "0.43467233", "0.43399668", "0.4327199", "0.42959213", "0.42946282", "0.42894", "0.42871627", "0.42711356", "0.42695728", "0.42641404", "0.4257359", "0.4257359", "0.42363098", "0.4235322", "0.42268923", "0.42171204", "0.4215651", "0.41932225", "0.41859728", "0.41818365", "0.41790828", "0.4178713", "0.41532007", "0.4148703", "0.414607", "0.41430926", "0.41421247", "0.41420612", "0.41334355", "0.41299295", "0.41259643", "0.41227743", "0.41120696", "0.40985298", "0.40901244", "0.40900362", "0.40804335", "0.40772948", "0.40770036", "0.40724644", "0.40662208", "0.4060957", "0.406", "0.40589365", "0.40580752", "0.40547282", "0.40546143", "0.40536308", "0.40531492", "0.40523705", "0.4050439" ]
0.84631157
0
WithDeviceID adds the deviceID to the get device status params
func (o *GetDeviceHealthParams) WithDeviceID(deviceID string) *GetDeviceHealthParams { o.SetDeviceID(deviceID) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (p Params) SetDeviceID(id string) {\n\tp[\"image_request[device_id]\"] = id\n}", "func (o *GetOutagesParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (o *GetDeviceHealthParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *UpdateDeviceParams) WithDeviceID(deviceID string) *UpdateDeviceParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *UpdateDeviceParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) WithDeviceID(deviceID string) *DevicesGetModuleComponentCommandHistoryParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *GetServiceDetailsParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *IPAMServicesReadParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (o *GetParams) WithDeviceID(deviceID string) *GetParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (rb *ResourceBuilder) SetDeviceID(val string) {\n\tif rb.config.DeviceID.Enabled {\n\t\trb.res.Attributes().PutStr(\"device.id\", val)\n\t}\n}", "func (o *DeleteDevicesDeviceidInterfacesInterfacenameParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *PostDeviceRackParams) SetDeviceID(deviceID *int64) {\n\to.DeviceID = deviceID\n}", "func (o *PostDevicesDeviceidBackupsBackupidApplyParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (_options *ListTagsSubscriptionOptions) SetDeviceID(deviceID string) *ListTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (o *DeleteDeviceUsingDELETEParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *RevokeDeviceCertificateUsingDELETEParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *PostIPAMSwitchesParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (_options *CreateTagsSubscriptionOptions) SetDeviceID(deviceID string) *CreateTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (m *DeviceConfigurationItemRequestBuilder) DeviceStatusesById(id string)(*ie1759fa3aebfd08bd0a0973770111e293804186cb2bccc14cfdf3f11a34c8f75.DeviceConfigurationDeviceStatusItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"deviceConfigurationDeviceStatus%2Did\"] = id\n }\n return ie1759fa3aebfd08bd0a0973770111e293804186cb2bccc14cfdf3f11a34c8f75.NewDeviceConfigurationDeviceStatusItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (o *GetServiceDetailsParams) WithDeviceID(deviceID string) *GetServiceDetailsParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (euo *EquipmentUpdateOne) SetDeviceID(s string) *EquipmentUpdateOne {\n\teuo.device_id = &s\n\treturn euo\n}", "func (_options *DeleteTagsSubscriptionOptions) SetDeviceID(deviceID string) *DeleteTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (d *MotorDev) SetDeviceID(id uint32) *MotorDev {\n d.Info.DeviceId = id\n return d\n}", "func (eu *EquipmentUpdate) SetDeviceID(s string) *EquipmentUpdate {\n\teu.device_id = &s\n\treturn eu\n}", "func (o *IpamIPAddressesListParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (o *GetOutagesParams) WithDeviceID(deviceID *string) *GetOutagesParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func withStatusdID(id int) statusdOption {\n\treturn func(m *StatusdMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Statusd\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Statusd, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Statusd.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func (rec *RawEventCreate) SetDeviceID(s string) *RawEventCreate {\n\trec.mutation.SetDeviceID(s)\n\treturn rec\n}", "func (o *IPAMServicesReadParams) WithDeviceID(deviceID *string) *IPAMServicesReadParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *UpdateProjectDeviceParams) bindDeviceID(rawData []string, hasKey bool, formats strfmt.Registry) error {\n\tvar raw string\n\tif len(rawData) > 0 {\n\t\traw = rawData[len(rawData)-1]\n\t}\n\n\t// Required: true\n\t// Parameter is provided by construction from the route\n\n\to.DeviceID = raw\n\n\treturn nil\n}", "func (o *GetAOrderStatusParams) WithStatusID(statusID int32) *GetAOrderStatusParams {\n\to.SetStatusID(statusID)\n\treturn o\n}", "func withRoomStatusID(id int) roomstatusOption {\n\treturn func(m *RoomStatusMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *RoomStatus\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*RoomStatus, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().RoomStatus.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func (o *SyncStatusUsingGETParams) WithRequestID(requestID string) *SyncStatusUsingGETParams {\n\to.SetRequestID(requestID)\n\treturn o\n}", "func (o *RevokeDeviceCertificateUsingDELETEParams) WithDeviceID(deviceID string) *RevokeDeviceCertificateUsingDELETEParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *DeleteDeviceUsingDELETEParams) WithDeviceID(deviceID string) *DeleteDeviceUsingDELETEParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (r *DeviceConfigurationDeviceStatusRequest) Get(ctx context.Context) (resObj *DeviceConfigurationDeviceStatus, 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 (m *GraphBaseServiceClient) DevicesById(id string)(*ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.DeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"device%2Did\"] = id\n }\n return ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.NewDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (m *GraphBaseServiceClient) DevicesById(id string)(*ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.DeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"device%2Did\"] = id\n }\n return ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.NewDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (isrtu *IPStaticRoutingTableUpdate) SetOnDeviceID(id int) *IPStaticRoutingTableUpdate {\n\tisrtu.mutation.SetOnDeviceID(id)\n\treturn isrtu\n}", "func (o *DeleteDevicesDeviceidInterfacesInterfacenameParams) WithDeviceID(deviceID string) *DeleteDevicesDeviceidInterfacesInterfacenameParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *GetAOrderStatusParams) SetStatusID(statusID int32) {\n\to.StatusID = statusID\n}", "func (isrtuo *IPStaticRoutingTableUpdateOne) SetOnDeviceID(id int) *IPStaticRoutingTableUpdateOne {\n\tisrtuo.mutation.SetOnDeviceID(id)\n\treturn isrtuo\n}", "func (m *DeviceConfigurationItemRequestBuilder) UserStatusesById(id string)(*i13d5635acea3d1befd38097b223c984a262de351ddcc99002d56e0362ecf8c7c.DeviceConfigurationUserStatusItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"deviceConfigurationUserStatus%2Did\"] = id\n }\n return i13d5635acea3d1befd38097b223c984a262de351ddcc99002d56e0362ecf8c7c.NewDeviceConfigurationUserStatusItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (r *DeviceComplianceDeviceStatusRequest) Get(ctx context.Context) (resObj *DeviceComplianceDeviceStatus, 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 withRentalstatusID(id int) rentalstatusOption {\n\treturn func(m *RentalstatusMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Rentalstatus\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Rentalstatus, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Rentalstatus.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func NewGetDevicesDeviceidMactableOK() *GetDevicesDeviceidMactableOK {\n\treturn &GetDevicesDeviceidMactableOK{}\n}", "func withBillingstatusID(id int) billingstatusOption {\n\treturn func(m *BillingstatusMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Billingstatus\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Billingstatus, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Billingstatus.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func (o *PostDeviceRackParams) WithDeviceID(deviceID *int64) *PostDeviceRackParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (b *addPushNotificationsOnChannelsBuilder) DeviceIDForPush(deviceID string) *addPushNotificationsOnChannelsBuilder {\n\tb.opts.DeviceIDForPush = deviceID\n\treturn b\n}", "func (e *EdgeRequestContext) DeviceID() string {\n\treturn e.raw.DeviceID\n}", "func (o *PostDevicesDeviceidBackupsBackupidApplyParams) WithDeviceID(deviceID string) *PostDevicesDeviceidBackupsBackupidApplyParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (m *DeviceManagementRequestBuilder) ManagedDevicesById(id string)(*ic17628b2ada33156bca6f6158e18f62f1027784aa76d9f9a69a4d0cee7e57f3e.ManagedDeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"managedDevice%2Did\"] = id\n }\n return ic17628b2ada33156bca6f6158e18f62f1027784aa76d9f9a69a4d0cee7e57f3e.NewManagedDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func parseDeviceID() Handler {\n\treturn func(rc *RouterContext, w http.ResponseWriter, r *http.Request) *HTTPError {\n\n\t\tdeviceid := r.Header.Get(\"deviceid\")\n\t\tif deviceid == \"\" {\n\t\t\treturn handleMissingDataError(\"deviceid\")\n\t\t}\n\n\t\trc.deviceid = deviceid\n\t\treturn nil\n\t}\n}", "func deviceStatusHandler(devices map[string]*Device) http.HandlerFunc {\n\treturn func(respWriter http.ResponseWriter, request *http.Request) {\n\t\trespWriter.Header().Add(\"Content-Type\", \"application/json\")\n\t\tbytes, err := json.Marshal(&devices)\n\t\tif err != nil {\n\t\t\thttp.Error(respWriter, \"Can't marshall devices\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\trespWriter.Write(bytes)\n\t}\n}", "func getDeviceStatus(dev internal.BlockDevice) v1alpha1.DeviceStatus {\n\tstatus := v1alpha1.DeviceStatus{}\n\tif dev.FSType != \"\" {\n\t\tklog.Infof(\"device %q with filesystem %q is not available\", dev.Name, dev.FSType)\n\t\tstatus.State = v1alpha1.NotAvailable\n\t\treturn status\n\t}\n\n\tnoBiosBootInPartLabel, err := lvset.FilterMap[\"noBiosBootInPartLabel\"](dev, nil)\n\tif err != nil {\n\t\tstatus.State = v1alpha1.Unknown\n\t\treturn status\n\t}\n\tif !noBiosBootInPartLabel {\n\t\tklog.Infof(\"device %q with part label %q is not available\", dev.Name, dev.PartLabel)\n\t\tstatus.State = v1alpha1.NotAvailable\n\t\treturn status\n\t}\n\n\tcanOpen, err := lvset.FilterMap[\"canOpenExclusively\"](dev, nil)\n\tif err != nil {\n\t\tstatus.State = v1alpha1.Unknown\n\t\treturn status\n\t}\n\tif !canOpen {\n\t\tklog.Infof(\"device %q is not available as it can't be opened exclusively\", dev.Name)\n\t\tstatus.State = v1alpha1.NotAvailable\n\t\treturn status\n\t}\n\n\thasBindMounts, mountPoint, err := dev.HasBindMounts()\n\tif err != nil {\n\t\tstatus.State = v1alpha1.Unknown\n\t\treturn status\n\t}\n\n\tif hasBindMounts {\n\t\tklog.Infof(\"device %q with mount point %q is not available\", dev.Name, mountPoint)\n\t\tstatus.State = v1alpha1.NotAvailable\n\t\treturn status\n\t}\n\n\tklog.Infof(\"device %q is available\", dev.Name)\n\tstatus.State = v1alpha1.Available\n\treturn status\n}", "func withStatusd(node *Statusd) statusdOption {\n\treturn func(m *StatusdMutation) {\n\t\tm.oldValue = func(context.Context) (*Statusd, error) {\n\t\t\treturn node, nil\n\t\t}\n\t\tm.id = &node.ID\n\t}\n}", "func (o *AdminGetBannedDevicesV4Params) WithContext(ctx context.Context) *AdminGetBannedDevicesV4Params {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *PostIPAMSwitchesParams) WithDeviceID(deviceID *string) *PostIPAMSwitchesParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (c *Client) GetIDDevice(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewGetIDDeviceRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func (c *Controller) DeviceStatus(d *ControllerDevice) (ControllerDeviceStatus, error) {\n\tvar packets []*Packet\n\tseqIDs := map[uint16]bool{}\n\tc.switchMappingLock.RLock()\n\tvar curSwitch uint32\n\tif len(c.switches[d.deviceID]) > 0 {\n\t\tcurSwitch = c.switches[d.deviceID][c.switchIndices[d.deviceID]]\n\t}\n\tfor _, switchID := range c.switches[d.deviceID] {\n\t\tseqID := c.nextSeqID()\n\t\tpackets = append(packets, NewPacketGetStatusPaginated(switchID, seqID))\n\t\tseqIDs[seqID] = true\n\t}\n\tc.switchMappingLock.RUnlock()\n\n\tif len(packets) == 0 {\n\t\treturn ControllerDeviceStatus{}, errors.Wrap(UnreachableError, \"lookup device status\")\n\t}\n\n\tvar responsePacket *StatusPaginatedResponse\n\tvar decodeErr error\n\tvar numResponses int\n\terr := c.callAndWait(packets, false, func(p *Packet) bool {\n\t\tif seq, err := p.Seq(); err == nil && p.IsResponse && !seqIDs[seq] {\n\t\t\t// This is a response to a packet we did not send.\n\t\t\treturn false\n\t\t}\n\t\tif IsStatusPaginatedResponse(p) {\n\t\t\tnumResponses++\n\t\t\tresponses, err := DecodeStatusPaginatedResponse(p)\n\t\t\tif err == nil {\n\t\t\t\t// Always prioritize a response directly from the actual\n\t\t\t\t// device, since it will be the most up-to-date.\n\t\t\t\tswitchID := binary.BigEndian.Uint32(p.Data[:4])\n\t\t\t\tisPrimary := d.isSwitch(switchID)\n\n\t\t\t\tfor _, resp := range responses {\n\t\t\t\t\tif resp.Device == d.deviceIndex() {\n\t\t\t\t\t\t// Prioritize statuses from the device's switch and\n\t\t\t\t\t\t// the switch that we control this device through,\n\t\t\t\t\t\t// since both switches are likely to have the most\n\t\t\t\t\t\t// up-to-date information.\n\t\t\t\t\t\tif responsePacket == nil || switchID == curSwitch || isPrimary {\n\t\t\t\t\t\t\t// Doing &resp references the for-loop variable.\n\t\t\t\t\t\t\tresponsePacket = new(StatusPaginatedResponse)\n\t\t\t\t\t\t\t*responsePacket = resp\n\t\t\t\t\t\t\tif isPrimary {\n\t\t\t\t\t\t\t\treturn true\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} else {\n\t\t\t\tdecodeErr = err\n\t\t\t}\n\t\t} else if p.IsResponse && len(p.Data) >= 4 && p.Data[len(p.Data)-1] != 0 {\n\t\t\t// This is an error response from some switch.\n\t\t\tnumResponses++\n\t\t\tif decodeErr == nil {\n\t\t\t\tdecodeErr = RemoteCallError\n\t\t\t}\n\t\t}\n\t\treturn numResponses >= len(packets)\n\t})\n\n\tif responsePacket != nil {\n\t\tstatus := ControllerDeviceStatus{\n\t\t\tStatusPaginatedResponse: *responsePacket,\n\t\t\tIsOnline: true,\n\t\t}\n\t\td.lastStatusLock.Lock()\n\t\td.lastStatus = status\n\t\td.lastStatusLock.Unlock()\n\t\treturn status, nil\n\t}\n\n\tif decodeErr != nil {\n\t\terr = decodeErr\n\t} else if err == nil {\n\t\terr = UnreachableError\n\t}\n\tc.switchFailed(d)\n\treturn ControllerDeviceStatus{}, errors.Wrap(err, \"lookup device status\")\n}", "func (devices *DeviceSet) GetDeviceStatus(hash string) (*DevStatus, error) {\n\tinfo, err := devices.lookupDeviceWithLock(hash)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo.lock.Lock()\n\tdefer info.lock.Unlock()\n\n\tdevices.Lock()\n\tdefer devices.Unlock()\n\n\tstatus := &DevStatus{\n\t\tDeviceID: info.DeviceID,\n\t\tSize: info.Size,\n\t\tTransactionID: info.TransactionID,\n\t}\n\n\tif err := devices.activateDeviceIfNeeded(info, false); err != nil {\n\t\treturn nil, fmt.Errorf(\"devmapper: Error activating devmapper device for '%s': %s\", hash, err)\n\t}\n\n\tsizeInSectors, mappedSectors, highestMappedSector, err := devices.deviceStatus(info.DevName())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstatus.SizeInSectors = sizeInSectors\n\tstatus.MappedSectors = mappedSectors\n\tstatus.HighestMappedSector = highestMappedSector\n\n\treturn status, nil\n}", "func (m *DeviceConfigurationItemRequestBuilder) DeviceStatuses()(*i2052556f4fb1ecc2b8520d93accde420e5a85783ea309802622a14a2965cac8c.DeviceStatusesRequestBuilder) {\n return i2052556f4fb1ecc2b8520d93accde420e5a85783ea309802622a14a2965cac8c.NewDeviceStatusesRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func (vera *Vera) getDeviceInfo(deviceID string) (DeviceInfo, error) {\n\tvar device Device\n\n\tfor _, d := range vera.Devices.Devices {\n\t\tif deviceID == d.PKDevice {\n\t\t\tdevice = d\n\t\t}\n\t}\n\n\tif device == (Device{}) {\n\t\treturn DeviceInfo{}, fmt.Errorf(\"%w: %s\", errDeviceNotFound, deviceID)\n\t}\n\n\turl := https + device.ServerDevice + devicePath + deviceID\n\n\tdeviceInfo, err := vera.getDeviceInfoURL(url)\n\t// Try using ServerDeviceAlt if ServerDevice doesn't work\n\tif err != nil {\n\t\turl = https + device.ServerDeviceAlt + devicePath + deviceID\n\t\tdeviceInfo, err = vera.getDeviceInfoURL(url)\n\t}\n\n\treturn deviceInfo, err\n}", "func (m *DeviceManagementRequestBuilder) IosUpdateStatusesById(id string)(*i4d3a26b3bf54ee27026f84d5aed96158baa8d422d5fa52c1cd1a2174a2ef12c3.IosUpdateDeviceStatusItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"iosUpdateDeviceStatus%2Did\"] = id\n }\n return i4d3a26b3bf54ee27026f84d5aed96158baa8d422d5fa52c1cd1a2174a2ef12c3.NewIosUpdateDeviceStatusItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func withPatientID(id int) patientOption {\n\treturn func(m *PatientMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Patient\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Patient, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Patient.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func (o *SyncStatusUsingGETParams) WithContext(ctx context.Context) *SyncStatusUsingGETParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (c *Client) NewGetIDDeviceRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"https\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif c.JWTSigner != nil {\n\t\tif err := c.JWTSigner.Sign(req); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn req, nil\n}", "func withPatientrecordID(id int) patientrecordOption {\n\treturn func(m *PatientrecordMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Patientrecord\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Patientrecord, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Patientrecord.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func verifyDeviceID() Handler {\n\treturn func(rc *RouterContext, w http.ResponseWriter, r *http.Request) *HTTPError {\n\n\t\t_, err := rc.db.VerifyDeviceID(rc.ctx, rc.deviceid)\n\n\t\tif err != nil {\n\t\t\tif err.Error() == ErrNotRegistered {\n\t\t\t\treturn &HTTPError{\n\t\t\t\t\tErrorCode: ErrNotRegistered,\n\t\t\t\t\tGenericResponse: HTTPResponse(http.StatusUnauthorized),\n\t\t\t\t\tLevel: 1,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn &HTTPError{\n\t\t\t\tdeviceid: rc.deviceid,\n\t\t\t\tErrorCode: ErrInternal,\n\t\t\t\tIError: err,\n\t\t\t\tLevel: 3,\n\t\t\t\tGenericResponse: HTTPResponse(http.StatusInternalServerError),\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n}", "func (c *ControllerDevice) DeviceID() string {\n\treturn c.deviceID\n}", "func (o *AdminGetBannedDevicesV4Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DeviceType != nil {\n\n\t\t// query param deviceType\n\t\tvar qrDeviceType string\n\t\tif o.DeviceType != nil {\n\t\t\tqrDeviceType = *o.DeviceType\n\t\t}\n\t\tqDeviceType := qrDeviceType\n\t\tif qDeviceType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"deviceType\", qDeviceType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.EndDate != nil {\n\n\t\t// query param endDate\n\t\tvar qrEndDate string\n\t\tif o.EndDate != nil {\n\t\t\tqrEndDate = *o.EndDate\n\t\t}\n\t\tqEndDate := qrEndDate\n\t\tif qEndDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"endDate\", qEndDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.StartDate != nil {\n\n\t\t// query param startDate\n\t\tvar qrStartDate string\n\t\tif o.StartDate != nil {\n\t\t\tqrStartDate = *o.StartDate\n\t\t}\n\t\tqStartDate := qrStartDate\n\t\tif qStartDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"startDate\", qStartDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "func (c *SmartThingsClient) DeviceFullStatus(deviceID string) (*DeviceStatus, error) {\n\n\treq, err := c.newRequest(http.MethodGet, \"/v1/devices/\"+deviceID+\"/\"+\"status\", nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar deviceStatus DeviceStatus\n\t_, err = c.do(req, &deviceStatus)\n\treturn &deviceStatus, err\n}", "func (rrc *ReserveRoomCreate) SetStatusID(id int) *ReserveRoomCreate {\n\trrc.mutation.SetStatusID(id)\n\treturn rrc\n}", "func concatDeviceIDPortID(deviceID string, portNo uint32) string {\n\treturn fmt.Sprintf(\"%s:%d\", deviceID, portNo)\n}", "func (db *MongoDB) GetDevicesByID(c echo.Context) (err error) {\n\tid := c.Param(\"id\")\n\tdata := model.Device{}\n\tdb.DCol.FindId(bson.ObjectIdHex(id)).One(&data)\n\treturn c.JSON(http.StatusOK, &data)\n}", "func runOperationDevicesGetDevicesDeviceidMactable(cmd *cobra.Command, args []string) error {\n\tappCli, err := makeClient(cmd, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// retrieve flag values from cmd and fill params\n\tparams := devices.NewGetDevicesDeviceidMactableParams()\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactableCountFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactableDeviceIDFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactablePageFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactableSearchFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactableSortByFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationDevicesGetDevicesDeviceidMactableSortDescFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif dryRun {\n\n\t\tlogDebugf(\"dry-run flag specified. Skip sending request.\")\n\t\treturn nil\n\t}\n\t// make request and then print result\n\tmsgStr, err := parseOperationDevicesGetDevicesDeviceidMactableResult(appCli.Devices.GetDevicesDeviceidMactable(params, nil))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !debug {\n\n\t\tfmt.Println(msgStr)\n\t}\n\treturn nil\n}", "func (a *ActiveDevice) DeviceID() keybase1.DeviceID {\n\ta.RLock()\n\tdefer a.RUnlock()\n\treturn a.deviceID\n}", "func (m *ManagedEBooksManagedEBookItemRequestBuilder) DeviceStatesById(id string)(*ManagedEBooksItemDeviceStatesDeviceInstallStateItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"deviceInstallState%2Did\"] = id\n }\n return NewManagedEBooksItemDeviceStatesDeviceInstallStateItemRequestBuilderInternal(urlTplParams, m.requestAdapter)\n}", "func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid models.UID, status models.DeviceStatus) error {\n\tnamespace, err := s.store.NamespaceGet(ctx, tenant)\n\tif err != nil {\n\t\treturn NewErrNamespaceNotFound(tenant, err)\n\t}\n\n\tdevice, err := s.store.DeviceGetByUID(ctx, uid, tenant)\n\tif err != nil {\n\t\treturn NewErrDeviceNotFound(uid, err)\n\t}\n\n\tif device.Status == models.DeviceStatusAccepted {\n\t\treturn NewErrDeviceStatusAccepted(nil)\n\t}\n\n\t// NOTICE: when there is an already accepted device with the same MAC address, we need to update the device UID\n\t// transfer the sessions and delete the old device.\n\n\tsameMacDev, err := s.store.DeviceGetByMac(ctx, device.Identity.MAC, device.TenantID, models.DeviceStatusAccepted)\n\tif err != nil && err != store.ErrNoDocuments {\n\t\treturn NewErrDeviceNotFound(models.UID(device.UID), err)\n\t}\n\n\tif sameMacDev != nil && sameMacDev.UID != device.UID {\n\t\tif err := s.store.SessionUpdateDeviceUID(ctx, models.UID(sameMacDev.UID), models.UID(device.UID)); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.store.DeviceRename(ctx, models.UID(device.UID), sameMacDev.Name); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.store.DeviceDelete(ctx, models.UID(sameMacDev.UID)); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n\t}\n\n\tif status != models.DeviceStatusAccepted {\n\t\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n\t}\n\n\tswitch {\n\tcase envs.IsCommunity(), envs.IsEnterprise():\n\t\tif namespace.HasMaxDevices() && namespace.HasMaxDevicesReached() {\n\t\t\treturn NewErrDeviceMaxDevicesReached(namespace.MaxDevices)\n\t\t}\n\tcase envs.IsCloud():\n\t\tif namespace.Billing.IsActive() {\n\t\t\tif err := s.BillingReport(s.client.(req.Client), namespace.TenantID, ReportDeviceAccept); err != nil {\n\t\t\t\treturn NewErrBillingReportNamespaceDelete(err)\n\t\t\t}\n\t\t} else {\n\t\t\t// TODO: this strategy that stores the removed devices in the database can be simplified.\n\t\t\tremoved, err := s.store.DeviceRemovedGet(ctx, tenant, uid)\n\t\t\tif err != nil && err != store.ErrNoDocuments {\n\t\t\t\treturn NewErrDeviceRemovedGet(err)\n\t\t\t}\n\n\t\t\tif removed != nil {\n\t\t\t\tif err := s.store.DeviceRemovedDelete(ctx, tenant, uid); err != nil {\n\t\t\t\t\treturn NewErrDeviceRemovedDelete(err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount, err := s.store.DeviceRemovedCount(ctx, tenant)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn NewErrDeviceRemovedCount(err)\n\t\t\t\t}\n\n\t\t\t\tif namespace.HasMaxDevices() && int64(namespace.DevicesCount)+count >= int64(namespace.MaxDevices) {\n\t\t\t\t\treturn NewErrDeviceRemovedFull(namespace.MaxDevices, nil)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tok, err := s.BillingEvaluate(s.client.(req.Client), namespace.TenantID)\n\t\t\tif err != nil {\n\t\t\t\treturn NewErrBillingEvaluate(err)\n\t\t\t}\n\n\t\t\tif !ok {\n\t\t\t\treturn ErrDeviceLimit\n\t\t\t}\n\t\t}\n\t}\n\n\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n}", "func (o *SyncStatusUsingGETParams) WithNamespaceSelfLinkID(namespaceSelfLinkID string) *SyncStatusUsingGETParams {\n\to.SetNamespaceSelfLinkID(namespaceSelfLinkID)\n\treturn o\n}", "func (c *StatusdClient) Get(ctx context.Context, id int) (*Statusd, error) {\n\treturn c.Query().Where(statusd.ID(id)).Only(ctx)\n}", "func GetIDDevicePath(id int) string {\n\tparam0 := strconv.Itoa(id)\n\n\treturn fmt.Sprintf(\"/sources/devices/%s\", param0)\n}", "func (eu *EquipmentUpdate) ClearDeviceID() *EquipmentUpdate {\n\teu.device_id = nil\n\teu.cleardevice_id = true\n\treturn eu\n}", "func (sdk *SDKSteps) CreateRequestWithDID(agent string) error {\n\tdid, found := sdk.context.PublicDIDDocs[agent]\n\tif !found {\n\t\treturn fmt.Errorf(\"no public did found for %s\", agent)\n\t}\n\n\tclient, found := sdk.context.OutOfBandClients[agent]\n\tif !found {\n\t\treturn fmt.Errorf(\"no oob client found for %s\", agent)\n\t}\n\n\treq, err := client.CreateRequest(\n\t\t[]*decorator.Attachment{{\n\t\t\tID: uuid.New().String(),\n\t\t\tDescription: \"bdd test\",\n\t\t\tData: decorator.AttachmentData{\n\t\t\t\tJSON: map[string]interface{}{},\n\t\t\t},\n\t\t}},\n\t\toutofband.WithLabel(agent),\n\t\toutofband.WithServices(did.ID),\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create oob request for %s : %w\", agent, err)\n\t}\n\n\tsdk.pendingRequests[agent] = req\n\n\treturn nil\n}", "func DeleteDeviceTwinByDeviceID(obm orm.Ormer, deviceID string) error {\n\tnum, err := obm.QueryTable(DeviceTwinTableName).Filter(\"deviceid\", deviceID).Delete()\n\tif err != nil {\n\t\tklog.Errorf(\"Something wrong when deleting data: %v\", err)\n\t\treturn err\n\t}\n\tklog.V(4).Infof(\"Delete affected Num: %d\", num)\n\treturn nil\n}", "func (m *DepositMutation) SetStatusdID(id int) {\n\tm._Statusd = &id\n}", "func (a *ActiveDevice) internalUpdateUserVersionDeviceID(uv keybase1.UserVersion, deviceID keybase1.DeviceID) error {\n\n\tif uv.IsNil() {\n\t\treturn errors.New(\"ActiveDevice.set with nil uid\")\n\t}\n\tif deviceID.IsNil() {\n\t\treturn errors.New(\"ActiveDevice.set with nil deviceID\")\n\t}\n\n\tif a.uv.IsNil() && a.deviceID.IsNil() {\n\t\ta.uv = uv\n\t\ta.deviceID = deviceID\n\t} else if !a.uv.Eq(uv) {\n\t\treturn errors.New(\"ActiveDevice.set uid mismatch\")\n\t} else if !a.deviceID.Eq(deviceID) {\n\t\treturn errors.New(\"ActiveDevice.set deviceID mismatch\")\n\t}\n\n\treturn nil\n}", "func (r *Repository) GetByDeviceID(DeviceID string) (*Auth, error) {\n\tRequest := request.New(DB)\n\tvar orderBy []string\n\torderBy = append(orderBy, CreatedAt)\n\trows, err := Request.\n\t\tSelect([]string{}).\n\t\tFrom(r.tableName).\n\t\tWhere(Request.NewCond(DeviceIDColumn, \"=\", DeviceID)).\n\t\tOrderBy(orderBy).\n\t\tDesc().\n\t\tLimit(1).\n\t\tQuery()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tauths := parseRows(rows)\n\tif len(auths) > 0 {\n\t\treturn &auths[0], nil\n\t}\n\treturn nil, errors.New(\"no user with this device id\")\n}", "func NewQueryDeviceStatusForPCdnRequestWithoutParam() *QueryDeviceStatusForPCdnRequest {\n\n return &QueryDeviceStatusForPCdnRequest{\n JDCloudRequest: core.JDCloudRequest{\n URL: \"/pcdn:queryDeviceStatus\",\n Method: \"GET\",\n Header: nil,\n Version: \"v1\",\n },\n }\n}", "func NewGetGpsByDeviceIDOK() *GetGpsByDeviceIDOK {\n\treturn &GetGpsByDeviceIDOK{}\n}", "func registerOperationDevicesGetDevicesDeviceidMactableParamFlags(cmd *cobra.Command) error {\n\tif err := registerOperationDevicesGetDevicesDeviceidMactableCountParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err := registerOperationDevicesGetDevicesDeviceidMactableDeviceIDParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err := registerOperationDevicesGetDevicesDeviceidMactablePageParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err := registerOperationDevicesGetDevicesDeviceidMactableSearchParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err := registerOperationDevicesGetDevicesDeviceidMactableSortByParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err := registerOperationDevicesGetDevicesDeviceidMactableSortDescParamFlags(\"\", cmd); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m MetaData) GetDeviceID() string {\n\tif len(m) == 0 {\n\t\treturn \"\"\n\t}\n\tfor _, k := range []string{\"grpcgateway-x-device-id\", \"x-device-id\", \"device-id\"} {\n\t\tif v := m[k]; v != \"\" {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn \"\"\n}", "func withRoomInfoID(id int) roominfoOption {\n\treturn func(m *RoomInfoMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *RoomInfo\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*RoomInfo, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().RoomInfo.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func ID(id int) predicate.DeviceRequest {\n\treturn predicate.DeviceRequest(sql.FieldEQ(FieldID, id))\n}", "func withStatisticID(id int) statisticOption {\n\treturn func(m *StatisticMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Statistic\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Statistic, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Statistic.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func withStatisticID(id int) statisticOption {\n\treturn func(m *StatisticMutation) {\n\t\tvar (\n\t\t\terr error\n\t\t\tonce sync.Once\n\t\t\tvalue *Statistic\n\t\t)\n\t\tm.oldValue = func(ctx context.Context) (*Statistic, error) {\n\t\t\tonce.Do(func() {\n\t\t\t\tif m.done {\n\t\t\t\t\terr = fmt.Errorf(\"querying old values post mutation is not allowed\")\n\t\t\t\t} else {\n\t\t\t\t\tvalue, err = m.Client().Statistic.Get(ctx, id)\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn value, err\n\t\t}\n\t\tm.id = &id\n\t}\n}", "func (d *Device) SetStatus(status status.FieldDeviceStatus) { d.status = status }", "func (euo *EquipmentUpdateOne) ClearDeviceID() *EquipmentUpdateOne {\n\teuo.device_id = nil\n\teuo.cleardevice_id = true\n\treturn euo\n}" ]
[ "0.6687366", "0.64014286", "0.6308419", "0.62866277", "0.6286201", "0.6244915", "0.6240715", "0.6218305", "0.6179623", "0.61361784", "0.61109793", "0.6053119", "0.60001737", "0.5988572", "0.5915154", "0.5914226", "0.58787405", "0.58656484", "0.58461535", "0.58336484", "0.58162487", "0.5756441", "0.5742269", "0.57325464", "0.56738394", "0.5596423", "0.5498277", "0.5484772", "0.54764825", "0.5378166", "0.5308027", "0.5234188", "0.51895964", "0.5186818", "0.508611", "0.50691295", "0.50542027", "0.50416285", "0.5016157", "0.5016157", "0.5013567", "0.5006783", "0.5006237", "0.49942553", "0.49495146", "0.4892295", "0.48814654", "0.48739597", "0.4813054", "0.4771174", "0.47640115", "0.47552878", "0.47511724", "0.47432426", "0.4671344", "0.46693468", "0.46490097", "0.46242282", "0.4623493", "0.46034405", "0.45950103", "0.45880786", "0.45399112", "0.45383325", "0.45032215", "0.45008582", "0.44779196", "0.44617343", "0.44615975", "0.44570464", "0.44479606", "0.44405738", "0.44396913", "0.44381264", "0.44363096", "0.4424262", "0.4407367", "0.4382396", "0.43819445", "0.43547598", "0.43540847", "0.43514216", "0.43510196", "0.4346579", "0.43464267", "0.4332307", "0.43243966", "0.43168637", "0.42987216", "0.429143", "0.42886037", "0.42848584", "0.42844257", "0.42824388", "0.42761642", "0.42565677", "0.42527696", "0.42527696", "0.42448616", "0.4238059" ]
0.63288224
2
SetDeviceID adds the deviceId to the get device status params
func (o *GetDeviceHealthParams) SetDeviceID(deviceID string) { o.DeviceID = deviceID }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (rb *ResourceBuilder) SetDeviceID(val string) {\n\tif rb.config.DeviceID.Enabled {\n\t\trb.res.Attributes().PutStr(\"device.id\", val)\n\t}\n}", "func (p Params) SetDeviceID(id string) {\n\tp[\"image_request[device_id]\"] = id\n}", "func (o *GetParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (d *MotorDev) SetDeviceID(id uint32) *MotorDev {\n d.Info.DeviceId = id\n return d\n}", "func (o *GetOutagesParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (o *IPAMServicesReadParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (o *GetServiceDetailsParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *PostDeviceRackParams) SetDeviceID(deviceID *int64) {\n\to.DeviceID = deviceID\n}", "func (o *UpdateDeviceParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (rec *RawEventCreate) SetDeviceID(s string) *RawEventCreate {\n\trec.mutation.SetDeviceID(s)\n\treturn rec\n}", "func (o *PostIPAMSwitchesParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (euo *EquipmentUpdateOne) SetDeviceID(s string) *EquipmentUpdateOne {\n\teuo.device_id = &s\n\treturn euo\n}", "func (o *DeleteDevicesDeviceidInterfacesInterfacenameParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (_options *ListTagsSubscriptionOptions) SetDeviceID(deviceID string) *ListTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (_options *CreateTagsSubscriptionOptions) SetDeviceID(deviceID string) *CreateTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (eu *EquipmentUpdate) SetDeviceID(s string) *EquipmentUpdate {\n\teu.device_id = &s\n\treturn eu\n}", "func (o *PostDevicesDeviceidBackupsBackupidApplyParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *IpamIPAddressesListParams) SetDeviceID(deviceID *string) {\n\to.DeviceID = deviceID\n}", "func (_options *DeleteTagsSubscriptionOptions) SetDeviceID(deviceID string) *DeleteTagsSubscriptionOptions {\n\t_options.DeviceID = core.StringPtr(deviceID)\n\treturn _options\n}", "func (m *DeviceManagementIntentDeviceState) SetDeviceId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (o *DeleteDeviceUsingDELETEParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (o *RevokeDeviceCertificateUsingDELETEParams) SetDeviceID(deviceID string) {\n\to.DeviceID = deviceID\n}", "func (m *AgreementAcceptance) SetDeviceId(value *string)() {\n m.deviceId = value\n}", "func (m *UserExperienceAnalyticsAnomalyDevice) SetDeviceId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *UserExperienceAnalyticsDeviceStartupHistory) SetDeviceId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (o *UpdateProjectDeviceParams) bindDeviceID(rawData []string, hasKey bool, formats strfmt.Registry) error {\n\tvar raw string\n\tif len(rawData) > 0 {\n\t\traw = rawData[len(rawData)-1]\n\t}\n\n\t// Required: true\n\t// Parameter is provided by construction from the route\n\n\to.DeviceID = raw\n\n\treturn nil\n}", "func (isrtu *IPStaticRoutingTableUpdate) SetOnDeviceID(id int) *IPStaticRoutingTableUpdate {\n\tisrtu.mutation.SetOnDeviceID(id)\n\treturn isrtu\n}", "func (o *UpdateDeviceParams) WithDeviceID(deviceID string) *UpdateDeviceParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (isrtuo *IPStaticRoutingTableUpdateOne) SetOnDeviceID(id int) *IPStaticRoutingTableUpdateOne {\n\tisrtuo.mutation.SetOnDeviceID(id)\n\treturn isrtuo\n}", "func (m *UserExperienceAnalyticsMetricHistory) SetDeviceId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) WithDeviceID(deviceID string) *DevicesGetModuleComponentCommandHistoryParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *GetDeviceHealthParams) WithDeviceID(deviceID string) *GetDeviceHealthParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (m *Middleware) SetDeviceUID(w http.ResponseWriter, value ksuid.KSUID) {\n\tc := *m.duidCookieSettings\n\tc.Value = value.String()\n\thttp.SetCookie(w, &c)\n}", "func (m *UserExperienceAnalyticsDeviceScopesItemTriggerDeviceScopeActionPostRequestBody) SetDeviceScopeId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceScopeId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *UserExperienceAnalyticsAnomalyDevice) SetDeviceStatus(value *UserExperienceAnalyticsDeviceStatus)() {\n err := m.GetBackingStore().Set(\"deviceStatus\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *DeviceConfigurationItemRequestBuilder) DeviceStatusesById(id string)(*ie1759fa3aebfd08bd0a0973770111e293804186cb2bccc14cfdf3f11a34c8f75.DeviceConfigurationDeviceStatusItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"deviceConfigurationDeviceStatus%2Did\"] = id\n }\n return ie1759fa3aebfd08bd0a0973770111e293804186cb2bccc14cfdf3f11a34c8f75.NewDeviceConfigurationDeviceStatusItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (eu *EquipmentUpdate) ClearDeviceID() *EquipmentUpdate {\n\teu.device_id = nil\n\teu.cleardevice_id = true\n\treturn eu\n}", "func (e *EdgeRequestContext) DeviceID() string {\n\treturn e.raw.DeviceID\n}", "func (m *FileEvidence) SetMdeDeviceId(value *string)() {\n err := m.GetBackingStore().Set(\"mdeDeviceId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (euo *EquipmentUpdateOne) ClearDeviceID() *EquipmentUpdateOne {\n\teuo.device_id = nil\n\teuo.cleardevice_id = true\n\treturn euo\n}", "func (a *ActiveDevice) Set(m MetaContext, uv keybase1.UserVersion, deviceID keybase1.DeviceID,\n\tsigKey, encKey GenericKey, deviceName string, deviceCtime keybase1.Time, keychainMode KeychainMode) error {\n\ta.Lock()\n\tdefer a.Unlock()\n\n\tif err := a.internalUpdateUserVersionDeviceID(uv, deviceID); err != nil {\n\t\treturn err\n\t}\n\n\ta.signingKey = sigKey\n\ta.encryptionKey = encKey\n\ta.deviceName = deviceName\n\ta.deviceCtime = deviceCtime\n\ta.nistFactory = NewNISTFactory(m.G(), uv.Uid, deviceID, sigKey)\n\ta.secretSyncer = NewSecretSyncer(m.G())\n\ta.keychainMode = keychainMode\n\n\treturn nil\n}", "func (o *GetServiceDetailsParams) WithDeviceID(deviceID string) *GetServiceDetailsParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (o *VirtualizationBaseHostPciDeviceAllOf) SetDeviceId(v int64) {\n\to.DeviceId = &v\n}", "func (m *CreatePostRequestBody) SetPhysicalDeviceId(value *string)() {\n m.physicalDeviceId = value\n}", "func (m MetaData) GetDeviceID() string {\n\tif len(m) == 0 {\n\t\treturn \"\"\n\t}\n\tfor _, k := range []string{\"grpcgateway-x-device-id\", \"x-device-id\", \"device-id\"} {\n\t\tif v := m[k]; v != \"\" {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn \"\"\n}", "func parseDeviceID() Handler {\n\treturn func(rc *RouterContext, w http.ResponseWriter, r *http.Request) *HTTPError {\n\n\t\tdeviceid := r.Header.Get(\"deviceid\")\n\t\tif deviceid == \"\" {\n\t\t\treturn handleMissingDataError(\"deviceid\")\n\t\t}\n\n\t\trc.deviceid = deviceid\n\t\treturn nil\n\t}\n}", "func (m *RepairinvoiceMutation) SetDeviceid(i int) {\n\tm.deviceid = &i\n\tm.adddeviceid = nil\n}", "func (m *GraphBaseServiceClient) DevicesById(id string)(*ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.DeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"device%2Did\"] = id\n }\n return ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.NewDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (m *GraphBaseServiceClient) DevicesById(id string)(*ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.DeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"device%2Did\"] = id\n }\n return ib6d66da0f7d4860b7205f5fdb1200fc9000adb4fbc853a2f05f70c644580220f.NewDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (o *ApplianceDeviceClaimAllOf) SetDeviceId(v string) {\n\to.DeviceId = &v\n}", "func (a *ActiveDevice) internalUpdateUserVersionDeviceID(uv keybase1.UserVersion, deviceID keybase1.DeviceID) error {\n\n\tif uv.IsNil() {\n\t\treturn errors.New(\"ActiveDevice.set with nil uid\")\n\t}\n\tif deviceID.IsNil() {\n\t\treturn errors.New(\"ActiveDevice.set with nil deviceID\")\n\t}\n\n\tif a.uv.IsNil() && a.deviceID.IsNil() {\n\t\ta.uv = uv\n\t\ta.deviceID = deviceID\n\t} else if !a.uv.Eq(uv) {\n\t\treturn errors.New(\"ActiveDevice.set uid mismatch\")\n\t} else if !a.deviceID.Eq(deviceID) {\n\t\treturn errors.New(\"ActiveDevice.set deviceID mismatch\")\n\t}\n\n\treturn nil\n}", "func (m *ImportedWindowsAutopilotDeviceIdentityState) SetDeviceRegistrationId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceRegistrationId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *DeviceLocalCredentialInfo) SetDeviceName(value *string)() {\n err := m.GetBackingStore().Set(\"deviceName\", value)\n if err != nil {\n panic(err)\n }\n}", "func (rec *RawEventCreate) SetNillableDeviceID(s *string) *RawEventCreate {\n\tif s != nil {\n\t\trec.SetDeviceID(*s)\n\t}\n\treturn rec\n}", "func (c *ControllerDevice) DeviceID() string {\n\treturn c.deviceID\n}", "func (m *ImportedWindowsAutopilotDeviceIdentityState) SetDeviceImportStatus(value *ImportedWindowsAutopilotDeviceIdentityImportStatus)() {\n err := m.GetBackingStore().Set(\"deviceImportStatus\", value)\n if err != nil {\n panic(err)\n }\n}", "func GetIDDevicePath(id int) string {\n\tparam0 := strconv.Itoa(id)\n\n\treturn fmt.Sprintf(\"/sources/devices/%s\", param0)\n}", "func (m *UserExperienceAnalyticsAnomalyDevice) SetDeviceName(value *string)() {\n err := m.GetBackingStore().Set(\"deviceName\", value)\n if err != nil {\n panic(err)\n }\n}", "func (c *Client) GetIDDevice(ctx context.Context, path string) (*http.Response, error) {\n\treq, err := c.NewGetIDDeviceRequest(ctx, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.Client.Do(ctx, req)\n}", "func (o *GetParams) WithDeviceID(deviceID string) *GetParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (s *DevStat) SetStatus(active, connected bool) {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\ts.DeviceActive = active\n\ts.DeviceConnected = connected\n\n}", "func (filterdev *NetworkTap) SetDatalink(t int) (int, error) {\n\t_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(filterdev.device.Fd()), syscall.BIOCSDLT, uintptr(unsafe.Pointer(&t)))\n\tif err != 0 {\n\t\treturn 0, syscall.Errno(err)\n\t}\n\treturn t, nil\n}", "func (dt *DeviceToken) SetID(id string) error {\n\tdeviceTokenID, err := strconv.ParseUint(id, 10, 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdt.ID = uint(deviceTokenID)\n\treturn nil\n}", "func (a *ActiveDevice) DeviceID() keybase1.DeviceID {\n\ta.RLock()\n\tdefer a.RUnlock()\n\treturn a.deviceID\n}", "func (m *DeviceManagementRequestBuilder) ManagedDevicesById(id string)(*ic17628b2ada33156bca6f6158e18f62f1027784aa76d9f9a69a4d0cee7e57f3e.ManagedDeviceItemRequestBuilder) {\n urlTplParams := make(map[string]string)\n for idx, item := range m.pathParameters {\n urlTplParams[idx] = item\n }\n if id != \"\" {\n urlTplParams[\"managedDevice%2Did\"] = id\n }\n return ic17628b2ada33156bca6f6158e18f62f1027784aa76d9f9a69a4d0cee7e57f3e.NewManagedDeviceItemRequestBuilderInternal(urlTplParams, m.requestAdapter);\n}", "func (d *Device) SetStatus(status status.FieldDeviceStatus) { d.status = status }", "func (s *service) SetDeviceDiscoveryRequest(ctx context.Context, req *api.DeviceDiscovery) (*api.Empty, error) {\n\tdiscoverMetrics.SetRequestTotalCounters.WithLabelValues(req.GetId()).Inc()\n\tif err := s.Manager.SetDevicesDiscoveryRequest(ctx, *req); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &api.Empty{}, nil\n}", "func (o *InfraBasePciConfigurationAllOf) SetDeviceId(v int64) {\n\to.DeviceId = &v\n}", "func (m *UpdateDeviceRequest) SetDeviceId(v string) *UpdateDeviceRequest {\n\tm.DeviceId = &v\n\treturn m\n}", "func TestDeviceSetName(t *testing.T) {\n\tpool := getStoragePool(t)\n\tassert.NotNil(t, pool)\n\n\tsdsID := getSdsID()\n\tassert.NotEqual(t, sdsID, \"\")\n\n\tdev := &types.DeviceParam{\n\t\tDeviceCurrentPathname: \"/dev/sdc\",\n\t\tSdsID: sdsID,\n\t}\n\n\tdeviceID, err := pool.AttachDevice(dev)\n\tassert.Nil(t, err)\n\tassert.NotNil(t, deviceID)\n\n\terr = pool.SetDeviceName(deviceID, \"device_renamed\")\n\tassert.Nil(t, err)\n\n\tsystem := getSystem()\n\tdevice, err1 := system.GetDevice(deviceID)\n\tassert.Nil(t, err1)\n\tassert.Equal(t, device.Name, \"device_renamed\")\n\n\terr = pool.RemoveDevice(deviceID)\n\tassert.Nil(t, err)\n}", "func (euo *EquipmentUpdateOne) SetNillableDeviceID(s *string) *EquipmentUpdateOne {\n\tif s != nil {\n\t\teuo.SetDeviceID(*s)\n\t}\n\treturn euo\n}", "func DeleteDeviceTwinByDeviceID(obm orm.Ormer, deviceID string) error {\n\tnum, err := obm.QueryTable(DeviceTwinTableName).Filter(\"deviceid\", deviceID).Delete()\n\tif err != nil {\n\t\tklog.Errorf(\"Something wrong when deleting data: %v\", err)\n\t\treturn err\n\t}\n\tklog.V(4).Infof(\"Delete affected Num: %d\", num)\n\treturn nil\n}", "func (m *GetDeviceRequest) GetDeviceId() (val string, set bool) {\n\tif m.DeviceId == nil {\n\t\treturn\n\t}\n\n\treturn *m.DeviceId, true\n}", "func (o *DeleteDevicesDeviceidInterfacesInterfacenameParams) WithDeviceID(deviceID string) *DeleteDevicesDeviceidInterfacesInterfacenameParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (p *EnricherProcessor) HandleDeviceIDDetails(ctx details.Enricher_ProcessorContext, message *deviceId.Details) error {\n\tstate := ctx.State()\n\tstate.Details = message\n\n\tctx.SaveState(state)\n\n\tp.output(ctx, state)\n\n\treturn nil\n}", "func (o *IPAMServicesReadParams) WithDeviceID(deviceID *string) *IPAMServicesReadParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (devices *DeviceSet) constructDeviceIDMap() {\n\tlogrus.Debug(\"devmapper: constructDeviceIDMap()\")\n\tdefer logrus.Debug(\"devmapper: constructDeviceIDMap() END\")\n\n\tfor _, info := range devices.Devices {\n\t\tdevices.markDeviceIDUsed(info.DeviceID)\n\t\tlogrus.Debugf(\"devmapper: Added deviceId=%d to DeviceIdMap\", info.DeviceID)\n\t}\n}", "func (m *UpdateMegaParProfileRequest) SetDeviceId(v string) *UpdateMegaParProfileRequest {\n\tm.DeviceId = &v\n\treturn m\n}", "func deviceStatusHandler(devices map[string]*Device) http.HandlerFunc {\n\treturn func(respWriter http.ResponseWriter, request *http.Request) {\n\t\trespWriter.Header().Add(\"Content-Type\", \"application/json\")\n\t\tbytes, err := json.Marshal(&devices)\n\t\tif err != nil {\n\t\t\thttp.Error(respWriter, \"Can't marshall devices\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\trespWriter.Write(bytes)\n\t}\n}", "func (c *Controller) SetDeviceStatus(d *ControllerDevice, status bool) error {\n\treturn c.setDeviceStatus(d, status, false)\n}", "func (m *WindowsInformationProtectionDeviceRegistration) SetDeviceRegistrationId(value *string)() {\n err := m.GetBackingStore().Set(\"deviceRegistrationId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *WindowsInformationProtectionDeviceRegistration) SetDeviceName(value *string)() {\n err := m.GetBackingStore().Set(\"deviceName\", value)\n if err != nil {\n panic(err)\n }\n}", "func concatDeviceIDPortID(deviceID string, portNo uint32) string {\n\treturn fmt.Sprintf(\"%s:%d\", deviceID, portNo)\n}", "func (devices *DeviceSet) registerDevice(id int, hash string, size uint64, transactionID uint64) (*devInfo, error) {\n\tlogrus.Debugf(\"devmapper: registerDevice(%v, %v)\", id, hash)\n\tinfo := &devInfo{\n\t\tHash: hash,\n\t\tDeviceID: id,\n\t\tSize: size,\n\t\tTransactionID: transactionID,\n\t\tInitialized: false,\n\t\tdevices: devices,\n\t}\n\n\tdevices.Devices[hash] = info\n\n\tif err := devices.saveMetadata(info); err != nil {\n\t\t// Try to remove unused device\n\t\tdelete(devices.Devices, hash)\n\t\treturn nil, err\n\t}\n\n\treturn info, nil\n}", "func (b *addPushNotificationsOnChannelsBuilder) DeviceIDForPush(deviceID string) *addPushNotificationsOnChannelsBuilder {\n\tb.opts.DeviceIDForPush = deviceID\n\treturn b\n}", "func (ctx *HandlerContext) SpecificDeviceHandler(w http.ResponseWriter, r *http.Request) {\n\tsessionState := &SessionState{}\n\tsessID, err := sessions.GetState(r, ctx.SigningKey, ctx.SessStore, sessionState)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"problem with session %v\", err), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tdeviceID := sessionState.Device.ID\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tdevice, err := ctx.deviceStore.GetByID(deviceID)\n\t\tif err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"device not found: %v\", err), http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\t\trespond(w, device, http.StatusOK, ctx.PubVapid)\n\tcase \"PATCH\":\n\t\t// segment := path.Base(r.URL.Path)\n\t\t// if segment != \"me\" || segment != deviceID.Hex() {\n\t\t// \thttp.Error(w, \"unathorized\", http.StatusUnauthorized)\n\t\t// \treturn\n\t\t// }\n\t\tif r.Header.Get(headerContentType) != contentTypeJSON {\n\t\t\thttp.Error(w, \"content type must be application/json\", http.StatusUnsupportedMediaType)\n\t\t\treturn\n\t\t}\n\n\t\tdevice, err := ctx.deviceStore.GetByID(deviceID)\n\t\tif err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"error getting device: %v\", err), http.StatusNotFound)\n\t\t}\n\n\t\tdeviceUpdates := &devices.Updates{}\n\t\tif err := json.NewDecoder(r.Body).Decode(deviceUpdates); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"error decoding JSON: %v\", err), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tif err = device.ApplyUpdates(deviceUpdates); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"error updating device: %v\", err), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tif err = ctx.deviceStore.Update(deviceID, device); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"error updating device: %v\", err), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tsessionState.Device = device\n\t\tif err := ctx.SessStore.Save(sessID, sessionState); err != nil {\n\t\t\thttp.Error(w, fmt.Sprintf(\"error updating session state: %v\", err), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\trespond(w, device, http.StatusOK, ctx.PubVapid)\n\n\tdefault:\n\t\thttp.Error(w, \"method must be GET or PATCH\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n}", "func (o *PostDeviceRackParams) WithDeviceID(deviceID *int64) *PostDeviceRackParams {\n\to.SetDeviceID(deviceID)\n\treturn o\n}", "func (m *UpdateDeviceRequest) GetDeviceId() (val string, set bool) {\n\tif m.DeviceId == nil {\n\t\treturn\n\t}\n\n\treturn *m.DeviceId, true\n}", "func (m *WindowsInformationProtectionDeviceRegistration) SetDeviceType(value *string)() {\n err := m.GetBackingStore().Set(\"deviceType\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *DeviceHealthAttestationState) SetDeviceHealthAttestationStatus(value *string)() {\n err := m.GetBackingStore().Set(\"deviceHealthAttestationStatus\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m *AgedAccountsPayable) SetVendorId(value *string)() {\n err := m.GetBackingStore().Set(\"vendorId\", value)\n if err != nil {\n panic(err)\n }\n}", "func (c *Client) NewGetIDDeviceRequest(ctx context.Context, path string) (*http.Request, error) {\n\tscheme := c.Scheme\n\tif scheme == \"\" {\n\t\tscheme = \"https\"\n\t}\n\tu := url.URL{Host: c.Host, Scheme: scheme, Path: path}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif c.JWTSigner != nil {\n\t\tif err := c.JWTSigner.Sign(req); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn req, nil\n}", "func (s *service) UpdateDeviceStatus(ctx context.Context, tenant string, uid models.UID, status models.DeviceStatus) error {\n\tnamespace, err := s.store.NamespaceGet(ctx, tenant)\n\tif err != nil {\n\t\treturn NewErrNamespaceNotFound(tenant, err)\n\t}\n\n\tdevice, err := s.store.DeviceGetByUID(ctx, uid, tenant)\n\tif err != nil {\n\t\treturn NewErrDeviceNotFound(uid, err)\n\t}\n\n\tif device.Status == models.DeviceStatusAccepted {\n\t\treturn NewErrDeviceStatusAccepted(nil)\n\t}\n\n\t// NOTICE: when there is an already accepted device with the same MAC address, we need to update the device UID\n\t// transfer the sessions and delete the old device.\n\n\tsameMacDev, err := s.store.DeviceGetByMac(ctx, device.Identity.MAC, device.TenantID, models.DeviceStatusAccepted)\n\tif err != nil && err != store.ErrNoDocuments {\n\t\treturn NewErrDeviceNotFound(models.UID(device.UID), err)\n\t}\n\n\tif sameMacDev != nil && sameMacDev.UID != device.UID {\n\t\tif err := s.store.SessionUpdateDeviceUID(ctx, models.UID(sameMacDev.UID), models.UID(device.UID)); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.store.DeviceRename(ctx, models.UID(device.UID), sameMacDev.Name); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.store.DeviceDelete(ctx, models.UID(sameMacDev.UID)); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n\t}\n\n\tif status != models.DeviceStatusAccepted {\n\t\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n\t}\n\n\tswitch {\n\tcase envs.IsCommunity(), envs.IsEnterprise():\n\t\tif namespace.HasMaxDevices() && namespace.HasMaxDevicesReached() {\n\t\t\treturn NewErrDeviceMaxDevicesReached(namespace.MaxDevices)\n\t\t}\n\tcase envs.IsCloud():\n\t\tif namespace.Billing.IsActive() {\n\t\t\tif err := s.BillingReport(s.client.(req.Client), namespace.TenantID, ReportDeviceAccept); err != nil {\n\t\t\t\treturn NewErrBillingReportNamespaceDelete(err)\n\t\t\t}\n\t\t} else {\n\t\t\t// TODO: this strategy that stores the removed devices in the database can be simplified.\n\t\t\tremoved, err := s.store.DeviceRemovedGet(ctx, tenant, uid)\n\t\t\tif err != nil && err != store.ErrNoDocuments {\n\t\t\t\treturn NewErrDeviceRemovedGet(err)\n\t\t\t}\n\n\t\t\tif removed != nil {\n\t\t\t\tif err := s.store.DeviceRemovedDelete(ctx, tenant, uid); err != nil {\n\t\t\t\t\treturn NewErrDeviceRemovedDelete(err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount, err := s.store.DeviceRemovedCount(ctx, tenant)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn NewErrDeviceRemovedCount(err)\n\t\t\t\t}\n\n\t\t\t\tif namespace.HasMaxDevices() && int64(namespace.DevicesCount)+count >= int64(namespace.MaxDevices) {\n\t\t\t\t\treturn NewErrDeviceRemovedFull(namespace.MaxDevices, nil)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tok, err := s.BillingEvaluate(s.client.(req.Client), namespace.TenantID)\n\t\t\tif err != nil {\n\t\t\t\treturn NewErrBillingEvaluate(err)\n\t\t\t}\n\n\t\t\tif !ok {\n\t\t\t\treturn ErrDeviceLimit\n\t\t\t}\n\t\t}\n\t}\n\n\treturn s.store.DeviceUpdateStatus(ctx, uid, status)\n}", "func (eu *EquipmentUpdate) SetNillableDeviceID(s *string) *EquipmentUpdate {\n\tif s != nil {\n\t\teu.SetDeviceID(*s)\n\t}\n\treturn eu\n}", "func (devices *DeviceSet) GetDeviceStatus(hash string) (*DevStatus, error) {\n\tinfo, err := devices.lookupDeviceWithLock(hash)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo.lock.Lock()\n\tdefer info.lock.Unlock()\n\n\tdevices.Lock()\n\tdefer devices.Unlock()\n\n\tstatus := &DevStatus{\n\t\tDeviceID: info.DeviceID,\n\t\tSize: info.Size,\n\t\tTransactionID: info.TransactionID,\n\t}\n\n\tif err := devices.activateDeviceIfNeeded(info, false); err != nil {\n\t\treturn nil, fmt.Errorf(\"devmapper: Error activating devmapper device for '%s': %s\", hash, err)\n\t}\n\n\tsizeInSectors, mappedSectors, highestMappedSector, err := devices.deviceStatus(info.DevName())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstatus.SizeInSectors = sizeInSectors\n\tstatus.MappedSectors = mappedSectors\n\tstatus.HighestMappedSector = highestMappedSector\n\n\treturn status, nil\n}", "func (o *TechsupportmanagementEndPointAllOf) SetDeviceMoid(v string) {\n\to.DeviceMoid = &v\n}", "func (m *GetDeviceRequest) SetDeviceId(v string) *GetDeviceRequest {\n\tm.DeviceId = &v\n\treturn m\n}", "func (vera *Vera) getDeviceInfo(deviceID string) (DeviceInfo, error) {\n\tvar device Device\n\n\tfor _, d := range vera.Devices.Devices {\n\t\tif deviceID == d.PKDevice {\n\t\t\tdevice = d\n\t\t}\n\t}\n\n\tif device == (Device{}) {\n\t\treturn DeviceInfo{}, fmt.Errorf(\"%w: %s\", errDeviceNotFound, deviceID)\n\t}\n\n\turl := https + device.ServerDevice + devicePath + deviceID\n\n\tdeviceInfo, err := vera.getDeviceInfoURL(url)\n\t// Try using ServerDeviceAlt if ServerDevice doesn't work\n\tif err != nil {\n\t\turl = https + device.ServerDeviceAlt + devicePath + deviceID\n\t\tdeviceInfo, err = vera.getDeviceInfoURL(url)\n\t}\n\n\treturn deviceInfo, err\n}", "func (o *GetAOrderStatusParams) SetStatusID(statusID int32) {\n\to.StatusID = statusID\n}" ]
[ "0.7785044", "0.77081025", "0.7526304", "0.745228", "0.7379186", "0.73099244", "0.72466093", "0.7216257", "0.7153561", "0.7121655", "0.70497", "0.7043483", "0.6979578", "0.68810636", "0.68505144", "0.68119067", "0.6803687", "0.6719926", "0.6678612", "0.6663735", "0.6542931", "0.64915705", "0.6484269", "0.643524", "0.6022229", "0.5980687", "0.598051", "0.59109116", "0.58812374", "0.58792514", "0.5878438", "0.5871121", "0.5568505", "0.5543862", "0.55376655", "0.5487612", "0.54367274", "0.54321635", "0.5424464", "0.538959", "0.5344529", "0.5333078", "0.5273742", "0.5267328", "0.5207941", "0.5199859", "0.5193496", "0.5166172", "0.51565844", "0.51565844", "0.51201487", "0.5109872", "0.50634927", "0.5050062", "0.5021598", "0.49845722", "0.4971625", "0.49708197", "0.49495482", "0.49274036", "0.48879385", "0.48378175", "0.4833806", "0.4823454", "0.48200342", "0.48049733", "0.4804136", "0.4799659", "0.47769547", "0.47723997", "0.47661293", "0.47640854", "0.47577652", "0.47573686", "0.47505122", "0.47492984", "0.4748678", "0.4741673", "0.4740905", "0.4734482", "0.47339752", "0.47218385", "0.471243", "0.47109875", "0.469139", "0.46864423", "0.46769667", "0.46765056", "0.4672599", "0.46629587", "0.46350044", "0.46308932", "0.4629464", "0.46255288", "0.46250835", "0.46166575", "0.4611526", "0.4606625", "0.4605587", "0.46049765" ]
0.7332639
5
WriteToRequest writes these params to a swagger request
func (o *GetDeviceHealthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { if err := r.SetTimeout(o.timeout); err != nil { return err } var res []error // header param Authorization if err := r.SetHeaderParam("Authorization", o.Authorization); err != nil { return err } // path param deviceId if err := r.SetPathParam("deviceId", o.DeviceID); err != nil { return err } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *FileInfoCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.ByteOffset != nil {\n\n\t\t// query param byte_offset\n\t\tvar qrByteOffset int64\n\n\t\tif o.ByteOffset != nil {\n\t\t\tqrByteOffset = *o.ByteOffset\n\t\t}\n\t\tqByteOffset := swag.FormatInt64(qrByteOffset)\n\t\tif qByteOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"byte_offset\", qByteOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Overwrite != nil {\n\n\t\t// query param overwrite\n\t\tvar qrOverwrite bool\n\n\t\tif o.Overwrite != nil {\n\t\t\tqrOverwrite = *o.Overwrite\n\t\t}\n\t\tqOverwrite := swag.FormatBool(qrOverwrite)\n\t\tif qOverwrite != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"overwrite\", qOverwrite); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param path\n\tif err := r.SetPathParam(\"path\", o.Path); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.StreamName != nil {\n\n\t\t// query param stream_name\n\t\tvar qrStreamName string\n\n\t\tif o.StreamName != nil {\n\t\t\tqrStreamName = *o.StreamName\n\t\t}\n\t\tqStreamName := qrStreamName\n\t\tif qStreamName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"stream_name\", qStreamName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param volume.uuid\n\tif err := r.SetPathParam(\"volume.uuid\", o.VolumeUUID); 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 *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Device-Id\n\tif err := r.SetHeaderParam(\"Device-Id\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DeviceOS != nil {\n\n\t\t// header param Device-OS\n\t\tif err := r.SetHeaderParam(\"Device-OS\", *o.DeviceOS); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param fiscalDocumentNumber\n\tif err := r.SetPathParam(\"fiscalDocumentNumber\", swag.FormatUint64(o.FiscalDocumentNumber)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param fiscalDriveNumber\n\tif err := r.SetPathParam(\"fiscalDriveNumber\", swag.FormatUint64(o.FiscalDriveNumber)); err != nil {\n\t\treturn err\n\t}\n\n\t// query param fiscalSign\n\tqrFiscalSign := o.FiscalSign\n\tqFiscalSign := swag.FormatUint64(qrFiscalSign)\n\tif qFiscalSign != \"\" {\n\t\tif err := r.SetQueryParam(\"fiscalSign\", qFiscalSign); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.SendToEmail != nil {\n\n\t\t// query param sendToEmail\n\t\tvar qrSendToEmail string\n\t\tif o.SendToEmail != nil {\n\t\t\tqrSendToEmail = *o.SendToEmail\n\t\t}\n\t\tqSendToEmail := qrSendToEmail\n\t\tif qSendToEmail != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sendToEmail\", qSendToEmail); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *StartV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Environment != nil {\n\n\t\t// query param environment\n\t\tvar qrEnvironment string\n\t\tif o.Environment != nil {\n\t\t\tqrEnvironment = *o.Environment\n\t\t}\n\t\tqEnvironment := qrEnvironment\n\t\tif qEnvironment != \"\" {\n\t\t\tif err := r.SetQueryParam(\"environment\", qEnvironment); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateAutoTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID.String()); 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 *GetIntrospectionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ResponseAsJwt != nil {\n\n\t\t// query param response_as_jwt\n\t\tvar qrResponseAsJwt bool\n\t\tif o.ResponseAsJwt != nil {\n\t\t\tqrResponseAsJwt = *o.ResponseAsJwt\n\t\t}\n\t\tqResponseAsJwt := swag.FormatBool(qrResponseAsJwt)\n\t\tif qResponseAsJwt != \"\" {\n\t\t\tif err := r.SetQueryParam(\"response_as_jwt\", qResponseAsJwt); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param token\n\tqrToken := o.Token\n\tqToken := qrToken\n\tif qToken != \"\" {\n\t\tif err := r.SetQueryParam(\"token\", qToken); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.TokenTypeHint != nil {\n\n\t\t// query param token_type_hint\n\t\tvar qrTokenTypeHint string\n\t\tif o.TokenTypeHint != nil {\n\t\t\tqrTokenTypeHint = *o.TokenTypeHint\n\t\t}\n\t\tqTokenTypeHint := qrTokenTypeHint\n\t\tif qTokenTypeHint != \"\" {\n\t\t\tif err := r.SetQueryParam(\"token_type_hint\", qTokenTypeHint); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostContextsAddPhpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param name\n\tqrName := o.Name\n\tqName := qrName\n\tif qName != \"\" {\n\n\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Private != nil {\n\n\t\t// query param private\n\t\tvar qrPrivate int64\n\n\t\tif o.Private != nil {\n\t\t\tqrPrivate = *o.Private\n\t\t}\n\t\tqPrivate := swag.FormatInt64(qrPrivate)\n\t\tif qPrivate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"private\", qPrivate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetInstancesDocsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.OperationID != nil {\n\n\t\t// query param operationId\n\t\tvar qrOperationID string\n\t\tif o.OperationID != nil {\n\t\t\tqrOperationID = *o.OperationID\n\t\t}\n\t\tqOperationID := qrOperationID\n\t\tif qOperationID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"operationId\", qOperationID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Version != nil {\n\n\t\t// query param version\n\t\tvar qrVersion string\n\t\tif o.Version != nil {\n\t\t\tqrVersion = *o.Version\n\t\t}\n\t\tqVersion := qrVersion\n\t\tif qVersion != \"\" {\n\t\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CloudTargetCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.CheckOnly != nil {\n\n\t\t// query param check_only\n\t\tvar qrCheckOnly bool\n\n\t\tif o.CheckOnly != nil {\n\t\t\tqrCheckOnly = *o.CheckOnly\n\t\t}\n\t\tqCheckOnly := swag.FormatBool(qrCheckOnly)\n\t\tif qCheckOnly != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"check_only\", qCheckOnly); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.IgnoreWarnings != nil {\n\n\t\t// query param ignore_warnings\n\t\tvar qrIgnoreWarnings bool\n\n\t\tif o.IgnoreWarnings != nil {\n\t\t\tqrIgnoreWarnings = *o.IgnoreWarnings\n\t\t}\n\t\tqIgnoreWarnings := swag.FormatBool(qrIgnoreWarnings)\n\t\tif qIgnoreWarnings != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ignore_warnings\", qIgnoreWarnings); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ReturnTimeout != nil {\n\n\t\t// query param return_timeout\n\t\tvar qrReturnTimeout int64\n\n\t\tif o.ReturnTimeout != nil {\n\t\t\tqrReturnTimeout = *o.ReturnTimeout\n\t\t}\n\t\tqReturnTimeout := swag.FormatInt64(qrReturnTimeout)\n\t\tif qReturnTimeout != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_timeout\", qReturnTimeout); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SayParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Sinkid != nil {\n\n\t\t// query param sinkid\n\t\tvar qrSinkid string\n\t\tif o.Sinkid != nil {\n\t\t\tqrSinkid = *o.Sinkid\n\t\t}\n\t\tqSinkid := qrSinkid\n\t\tif qSinkid != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sinkid\", qSinkid); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Voiceid != nil {\n\n\t\t// query param voiceid\n\t\tvar qrVoiceid string\n\t\tif o.Voiceid != nil {\n\t\t\tqrVoiceid = *o.Voiceid\n\t\t}\n\t\tqVoiceid := qrVoiceid\n\t\tif qVoiceid != \"\" {\n\t\t\tif err := r.SetQueryParam(\"voiceid\", qVoiceid); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *HandleGetAboutUsingGETParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param apiVersion\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\n\tif err := r.SetQueryParam(\"apiVersion\", qAPIVersion); 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 *GetFileSystemParametersInternalParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID string\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID\n\t\tif qAccountID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.AccountName != nil {\n\n\t\t// query param accountName\n\t\tvar qrAccountName string\n\t\tif o.AccountName != nil {\n\t\t\tqrAccountName = *o.AccountName\n\t\t}\n\t\tqAccountName := qrAccountName\n\t\tif qAccountName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountName\", qAccountName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.AttachedCluster != nil {\n\n\t\t// query param attachedCluster\n\t\tvar qrAttachedCluster bool\n\t\tif o.AttachedCluster != nil {\n\t\t\tqrAttachedCluster = *o.AttachedCluster\n\t\t}\n\t\tqAttachedCluster := swag.FormatBool(qrAttachedCluster)\n\t\tif qAttachedCluster != \"\" {\n\t\t\tif err := r.SetQueryParam(\"attachedCluster\", qAttachedCluster); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param blueprintName\n\tqrBlueprintName := o.BlueprintName\n\tqBlueprintName := qrBlueprintName\n\tif qBlueprintName != \"\" {\n\t\tif err := r.SetQueryParam(\"blueprintName\", qBlueprintName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param clusterName\n\tqrClusterName := o.ClusterName\n\tqClusterName := qrClusterName\n\tif qClusterName != \"\" {\n\t\tif err := r.SetQueryParam(\"clusterName\", qClusterName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param fileSystemType\n\tqrFileSystemType := o.FileSystemType\n\tqFileSystemType := qrFileSystemType\n\tif qFileSystemType != \"\" {\n\t\tif err := r.SetQueryParam(\"fileSystemType\", qFileSystemType); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Secure != nil {\n\n\t\t// query param secure\n\t\tvar qrSecure bool\n\t\tif o.Secure != nil {\n\t\t\tqrSecure = *o.Secure\n\t\t}\n\t\tqSecure := swag.FormatBool(qrSecure)\n\t\tif qSecure != \"\" {\n\t\t\tif err := r.SetQueryParam(\"secure\", qSecure); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param storageName\n\tqrStorageName := o.StorageName\n\tqStorageName := qrStorageName\n\tif qStorageName != \"\" {\n\t\tif err := r.SetQueryParam(\"storageName\", qStorageName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param workspaceId\n\tif err := r.SetPathParam(\"workspaceId\", swag.FormatInt64(o.WorkspaceID)); 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 *ServeBuildFieldShortParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param btLocator\n\tif err := r.SetPathParam(\"btLocator\", o.BtLocator); err != nil {\n\t\treturn err\n\t}\n\n\t// path param buildLocator\n\tif err := r.SetPathParam(\"buildLocator\", o.BuildLocator); err != nil {\n\t\treturn err\n\t}\n\n\t// path param field\n\tif err := r.SetPathParam(\"field\", o.Field); err != nil {\n\t\treturn err\n\t}\n\n\t// path param projectLocator\n\tif err := r.SetPathParam(\"projectLocator\", o.ProjectLocator); 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 *GetRequestDetailsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param extra\n\tif err := r.SetPathParam(\"extra\", o.Extra); 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 *GetWorkItemParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DollarExpand != nil {\n\n\t\t// query param $expand\n\t\tvar qrNrDollarExpand string\n\t\tif o.DollarExpand != nil {\n\t\t\tqrNrDollarExpand = *o.DollarExpand\n\t\t}\n\t\tqNrDollarExpand := qrNrDollarExpand\n\t\tif qNrDollarExpand != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$expand\", qNrDollarExpand); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.AsOf != nil {\n\n\t\t// query param asOf\n\t\tvar qrAsOf strfmt.DateTime\n\t\tif o.AsOf != nil {\n\t\t\tqrAsOf = *o.AsOf\n\t\t}\n\t\tqAsOf := qrAsOf.String()\n\t\tif qAsOf != \"\" {\n\t\t\tif err := r.SetQueryParam(\"asOf\", qAsOf); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt32(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); 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 *IntegrationsManualHTTPSCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Data); 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 *ValidateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostSecdefSearchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Symbol); 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 *UserShowV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); 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 *GetLogsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.From != nil {\n\n\t\t// query param from\n\t\tvar qrFrom string\n\t\tif o.From != nil {\n\t\t\tqrFrom = *o.From\n\t\t}\n\t\tqFrom := qrFrom\n\t\tif qFrom != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeFields != nil {\n\n\t\t// query param include_fields\n\t\tvar qrIncludeFields bool\n\t\tif o.IncludeFields != nil {\n\t\t\tqrIncludeFields = *o.IncludeFields\n\t\t}\n\t\tqIncludeFields := swag.FormatBool(qrIncludeFields)\n\t\tif qIncludeFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_fields\", qIncludeFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeTotals != nil {\n\n\t\t// query param include_totals\n\t\tvar qrIncludeTotals bool\n\t\tif o.IncludeTotals != nil {\n\t\t\tqrIncludeTotals = *o.IncludeTotals\n\t\t}\n\t\tqIncludeTotals := swag.FormatBool(qrIncludeTotals)\n\t\tif qIncludeTotals != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_totals\", qIncludeTotals); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int64\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt64(qrPerPage)\n\t\tif qPerPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Take != nil {\n\n\t\t// query param take\n\t\tvar qrTake int64\n\t\tif o.Take != nil {\n\t\t\tqrTake = *o.Take\n\t\t}\n\t\tqTake := swag.FormatInt64(qrTake)\n\t\tif qTake != \"\" {\n\t\t\tif err := r.SetQueryParam(\"take\", qTake); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostGetOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tvaluesRelated := o.Related\n\n\tjoinedRelated := swag.JoinByFormat(valuesRelated, \"\")\n\t// query array param related\n\tif err := r.SetQueryParam(\"related\", joinedRelated...); 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 *BarParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); 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 *ConfigGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Option != nil {\n\n\t\t// binding items for option\n\t\tjoinedOption := o.bindParamOption(reg)\n\n\t\t// query array param option\n\t\tif err := r.SetQueryParam(\"option\", joinedOption...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ProjectID != nil {\n\n\t\t// query param project_id\n\t\tvar qrProjectID int64\n\n\t\tif o.ProjectID != nil {\n\t\t\tqrProjectID = *o.ProjectID\n\t\t}\n\t\tqProjectID := swag.FormatInt64(qrProjectID)\n\t\tif qProjectID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"project_id\", qProjectID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.UserID != nil {\n\n\t\t// query param user_id\n\t\tvar qrUserID int64\n\n\t\tif o.UserID != nil {\n\t\t\tqrUserID = *o.UserID\n\t\t}\n\t\tqUserID := swag.FormatInt64(qrUserID)\n\t\tif qUserID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"user_id\", qUserID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetSsoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param code\n\tqrCode := o.Code\n\tqCode := qrCode\n\tif qCode != \"\" {\n\t\tif err := r.SetQueryParam(\"code\", qCode); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param resource_id\n\tqrResourceID := o.ResourceID\n\tqResourceID := qrResourceID\n\tif qResourceID != \"\" {\n\t\tif err := r.SetQueryParam(\"resource_id\", qResourceID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AllLookmlTestsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.FileID != nil {\n\n\t\t// query param file_id\n\t\tvar qrFileID string\n\t\tif o.FileID != nil {\n\t\t\tqrFileID = *o.FileID\n\t\t}\n\t\tqFileID := qrFileID\n\t\tif qFileID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"file_id\", qFileID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param project_id\n\tif err := r.SetPathParam(\"project_id\", o.ProjectID); 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 *APIServiceHaltsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Height != nil {\n\n\t\t// query param height\n\t\tvar qrHeight string\n\t\tif o.Height != nil {\n\t\t\tqrHeight = *o.Height\n\t\t}\n\t\tqHeight := qrHeight\n\t\tif qHeight != \"\" {\n\t\t\tif err := r.SetQueryParam(\"height\", qHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Connection != nil {\n\n\t\t// query param connection\n\t\tvar qrConnection string\n\t\tif o.Connection != nil {\n\t\t\tqrConnection = *o.Connection\n\t\t}\n\t\tqConnection := qrConnection\n\t\tif qConnection != \"\" {\n\t\t\tif err := r.SetQueryParam(\"connection\", qConnection); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeFields != nil {\n\n\t\t// query param include_fields\n\t\tvar qrIncludeFields bool\n\t\tif o.IncludeFields != nil {\n\t\t\tqrIncludeFields = *o.IncludeFields\n\t\t}\n\t\tqIncludeFields := swag.FormatBool(qrIncludeFields)\n\t\tif qIncludeFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_fields\", qIncludeFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeTotals != nil {\n\n\t\t// query param include_totals\n\t\tvar qrIncludeTotals bool\n\t\tif o.IncludeTotals != nil {\n\t\t\tqrIncludeTotals = *o.IncludeTotals\n\t\t}\n\t\tqIncludeTotals := swag.FormatBool(qrIncludeTotals)\n\t\tif qIncludeTotals != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_totals\", qIncludeTotals); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int64\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt64(qrPerPage)\n\t\tif qPerPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SearchEngine != nil {\n\n\t\t// query param search_engine\n\t\tvar qrSearchEngine string\n\t\tif o.SearchEngine != nil {\n\t\t\tqrSearchEngine = *o.SearchEngine\n\t\t}\n\t\tqSearchEngine := qrSearchEngine\n\t\tif qSearchEngine != \"\" {\n\t\t\tif err := r.SetQueryParam(\"search_engine\", qSearchEngine); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBlockGeneratorResultParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); 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 *CreateRuntimeMapParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.FileUpload != nil {\n\n\t\tif o.FileUpload != nil {\n\n\t\t\t// form file param file_upload\n\t\t\tif err := r.SetFileParam(\"file_upload\", o.FileUpload); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetUserUsageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Cloud != nil {\n\n\t\t// query param cloud\n\t\tvar qrCloud string\n\t\tif o.Cloud != nil {\n\t\t\tqrCloud = *o.Cloud\n\t\t}\n\t\tqCloud := qrCloud\n\t\tif qCloud != \"\" {\n\t\t\tif err := r.SetQueryParam(\"cloud\", qCloud); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterenddate != nil {\n\n\t\t// query param filterenddate\n\t\tvar qrFilterenddate int64\n\t\tif o.Filterenddate != nil {\n\t\t\tqrFilterenddate = *o.Filterenddate\n\t\t}\n\t\tqFilterenddate := swag.FormatInt64(qrFilterenddate)\n\t\tif qFilterenddate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterenddate\", qFilterenddate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Since != nil {\n\n\t\t// query param since\n\t\tvar qrSince int64\n\t\tif o.Since != nil {\n\t\t\tqrSince = *o.Since\n\t\t}\n\t\tqSince := swag.FormatInt64(qrSince)\n\t\tif qSince != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since\", qSince); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Zone != nil {\n\n\t\t// query param zone\n\t\tvar qrZone string\n\t\tif o.Zone != nil {\n\t\t\tqrZone = *o.Zone\n\t\t}\n\t\tqZone := qrZone\n\t\tif qZone != \"\" {\n\t\t\tif err := r.SetQueryParam(\"zone\", qZone); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetOrderParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.MerchantID != nil {\n\n\t\t// query param merchantId\n\t\tvar qrMerchantID int64\n\t\tif o.MerchantID != nil {\n\t\t\tqrMerchantID = *o.MerchantID\n\t\t}\n\t\tqMerchantID := swag.FormatInt64(qrMerchantID)\n\t\tif qMerchantID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"merchantId\", qMerchantID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPropertyDescriptorParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\t// query param propertyName\n\tqrPropertyName := o.PropertyName\n\tqPropertyName := qrPropertyName\n\tif qPropertyName != \"\" {\n\n\t\tif err := r.SetQueryParam(\"propertyName\", qPropertyName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCurrentGenerationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateGitWebhookUsingPOSTParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param apiVersion\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\n\tif err := r.SetQueryParam(\"apiVersion\", qAPIVersion); err != nil {\n\t\treturn err\n\t}\n\tif err := r.SetBodyParam(o.GitWebhookSpec); 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 *ViewsGetByIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param identifier\n\tif err := r.SetPathParam(\"identifier\", o.Identifier); 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 *UpdateDeviceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.UpdateDeviceRequest != nil {\n\t\tif err := r.SetBodyParam(o.UpdateDeviceRequest); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SaveTemplateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\t// path param templateId\n\tif err := r.SetPathParam(\"templateId\", o.TemplateID); 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 *ConvertParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param from.currency_code\n\tif err := r.SetPathParam(\"from.currency_code\", o.FromCurrencyCode); err != nil {\n\t\treturn err\n\t}\n\n\tif o.FromNanos != nil {\n\n\t\t// query param from.nanos\n\t\tvar qrFromNanos int32\n\t\tif o.FromNanos != nil {\n\t\t\tqrFromNanos = *o.FromNanos\n\t\t}\n\t\tqFromNanos := swag.FormatInt32(qrFromNanos)\n\t\tif qFromNanos != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from.nanos\", qFromNanos); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.FromUnits != nil {\n\n\t\t// query param from.units\n\t\tvar qrFromUnits string\n\t\tif o.FromUnits != nil {\n\t\t\tqrFromUnits = *o.FromUnits\n\t\t}\n\t\tqFromUnits := qrFromUnits\n\t\tif qFromUnits != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from.units\", qFromUnits); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param to_code\n\tif err := r.SetPathParam(\"to_code\", o.ToCode); 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 *SystemEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Filters != nil {\n\n\t\t// query param filters\n\t\tvar qrFilters string\n\t\tif o.Filters != nil {\n\t\t\tqrFilters = *o.Filters\n\t\t}\n\t\tqFilters := qrFilters\n\t\tif qFilters != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filters\", qFilters); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Since != nil {\n\n\t\t// query param since\n\t\tvar qrSince string\n\t\tif o.Since != nil {\n\t\t\tqrSince = *o.Since\n\t\t}\n\t\tqSince := qrSince\n\t\tif qSince != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since\", qSince); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Until != nil {\n\n\t\t// query param until\n\t\tvar qrUntil string\n\t\tif o.Until != nil {\n\t\t\tqrUntil = *o.Until\n\t\t}\n\t\tqUntil := qrUntil\n\t\tif qUntil != \"\" {\n\t\t\tif err := r.SetQueryParam(\"until\", qUntil); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBundleByKeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Audit != nil {\n\n\t\t// query param audit\n\t\tvar qrAudit string\n\n\t\tif o.Audit != nil {\n\t\t\tqrAudit = *o.Audit\n\t\t}\n\t\tqAudit := qrAudit\n\t\tif qAudit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"audit\", qAudit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// query param externalKey\n\tqrExternalKey := o.ExternalKey\n\tqExternalKey := qrExternalKey\n\tif qExternalKey != \"\" {\n\n\t\tif err := r.SetQueryParam(\"externalKey\", qExternalKey); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.IncludedDeleted != nil {\n\n\t\t// query param includedDeleted\n\t\tvar qrIncludedDeleted bool\n\n\t\tif o.IncludedDeleted != nil {\n\t\t\tqrIncludedDeleted = *o.IncludedDeleted\n\t\t}\n\t\tqIncludedDeleted := swag.FormatBool(qrIncludedDeleted)\n\t\tif qIncludedDeleted != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"includedDeleted\", qIncludedDeleted); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SwarmUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.RotateManagerToken != nil {\n\n\t\t// query param rotateManagerToken\n\t\tvar qrRotateManagerToken bool\n\t\tif o.RotateManagerToken != nil {\n\t\t\tqrRotateManagerToken = *o.RotateManagerToken\n\t\t}\n\t\tqRotateManagerToken := swag.FormatBool(qrRotateManagerToken)\n\t\tif qRotateManagerToken != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateManagerToken\", qRotateManagerToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.RotateManagerUnlockKey != nil {\n\n\t\t// query param rotateManagerUnlockKey\n\t\tvar qrRotateManagerUnlockKey bool\n\t\tif o.RotateManagerUnlockKey != nil {\n\t\t\tqrRotateManagerUnlockKey = *o.RotateManagerUnlockKey\n\t\t}\n\t\tqRotateManagerUnlockKey := swag.FormatBool(qrRotateManagerUnlockKey)\n\t\tif qRotateManagerUnlockKey != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateManagerUnlockKey\", qRotateManagerUnlockKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.RotateWorkerToken != nil {\n\n\t\t// query param rotateWorkerToken\n\t\tvar qrRotateWorkerToken bool\n\t\tif o.RotateWorkerToken != nil {\n\t\t\tqrRotateWorkerToken = *o.RotateWorkerToken\n\t\t}\n\t\tqRotateWorkerToken := swag.FormatBool(qrRotateWorkerToken)\n\t\tif qRotateWorkerToken != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateWorkerToken\", qRotateWorkerToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param version\n\tqrVersion := o.Version\n\tqVersion := swag.FormatInt64(qrVersion)\n\tif qVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ServiceInstanceGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.XBrokerAPIOriginatingIdentity != nil {\n\n\t\t// header param X-Broker-API-Originating-Identity\n\t\tif err := r.SetHeaderParam(\"X-Broker-API-Originating-Identity\", *o.XBrokerAPIOriginatingIdentity); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param X-Broker-API-Version\n\tif err := r.SetHeaderParam(\"X-Broker-API-Version\", o.XBrokerAPIVersion); err != nil {\n\t\treturn err\n\t}\n\n\t// path param instance_id\n\tif err := r.SetPathParam(\"instance_id\", o.InstanceID); 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 *ShowPackageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param media_type\n\tif err := r.SetPathParam(\"media_type\", o.MediaType); err != nil {\n\t\treturn err\n\t}\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param package\n\tif err := r.SetPathParam(\"package\", o.Package); err != nil {\n\t\treturn err\n\t}\n\n\t// path param release\n\tif err := r.SetPathParam(\"release\", o.Release); 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 *SizeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Parameters); 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 *GetOutagesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param count\n\tqrCount := o.Count\n\tqCount := swag.FormatFloat64(qrCount)\n\tif qCount != \"\" {\n\n\t\tif err := r.SetQueryParam(\"count\", qCount); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.DeviceID != nil {\n\n\t\t// query param deviceId\n\t\tvar qrDeviceID string\n\n\t\tif o.DeviceID != nil {\n\t\t\tqrDeviceID = *o.DeviceID\n\t\t}\n\t\tqDeviceID := qrDeviceID\n\t\tif qDeviceID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"deviceId\", qDeviceID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.InProgress != nil {\n\n\t\t// query param inProgress\n\t\tvar qrInProgress bool\n\n\t\tif o.InProgress != nil {\n\t\t\tqrInProgress = *o.InProgress\n\t\t}\n\t\tqInProgress := swag.FormatBool(qrInProgress)\n\t\tif qInProgress != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"inProgress\", qInProgress); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// query param page\n\tqrPage := o.Page\n\tqPage := swag.FormatFloat64(qrPage)\n\tif qPage != \"\" {\n\n\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Period != nil {\n\n\t\t// query param period\n\t\tvar qrPeriod float64\n\n\t\tif o.Period != nil {\n\t\t\tqrPeriod = *o.Period\n\t\t}\n\t\tqPeriod := swag.FormatFloat64(qrPeriod)\n\t\tif qPeriod != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"period\", qPeriod); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *TerminateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param extractorId\n\tif err := r.SetPathParam(\"extractorId\", o.ExtractorID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param inputId\n\tif err := r.SetPathParam(\"inputId\", o.InputID); 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 *ServeFieldParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param field\n\tif err := r.SetPathParam(\"field\", o.Field); err != nil {\n\t\treturn err\n\t}\n\n\t// path param vcsRootLocator\n\tif err := r.SetPathParam(\"vcsRootLocator\", o.VcsRootLocator); 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 *PostV1DevicesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// form param device_identifier\n\tfrDeviceIdentifier := o.DeviceIdentifier\n\tfDeviceIdentifier := frDeviceIdentifier\n\tif fDeviceIdentifier != \"\" {\n\t\tif err := r.SetFormParam(\"device_identifier\", fDeviceIdentifier); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// form param kind\n\tfrKind := o.Kind\n\tfKind := frKind\n\tif fKind != \"\" {\n\t\tif err := r.SetFormParam(\"kind\", fKind); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// form param name\n\tfrName := o.Name\n\tfName := frName\n\tif fName != \"\" {\n\t\tif err := r.SetFormParam(\"name\", fName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.NotificationIdentifier != nil {\n\n\t\t// form param notification_identifier\n\t\tvar frNotificationIdentifier string\n\t\tif o.NotificationIdentifier != nil {\n\t\t\tfrNotificationIdentifier = *o.NotificationIdentifier\n\t\t}\n\t\tfNotificationIdentifier := frNotificationIdentifier\n\t\tif fNotificationIdentifier != \"\" {\n\t\t\tif err := r.SetFormParam(\"notification_identifier\", fNotificationIdentifier); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SubscribeNotification != nil {\n\n\t\t// form param subscribe_notification\n\t\tvar frSubscribeNotification bool\n\t\tif o.SubscribeNotification != nil {\n\t\t\tfrSubscribeNotification = *o.SubscribeNotification\n\t\t}\n\t\tfSubscribeNotification := swag.FormatBool(frSubscribeNotification)\n\t\tif fSubscribeNotification != \"\" {\n\t\t\tif err := r.SetFormParam(\"subscribe_notification\", fSubscribeNotification); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *QueryFirewallFieldsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset string\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := qrOffset\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PlatformID != nil {\n\n\t\t// query param platform_id\n\t\tvar qrPlatformID string\n\n\t\tif o.PlatformID != nil {\n\t\t\tqrPlatformID = *o.PlatformID\n\t\t}\n\t\tqPlatformID := qrPlatformID\n\t\tif qPlatformID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"platform_id\", qPlatformID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCatalogXMLParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID strfmt.UUID\n\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID.String()\n\t\tif qAccountID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.RequestedDate != nil {\n\n\t\t// query param requestedDate\n\t\tvar qrRequestedDate strfmt.DateTime\n\n\t\tif o.RequestedDate != nil {\n\t\t\tqrRequestedDate = *o.RequestedDate\n\t\t}\n\t\tqRequestedDate := qrRequestedDate.String()\n\t\tif qRequestedDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"requestedDate\", qRequestedDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetClockParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param X-Killbill-ApiKey\n\tif err := r.SetHeaderParam(\"X-Killbill-ApiKey\", o.XKillbillAPIKey); err != nil {\n\t\treturn err\n\t}\n\n\t// header param X-Killbill-ApiSecret\n\tif err := r.SetHeaderParam(\"X-Killbill-ApiSecret\", o.XKillbillAPISecret); err != nil {\n\t\treturn err\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AdminCreateJusticeUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param targetNamespace\n\tif err := r.SetPathParam(\"targetNamespace\", o.TargetNamespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param userId\n\tif err := r.SetPathParam(\"userId\", o.UserID); 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 *UpdateWidgetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Accept != nil {\n\n\t\t// header param Accept\n\t\tif err := r.SetHeaderParam(\"Accept\", *o.Accept); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.ContentType != nil {\n\n\t\t// header param Content-Type\n\t\tif err := r.SetHeaderParam(\"Content-Type\", *o.ContentType); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param uuid\n\tif err := r.SetPathParam(\"uuid\", o.UUID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.WidgetBody); 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 *TestEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetLogsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.XRequestID != nil {\n\n\t\t// header param X-Request-Id\n\t\tif err := r.SetHeaderParam(\"X-Request-Id\", *o.XRequestID); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PageSize != nil {\n\n\t\t// query param page_size\n\t\tvar qrPageSize int64\n\t\tif o.PageSize != nil {\n\t\t\tqrPageSize = *o.PageSize\n\t\t}\n\t\tqPageSize := swag.FormatInt64(qrPageSize)\n\t\tif qPageSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page_size\", qPageSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param project_name\n\tif err := r.SetPathParam(\"project_name\", o.ProjectName); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ListSourceFileOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetDrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param drgId\n\tif err := r.SetPathParam(\"drgId\", o.DrgID); 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 *UpdateFlowParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param bucketId\n\tif err := r.SetPathParam(\"bucketId\", o.BucketID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param flowId\n\tif err := r.SetPathParam(\"flowId\", o.FlowID); 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 *CreateWidgetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Accept != nil {\n\n\t\t// header param Accept\n\t\tif err := r.SetHeaderParam(\"Accept\", *o.Accept); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.ContentType != nil {\n\n\t\t// header param Content-Type\n\t\tif err := r.SetHeaderParam(\"Content-Type\", *o.ContentType); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif err := r.SetBodyParam(o.WidgetBody); 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 *GetBodyResourceByDatePeriodParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param date\n\tif err := r.SetPathParam(\"date\", o.Date.String()); err != nil {\n\t\treturn err\n\t}\n\n\t// path param period\n\tif err := r.SetPathParam(\"period\", o.Period); err != nil {\n\t\treturn err\n\t}\n\n\t// path param resource-path\n\tif err := r.SetPathParam(\"resource-path\", o.ResourcePath); 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 *GetAboutUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tvaluesSelect := o.Select\n\n\tjoinedSelect := swag.JoinByFormat(valuesSelect, \"csv\")\n\t// query array param select\n\tif err := r.SetQueryParam(\"select\", joinedSelect...); 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 *ExtractionListV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param id\n\tqrID := o.ID\n\tqID := qrID\n\tif qID != \"\" {\n\n\t\tif err := r.SetQueryParam(\"id\", qID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset string\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := qrOffset\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAuditEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param resourceCrn\n\tqrResourceCrn := o.ResourceCrn\n\tqResourceCrn := qrResourceCrn\n\tif qResourceCrn != \"\" {\n\t\tif err := r.SetQueryParam(\"resourceCrn\", qResourceCrn); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Size != nil {\n\n\t\t// query param size\n\t\tvar qrSize int32\n\t\tif o.Size != nil {\n\t\t\tqrSize = *o.Size\n\t\t}\n\t\tqSize := swag.FormatInt32(qrSize)\n\t\tif qSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"size\", qSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PcloudSystempoolsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param cloud_instance_id\n\tif err := r.SetPathParam(\"cloud_instance_id\", o.CloudInstanceID); 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 *WaitListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param address\n\tif err := r.SetPathParam(\"address\", o.Address); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Height != nil {\n\n\t\t// query param height\n\t\tvar qrHeight uint64\n\n\t\tif o.Height != nil {\n\t\t\tqrHeight = *o.Height\n\t\t}\n\t\tqHeight := swag.FormatUint64(qrHeight)\n\t\tif qHeight != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"height\", qHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PublicKey != nil {\n\n\t\t// query param public_key\n\t\tvar qrPublicKey string\n\n\t\tif o.PublicKey != nil {\n\t\t\tqrPublicKey = *o.PublicKey\n\t\t}\n\t\tqPublicKey := qrPublicKey\n\t\tif qPublicKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"public_key\", qPublicKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *BudgetAddParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetGCParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param gc_id\n\tif err := r.SetPathParam(\"gc_id\", swag.FormatInt64(o.GcID)); 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 *PartialUpdateAppParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\t// path param app_id\n\tif err := r.SetPathParam(\"app_id\", swag.FormatInt64(o.AppID)); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\t// path param team_id\n\tif err := r.SetPathParam(\"team_id\", swag.FormatInt64(o.TeamID)); 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 *StartPacketCaptureParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); 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 *TaskSchemasIDGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param identifier\n\tif err := r.SetPathParam(\"identifier\", o.Identifier); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ResolveRef != nil {\n\n\t\t// query param resolveRef\n\t\tvar qrResolveRef bool\n\t\tif o.ResolveRef != nil {\n\t\t\tqrResolveRef = *o.ResolveRef\n\t\t}\n\t\tqResolveRef := swag.FormatBool(qrResolveRef)\n\t\tif qResolveRef != \"\" {\n\t\t\tif err := r.SetQueryParam(\"resolveRef\", qResolveRef); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UploadTaskFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Description != nil {\n\n\t\t// form param description\n\t\tvar frDescription string\n\t\tif o.Description != nil {\n\t\t\tfrDescription = *o.Description\n\t\t}\n\t\tfDescription := frDescription\n\t\tif fDescription != \"\" {\n\t\t\tif err := r.SetFormParam(\"description\", fDescription); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.File != nil {\n\n\t\tif o.File != nil {\n\t\t\t// form file param file\n\t\t\tif err := r.SetFileParam(\"file\", o.File); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); 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 *PetCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *QueryChangesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetInstrumentsInstrumentOrderBookParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AcceptDatetimeFormat != nil {\n\n\t\t// header param Accept-Datetime-Format\n\t\tif err := r.SetHeaderParam(\"Accept-Datetime-Format\", *o.AcceptDatetimeFormat); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param instrument\n\tif err := r.SetPathParam(\"instrument\", o.Instrument); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Time != nil {\n\n\t\t// query param time\n\t\tvar qrTime string\n\t\tif o.Time != nil {\n\t\t\tqrTime = *o.Time\n\t\t}\n\t\tqTime := qrTime\n\t\tif qTime != \"\" {\n\t\t\tif err := r.SetQueryParam(\"time\", qTime); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetScopeConfigurationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param scope_id\n\tif err := r.SetPathParam(\"scope_id\", o.ScopeID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param site_id\n\tif err := r.SetPathParam(\"site_id\", o.SiteID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param stack_id\n\tif err := r.SetPathParam(\"stack_id\", o.StackID); 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 *UpdateEventParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param eventId\n\tif err := r.SetPathParam(\"eventId\", o.EventID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param koronaAccountId\n\tif err := r.SetPathParam(\"koronaAccountId\", o.KoronaAccountID); 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 *GetV1FunctionalitiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Impacted != nil {\n\n\t\t// query param impacted\n\t\tvar qrImpacted string\n\n\t\tif o.Impacted != nil {\n\t\t\tqrImpacted = *o.Impacted\n\t\t}\n\t\tqImpacted := qrImpacted\n\t\tif qImpacted != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"impacted\", qImpacted); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Labels != nil {\n\n\t\t// query param labels\n\t\tvar qrLabels string\n\n\t\tif o.Labels != nil {\n\t\t\tqrLabels = *o.Labels\n\t\t}\n\t\tqLabels := qrLabels\n\t\tif qLabels != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"labels\", qLabels); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Lite != nil {\n\n\t\t// query param lite\n\t\tvar qrLite bool\n\n\t\tif o.Lite != nil {\n\t\t\tqrLite = *o.Lite\n\t\t}\n\t\tqLite := swag.FormatBool(qrLite)\n\t\tif qLite != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"lite\", qLite); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Owner != nil {\n\n\t\t// query param owner\n\t\tvar qrOwner string\n\n\t\tif o.Owner != nil {\n\t\t\tqrOwner = *o.Owner\n\t\t}\n\t\tqOwner := qrOwner\n\t\tif qOwner != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"owner\", qOwner); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int32\n\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt32(qrPerPage)\n\t\tif qPerPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ContainerUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.Update); 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 *GetPointsByQueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DollarSkip != nil {\n\n\t\t// query param $skip\n\t\tvar qrNrDollarSkip int32\n\t\tif o.DollarSkip != nil {\n\t\t\tqrNrDollarSkip = *o.DollarSkip\n\t\t}\n\t\tqNrDollarSkip := swag.FormatInt32(qrNrDollarSkip)\n\t\tif qNrDollarSkip != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$skip\", qNrDollarSkip); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.DollarTop != nil {\n\n\t\t// query param $top\n\t\tvar qrNrDollarTop int32\n\t\tif o.DollarTop != nil {\n\t\t\tqrNrDollarTop = *o.DollarTop\n\t\t}\n\t\tqNrDollarTop := swag.FormatInt32(qrNrDollarTop)\n\t\tif qNrDollarTop != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$top\", qNrDollarTop); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); 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 *SyncStatusUsingGETParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespaceSelfLinkId\n\tif err := r.SetPathParam(\"namespaceSelfLinkId\", o.NamespaceSelfLinkID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param requestId\n\tif err := r.SetPathParam(\"requestId\", o.RequestID); 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 *ResolveBatchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Account != nil {\n\n\t\t// query param account\n\t\tvar qrAccount string\n\t\tif o.Account != nil {\n\t\t\tqrAccount = *o.Account\n\t\t}\n\t\tqAccount := qrAccount\n\t\tif qAccount != \"\" {\n\t\t\tif err := r.SetQueryParam(\"account\", qAccount); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Environment != nil {\n\n\t\t// query param environment\n\t\tvar qrEnvironment string\n\t\tif o.Environment != nil {\n\t\t\tqrEnvironment = *o.Environment\n\t\t}\n\t\tqEnvironment := qrEnvironment\n\t\tif qEnvironment != \"\" {\n\t\t\tif err := r.SetQueryParam(\"environment\", qEnvironment); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.From != nil {\n\n\t\t// query param from\n\t\tvar qrFrom string\n\t\tif o.From != nil {\n\t\t\tqrFrom = *o.From\n\t\t}\n\t\tqFrom := qrFrom\n\t\tif qFrom != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Region != nil {\n\n\t\t// query param region\n\t\tvar qrRegion string\n\t\tif o.Region != nil {\n\t\t\tqrRegion = *o.Region\n\t\t}\n\t\tqRegion := qrRegion\n\t\tif qRegion != \"\" {\n\t\t\tif err := r.SetQueryParam(\"region\", qRegion); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.To != nil {\n\n\t\t// query param to\n\t\tvar qrTo string\n\t\tif o.To != nil {\n\t\t\tqrTo = *o.To\n\t\t}\n\t\tqTo := qrTo\n\t\tif qTo != \"\" {\n\t\t\tif err := r.SetQueryParam(\"to\", qTo); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAccountParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\tif o.Authorization != nil {\n\n\t\t// header param Authorization\n\t\tif err := r.SetHeaderParam(\"Authorization\", *o.Authorization); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.Country != nil {\n\n\t\t// query param country\n\t\tvar qrCountry string\n\t\tif o.Country != nil {\n\t\t\tqrCountry = *o.Country\n\t\t}\n\t\tqCountry := qrCountry\n\t\tif qCountry != \"\" {\n\t\t\tif err := r.SetQueryParam(\"country\", qCountry); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Email != nil {\n\n\t\t// query param email\n\t\tvar qrEmail string\n\t\tif o.Email != nil {\n\t\t\tqrEmail = *o.Email\n\t\t}\n\t\tqEmail := qrEmail\n\t\tif qEmail != \"\" {\n\t\t\tif err := r.SetQueryParam(\"email\", qEmail); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tvaluesFields := o.Fields\n\n\tjoinedFields := swag.JoinByFormat(valuesFields, \"csv\")\n\t// query array param fields\n\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\treturn err\n\t}\n\n\tif o.PersonID != nil {\n\n\t\t// query param person_id\n\t\tvar qrPersonID string\n\t\tif o.PersonID != nil {\n\t\t\tqrPersonID = *o.PersonID\n\t\t}\n\t\tqPersonID := qrPersonID\n\t\tif qPersonID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"person_id\", qPersonID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdatePatientParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param ID\n\tif err := r.SetPathParam(\"ID\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Patient != nil {\n\t\tif err := r.SetBodyParam(o.Patient); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateCustomIDPParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.CustomIDP != nil {\n\t\tif err := r.SetBodyParam(o.CustomIDP); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param aid\n\tif err := r.SetPathParam(\"aid\", o.Aid); err != nil {\n\t\treturn err\n\t}\n\n\t// path param iid\n\tif err := r.SetPathParam(\"iid\", o.Iid); err != nil {\n\t\treturn err\n\t}\n\n\t// path param tid\n\tif err := r.SetPathParam(\"tid\", o.Tid); 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 *GetSeriesIDFilterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AcceptLanguage != nil {\n\n\t\t// header param Accept-Language\n\t\tif err := r.SetHeaderParam(\"Accept-Language\", *o.AcceptLanguage); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// query param keys\n\tqrKeys := o.Keys\n\tqKeys := qrKeys\n\tif qKeys != \"\" {\n\t\tif err := r.SetQueryParam(\"keys\", qKeys); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateBlueprintInWorkspaceInternalParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID string\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID\n\t\tif qAccountID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param workspaceId\n\tif err := r.SetPathParam(\"workspaceId\", swag.FormatInt64(o.WorkspaceID)); 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 *OrgGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param org\n\tif err := r.SetPathParam(\"org\", o.Org); 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 *ExtrasGraphsReadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetVersioningPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Description != nil {\n\n\t\t// query param Description\n\t\tvar qrDescription string\n\t\tif o.Description != nil {\n\t\t\tqrDescription = *o.Description\n\t\t}\n\t\tqDescription := qrDescription\n\t\tif qDescription != \"\" {\n\t\t\tif err := r.SetQueryParam(\"Description\", qDescription); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IgnoreFilesGreaterThan != nil {\n\n\t\t// query param IgnoreFilesGreaterThan\n\t\tvar qrIgnoreFilesGreaterThan string\n\t\tif o.IgnoreFilesGreaterThan != nil {\n\t\t\tqrIgnoreFilesGreaterThan = *o.IgnoreFilesGreaterThan\n\t\t}\n\t\tqIgnoreFilesGreaterThan := qrIgnoreFilesGreaterThan\n\t\tif qIgnoreFilesGreaterThan != \"\" {\n\t\t\tif err := r.SetQueryParam(\"IgnoreFilesGreaterThan\", qIgnoreFilesGreaterThan); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxSizePerFile != nil {\n\n\t\t// query param MaxSizePerFile\n\t\tvar qrMaxSizePerFile string\n\t\tif o.MaxSizePerFile != nil {\n\t\t\tqrMaxSizePerFile = *o.MaxSizePerFile\n\t\t}\n\t\tqMaxSizePerFile := qrMaxSizePerFile\n\t\tif qMaxSizePerFile != \"\" {\n\t\t\tif err := r.SetQueryParam(\"MaxSizePerFile\", qMaxSizePerFile); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxTotalSize != nil {\n\n\t\t// query param MaxTotalSize\n\t\tvar qrMaxTotalSize string\n\t\tif o.MaxTotalSize != nil {\n\t\t\tqrMaxTotalSize = *o.MaxTotalSize\n\t\t}\n\t\tqMaxTotalSize := qrMaxTotalSize\n\t\tif qMaxTotalSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"MaxTotalSize\", qMaxTotalSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param Name\n\t\tvar qrName string\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"Name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param Uuid\n\tif err := r.SetPathParam(\"Uuid\", o.UUID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.VersionsDataSourceBucket != nil {\n\n\t\t// query param VersionsDataSourceBucket\n\t\tvar qrVersionsDataSourceBucket string\n\t\tif o.VersionsDataSourceBucket != nil {\n\t\t\tqrVersionsDataSourceBucket = *o.VersionsDataSourceBucket\n\t\t}\n\t\tqVersionsDataSourceBucket := qrVersionsDataSourceBucket\n\t\tif qVersionsDataSourceBucket != \"\" {\n\t\t\tif err := r.SetQueryParam(\"VersionsDataSourceBucket\", qVersionsDataSourceBucket); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.VersionsDataSourceName != nil {\n\n\t\t// query param VersionsDataSourceName\n\t\tvar qrVersionsDataSourceName string\n\t\tif o.VersionsDataSourceName != nil {\n\t\t\tqrVersionsDataSourceName = *o.VersionsDataSourceName\n\t\t}\n\t\tqVersionsDataSourceName := qrVersionsDataSourceName\n\t\tif qVersionsDataSourceName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"VersionsDataSourceName\", qVersionsDataSourceName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBuildPropertiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param buildId\n\tif err := r.SetPathParam(\"buildId\", swag.FormatInt32(o.BuildID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); 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 *AdminGetBannedDevicesV4Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DeviceType != nil {\n\n\t\t// query param deviceType\n\t\tvar qrDeviceType string\n\t\tif o.DeviceType != nil {\n\t\t\tqrDeviceType = *o.DeviceType\n\t\t}\n\t\tqDeviceType := qrDeviceType\n\t\tif qDeviceType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"deviceType\", qDeviceType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.EndDate != nil {\n\n\t\t// query param endDate\n\t\tvar qrEndDate string\n\t\tif o.EndDate != nil {\n\t\t\tqrEndDate = *o.EndDate\n\t\t}\n\t\tqEndDate := qrEndDate\n\t\tif qEndDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"endDate\", qEndDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.StartDate != nil {\n\n\t\t// query param startDate\n\t\tvar qrStartDate string\n\t\tif o.StartDate != nil {\n\t\t\tqrStartDate = *o.StartDate\n\t\t}\n\t\tqStartDate := qrStartDate\n\t\tif qStartDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"startDate\", qStartDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "func (o *BikePointGetAllParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DecryptParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Parameters); 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 *DeleteRequestsRequestNameParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param requestName\n\tqrRequestName := o.RequestName\n\tqRequestName := qrRequestName\n\tif qRequestName != \"\" {\n\t\tif err := r.SetQueryParam(\"requestName\", qRequestName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Synchronous != nil {\n\n\t\t// query param synchronous\n\t\tvar qrSynchronous bool\n\t\tif o.Synchronous != nil {\n\t\t\tqrSynchronous = *o.Synchronous\n\t\t}\n\t\tqSynchronous := swag.FormatBool(qrSynchronous)\n\t\tif qSynchronous != \"\" {\n\t\t\tif err := r.SetQueryParam(\"synchronous\", qSynchronous); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SearchAbsoluteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Decorate != nil {\n\n\t\t// query param decorate\n\t\tvar qrDecorate bool\n\t\tif o.Decorate != nil {\n\t\t\tqrDecorate = *o.Decorate\n\t\t}\n\t\tqDecorate := swag.FormatBool(qrDecorate)\n\t\tif qDecorate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"decorate\", qDecorate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param from\n\tqrFrom := o.From\n\tqFrom := qrFrom\n\tif qFrom != \"\" {\n\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param query\n\tqrQuery := o.Query\n\tqQuery := qrQuery\n\tif qQuery != \"\" {\n\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param to\n\tqrTo := o.To\n\tqTo := qrTo\n\tif qTo != \"\" {\n\t\tif err := r.SetQueryParam(\"to\", qTo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCountersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.ClusterNodeID != nil {\n\n\t\t// query param clusterNodeId\n\t\tvar qrClusterNodeID string\n\n\t\tif o.ClusterNodeID != nil {\n\t\t\tqrClusterNodeID = *o.ClusterNodeID\n\t\t}\n\t\tqClusterNodeID := qrClusterNodeID\n\t\tif qClusterNodeID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"clusterNodeId\", qClusterNodeID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Nodewise != nil {\n\n\t\t// query param nodewise\n\t\tvar qrNodewise bool\n\n\t\tif o.Nodewise != nil {\n\t\t\tqrNodewise = *o.Nodewise\n\t\t}\n\t\tqNodewise := swag.FormatBool(qrNodewise)\n\t\tif qNodewise != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"nodewise\", qNodewise); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *MetroclusterInterconnectGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param adapter\n\tif err := r.SetPathParam(\"adapter\", o.Adapter); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// binding items for fields\n\t\tjoinedFields := o.bindParamFields(reg)\n\n\t\t// query array param fields\n\t\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param node.uuid\n\tif err := r.SetPathParam(\"node.uuid\", o.NodeUUID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param partner_type\n\tif err := r.SetPathParam(\"partner_type\", o.PartnerType); 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 *PutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Item != nil {\n\t\tif err := r.SetBodyParam(o.Item); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param itemId\n\tif err := r.SetPathParam(\"itemId\", o.ItemID); 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 *CreateAccessPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DeleteDataSourceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.APIKey != nil {\n\n\t\t// query param ApiKey\n\t\tvar qrAPIKey string\n\n\t\tif o.APIKey != nil {\n\t\t\tqrAPIKey = *o.APIKey\n\t\t}\n\t\tqAPIKey := qrAPIKey\n\t\tif qAPIKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ApiKey\", qAPIKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.APISecret != nil {\n\n\t\t// query param ApiSecret\n\t\tvar qrAPISecret string\n\n\t\tif o.APISecret != nil {\n\t\t\tqrAPISecret = *o.APISecret\n\t\t}\n\t\tqAPISecret := qrAPISecret\n\t\tif qAPISecret != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ApiSecret\", qAPISecret); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.CreationDate != nil {\n\n\t\t// query param CreationDate\n\t\tvar qrCreationDate int32\n\n\t\tif o.CreationDate != nil {\n\t\t\tqrCreationDate = *o.CreationDate\n\t\t}\n\t\tqCreationDate := swag.FormatInt32(qrCreationDate)\n\t\tif qCreationDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"CreationDate\", qCreationDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Disabled != nil {\n\n\t\t// query param Disabled\n\t\tvar qrDisabled bool\n\n\t\tif o.Disabled != nil {\n\t\t\tqrDisabled = *o.Disabled\n\t\t}\n\t\tqDisabled := swag.FormatBool(qrDisabled)\n\t\tif qDisabled != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"Disabled\", qDisabled); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.EncryptionKey != nil {\n\n\t\t// query param EncryptionKey\n\t\tvar qrEncryptionKey string\n\n\t\tif o.EncryptionKey != nil {\n\t\t\tqrEncryptionKey = *o.EncryptionKey\n\t\t}\n\t\tqEncryptionKey := qrEncryptionKey\n\t\tif qEncryptionKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"EncryptionKey\", qEncryptionKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.EncryptionMode != nil {\n\n\t\t// query param EncryptionMode\n\t\tvar qrEncryptionMode string\n\n\t\tif o.EncryptionMode != nil {\n\t\t\tqrEncryptionMode = *o.EncryptionMode\n\t\t}\n\t\tqEncryptionMode := qrEncryptionMode\n\t\tif qEncryptionMode != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"EncryptionMode\", qEncryptionMode); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.FlatStorage != nil {\n\n\t\t// query param FlatStorage\n\t\tvar qrFlatStorage bool\n\n\t\tif o.FlatStorage != nil {\n\t\t\tqrFlatStorage = *o.FlatStorage\n\t\t}\n\t\tqFlatStorage := swag.FormatBool(qrFlatStorage)\n\t\tif qFlatStorage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"FlatStorage\", qFlatStorage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.LastSynchronizationDate != nil {\n\n\t\t// query param LastSynchronizationDate\n\t\tvar qrLastSynchronizationDate int32\n\n\t\tif o.LastSynchronizationDate != nil {\n\t\t\tqrLastSynchronizationDate = *o.LastSynchronizationDate\n\t\t}\n\t\tqLastSynchronizationDate := swag.FormatInt32(qrLastSynchronizationDate)\n\t\tif qLastSynchronizationDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"LastSynchronizationDate\", qLastSynchronizationDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param Name\n\tif err := r.SetPathParam(\"Name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ObjectsBaseFolder != nil {\n\n\t\t// query param ObjectsBaseFolder\n\t\tvar qrObjectsBaseFolder string\n\n\t\tif o.ObjectsBaseFolder != nil {\n\t\t\tqrObjectsBaseFolder = *o.ObjectsBaseFolder\n\t\t}\n\t\tqObjectsBaseFolder := qrObjectsBaseFolder\n\t\tif qObjectsBaseFolder != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsBaseFolder\", qObjectsBaseFolder); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsBucket != nil {\n\n\t\t// query param ObjectsBucket\n\t\tvar qrObjectsBucket string\n\n\t\tif o.ObjectsBucket != nil {\n\t\t\tqrObjectsBucket = *o.ObjectsBucket\n\t\t}\n\t\tqObjectsBucket := qrObjectsBucket\n\t\tif qObjectsBucket != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsBucket\", qObjectsBucket); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsHost != nil {\n\n\t\t// query param ObjectsHost\n\t\tvar qrObjectsHost string\n\n\t\tif o.ObjectsHost != nil {\n\t\t\tqrObjectsHost = *o.ObjectsHost\n\t\t}\n\t\tqObjectsHost := qrObjectsHost\n\t\tif qObjectsHost != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsHost\", qObjectsHost); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsPort != nil {\n\n\t\t// query param ObjectsPort\n\t\tvar qrObjectsPort int32\n\n\t\tif o.ObjectsPort != nil {\n\t\t\tqrObjectsPort = *o.ObjectsPort\n\t\t}\n\t\tqObjectsPort := swag.FormatInt32(qrObjectsPort)\n\t\tif qObjectsPort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsPort\", qObjectsPort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsSecure != nil {\n\n\t\t// query param ObjectsSecure\n\t\tvar qrObjectsSecure bool\n\n\t\tif o.ObjectsSecure != nil {\n\t\t\tqrObjectsSecure = *o.ObjectsSecure\n\t\t}\n\t\tqObjectsSecure := swag.FormatBool(qrObjectsSecure)\n\t\tif qObjectsSecure != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsSecure\", qObjectsSecure); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsServiceName != nil {\n\n\t\t// query param ObjectsServiceName\n\t\tvar qrObjectsServiceName string\n\n\t\tif o.ObjectsServiceName != nil {\n\t\t\tqrObjectsServiceName = *o.ObjectsServiceName\n\t\t}\n\t\tqObjectsServiceName := qrObjectsServiceName\n\t\tif qObjectsServiceName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsServiceName\", qObjectsServiceName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PeerAddress != nil {\n\n\t\t// query param PeerAddress\n\t\tvar qrPeerAddress string\n\n\t\tif o.PeerAddress != nil {\n\t\t\tqrPeerAddress = *o.PeerAddress\n\t\t}\n\t\tqPeerAddress := qrPeerAddress\n\t\tif qPeerAddress != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"PeerAddress\", qPeerAddress); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SkipSyncOnRestart != nil {\n\n\t\t// query param SkipSyncOnRestart\n\t\tvar qrSkipSyncOnRestart bool\n\n\t\tif o.SkipSyncOnRestart != nil {\n\t\t\tqrSkipSyncOnRestart = *o.SkipSyncOnRestart\n\t\t}\n\t\tqSkipSyncOnRestart := swag.FormatBool(qrSkipSyncOnRestart)\n\t\tif qSkipSyncOnRestart != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"SkipSyncOnRestart\", qSkipSyncOnRestart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.StorageType != nil {\n\n\t\t// query param StorageType\n\t\tvar qrStorageType string\n\n\t\tif o.StorageType != nil {\n\t\t\tqrStorageType = *o.StorageType\n\t\t}\n\t\tqStorageType := qrStorageType\n\t\tif qStorageType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"StorageType\", qStorageType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.VersioningPolicyName != nil {\n\n\t\t// query param VersioningPolicyName\n\t\tvar qrVersioningPolicyName string\n\n\t\tif o.VersioningPolicyName != nil {\n\t\t\tqrVersioningPolicyName = *o.VersioningPolicyName\n\t\t}\n\t\tqVersioningPolicyName := qrVersioningPolicyName\n\t\tif qVersioningPolicyName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"VersioningPolicyName\", qVersioningPolicyName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Watch != nil {\n\n\t\t// query param Watch\n\t\tvar qrWatch bool\n\n\t\tif o.Watch != nil {\n\t\t\tqrWatch = *o.Watch\n\t\t}\n\t\tqWatch := swag.FormatBool(qrWatch)\n\t\tif qWatch != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"Watch\", qWatch); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}" ]
[ "0.7198161", "0.714435", "0.70471495", "0.7021836", "0.69967365", "0.69959503", "0.6979433", "0.6979074", "0.69695425", "0.6966308", "0.69242847", "0.6908102", "0.69045216", "0.6871055", "0.68575305", "0.68564737", "0.6851862", "0.6845359", "0.6844677", "0.684266", "0.68300045", "0.68283993", "0.68213093", "0.68209827", "0.681858", "0.6810088", "0.67938024", "0.6792597", "0.67860335", "0.6781293", "0.6778168", "0.67739195", "0.676121", "0.676101", "0.6760405", "0.675646", "0.67500865", "0.67439634", "0.6743771", "0.6742206", "0.67405975", "0.67344606", "0.67331755", "0.67328155", "0.67320985", "0.67255586", "0.6724229", "0.67159885", "0.67127234", "0.67094815", "0.67085487", "0.6705413", "0.67020816", "0.6698303", "0.66938454", "0.6692077", "0.66849154", "0.6677396", "0.66709644", "0.6670931", "0.6670394", "0.6666765", "0.6666114", "0.6665216", "0.6662671", "0.66568", "0.6653157", "0.6646967", "0.6645966", "0.6642767", "0.6640608", "0.6638263", "0.6634605", "0.66345316", "0.6625767", "0.66217625", "0.6619463", "0.66181296", "0.66144806", "0.6606646", "0.6605777", "0.66039085", "0.6598786", "0.65961313", "0.65951705", "0.6591678", "0.6586235", "0.65826946", "0.658246", "0.6574939", "0.6572858", "0.6569902", "0.6568091", "0.65670824", "0.65661305", "0.6565009", "0.6561903", "0.65615994", "0.6560924", "0.6557316" ]
0.659942
82
palindromeIndex returns the index whose deletion would cause in s becoming a palindrome. 1 is returned if s is already a palindrome.
func palindromeIndex(s string) int { n := len(s) for i := 0; i < n/2; i++ { // problem, find which index // is at fault. if s[i] != s[n-i-1] { if palindrome(s[:i] + s[i+1:]) { return i } else { return n - i - 1 } } } return -1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func palindromeIndex(s string) int32 {\n\tl := len(s) - 1\n\tfor i := 0; i <= l; i, l = i+1, l-1 {\n\t\tif s[i] == s[l] {\n\t\t\tcontinue\n\t\t}\n\t\tif palindrome(s[i+1 : l+1]) {\n\t\t\treturn int32(i)\n\t\t}\n\t\tif palindrome(s[i:l]) {\n\t\t\treturn int32(l)\n\t\t}\n\t\treturn -1\n\t}\n\treturn -1\n}", "func palindrome(s string) bool {\n\tleft := 0\n\tright := len(s) - 1\n\n\tfor left < right {\n\t\tif s[left] != s[right] {\n\t\t\treturn false\n\t\t}\n\t\tleft++\n\t\tright--\n\t}\n\treturn true\n}", "func IsPalindrome(s string) bool {\n\tfor i := range s {\n\t\tif s[i] != s[len(s)-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isPalindrome(s string) bool {\n\ts = cleanString(s)\n\n\ti := 0\n\tj := len(s) - 1\n\tfor i < j {\n\t\tif s[i] != s[j] {\n\t\t\treturn false\n\t\t}\n\t\ti += 1\n\t\tj -= 1\n\t}\n\n\treturn true\n}", "func isPalindrome(s string) bool {\n\t// defer timeTrack(time.Now(), \"isPalindrome()\")\n\n\tfor i := 0; i < len(s)/2; i++ {\n\t\tif s[i] != s[len(s)-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isPalindrome(s string) bool {\n\t// defer timeTrack(time.Now(), \"isPalindrome()\")\n\n\tfor i := 0; i < len(s)/2; i++ {\n\t\tif s[i] != s[len(s)-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isPalindrome(s string) bool {\n\tn := len(s)\n\tfor i := 0; i < (n / 2); i++ {\n\t\tif s[i] != s[n-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func isPalindrome(s string, i, j int) bool {\n\tfor ; i < j; i, j = i+1, j-1 {\n\t\tif s[i] != s[j] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func PalindromesNaive(text string) (int, int) {\n\tllen, tlen := 0, len(text)\n\tif tlen > 1 {\n\t\tllen = 2*tlen + 1\n\t}\n\tlengths := make([]int, llen)\n\tfor i := 0; i < llen; i++ {\n\t\tstart := i / 2\n\t\tend := start + i%2\n\t\tfor start > 0 && end < tlen && text[start-1] == text[end] {\n\t\t\tstart -= 1\n\t\t\tend += 1\n\t\t\tlengths[i] = end - start\n\t\t}\n\t\tlengths[i] = end - start\n\t}\n\treturn LargestStartEnd(lengths)\n}", "func isP(s string) string {\n mid := len(s) / 2\n last := len(s) - 1\n for i := 0; i < mid; i++ {\n if s[i] != s[last-i] {\n return \"No this is not a Palimdrome.\"\n }\n }\n return \"Yes this is a Palindrome\"\n}", "func longestPalindrome(s string) string {\n\tn := len(s)\n\tdp := make([][]bool, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([]bool, n)\n\t}\n\tmax := [2]int{0, 0}\n\tfor i := n - 1; i >= 0; i-- {\n\t\tfor j := i; j < n; j++ {\n\t\t\tdp[i][j] = s[i] == s[j]\n\t\t\tif dp[i][j] && j-i > 2 {\n\t\t\t\tdp[i][j] = dp[i+1][j-1]\n\t\t\t}\n\t\t\tif dp[i][j] && max[1]-max[0] < j-i {\n\t\t\t\tmax = [2]int{i, j}\n\t\t\t}\n\t\t}\n\t}\n\treturn s[max[0] : max[1]+1]\n}", "func IsPalindrome(s sort.Interface) bool {\n\tif s.Len() == 0 {\n\t\treturn false\n\t}\n\tleft := 0\n\tright := s.Len() - 1\n\tfor left < right {\n\t\tif s.Less(left, right) || s.Less(right, left) {\n\t\t\treturn false\n\t\t}\n\t\tleft++\n\t\tright--\n\t}\n\treturn true\n}", "func isPalindrome(n int) bool {\n\ts := strconv.Itoa(n)\n\n\tfor i := 0; i < len(s)/2; i++ {\n\t\tif s[i] != s[len(s)-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func PalindromesFast(text string) (int, int) {\n\tlengths := make([]int, 2*len(text)+1)\n\ti, j, d, s, e, plen, k := 0, 0, 0, 0, 0, 0, 0\n\tfor i < len(text) {\n\t\t// is the string so far a palindrome ?\n\t\tif i > plen && text[i-plen-1] == text[i] {\n\t\t\t// yes, so we extend the current found palindrome length\n\t\t\t// and keep checking forward else ...\n\t\t\tplen += 2\n\t\t\ti++\n\t\t\tcontinue\n\t\t}\n\t\t// ... we have reached the end of the current found palindrome\n\t\t// so we set the current palindrome length etc. ...\n\t\tlengths[k] = plen\n\t\tk++\n\t\ts = k - 2\n\t\te = s - plen\n\t\t// ... then backtrack over the last found palindrome to see ...\n\t\tb := true\n\t\tfor j = s; j > e; j-- {\n\t\t\td = j - e - 1\n\t\t\t// ... if we have a reflection of the same length ...\n\t\t\tif lengths[j] == d {\n\t\t\t\t// ... yes, so we set new palindrome length ...\n\t\t\t\tplen = d\n\t\t\t\t// ... and stop backtracking.\n\t\t\t\tb = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t// ... no, so we take the smaller length,\n\t\t\t// update the lengths and continue backtracking.\n\t\t\tlengths[k] = MinInt(d, lengths[j])\n\t\t\tk++\n\t\t}\n\t\t// if we we're backtracking then reset palindrome length\n\t\t// and move on.\n\t\tif b {\n\t\t\tplen = 1\n\t\t\ti++\n\t\t}\n\t}\n\t// we're done scanning the text so we perform\n\t// one last backtrack.\n\tlengths[k] = plen\n\tk++\n\ts = k - 2\n\te = s - (2*len(text) + 1 - k)\n\tfor i := s; i > e; i-- {\n\t\td = i - e - 1\n\t\tlengths[k] = MinInt(d, lengths[i])\n\t\tk++\n\t}\n\treturn LargestStartEnd(lengths)\n}", "func IsPalindrome(s string) string {\t\n\n\tletters := []string{} //get only lowercase letters\n\n\tfor _, char := range s {\n\t\tif unicode.IsLetter(rune(char)){\n\t\t\tletters = append(letters, string(unicode.ToLower(char)))\n\t\t}\n\t}\n\tfor i := 0; i < len(letters); i++ {\n\t\tif letters[i] != letters[len(letters)-i-1] {\n\t\t\treturn \"false\"\n\t\t}\n\t}\n\treturn \"true\"\t\n}", "func isPalindrome(x int) bool {\n\tstr := strconv.Itoa(x)\n\tr := strings.Split(str, \"\")\n\tfor i := 0; i < len(r)/2; i++ {\n\t\tif r[i] != r[len(r)-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func longestPalindrome(s string) string {\n\tn := len(s)\n\tvar longestP string\n\n\tfor i := 0; i < n; i++ {\n\t\tfor j := i; j < n; j++ {\n\t\t\tif j-i+1 > len(longestP) && isPalyndrome(s[i:j+1]) {\n\t\t\t\tlongestP = s[i : j+1]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn longestP\n}", "func longestPalindrome(s string) string {\n\tif len(s) < 2 {\n\t\treturn s\n\t}\n\n\tpalindrome := \"\"\n\n\truneIndex := createRuneIndex(s)\n\n\tfor r, indices := range runeIndex {\n\n\t\t// skip if rune only occurs once\n\t\tif len(indices) < 2 {\n\t\t\tcontinue\n\t\t}\n\n\t\t// check palindrome for each \"pairing\" of where the rune occurs;\n\t\t// skip if the length between the two runes is less than the current palindrome\n\t\tfor i := 0; i < len(indices); i++ {\n\t\t\tfor j := len(indices)-1; i < j; j-- {\n\t\t\t\tstart := indices[i]\n\t\t\t\tend := indices[j] + len(string(r)) // string length is based on bytes; we need bytes of rune\n\t\t\t\tif len(palindrome) >= end - start {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif isPalindrome(s[start:end]) {\n\t\t\t\t\tpalindrome = s[start:end]\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif palindrome == \"\" {\n\t\tpalindrome = s[0:1]\n\t}\n\n\treturn palindrome\n}", "func palindrome(n int) int {\n\tst := int(math.Pow10(n)) - 1\n\tmx := 0\n\tfor i := st; i > 0; i-- {\n\t\tif i*st <= mx {\n\t\t\tbreak\n\t\t}\n\t\tfor j := st; j > 0; j-- {\n\t\t\tpd := i * j\n\t\t\tif pd < mx {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif pd > mx && isPalindrome(pd) {\n\t\t\t\tmx = pd\n\t\t\t}\n\t\t}\n\t}\n\treturn mx\n}", "func CheckPalindrome(str string) bool {\n\ti := 0\n\tj := len(str) - 1\n\tfor i < j && str[i] == str[j] {\n\t\ti++\n\t\tj--\n\t}\n\tif i < j {\n\t\treturn false\n\t}\n\treturn true\n}", "func Palindrome(str string) bool {\n\tj := len(str) - 1\n\n\tfor i := 0; i != j; i++ {\n\t\tif str[i] != str[j] {\n\t\t\treturn false\n\t\t}\n\t\tj--\n\t}\n\n\treturn true\n}", "func isPalindrome(x string) bool {\n\trunes := []rune(x)\n\truneCount := len(runes)\n\tfor i := 0; i < runeCount/2; i++ {\n\t\tif runes[i] != runes[runeCount-1-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func longestPalindrome(s string) string {\n\tN := len(s)\n\tDP := make([][]bool, N)\n\tresult := \"\"\n\tfor i := 0; i < N; i++ {\n\t\tDP[i] = make([]bool, N)\n\t\tDP[i][i] = true\n\t\tresult = s[i:i+1]\n\t}\n\n\tfor j := 1; j < N; j++ {\n\t\tfor i := 0; i < j; i++ {\n\t\t\tDP[i][j] = (s[i] == s[j]) && ( (j - i) <= 2 || DP[i+1][j-1])\n\t\t\tif DP[i][j] && (j - i + 1) > len(result) {\n\t\t\t\tresult = s[i:j+1]\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}", "func isPalindromeRecursive(value string, i int) bool {\n\tif i < len(value) /2 {\n\t\tvar firstIndex = i\n\t\tvar lastIndex = len(value) - i -1\n\t\t//compare per index\n\t\tfmt.Println(string(value[firstIndex]) , \" : \" , string(value[lastIndex]))\n\n\t\tif string(value[firstIndex]) != string(value[lastIndex]) {\n\t\t\tfmt.Println(\"Palindrome recursive false\")\n\t\t\treturn false\n\t\t} else {\n\t\t\t//if true call again the recursive, and add 1 for i var\n\t\t\treturn isPalindromeRecursive(value, i+1)\n\t\t}\n\t} else {\n\t\tfmt.Println(\"Palindrome recursive true\")\n\t\treturn true\n\t}\n}", "func IsPalindrome(s sort.Interface) bool {\n\t// TODO\n\treturn false\n}", "func validPalindrome(s string) bool {\n return validPalindromeDeleted(s, false)\n}", "func IsPalindrome(num int) bool {\n\tstr := strconv.Itoa(num)\n\tlast := len(str) - 1\n\tfor i := 0; i < len(str)/2; i++ {\n\t\tif str[i] != str[last-i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isP(s string) string {\n\tmid := len(s) / 2\n\tlast := len(s) - 1\n \n\tfor i := 0; i < mid; i++ {\n\t\tif s[i] != s[last-i] {\n\t\t\treturn \"NO. It's not a Palindrome.\"\n\t\t}\n\t}\n\t\n\treturn \"YES! You've entered a Palindrome\"\n}", "func IsPalindrome(value string) bool {\n\n\tlength := len(value)\n\n\tfor i := 0; i < length/2; i++ {\n\t\tif value[i] != value[length-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func isPalindrome(s string) bool{\n //reverse the string number\n r := make([]byte, len(s))\n for i := 0; i < len(s); i++ {\n r[i] = s[len(s)-1-i]\n }\n revString := string(r) //reverse is intially a string\n revInt, _ := strconv.Atoi(revString) //convert string to int\n origInt, _ := strconv.Atoi(s) //convert string to integer\n\n fmt.Println(origInt, revInt)\n return origInt == revInt //check if the reverse integer is equal to original\n}", "func IsPalindrome(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\tints := make([]int, 0)\n\tfor x != 0 {\n\t\tints = append(ints, x%10)\n\t\tx = x / 10\n\t}\n\tlength := len(ints)\n\tfor i := 0; i < length/2; i++ {\n\t\t//fmt.Printf(\"v1: %v v2: %v\\n\", ints[i], ints[length-i-1])\n\t\tif ints[i] != ints[length-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isPalindrome(s string) bool {\n\ts = strings.ToLower(s)\n\tvar str []rune\n\tfor _, ch := range s {\n\t\tif unicode.IsLetter(ch) || unicode.IsDigit(ch) {\n\t\t\tstr = append(str, ch)\n\t\t}\n\t}\n\n\tfor i := 0; i < len(str)/2; i++ {\n\t\tif str[i] != str[len(str)-i-1] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func isP(s string) string {\n\tmid := len(s) / 2\n\tlast := len(s) - 1\n\n\tfor i := 0; i < mid; i++ {\n\t\n\t//printed if string is not a palindrome\n\tif s[i] != s[last-i] {\n\t\treturn \"NO. It's not a Palimdrome.\"\n \t}\n}\n //printed if string is a paindrome\n return \"YES! You've entered a Palindrome\"\n}", "func Palindrome(value string) bool {\n\tvar temp = \"\"\n\n\tfor i := len(value) -1; i >= 0; i-- {\n\t\ttemp = temp + string(value[i])\n\t}\n\tfmt.Println(temp)\n\tresult := temp == value\n\treturn result\n}", "func palindrome(str string) bool {\n\tsplitStr := strings.Split(str, \"\")\n\tfor i, j := 0, len(splitStr) - 1; i < j; i, j = i + 1, j - 1 {\n\t\tif splitStr[i] != splitStr[j] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true \n}", "func longestPalindrome(s string) string {\n\tl := len(s)\n\tsubs := \"\"\n\tcount := 0\n\tfor i := 0; i < l; i++ {\n\t\todd := getSame(s[0:i], s[i:l])\n\t\tsingle := getSame(s[0:i], s[i+1:l])\n\n\t\tif count < odd * 2 {\n\t\t\tcount = odd *2\n\t\t\tsubs = s[i-odd:i+odd]\n\t\t}\n\n\t\tif count < single * 2 + 1 {\n\t\t\tcount = single * 2 + 1\n\t\t\tsubs = s[i-single:i+1+single]\n\t\t}\n\t}\n\treturn subs\n}", "func isPalindrome(s string) bool {\n\treturn helper([]rune(s))\n}", "func isPalindrome(input string) bool {\n\n\tletters := splitInput(input)\n\n\tleftPointer := 0\n\trightPointer := len(letters) - 1\n\tres := true\n\tfor true {\n\t\tif leftPointer >= rightPointer {\n\t\t\tbreak\n\t\t}\n\n\t\tif letters[leftPointer] == letters[rightPointer] {\n\t\t\tleftPointer++\n\t\t\trightPointer--\n\t\t} else {\n\t\t\tres = false\n\t\t\tbreak\n\t\t}\n\n\t}\n\treturn res\n}", "func isP(s string) string {\n mid := len(s) / 2 //calculates the midpoint of the slice\n last := len(s) - 1 //calculates the end of the slice like an array (arrays begin at 0 not 1)\n for i := 0; i < mid; i++ {//if a letter greater <blank> \n if s[i] != s[last-i] { //compares the slices\n return \"NO. It's not a Palimdrome.\" //displays if false\n }\n }\n return \"YES! You've entered a Palindrome\" //displays if true\n\n}", "func isPalindrome(num int) bool {\n numStr := strconv.Itoa(num)\n strLen := len(numStr)\n if strLen % 2 != 0 {\n return false\n }\n for i := 0; i < strLen/2; i++ {\n if numStr[strLen/2+i] != numStr[strLen/2-i-1]{\n return false\n }\n }\n return true\n}", "func longestPalindromSubstring(s string) (int, string) {\n\tl := len(s)\n\tif l == 0 {\n\t\treturn 0, \"\"\n\t}\n\t// A table array stores false at table[i][j] if the substring from index i to j is not\n\t// a palindrome and true otherwise.\n\ttable := make([][]bool, l)\n\tfor i := range table {\n\t\ttable[i] = make([]bool, l)\n\t}\n\n\t// Substring of length 1 is always a palindrome.\n\tmaxLength := 1\n\tfor i := range table {\n\t\ttable[i][i] = true\n\t}\n\n\tstart := 0\n\t// Substring of length 2.\n\tfor i := 0; i < l-1; i++ {\n\t\tif s[i] == s[i+1] {\n\t\t\ttable[i][i+1] = true\n\t\t\tstart = i\n\t\t\tmaxLength = 2\n\t\t}\n\t}\n\n\t// Substring of higher length\n\t// Let k keep the substring length\n\tfor k := 3; k <= l; k++ {\n\t\tfor i := 0; i < l-k+1; i++ {\n\t\t\t// Get the ending index.\n\t\t\tj := i + k - 1\n\t\t\t// Checking for sub-string from ith index to jth index iff s[i + 1] to s[(j-1)] is\n\t\t\t// a palindrome.\n\t\t\tif table[i+1][j-1] && s[i] == s[j] {\n\t\t\t\ttable[i][j] = true\n\t\t\t\tif k > maxLength {\n\t\t\t\t\tstart = i\n\t\t\t\t\tmaxLength = k\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// fmt.Printf(\"%#v\\n\", table)\n\treturn maxLength, string(s[start : start+maxLength])\n}", "func Palindrome(input string) bool {\n\tinputIsPalindrome := true\n\tlength := len(input)\n\n\tfor i := 0; i < length; i++ {\n\t\tif input[i] != input[length-i-1] {\n\t\t\tinputIsPalindrome = false\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn inputIsPalindrome\n}", "func palindrome(str string) bool {\n\treturn false\n}", "func isPalindrome(x int) bool {\n\n\ts := strconv.Itoa(x)\n\trunes := make([]rune, 0)\n\n\tif x < 0 {\n\t\ts = s[1:]\n\t\trunes = []rune(s)\n\t} else {\n\t\trunes = []rune(s)\n\t}\n\tfor i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {\n\t\trunes[i], runes[j] = runes[j], runes[i]\n\t}\n\n\tresult := string(runes)\n\n\tresultNum, _ := strconv.Atoi(result)\n\tif x < 0 {\n\t\tresultNum = resultNum * -1\n\t}\n\tif float64(resultNum) < math.Pow(-2, 31) || float64(resultNum) > math.Pow(2, 31) {\n\t\treturn false\n\t}\n\n\tif x < 0 {\n\t\tresult = fmt.Sprintf(\"%v%v\", result, \"-\")\n\t}\n\n\treturn result == s\n}", "func IsPalindrome(l []Item) bool {\n\tn := len(l)\n\tif n == 0 {\n\t\treturn true\n\t}\n\tif n == 1 {\n\t\treturn true\n\t}\n\n\tc := 0\n\tfor i := n - 1; i != n && i != c; i-- {\n\t\tif l[c] != l[i] {\n\t\t\treturn false\n\t\t}\n\t\tc++\n\t}\n\n\treturn true\n}", "func longestPalindrome(s string) string {\n\n}", "func LongestPalindrome(str string) string {\n l := len(str)\n odd := make([]bool, l)\n even := make([]bool, l)\n var oddRadius, evenRadius, oddCenter, evenCenter int\n for radius := 0; radius <= l/2; radius++ {\n for c := 0; c < l; c++ {\n if radius == 0 {\n odd[c] = true\n even[c] = true\n } else {\n if c-radius >= 0 && c+radius < l {\n odd[c] = odd[c] && (str[c-radius] == str[c+radius])\n } else {\n odd[c] = false\n }\n if c-radius+1 >= 0 && c+radius < l {\n even[c] = even[c] && (str[c-radius+1] == str[c+radius])\n } else {\n even[c] = false\n }\n }\n if odd[c] && radius > oddRadius {\n oddRadius = radius\n oddCenter = c\n }\n if even[c] && radius > evenRadius {\n evenRadius = radius\n evenCenter = c\n }\n }\n }\n if oddRadius >= evenRadius {\n return str[oddCenter-oddRadius: oddCenter+oddRadius+1]\n } else {\n return str[evenCenter-evenRadius+1: evenCenter+evenRadius+1]\n }\n}", "func palindromePermutation(s string) bool {\n\t// for all permutations\n\tccount := make(map[rune]int)\n\tfor _, c := range s {\n\t\tif c != ' ' {\n\t\t\tccount[c]++\n\t\t}\n\t}\n\n\t// more than 1 odd char means this cannot be a palindrome\n\todd := 0\n\tfor _, v := range ccount {\n\t\tif v%2 != 0 {\n\t\t\todd++\n\t\t\tif odd > 1 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func longestPalindrome(s string) string {\n\tif len(s) <= 1 {\n\t\treturn s\n\t}\n\tmaxLen := 1\n\tmaxStr := string(s[0])\n\n\tfor l := 2; l <= 3; l++ {\n\t\tfor i := 0; i <= len(s)-l; i++ {\n\t\t\tif isPalindrome(s[i : i+l]) {\n\n\t\t\t\tif maxLen < l {\n\t\t\t\t\tmaxLen = l\n\t\t\t\t\tmaxStr = s[i : i+l]\n\t\t\t\t}\n\n\t\t\t\tfor j := 1; j <= min(i, len(s)-i-l) && s[i-j] == s[i+l-1+j]; j++ {\n\t\t\t\t\tcLen := l + 2*j - 1\n\t\t\t\t\tif maxLen < cLen {\n\t\t\t\t\t\tmaxLen = cLen\n\t\t\t\t\t\tmaxStr = s[i-j : i+l+j]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn maxStr\n}", "func IsPalindromePermutation(s string) bool {\n\tinput := make([]rune, 0, len(s))\n\tfor _, r := range strings.ToLower(s) {\n\t\tif unicode.IsLetter(r) {\n\t\t\tinput = append(input, r)\n\t\t}\n\t}\n\n\tcounts := make(map[rune]int)\n\tfor _, r := range input {\n\t\tcounts[r]++\n\t}\n\n\tfoundOddCount := false\n\tfor _, c := range counts {\n\t\tif c%2 == 1 {\n\t\t\tif foundOddCount {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfoundOddCount = true\n\t\t}\n\t}\n\treturn true\n}", "func longestPalindromeSub(s string) string {\n\tif len(s) == 0 {\n\t\treturn s\n\t}\n\tcurLen, start := 0, -1\n\tfor i := 0; i < len(s); i++ {\n\t\tif isPalindromeSub(s, i-curLen-1, i) {\n\t\t\tstart = i - curLen - 1\n\t\t\tcurLen += 2\n\t\t} else if isPalindromeSub(s, i-curLen, i) {\n\t\t\tstart = i - curLen\n\t\t\tcurLen++\n\t\t}\n\t}\n\treturn s[start : start+curLen]\n}", "func IsPalindrome(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\n\t// x should be in range of -2^31 to 2^31 - 1\n\tif x > 2147483647 { //|| x < -2147483648 {\n\t\treturn false\n\t}\n\n\tif x >= 0 && x <= 9 {\n\t\treturn true\n\t}\n\n\tvar reverse int = 0\n\ttemp := x\n\t// reverse digit\n\tfor x > 0 {\n\t\tfloat := x % 10 // use last digit\n\t\treverse *= 10 // move digit\n\t\treverse += float // assign new value to that digit\n\t\tx /= 10 // cut last digit to calculate next\n\t}\n\n\tif temp == reverse {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func breakPalindrome(s string) string {\n\tn := len(s)\n\tmodable := n / 2\n\tif modable == 0 {\n\t\treturn \"\"\n\t}\n\n\tvar sb strings.Builder\n\ti := 0\n\tfor ; i < modable && s[i] == 'a'; i++ {\n\t\tsb.WriteByte('a')\n\t}\n\n\tif i == modable {\n\t\tif n%2 == 1 {\n\t\t\tsb.WriteByte(s[modable])\n\t\t}\n\n\t\tif modable+1 < n-1 {\n\t\t\tsb.WriteString(s[modable+1:n-1])\n\t\t}\n\n\t\tsb.WriteByte('b')\n\t} else {\n\t\tsb.WriteByte('a')\n\t\tsb.WriteString(s[i+1:])\n\t}\n\n\treturn sb.String()\n}", "func main() {\n\ts := \"abccccdd\"\n\tfmt.Println(longestPalindrome(s))\n}", "func longestPalindrome(s string) string {\n\tl := len(s)\n\tif l == 0 {\n\t\treturn \"\"\n\t}\n\n\tlongest := \"\"\n\tlongestLen := 0\n\n\tfor i := 0; i <= l-1; i++ {\n\t\tlen1 := calLP(s, i, i)\n\t\tlen2 := calLP(s, i, i+1)\n\t\tvar len int\n\t\tvar st string\n\t\tif len1 > len2 {\n\t\t\tlen = len1\n\t\t\tst = s[i-len/2 : i+len/2+1]\n\n\t\t} else {\n\t\t\tlen = len2\n\t\t\tst = s[i-len/2+1 : i+len/2+1]\n\t\t}\n\t\tif len > longestLen {\n\t\t\tlongestLen = len\n\t\t\tlongest = st\n\t\t}\n\n\t}\n\treturn longest\n}", "func longestPalindromeSubseq(s string) int {\n\n\t// 20200422:\n\t// 执行耗时:44 ms,击败了31.39% 的Go用户\n\t// 内存消耗:17 MB,击败了100.00% 的Go用户\n\t// 思路:\n\t// 对于回文来说,必须保证两头的字符都相同\n\t// 用 d[i][j]表示从字符串第i个字符到第j个字符之间的最长回文\n\t// 比较这段区间外的两个字符,如果它们相等,肯定能构成新的最长回文\n\t// 最终的最长回文会保存在dp[0][n-1]\n\t// 递推公式如下:\n\t// 当首位两个元素相等时:dp[0][n-1]=dp[1][n-2]+2\n\t// 否则:dp[0][n-1]=max(dp[1][n-1], dp[0][n-2])\n\n\tn := len(s)\n\tif n <= 1 {\n\t\treturn n\n\t}\n\n\tdp := make([][]int, n)\n\tfor i := 0; i < n; i++ {\n\t\tdp[i] = make([]int, n)\n\t\tdp[i][i] = 1\n\t}\n\n\tfor l := 2; l <= n; l++ {\n\t\tfor i := 0; i < n-l+1; i++ {\n\t\t\tj := i + l - 1\n\t\t\tupdateDP(dp, s, l, i, j)\n\t\t}\n\t}\n\n\treturn dp[0][n-1]\n}", "func palindrome(input string) bool {\n\t//hasil akhir yg diharapkan (true/false) defaultnya false\n\tvar kembalian bool\n\n\t//menampung jumlah karakter yang sama\n\tvar nilai int\n\n\t//panjang dari inputan ( jumlah karakternya )\n\tvar karakter int = len(input)\n\n\tfor i := 0; i < karakter; i++ {\n\t\t//misalkan karakter pertama dan terakhir sama, maka variabel nilai bertambah\n\t\tif input[i] == input[karakter-(i+1)] {\n\t\t\tnilai++\n\t\t}\n\t}\n\t//jika jumlah karakter input dan jumlah karakter yg sama sesuai maka true\n\tif nilai == karakter {\n\t\tkembalian = true\n\t}\n\treturn kembalian\n}", "func firstPalindrome(words []string) string {\n\tseen := make(map[string]bool)\n\tfor _, w := range words {\n\t\tif seen[w] {\n\t\t\tcontinue\n\t\t}\n\n\t\tok := true\n\t\tfor i := 0; i < len(w)/2 && ok; i++ {\n\t\t\tok = w[i] == w[len(w)-1-i]\n\t\t}\n\t\tif ok {\n\t\t\treturn w\n\t\t}\n\n\t\tseen[w] = true\n\t}\n\treturn \"\"\n}", "func palindromable(s string) bool {\n\tbs := []byte(s)\n\tm := make(map[byte]int)\n\tfor _, b := range bs {\n\t\tm[b]++\n\t}\n\tcenter := len(bs) % 2\n\tfor _, v := range m {\n\t\tif v%2 != 0 {\n\t\t\tif center == 0 {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tcenter--\n\t\t}\n\t}\n\treturn true\n}", "func isPalindrome(x int) bool {\n\tvar (\n\t\ty int\n\t\tz = x\n\t)\n\n\tfor x > 0 {\n\t\ty = y*10 + x%10\n\t\tx /= 10\n\t}\n\treturn y == z\n}", "func isP(s string) string {\n\tmid := len(s) / 2\n\tlast := len(s) - 1\n\tfor i := 0; i < mid; i++ { //checks if the last letter and the first letter are the same\n\t\tif s[i] != s[last-i] { // then moves on and check2nd letter and 2nd last letter and ect...\n\t\t\treturn \"NO. It's not a Palimdrome.\"\n\t\t}\n\t}\n\treturn \"YES! You've entered a Palindrome\"\n}", "func PalindromeComparePerChar(value string) bool {\n\tfor i := 0; i < len(value) / 2; i++ {\n\t\tvar firstIndex = i\n\t\tvar lastIndex = len(value) - i -1\n\t\t//compare per index\n\t\tfmt.Println(string(value[firstIndex]) , \" : \" , string(value[lastIndex]))\n\n\t\tif string(value[firstIndex]) != string(value[lastIndex]) {\n\t\t\tfmt.Println(\"Palindrome false\")\n\t\t\treturn false\n\t\t}\n\t}\n\tfmt.Println(\"Palindrome true\")\n\treturn true\n}", "func ASCIIPalindrome(s string) bool {\n\ti := 0\n\tj := len(s) - 1\n\n\tfor i < j {\n\t\tfor !(unicode.IsDigit(rune(s[i])) || unicode.IsLetter(rune(s[i]))) {\n\t\t\ti++\n\t\t}\n\t\tfor !(unicode.IsDigit(rune(s[j])) || unicode.IsLetter(rune(s[j]))) {\n\t\t\tj--\n\t\t}\n\n\t\tletterI := unicode.ToLower(rune(s[i]))\n\t\tletterJ := unicode.ToLower(rune(s[j]))\n\t\tif letterI != letterJ {\n\t\t\treturn false\n\t\t}\n\n\t\ti++\n\t\tj--\n\t}\n\treturn true\n}", "func reverseIndexRune(s string, r rune) int {\n\tif s == \"\" {\n\t\treturn -1\n\t}\n\n\trs := []rune(s)\n\tfor i := len(rs) - 1; i >= 0; i-- {\n\t\tif rs[i] == r {\n\t\t\treturn i\n\t\t}\n\t}\n\n\treturn -1\n}", "func longestPalindromic(s string) string {\n\tvar res string\n\tfor i := 0; i < len(s); i++ {\n\t\ts1 := palindrome(s, i, i)\n\t\ts2 := palindrome(s, i, i+1)\n\n\t\tif len(res) <= len(s1) {\n\t\t\tres = s1\n\t\t}\n\n\t\tif len(res) <= len(s2) {\n\t\t\tres = s2\n\t\t}\n\t}\n\n\treturn res\n}", "func IsPalindrome(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\tif x < 10 {\n\t\treturn true\n\t}\n\t// 先求出总共有多少位\n\tn := 2\n\tfor {\n\t\tif x/int(math.Pow10(n)) < 1 {\n\t\t\tbreak\n\t\t}\n\t\tn++\n\t}\n\t// 比较对称位上的值是否相等\n\tfor i, j := 1, n; i <= n/2; i, j = i+1, n+1-i {\n\t\tr := (x % int(math.Pow10(i))) / int(math.Pow10(i-1))\n\t\tl := (x % int(math.Pow10(j))) / int(math.Pow10(j-1))\n\n\t\tif r != l {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func isPalindrome(x int) bool {\n\tcopy_x := x\n\n\tif x < 0 {\n\t\treturn false\n\t}\n\n\trev := 0\n\n\tfor x > 0 {\n\t\trev = rev*10 + x%10\n\t\tx = x / 10\n\t}\n\n\tif rev == copy_x {\n\t\treturn true\n\t}\n\treturn false\n}", "func buildPalindrome(s string, left int, right int) string {\n\tfor right < len(s) && left >= 0 && s[left] == s[right] {\n\t\tleft--\n\t\tright++\n\t}\n\n\treturn string(s[left+1 : right])\n}", "func palindromeSol1(str string) bool {\n\trightPtr := len(str) - 1\n\tleftPtr := 0\n\tspace := rune(' ')\n\tfor rightPtr < len(str)/2 {\n\t\tright := rune(str[rightPtr])\n\t\tleft := rune(str[leftPtr])\n\t\t// Handle white space\n\t\tif right == space {\n\t\t\trightPtr++\n\t\t\tcontinue\n\t\t}\n\t\tif left == space {\n\t\t\tleftPtr--\n\t\t\tcontinue\n\t\t}\n\t\tif right != left {\n\t\t\treturn false\n\t\t}\n\t\tleftPtr--\n\t\trightPtr++\n\t}\n\treturn true\n}", "func isPalindrome(x int) bool {\n\tif x == 0 {\n\t\treturn true\n\t}\n\tif x < 0 {\n\t\treturn false\n\t}\n\tl := []int{}\n\tfor {\n\t\tbalance := x % 10\n\t\tl = append(l, balance)\n\t\tx = (x - balance) / 10\n\t\tif x == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\tr := make([]int, len(l))\n\tj := 0\n\tfor i := len(l) - 1; i >= 0; i-- {\n\t\tr[i] = l[j]\n\t\tj++\n\t}\n\n\tfor i, v := range l {\n\t\tif r[i] != v {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func longestPalindrome(s string) string {\n\tif len(s) < 2 {\n\t\treturn s\n\t}\n\tslice := make([]string, 0, 100)\n\tfor _, c := range s {\n\t\tslice = append(slice, \",\")\n\t\tslice = append(slice, string(c))\n\t}\n\tslice = append(slice, \",\")\n\t// abc --> ,a,b,c, abcd -->,a,b,c,d,\n\t// fmt.Printf(\"%s\", slice)\n\tmaxr, maxr_index, lens := 0, 0, len(slice)\n\tfor i := 1; i < lens; i++ {\n\t\t//main loop\n\t\tr, lefti, righti := 0, i-1, i+1\n\t\tfor {\n\t\t\tif lefti < 0 || righti >= lens {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif slice[lefti] == slice[righti] {\n\n\t\t\t\t//fmt.Printf(\"%s|%s|%d|%d\\n\", slice[lefti], slice[righti], lefti, righti)\n\t\t\t\tr++\n\t\t\t\tlefti--\n\t\t\t\trighti++\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif r > maxr {\n\t\t\tmaxr = r\n\t\t\tmaxr_index = i\n\t\t}\n\t}\n\t//slice_new :=slice[maxr_index-maxr:maxr+maxr_index]\n\ts_new := \"\"\n\t// fmt.Println(maxr)\n\t// fmt.Println(maxr_index)\n\tfor j := maxr_index - maxr; j < maxr+maxr_index; j++ {\n\t\tif j < lens {\n\t\t\tif slice[j] != \",\" {\n\t\t\t\ts_new += slice[j]\n\t\t\t}\n\t\t}\n\t}\n\t// \t//for _,s := range slice[maxr_index-maxr,j<:maxr+maxr_index-1]{\n\t// \t// if s != \",\"{\n\t// \t// s_new+=s\n\t// \t// }\n\t// }\n\treturn s_new\n}", "func isPalindrome2(x int) bool {\n\tif x < 0 || (x % 10 == 0 && x != 0) {\n\t\treturn false\n\t}\n\tvar rev int\n\tfor x > rev {\n\t\t//pop and push\n\t\trev = rev * 10 + x % 10\n\t\tx /= 10\n\t}\n\t// Considering about both odd and even cases.\n\treturn x == rev || x == rev / 10\n}", "func isPalindrome(x int) bool {\n\ty, z := 0, x // the reverse integer\n\n\tif x < 0 {\n\t\treturn false\n\t}\n\n\tfor z > 0 {\n\t\ty = y*10 + z%10\n\t\tz /= 10\n\t}\n\n\treturn x == y\n}", "func isPalindrome(str string) bool {\n\tvar reverse string\n\tfor _, char := range str {\n\t\treverse = string(char) + reverse\n\t}\n\treturn reverse == str\n}", "func minPalindrome(s string) string {\n\ttype key struct {\n\t\ta string // current string\n\t\tr string // prefix+suffix\n\t\tx int // moves required\n\t}\n\tvar cache = make(map[key]result)\n\tvar rec func(a string, r string, x int) result\n\trec = func(a string, r string, x int) result {\n\t\t// Termination condition.\n\t\tn := len(a)\n\t\tif n <= 1 {\n\t\t\treturn result{r + a + r, x}\n\t\t}\n\t\t// Check the cache.\n\t\tk := key{a, r, x}\n\t\tif result, ok := cache[k]; ok {\n\t\t\treturn result\n\t\t}\n\t\t// Compare a[i+1...j], a[i...j-1], and a[i+1...j+1].\n\t\tbest := rec(a[1:], a[:1], 1)\n\t\t{\n\t\t\tother := rec(a[:n-1], a[n-1:], 1)\n\t\t\tif other.beats(best) {\n\t\t\t\tbest = other\n\t\t\t}\n\t\t}\n\t\tif a[0] == a[n-1] {\n\t\t\tother := rec(a[1:n-1], a[:1], 0)\n\t\t\tif other.beats(best) {\n\t\t\t\tbest = other\n\t\t\t}\n\t\t}\n\t\t// Memoize the answer and return.\n\t\tanswer := result{r + best.s + r, best.n + x}\n\t\tcache[k] = answer\n\t\treturn answer\n\t}\n\treturn rec(s, \"\", 0).s\n}", "func IsPalindrome(list sort.Interface) bool {\n\tfor i, j := 0, list.Len()-1; i < j; i, j = i+1, j-1 {\n\t\tif list.Less(i, j) || list.Less(j, i) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func main() {\n\tfmt.Println(isPalindrome(12321))\n}", "func ShortestPalindrome(str string) string {\n\tj := 0\n\tfor i := len(str) - 1; i >= 0; i-- {\n\t\tif str[i] == str[j] {\n\t\t\tj++\n\t\t}\n\t}\n\n\tif j == len(str) {\n\t\treturn str\n\t}\n\n\tsubstr := str[j:]\n\tpalindrome := []rune(str[j:])\n\n\tfor i, j := 0, len(palindrome)-1; i < j; i, j = i+1, j-1 {\n\t\tpalindrome[i], palindrome[j] = palindrome[j], palindrome[i]\n\t}\n\n\treturn fmt.Sprintf(\"%s%s%s\", string(palindrome), ShortestPalindrome(str[:j]), substr)\n}", "func isPalindrome1(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\n\tvar rev int\n\tdividedx := x\n\n\tfor dividedx != 0 {\n\t\t//pop\n\t\tpop := dividedx % 10\n\t\tdividedx /= 10\n\t\t//push\n\t\trev = rev * 10 + pop\n\t}\n\n\treturn x == rev\n}", "func isPalindrome(x int) bool {\n\tif x < 0 || (x != 0 && x%10 == 0) {\n\t\treturn false\n\t}\n\treverse := 0\n\tfor x > reverse {\n\t\treverse = reverse*10 + x%10\n\t\tx /= 10\n\t}\n\n\treturn x == reverse || x == reverse/10\n}", "func palindromeSummer(n int) int {\n\tvar sum int\n\tvar listNum []int\n\t// Outer loop, every time the inner loop will have one fewer number to sum over\n\tfor i := 1; float64(i) < math.Sqrt(float64(n)); i++ {\n\t\tvar numToTest int\n\t\tnumToTest += i * i\n\t\tfor j := i + 1; float64(j) < math.Sqrt(float64(n)); j++ {\n\t\t\tnumToTest += j * j\n\t\t\t// Exit loop if numToTest is larger than n\n\t\t\tif numToTest > n {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\t// Convert the number to be tested into a string\n\t\t\tstr := fmt.Sprint(numToTest)\n\t\t\t// Create a flag to test if str is a palindrome\n\t\t\tpalindromeFlag := true\n\t\t\tif len(str) > 1 { // palindromeFlag is automatically true if numToTest is a single digit (1^2 + 2^2)\n\t\t\t\tfor k := 0; k <= len(str)/2-1; k++ {\n\t\t\t\t\tif str[len(str)-k-1] != str[k] {\n\t\t\t\t\t\tpalindromeFlag = false\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\t// If palindromeFlag is true and we don't already have that number in our list, we add numToTest to sum\n\t\t\tlistFlag := true\n\t\t\tfor _, listElement := range listNum {\n\t\t\t\tif numToTest == listElement {\n\t\t\t\t\tlistFlag = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif palindromeFlag && listFlag {\n\t\t\t\tsum += numToTest\n\t\t\t\tlistNum = append(listNum, numToTest)\n\t\t\t}\n\t\t}\n\t}\n\treturn sum\n}", "func chopPalindrome(n int) int {\n numberString := strconv.Itoa(n)\n newString := \"\"\n for i := 1; i < len(numberString) - 1; i++ {\n newString += string(numberString[i])\n }\n newPalindrome, _ := strconv.Atoi(newString)\n return newPalindrome\n}", "func solution(s []rune) bool {\n\n\t//to have a palindrome we must have at most 1 odd occurrence count of distinct character\n\n\t//if the characters are only ASCII, we can make a 255 bits array\n\t//0 value means the [index] character has even occurrences or 0\n\t//1 means it has odd, and we keep swapping the values for each duplicate\n\t//at the end we must have at most 1 value of 1\n\t//int64 has only 64bits, so we can use it only if we have max 64 distinct characters\n\t//we can presume we only have letters (26) so is safe to use for now even a int32, otherwise we will make an array of booleans\n\n\tvar count uint\n\tfor _, r := range s {\n\t\t//we ignore punctuation\n\t\tif unicode.IsLetter(r) == false {\n\t\t\tcontinue\n\t\t}\n\t\trc := unicode.ToLower(r)\n\t\tbit := uint(rc - 'a')\n\t\tcount ^= 1 << bit //flip/swap the value\n\t}\n\n\t//number AND number -1 should be 0 if it only has 1 bit of value 1\n\t//00010000 - 1 = 00001111\n\t//00010000 & 00001111 = 0\n\treturn count == 0 || (count&(count-1) == 0)\n}", "func UTF8Palindrome(s string) bool {\n\tfor utf8.RuneCountInString(s) > 1 {\n\t\tfirstRune, firstSize := utf8.DecodeRuneInString(s)\n\t\tlastRune, lastSize := utf8.DecodeLastRuneInString(s)\n\n\t\tif unicode.ToLower(firstRune) != unicode.ToLower(lastRune) {\n\t\t\treturn false\n\t\t}\n\n\t\ts = s[firstSize : len(s)-lastSize]\n\t}\n\treturn true\n}", "func (l *LinkedList) isPalindrome() bool {\n\thalfPoint := int(l.length / 2)\n\tcurrent := l.head\n\tstart := l.head\n\tfor i := halfPoint + 1; i < 0; i-- {\n\t\tcurrent = current.next\n\t}\n\t// now current points to the first element of the second half\n\t// we can reverse a new linked list with root current\n\tsecondHalf := LinkedList{head: current}\n\tsecondHalf.reverse()\n\tsecondHalfElement := secondHalf.head\n\tfor i := halfPoint + 1; i < 0; i-- {\n\t\tif start != secondHalfElement {\n\t\t\treturn false\n\t\t}\n\t\tstart = start.next\n\t\tsecondHalfElement = secondHalfElement.next\n\t}\n\treturn true\n}", "func findSumOfDualPalindromes(lim int) int {\n\tdefer timeTrack(time.Now(), \"findSumOfDualPalindromes()\")\n\n\tsum := 0\n\tfor i := 1; i < lim; i++ {\n\t\tbase10 := strconv.FormatInt(int64(i), 10)\n\t\tif isPalindrome(base10) == false {\n\t\t\tcontinue\n\t\t}\n\t\tbase2 := strconv.FormatInt(int64(i), 2)\n\t\tif isPalindrome(base2) == false {\n\t\t\tcontinue\n\t\t}\n\t\t// p(base10, \" : \", base2)\n\t\tsum += i\n\t}\n\treturn sum\n}", "func isPalindrome(listOfNumbers [6]int,numberDigits int ) bool {\n\n\tisValid := true \t\t // initiate return value\n\n\tfor i := 0 ; i < numberDigits ; i++ { // loop through array size\n\n\t\tif listOfNumbers[i] != listOfNumbers[(numberDigits - 1)-i] { \t // compare first element of array with its mirrored index value\n\n\t\t\tisValid = false \t // if not the same then it is not a palindrome\n\t\t}\n\t}\n\treturn isValid\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t // return if is palindrome\n}", "func CheckPlindromePermutation(s string) bool {\n\ttable := [128]int{} // Assumption\n\toddCount := 0\n\n\tfor _, c := range s {\n\t\tif c == ' ' {\n\t\t\tcontinue\n\t\t}\n\n\t\ttable[c]++\n\t\tif table[c]%2 == 0 {\n\t\t\toddCount--\n\t\t} else {\n\t\t\toddCount++\n\t\t}\n\t}\n\n\tif oddCount > 1 {\n\t\treturn false\n\t}\n\treturn true\n}", "func isPalindrome(num int) bool {\n\tif num < 0 {\n\t\treturn false\n\t}\n\treturn num == reverseInt(num)\n}", "func IterIsPalyn(s string) bool {\r\n n := len(s)\r\n for i := 0;i < n / 2;i++ {\r\n if s[i] != s[n - i - 1] {\r\n return false\r\n }\r\n }\r\n return true\r\n}", "func Index(s, t string) int {\n\tx := 0\n\ty := 0\n\tfor _, c := range s {\n\t\tif c == c {\n\t\t\tx++\n\t\t}\n\t}\n\tfor _, c := range t {\n\t\tif c == c {\n\t\t\ty++\n\t\t}\n\t}\n\tfor i := 0; i < x; i++ {\n\t\tif y != 0 && s[i] == t[0] {\n\t\t\tok := true\n\t\t\tmok := 0\n\t\t\tfor j := 0; j < y; j++ {\n\t\t\t\tif i+mok >= x || t[j] != s[i+mok] {\n\t\t\t\t\tok = false\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tmok++\n\t\t\t}\n\t\t\tif ok == true {\n\t\t\t\treturn i\n\t\t\t}\n\t\t}\n\t}\n\treturn -1\n}", "func shortestPalindrome(s string) string {\n\tss := []byte(s)\n\n\tlength := len(ss)\n\tif length <= 1 {\n\t\treturn s\n\t}\n\tls, rs := 0, 0\n\n\tminls, minrs := 0, 0\n\tminPadding := length + 1\n\tfor rs < length/2 {\n\t\tl, r := ls, rs\n\t\tfor {\n\t\t\tif l < 0 || r >= length {\n\t\t\t\tif l < 0 && length-r < minPadding {\n\t\t\t\t\tminls, minrs = ls, rs\n\t\t\t\t\tminPadding = length - r\n\t\t\t\t} else if r >= length && l+1 < minPadding {\n\t\t\t\t\tminls, minrs = ls, rs\n\t\t\t\t\tminPadding = l + 1\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif ss[l] == ss[r] {\n\t\t\t\tl--\n\t\t\t\tr++\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif rs == ls {\n\t\t\trs++\n\t\t} else {\n\t\t\tls++\n\t\t}\n\t}\n\n\tvar buf bytes.Buffer\n\tif (minls - 0 + 1) == (length - minrs) {\n\t\tbuf.WriteString(s)\n\t} else if (minls - 0 + 1) > (length - minrs) {\n\t\tbuf.WriteString(s)\n\t\titx := minls - (length - minrs)\n\t\tfor itx >= 0 {\n\t\t\tbuf.WriteByte(ss[itx])\n\t\t\titx--\n\t\t}\n\t} else {\n\t\titx := length - 1\n\t\tend := minrs + minls\n\t\tfor itx > end {\n\t\t\tbuf.WriteByte(ss[itx])\n\t\t\titx--\n\t\t}\n\t\tbuf.WriteString(s)\n\t}\n\treturn buf.String()\n}", "func palindrome(list *LinkedList) bool {\n\tif list == nil || list.IsEmpty() {\n\t\treturn false\n\t}\n\n\thalf := list.Len() / 2\n\tleft := list.start\n\tright := list.end\n\t// As optimization we traverse only half of the list in the worst case.\n\tfor i := 0; i <= half; i++ {\n\t\tif left.value != right.value {\n\t\t\treturn false\n\t\t}\n\n\t\tleft = left.next\n\t\tright = right.previous\n\t}\n\n\treturn true\n}", "func palindromePartition(s string, k int) int {\n\tdp := make([][]int, len(s)+1)\n\tfor i := range dp {\n\t\tdp[i] = make([]int, k+1)\n\t\tfor j := range dp[i] {\n\t\t\tdp[i][j] = math.MaxInt32\n\t\t}\n\t}\n\tdp[0][0] = 0\n\n\tfor i := range dp {\n\t\tfor j := 0; j < k; j++ {\n\t\t\tfor next := 1; i+next <= len(s); next++ {\n\t\t\t\tcost := 0\n\t\t\t\tfor a, b := i, i+next-1; a < b; a, b = a+1, b-1 {\n\t\t\t\t\tif s[a] != s[b] {\n\t\t\t\t\t\tcost++\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tdp[i+next][j+1] = min(dp[i+next][j+1], dp[i][j]+cost)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dp[len(s)][k]\n}", "func isPalindromeWithoutConcernOverflow(x int) bool {\n\tif x < 0 {\n\t\treturn false\n\t}\n\tif x == 0 {\n\t\treturn true\n\t}\n\tif x%10 == 0 {\n\t\treturn false\n\t}\n\ty := x\n\tvar rev int\n\tfor y > 0 {\n\t\trev = rev*10 + y%10\n\t\ty /= 10\n\t}\n\treturn x == rev\n}", "func main() {\n\tfmt.Println(longestPalindrome(\"babad\"))\n}", "func IsPalindromePermutation2(str string) bool {\n\tvar charMap [256]int\n\tcountOdd := 0\n\tfor _, c := range str {\n\t\tcharMap[int(c)]++\n\t\tif charMap[int(c)]%2 != 0 {\n\t\t\tcountOdd++\n\t\t} else {\n\t\t\tcountOdd--\n\t\t}\n\t}\n\treturn countOdd <= 1\n}", "func IsPalindromePermutation1(str string) bool {\n\tvar charMap [256]int\n\tfor _, c := range str {\n\t\tcharMap[int(c)]++\n\t}\n\n\tfoundOneOdd := false\n\tfor _, i := range charMap {\n\t\tif i%2 != 0 {\n\t\t\tif !foundOneOdd {\n\t\t\t\tfoundOneOdd = true\n\t\t\t} else {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}", "func (l *LinkedList) isPalindrome() bool {\n\t_l := NewLinkedList()\n\tprev := _l.root\n\tfor n := l.root.next; n != l.root; n = n.next {\n\t\t_n := &Node{data: n.data}\n\t\t_l.root.next = _n\n\t\t_n.next = prev\n\t\tprev = _n\n\t}\n\tfor n, _n := l.root.next, _l.root.next; n != l.root; n = n.next {\n\t\tif n.data != _n.data {\n\t\t\treturn false\n\t\t}\n\t\t_n = _n.next\n\t}\n\treturn true\n}", "func Problem0004() int {\n\tlargest := 0\n\tfor a := 999; a >= 100; a-- {\n\t\tfor b := 999; b >= a; b-- {\n\t\t\tnum := a * b\n\t\t\tif num > largest && isPalindrome(num) {\n\t\t\t\tlargest = num\n\t\t\t}\n\t\t}\n\t}\n\treturn largest\n}" ]
[ "0.8369605", "0.6754832", "0.6696241", "0.66374886", "0.6629554", "0.6629554", "0.6499939", "0.6495809", "0.64007354", "0.63392174", "0.63289094", "0.6284339", "0.62753356", "0.62350863", "0.6212849", "0.62006426", "0.6193667", "0.6182231", "0.61615044", "0.61486727", "0.6148466", "0.6137266", "0.612447", "0.61171484", "0.60845184", "0.60835046", "0.6073204", "0.60511553", "0.6036472", "0.6032859", "0.6031095", "0.6005286", "0.5967777", "0.5958663", "0.5952149", "0.5945617", "0.59285367", "0.5901133", "0.589405", "0.5891062", "0.5887682", "0.5854459", "0.5852089", "0.5849721", "0.5844461", "0.5822166", "0.58099496", "0.57993686", "0.57954365", "0.57893497", "0.5779648", "0.5752963", "0.5737998", "0.5737513", "0.57366294", "0.5736623", "0.5730754", "0.57218236", "0.57057303", "0.5703531", "0.56719357", "0.5661545", "0.5655538", "0.56527424", "0.56512153", "0.564856", "0.56389284", "0.56359285", "0.5623109", "0.5620967", "0.5612444", "0.55621815", "0.55597836", "0.55499196", "0.5545", "0.5534646", "0.5517571", "0.5465936", "0.5456174", "0.5451977", "0.54442513", "0.543796", "0.53974164", "0.5346829", "0.5339334", "0.5302367", "0.5247697", "0.5247064", "0.5226496", "0.51908356", "0.5190149", "0.5164935", "0.5163965", "0.51522774", "0.5107672", "0.5107385", "0.5050917", "0.5004313", "0.50035024", "0.4974028" ]
0.8492687
0
Register for registry user
func Register(ctx *gin.Context) { DB := common.GetDB() //获取数据 name := ctx.PostForm("name") telephone := ctx.PostForm("tel") password := ctx.PostForm("password") email := ctx.PostForm("email") //判断数据 if len(name) == 0 { name = utils.RandString(9) } if len(telephone) != 11 { response.Response(ctx, http.StatusUnprocessableEntity, 4221, gin.H{}, "手机号必须为11位") return } if len(password) < 6 { response.Response(ctx, http.StatusUnprocessableEntity, 4222, gin.H{}, "密码需大于6位") return } if !utils.EmailFormatCheck(email) { response.Response(ctx, http.StatusUnprocessableEntity, 4223, gin.H{}, "email格式错误") return } //处理数据 var user model.User DB.AutoMigrate(&user) if UserExist(DB, telephone) { response.Response(ctx, http.StatusUnprocessableEntity, 4224, gin.H{}, "用户已存在") return } hashpassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) if err != nil { response.Response(ctx, http.StatusInternalServerError, 5001, gin.H{}, "密码加密错误") return } DB.Create(&model.User{Name: name, Password: string(hashpassword), Telephone: telephone, Email: email}) response.Success(ctx, gin.H{}, "ok") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Register(w http.ResponseWriter, r *http.Request, opt router.UrlOptions, sm session.ISessionManager, s store.IStore) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tparams := make(map[string]interface{})\n\t\tutils.RenderTemplate(w, r, \"register\", sm, s, params)\n\n\tcase \"POST\":\n\t\tvar newUser *user.User\n\n\t\tdfc := s.GetDataSource(\"persistence\")\n\n\t\tp, ok := dfc.(persistence.IPersistance)\n\t\tif !ok {\n\t\t\tutl.Log(\"Invalid store\")\n\t\t\treturn\n\t\t}\n\n\t\tc := p.GetCollection(\"users\")\n\n\t\tnewUser = &user.User{\n\t\t\tID: bson.NewObjectId(),\n\t\t\tUsername: r.PostFormValue(\"username\"),\n\t\t\tPassword: utils.HashString(r.PostFormValue(\"password\")),\n\t\t}\n\n\t\terr := c.Insert(newUser)\n\t\tif err != nil {\n\t\t\tutl.Log(err)\n\t\t}\n\n\t\tutl.Log(\"Registered user\", newUser)\n\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\tdefault:\n\t}\n}", "func Register(w http.ResponseWriter, r *http.Request, opt router.UrlOptions, sm session.ISessionManager, s store.IStore) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tutils.RenderTemplate(w, r, \"register\", sm, make(map[string]interface{}))\n\n\tcase \"POST\":\n\t\tvar newUser *user.User\n\n\t\tdfc := s.GetDataSource(\"persistence\")\n\n\t\tp, ok := dfc.(persistence.IPersistance)\n\t\tif !ok {\n\t\t\tlogger.Log(\"Invalid store\")\n\t\t\treturn\n\t\t}\n\n\t\tc := p.GetCollection(\"users\")\n\n\t\tapiServer := r.PostFormValue(\"api-server\")\n\t\tusername := r.PostFormValue(\"username\")\n\t\tpassword := hash.EncryptString(r.PostFormValue(\"password\"))\n\n\t\tnewUser = &user.User{\n\t\t\tID: bson.NewObjectId(),\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t\tAPIServerIP: apiServer,\n\t\t}\n\n\t\terr := c.Insert(newUser)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tlogger.Log(\"Error registering user '\" + username + \"'\")\n\t\t\treturn\n\t\t}\n\t\tlogger.Log(\"Registered user '\" + username + \"'\")\n\n\t\tlogger.Log(\"Registering user in API server \" + apiServer)\n\t\tform := url.Values{}\n\t\tform.Add(\"username\", username)\n\t\tform.Add(\"password\", password)\n\n\t\tregisterURL := \"http://\" + apiServer + \":\" + os.Getenv(\"SH_API_SRV_PORT\") + \"/login/register\"\n\t\t_, err = http.PostForm(registerURL, form)\n\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tlogger.Log(\"Error registering user in endpoint \" + registerURL)\n\t\t}\n\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\tdefault:\n\t}\n}", "func Register(authMod common.Authorizer, d models.UserStore, w http.ResponseWriter, r *http.Request) {\n\n\t//get data from request\n\tdecoder := json.NewDecoder(r.Body)\n\tbody := models.User{}\n\terr := decoder.Decode(&body)\n\tif err != nil {\n\t\tcommon.DisplayAppError(w, err, \"Invalid user data\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t//create new user\n\tuserId, err := d.CreateUser(body)\n\tif err != nil {\n\t\tcommon.DisplayAppError(w, err, \"Invalid user data\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t//create JWT\n\tjwt, err := authMod.GenerateJWT(\n\t\tbody.UserName,\n\t\tuserId,\n\t)\n\tif err != nil {\n\t\tcommon.DisplayAppError(w, err, \"fail up\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\treturnUser := CreatedUser{\n\t\tbody.UserName,\n\t\tbody.Email,\n\t\tjwt,\n\t}\n\tcommon.WriteJson(w, \"Succesfully registered user\", returnUser, http.StatusCreated)\n}", "func registerUser() {\n\tgoes.Register(\n\t\t&User{},\n\t\tFirstNameUpdatedV1{},\n\t\tCreatedV1{},\n\t)\n}", "func Register(\n\tc *gin.Context,\n\tuserService service.UserCommander,\n\tdispatcher queue.Publisher,\n) {\n\tvar req ar.RegisterRequest\n\tif isValid, errors := validation.ValidateRequest(c, &req); !isValid {\n\t\thttp.BadRequest(c, http.Errors(errors))\n\t\treturn\n\t}\n\n\tuser, err := userService.Create(c.Request.Context(), request.UserCreateRequest{\n\t\tFirstName: req.FirstName,\n\t\tLastName: req.LastName,\n\t\tEmail: req.Email,\n\t\tPassword: req.Password,\n\t\tRole: identityEntity.RoleConsumer,\n\t})\n\n\tif err != nil {\n\t\thttp.BadRequest(c, http.Errors{err.Error()})\n\t\treturn\n\t}\n\n\traiseSuccessfulRegistration(user.GetID(), dispatcher)\n\n\thttp.Created(c, http.Data{\n\t\t\"User\": user,\n\t}, nil)\n}", "func (h *auth) Register(c echo.Context) error {\n\t// Filter params\n\tvar params service.RegisterParams\n\tif err := c.Bind(&params); err != nil {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"Could not get user's params.\"))\n\t}\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\tif params.Email == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No email provided.\"))\n\t}\n\tif params.RegistrationPassword == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No password provided.\"))\n\t}\n\tif params.PasswordNonce == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No nonce provided.\"))\n\t}\n\tif libsf.VersionLesser(libsf.APIVersion20200115, params.APIVersion) && params.PasswordCost <= 0 {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No password cost provided.\"))\n\t}\n\n\tservice := service.NewUser(h.db, h.sessions, params.APIVersion)\n\tregister, err := service.Register(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn c.JSON(http.StatusOK, register)\n}", "func (h *Handler) Register(w http.ResponseWriter, r *http.Request) {\n\n\tvar d UserCreateRequest\n\tif err := json.NewDecoder(r.Body).Decode(&d); err != nil {\n\t\trender.BadRequest(w, r, \"invalid json string\")\n\t\treturn\n\t}\n\tuser, err := h.Client.User.Create().\n\t\tSetEmail(d.Email).\n\t\tSetName(d.Name).\n\t\tSetPassword(d.Password).\n\t\tSave(r.Context())\n\tif err != nil {\n\t\tfmt.Printf(\"%v\", err.Error())\n\t\trender.InternalServerError(w, r, \"Failed to register the user\")\n\t\treturn\n\t}\n\tfmt.Println(\"User registered successfully\")\n\trender.OK(w, r, user)\n}", "func (rsh *routeServiceHandler) Register(w http.ResponseWriter, r *http.Request) {\n\n\tuser := &models.User{}\n\terr := json.NewDecoder(r.Body).Decode(user)\n\tif err != nil {\n\t\tsendResponse(w, r, StatusError, err.Error(), nil)\n\t\treturn\n\t}\n\n\tpass, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost)\n\tif err != nil {\n\t\tsendResponse(w, r, StatusError, err.Error(), nil)\n\t\treturn\n\t}\n\n\tuser.Password = string(pass)\n\n\tcreatedUser, err := rsh.ctlr.Register(*user)\n\tif err != nil {\n\t\tsendResponse(w, r, StatusError, err.Error(), createdUser)\n\t\treturn\n\t}\n\n\tsendResponse(w, r, StatusSuccess, \"\", createdUser)\n\treturn\n}", "func (env *Env) Register(w http.ResponseWriter, r *http.Request) {\n\tdata := &RegisterRequest{}\n\tif err := render.Bind(r, data); err != nil {\n\t\trender.Render(w, r, ErrInvalidRequest(err))\n\t\treturn\n\t}\n\n\tif !emailRegexp.MatchString(data.Email) {\n\t\trender.Render(w, r, ErrRender(errors.New(\"invalid email\")))\n\t\treturn\n\t}\n\n\tpassword := data.User.Password\n\t_, err := env.userRepository.CreateNewUser(r.Context(), data.User)\n\tif err != nil {\n\t\trender.Render(w, r, ErrRender(err))\n\t\treturn\n\t}\n\n\tdata.User.Password = password\n\ttokenString, err := loginLogic(r.Context(), env.userRepository, data.User)\n\tif err != nil {\n\t\trender.Render(w, r, ErrUnauthorized(err))\n\t\treturn\n\t}\n\n\trender.JSON(w, r, tokenString)\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\tvar dataResource UserResource\n\t//Decode the incoming User json\n\n\terr := json.NewDecoder(r.Body).Decode(&dataResource)\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"Invalid User data\",\n\t\t\t500,\n\t\t)\n\t\treturn\n\t}\n\tuser := &dataResource.Data\n\tcontext := NewContext()\n\tdefer context.Close()\n\n\tc := context.DbCollection(\"users\")\n\trepo := &data.UserRespository{c}\n\n\t//insert User document\n\trepo.CreateUser(user)\n\t//Clean-up the hashpassword to eliminate it from response\n\tuser.HashPassword = nil\n\n\tif j, err := json.Marshal(UserResource{Data: *user}); err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"An unexpected error has occurred\",\n\t\t\t500,\n\t\t)\n\t\treturn\n\t} else {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusCreated)\n\t\tw.Write(j)\n\t}\n\n}", "func Register() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tvar userdb models.UsersDB\n\t\tclient := IntiateMongoConn() //init mongoDB connection\n\t\t_ = json.NewDecoder(c.Request.Body).Decode(&userdb)\n\t\t// check if username is alreadyused\n\t\talreadyUsed, err := checkAlreadyused(&userdb, client)\n\t\tif err != nil {\n\t\t\tif alreadyUsed {\n\t\t\t\tc.String(http.StatusNotAcceptable, err.Error())\n\n\t\t\t} else {\n\t\t\t\tlog.Fatal(err)\n\t\t\t\tc.String(http.StatusInternalServerError, err.Error())\n\n\t\t\t}\n\t\t}\n\t\tif !alreadyUsed {\n\t\t\t// add this user to database if username is not ever used\n\t\t\taddOneUser(&userdb, client)\n\t\t\tc.String(http.StatusOK, \"Successfully registered, your username:\"+userdb.Username+\", your password:\"+userdb.Password)\n\n\t\t}\n\n\t}\n\n}", "func (a *App) Register(w http.ResponseWriter, r *http.Request) {\n\tvar registerInfo uvm.UserRegisterVM\n\n\tdecoder := json.NewDecoder(r.Body)\n\tvar err error\n\n\tif err = decoder.Decode(&registerInfo); err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid request body\")\n\t\treturn\n\t}\n\n\t//TODO validate user data\n\n\tregisterInfo.Password, err = utils.HashPassword(registerInfo.Password)\n\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, \"Could not register user\")\n\t\treturn\n\t}\n\n\tvar user models.User\n\n\tuser, err = a.UserStore.AddUser(registerInfo)\n\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t}\n\n\ttoken := auth.GenerateToken(a.APISecret, user)\n\n\tresult := models.UserResult{\n\t\tUsername: user.Username,\n\t\tPicture: user.Picture,\n\t\tRole: user.Role.Name,\n\t\tToken: token,\n\t}\n\n\trespondWithJSON(w, http.StatusOK, result)\n}", "func (g *Gateway) registerUser(c *gin.Context) {\n\tvar params registrationParams\n\terr := c.BindJSON(&params)\n\tif err != nil {\n\t\tabort(c, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), handlerTimeout)\n\tdefer cancel()\n\n\ttoken, err := g.collections.Tokens.Get(ctx, params.Token)\n\tif err != nil {\n\t\tabort(c, http.StatusNotFound, fmt.Errorf(\"token not found\"))\n\t\treturn\n\t}\n\tproj, err := g.collections.Projects.Get(ctx, token.ProjectID)\n\tif err != nil {\n\t\tabort(c, http.StatusNotFound, fmt.Errorf(\"project not found\"))\n\t\treturn\n\t}\n\tuser, err := g.collections.Users.GetOrCreate(ctx, proj.ID, params.DeviceID)\n\tif err != nil {\n\t\tabort(c, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tsession, err := g.collections.Sessions.Create(ctx, user.ID, user.ID)\n\tif err != nil {\n\t\tabort(c, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"id\": user.ID,\n\t\t\"session_id\": session.ID,\n\t})\n}", "func AcceptRegisterUser(w http.ResponseWriter, r *http.Request) {\n\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab url path variables\n\turlVars := mux.Vars(r)\n\tregUUID := urlVars[\"uuid\"]\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\trefUserUUID := gorillaContext.Get(r, \"auth_user_uuid\").(string)\n\n\tru, err := auth.FindUserRegistration(regUUID, auth.PendingRegistrationStatus, refStr)\n\tif err != nil {\n\n\t\tif err.Error() == \"not found\" {\n\t\t\terr := APIErrorNotFound(\"User registration\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\n\t\terr := APIErrGenericInternal(err.Error())\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\tuserUUID := uuid.NewV4().String() // generate a new userUUID to attach to the new project\n\ttoken, err := auth.GenToken() // generate a new user token\n\tcreated := time.Now().UTC()\n\t// Get Result Object\n\tres, err := auth.CreateUser(userUUID, ru.Name, ru.FirstName, ru.LastName, ru.Organization, ru.Description,\n\t\t[]auth.ProjectRoles{}, token, ru.Email, []string{}, created, refUserUUID, refStr)\n\n\tif err != nil {\n\t\tif err.Error() == \"exists\" {\n\t\t\terr := APIErrorConflict(\"User\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\n\t\terr := APIErrGenericInternal(err.Error())\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// update the registration\n\terr = auth.UpdateUserRegistration(regUUID, auth.AcceptedRegistrationStatus, refUserUUID, created, refStr)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not update registration, %v\", err.Error())\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := res.ExportJSON()\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\trespondOK(w, []byte(resJSON))\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\n\tif r.Method == http.MethodGet {\n\t\tfmt.Println(\"http:GET:Register\")\n\t\tsession, _ := auth.GetCookieStore().Get(r, auth.GetSessionCookie())\n\t\tif e := session.Values[auth.USER_COOKIE_AUTH]; e != nil && e.(bool) {\n\t\t\thttp.Redirect(w, r, \"/login\", http.StatusFound)\n\t\t\treturn\n\t\t}\n\n\t}\n\n\tif r.Method == http.MethodPost {\n\t\tm := make(map[string]interface{})\n\t\tfmt.Println(\"http:POST:Register\")\n\t\te := r.FormValue(query.USER_EMAIL_ADDRESS)\n\n\t\tex, _, err := model.Check_User_By_Email(e, \"\")\n\t\tif ex || err != nil {\n\t\t\tm[query.SUCCESS] = false\n\t\t\tb, _ := json.MarshalIndent(m, \"\", \" \")\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\n\t\tu, err := model.CreateUserEP(e, \"\")\n\t\tu.SendWelcomeEmail()\n\n\t\tif err != nil {\n\t\t\tprintln(err)\n\t\t}\n\t\tu.StoreUser()\n\n\t\tm[query.SUCCESS] = true\n\t\tb, _ := json.MarshalIndent(m, \"\", \" \")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(b)\n\t\treturn\n\t}\n}", "func (u *UserHandler) Register(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tvar registerReq domain.RegisterRequest\n\terr := json.NewDecoder(r.Body).Decode(&registerReq)\n\tif err != nil {\n\t\tlog.Warnf(\"Error decode user body when register : %s\", err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\terrors := u.Validator.Validate(registerReq)\n\tif errors != nil {\n\t\tlog.Warnf(\"Error validate register : %s\", err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tjson.NewEncoder(w).Encode(errors)\n\t\treturn\n\t}\n\tuser := domain.User{\n\t\tName: registerReq.Name,\n\t\tEmail: registerReq.Email,\n\t\tPassword: registerReq.Password,\n\t}\n\terr = u.UserSerivce.Register(r.Context(), &user)\n\tif err != nil {\n\t\tlog.Warnf(\"Error register user : %s\", err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tresponse := SuccessResponse{\n\t\tMessage: \"Success Register User\",\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(response)\n\treturn\n}", "func (user User) Register(c appengine.Context) (User, error) {\n\n\t// If existing user return error\n\tpotential_user, err := getUserFromUsername(c, user.Username)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\tif potential_user != (User{}) {\n\t\treturn user, errors.New(\"User with this username exists\")\n\t}\n\n\thashed_password, err := bcrypt.GenerateFromPassword([]byte(user.Password), COST)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\tuser.Password = string(hashed_password)\n\n\t// save the user\n\tkey := datastore.NewIncompleteKey(c, \"Users\", nil)\n\t_, err = datastore.Put(c, key, &user)\n\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\treturn user, nil\n}", "func RegisterUser(w http.ResponseWriter, r *http.Request) {\n\n\t// Init output\n\toutput := []byte(\"\")\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab url path variables\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\n\t// Read POST JSON body\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\terr := APIErrorInvalidRequestBody()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Parse pull options\n\trequestBody := auth.UserRegistration{}\n\terr = json.Unmarshal(body, &requestBody)\n\tif err != nil {\n\t\terr := APIErrorInvalidArgument(\"User\")\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// check if a user with that name already exists\n\tif auth.ExistsWithName(requestBody.Name, refStr) {\n\t\terr := APIErrorConflict(\"User\")\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\tuuid := uuid.NewV4().String()\n\tregistered := time.Now().UTC().Format(\"2006-01-02T15:04:05Z\")\n\ttkn, err := auth.GenToken()\n\tif err != nil {\n\t\terr := APIErrGenericInternal(\"\")\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\tur, err := auth.RegisterUser(uuid, requestBody.Name, requestBody.FirstName, requestBody.LastName, requestBody.Email,\n\t\trequestBody.Organization, requestBody.Description, registered, tkn, auth.PendingRegistrationStatus, refStr)\n\n\tif err != nil {\n\t\terr := APIErrGenericInternal(err.Error())\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\toutput, err = json.MarshalIndent(ur, \"\", \" \")\n\tif err != nil {\n\t\terr := APIErrGenericInternal(err.Error())\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\trespondOK(w, output)\n}", "func RegisterUser(w http.ResponseWriter, r *http.Request) {\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\thttp.Error(w, \"No input found!\", http.StatusBadRequest)\n\t\treturn\n\t}\n\tvar newReq User\n\terr = json.Unmarshal(body, &newReq)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tvar username = newReq.UserID\n\tif _, ok := userData[username]; ok {\n\t\thttp.Error(w, \"User already exists!\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// log.Println(util.StringWithCharset(random.Intn(20)+10, charset))\n\tpreHashString := newReq.UserID + util.StringWithCharset(random.Intn(20)+10, util.Charset)\n\thashedString := crypto.CreateSHA256Hash(preHashString)\n\tuserData[username] = hashedString\n\thashOutput := UserHash{hashedString}\n\tlog.Println(userData)\n\toutJSON, err := json.Marshal(hashOutput)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(outJSON)\n}", "func Register(w http.ResponseWriter, r *http.Request){\n\tvar user models.User\n\terr := json.NewDecoder(r.Body).Decode(&user)\n\t\n\tif err != nil {\n\t\thttp.Error(w, \"Error en los datos recibidos: \" + err.Error(), 400)\n\t\treturn\n\t}\n\n\tif len(user.Email) == 0 {\n\t\thttp.Error(w, \"El email es requerido.\", 400)\n\t\treturn\n\t}\n\n\tif len(user.Password) < 6 {\n\t\thttp.Error(w, \"La contraseña debe ser de al menos 6 caractéres.\", 400)\n\t\treturn\n\t}\n\n\t_, found, _ := db.UserExist(user.Email)\n\n\tif found == true {\n\t\thttp.Error(w, \"El usuario ya existe.\", 400)\n\t\treturn\n\t}\n\n\t_, status, err := db.Register(user)\n\n\tif err != nil {\n\t\thttp.Error(w, \"nN se pudo realizar el registro: \" + err.Error(), 500)\n\t\treturn\n\t}\n\n\tif status == false {\n\t\thttp.Error(w, \"No se pudo realizar el registro\", 500)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\tvar t models.User\n\terr := json.NewDecoder(r.Body).Decode((&t))\n\tif err != nil {\n\t\thttp.Error(w, \"Error en los datos recibidos \"+err.Error(), 400)\n\t\treturn\n\t}\n\tif len(t.Email) == 0 {\n\t\thttp.Error(w, \"El email es requerido\", 400)\n\t\treturn\n\t}\n\tif len(t.Password) < 6 {\n\t\thttp.Error(w, \"El password tiene que tener un mínimo de 6 caracteres\", 400)\n\t\treturn\n\t}\n\n\t_, found, _ := bd.CheckUserExist(t.Email)\n\n\tif found {\n\t\thttp.Error(w, \"Usuario ya existe\", 400)\n\t\treturn\n\t}\n\n\t_, status, err := bd.InsertRegister(t)\n\tif err != nil {\n\t\thttp.Error(w, \"Ocurrió un error al momento de registrar usuario\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tif !status {\n\t\thttp.Error(w, \"Ocurrió un error al momento de registrar usuario\", 400)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\tt:= models.Users{}\n\n\terr := json.NewDecoder(r.Body).Decode(&t)\n\n\tif err != nil {\n\t\thttp.Error(w, \"Error en los datos recibidos \"+err.Error(), 400)\n\t\treturn\n\t}\n\tif len(t.Login) < 6 {\n\t\thttp.Error(w, \"Error en los datos recibidos, ingrese un login mayor a 5 digitos \", 400)\n\t\treturn\n\t}\n\tif len(t.Password) < 6 {\n\t\thttp.Error(w, \"Ingrese una contraseña mayor a 5 digitos \", 400)\n\t\treturn\n\t}\n\n\t_, found, _ := bd.CheckUser(t.Login)\n\tif found == true {\n\t\thttp.Error(w, \"Ya existe un usuario registrado con ese login\", 400)\n\t\treturn\n\t}\n\n\tif t.Id_role == 3 {\n\t\tcod := bd.CodFamiliar(t.Cod_familiar)\n\t\tif cod == false {\n\t\t\thttp.Error(w, \"Debe ingresar un codigo de familia correcto\", 400)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif t.Id_role == 1 {\n\t\thttp.Error(w, \"Usted no esta autorizado para crear este tipo de usuario\", 400)\n\t\treturn\n\t}\n\n\t_, status, err := bd.InsertRegister(t)\n\tif err != nil {\n\t\thttp.Error(w, \"Ocurrió un error al intentar realizar el registro de usuario \"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tif status == false {\n\t\thttp.Error(w, \"No se ha logrado insertar el registro del usuario\", 400)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n}", "func Register(kontrolURL, kiteHome, username, token string, debug bool) error {\n\tvar err error\n\n\t// Open up a prompt if the username is not passed via a flag and it's not a\n\t// token based authentication. If token is empty, it means the user can be\n\t// authenticated via password\n\tif token == \"\" && username == \"\" {\n\t\tusername, err = ask(\"Username:\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// User can just press enter to use the default on the prompt\n\t\tif username == \"\" {\n\t\t\treturn errors.New(\"Username can not be empty.\")\n\t\t}\n\t}\n\n\tk := kite.New(\"klient\", protocol.Version)\n\tk.Config.Environment = protocol.Environment\n\tk.Config.Region = protocol.Region\n\tk.Config.Username = username\n\n\tif debug {\n\t\tk.SetLogLevel(kite.DEBUG)\n\t}\n\n\t// Production Koding servers are only working over HTTP\n\tk.Config.Transport = config.XHRPolling\n\n\t// Give a warning if an existing kite.key exists\n\tkiteKeyPath := kiteHome + \"/kite.key\"\n\tif _, err := readKey(kiteKeyPath); err == nil {\n\t\tresult, err := ask(fmt.Sprintf(\"An existing %s detected. Type 'yes' to override and continue:\", kiteKeyPath))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif result != \"yes\" {\n\t\t\treturn errors.New(\"aborting registration\")\n\t\t}\n\t}\n\n\tkontrol := k.NewClient(kontrolURL)\n\tif err := kontrol.Dial(); err != nil {\n\t\treturn err\n\t}\n\tdefer kontrol.Close()\n\n\t// Register is always called with sudo, so Init should have enough\n\t// permissions.\n\tif err := tlsproxy.Init(); err != nil {\n\t\treturn err\n\t}\n\n\tauthType := \"password\"\n\tif token != \"\" {\n\t\tauthType = \"token\"\n\t}\n\n\tvar args = struct {\n\t\tUsername string\n\t\tToken string\n\t\tAuthType string\n\t}{\n\t\tUsername: username,\n\t\tToken: token,\n\t\tAuthType: authType,\n\t}\n\n\t// If authtType is password, this causes Kontrol to execute the\n\t// 'kite.getPass' method (builtin method in the Kite library) on our own\n\t// local kite (the one we declared above) method bidirectional. So once we\n\t// execute this, we immediately get a prompt asking for our password, which\n\t// is then transfered back to Kontrol. If we have a token, it will not ask\n\t// for a password and will create retunr the key immediately if the token\n\t// is valid for the given username (which is passed via the args).\n\tresult, err := kontrol.TellWithTimeout(\"registerMachine\", 5*time.Minute, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// If the token is correct a valid and signed `kite.key` is returned\n\t// back. We go and create/override the ~/.kite/kite.key with this content.\n\tif err := writeKey(result.MustString(), kiteKeyPath); err != nil {\n\t\treturn err\n\t}\n\n\t// Using authenticated here instead of registered, so it is a\n\t// middleground in UX for both raw `klient -register` usage, and also\n\t// `kd install` usage. `kd install` is very user facing, and\n\t// registration is potentially confusing to the end user (since\n\t// they are already registered to koding.com.. etc)\n\tfmt.Println(\"Authenticated successfully\")\n\treturn nil\n}", "func registerUser(req *api.RegistrationRequestNet, ca *CA) (string, error) {\n\tlog.Debugf(\"Registering user id: %s\", req.Name)\n\tvar err error\n\n\tif req.Secret == \"\" {\n\t\treq.Secret = util.RandomString(12)\n\t}\n\n\treq.MaxEnrollments, err = getMaxEnrollments(req.MaxEnrollments, ca.Config.Registry.MaxEnrollments)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\taddAttributeToRequest(attrmgr.EnrollmentID, req.Name, &req.Attributes)\n\n\tinsert := registry.UserInfo{\n\t\tName: req.Name,\n\t\tPass: req.Secret,\n\t\tAttributes: req.Attributes,\n\t\tMaxEnrollments: req.MaxEnrollments,\n\t}\n\n\tregistry := ca.registry\n\n\t_, err = registry.GetUser(req.Name, nil)\n\tif err == nil {\n\t\treturn \"\", errors.Errorf(\"Identity '%s' is already registered\", req.Name)\n\t}\n\n\terr = registry.InsertUser(&insert)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn req.Secret, nil\n}", "func (us *UserRpcService) Register(ctx context.Context,\n\tin *pb.User) (*pb.User, error) {\n\n\tLog.INFO(\"Got a new user registeration request: %v\", in)\n\n\t// Get store from context, it is added by middleware.\n\tstore := ctx.Value(\"user_store\").(UserStoreService)\n\tif store == nil {\n\t\tLog.ERROR(\"Failed to read user store from context\")\n\t\treturn nil, internalError\n\t}\n\n\t// Create the user in store.\n\tuser, err := store.Create(ctx, in)\n\tif err != nil {\n\t\tLog.ERROR(\"Failed to create user in store, err=%s\", err.Error())\n\t\treturn nil, internalError\n\t}\n\n\tLog.DEBUG(\"Created user with %v\", user)\n\treturn user, nil\n}", "func registerHandler(c *gin.Context) {\n\t// Decode json.\n\tvar json registerRequest\n\tif err := c.ShouldBindJSON(&json); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\n\thash, err := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.MinCost)\n\tif err != nil {\n\t\tc.JSON(400, gin.H{\n\t\t\t\"message\": \"error creating user\",\n\t\t})\n\t\treturn\n\t}\n\n\t// Create Job and push the work to work queue.\n\tuser := types.User{\n\t\tUsername: json.Username,\n\t\tPassword: string(hash),\n\t\tRole: \"guest\",\n\t}\n\n\tdb := data.New()\n\tu, err := db.Users.CreateUser(user)\n\tif err != nil {\n\t\tc.JSON(400, gin.H{\n\t\t\t\"message\": \"error creating user\",\n\t\t})\n\t\treturn\n\t}\n\n\tc.JSON(200, gin.H{\n\t\t\"user\": u.Username,\n\t\t\"message\": \"user created\",\n\t})\n}", "func Register(user models.User) (string, bool, error){\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\t\n\tdefer cancel()\n\n\tdb := MongoClient.Database(\"test-api-go\")\n\tcol := db.Collection(\"users\")\n\n\tuser.Password, _ = PasswordEncrypt(user.Password)\n\n\tresult, err := col.InsertOne(ctx, user)\n\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\n\tObjID, _ := result.InsertedID.(primitive.ObjectID)\n\treturn ObjID.String(), true, nil\n}", "func Register(ctx echo.Context) error {\n\treq := new(registerRequest)\n\tif err := ctx.Bind(req); err != nil {\n\t\treturn err\n\t}\n\tuser := User{Username: req.Username, Password: md5Pwd(req.Password), Type: req.Type}\n\terr := db.Model(&User{}).First(&user, &User{Username: req.Username}).Error\n\tif err == gorm.ErrRecordNotFound {\n\t\te := db.Create(&user).Error\n\t\tif e == nil {\n\t\t\tctx.SetCookie(&http.Cookie{Name: cookieKey, Value: user.Base.ID.String()})\n\t\t\treturn ctx.JSON(http.StatusOK, &response{\n\t\t\t\tCode: 0,\n\t\t\t\tMsg: \"\",\n\t\t\t\tData: registerResponse{\n\t\t\t\t\tUsername: user.Username,\n\t\t\t\t\tType: user.Type,\n\t\t\t\t\tID: user.Base.ID,\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn e\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &response{\n\t\tCode: 1,\n\t\tMsg: \"User name has been taken\",\n\t}\n\treturn ctx.JSON(http.StatusBadRequest, res)\n}", "func Register (w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"content-type\", \"application/json\")\n\n\tvar user models.User\n\tvar res models.ResponseResult\n\n\tbody, _ := ioutil.ReadAll(r.Body)\n\terr := json.Unmarshal(body, &user)\n\n\tif err != nil {\n\t\tres.Error = err.Error()\n\t\t_ = json.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\tif msg, validationResult := user.Valid(); !validationResult {\n\t\tres.Error = msg\n\t\t_ = json.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\n\thash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 10)\n\tif err != nil {\n\t\tre := models.ResponseError{\n\t\t\tCode: constants.ErrCodeHashError,\n\t\t\tMessage: constants.MsgHashError,\n\t\t\tOriginalError: err,\n\t\t}\n\t\tres.Error = re\n\t\t_ = json.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\tuser.Password = string(hash)\n\t_, err = models.InsertOne(models.UserCollection, user)\n\n\tif err != nil {\n\t\tre := models.ResponseError{\n\t\t\tCode: constants.ErrCodeInsertOne,\n\t\t\tMessage: strings.Replace(constants.MsgErrorInsertOne, \"%COLLECTION%\", models.UserCollection, -1),\n\t\t\tOriginalError: err,\n\t\t}\n\t\tres.Error = re\n\t\t_ = json.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\tres.Error = false\n\tres.Result = strings.Replace(constants.MsgSuccessInsertedOne, \"%COLLECTION%\", models.UserCollection, -1)\n\t_ = json.NewEncoder(w).Encode(res)\n\n\treturn\n\n}", "func Register(r *http.Request) (bool, error) {\n\tusername := r.FormValue(\"username\")\n\tnewPassword := r.FormValue(\"password\")\n\tconfirmPassword := r.FormValue(\"confirm_password\")\n\tu, err := models.GetUserByUsername(username)\n\t// If we have an error which is not simply indicating that no user was found, report it\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false, err\n\t}\n\tu = models.User{}\n\t// If we've made it here, we should have a valid username given\n\t// Check that the passsword isn't blank\n\tif newPassword == \"\" {\n\t\treturn false, ErrEmptyPassword\n\t}\n\t// Make sure passwords match\n\tif newPassword != confirmPassword {\n\t\treturn false, ErrPasswordMismatch\n\t}\n\t// Let's create the password hash\n\th, err := bcrypt.GenerateFromPassword([]byte(newPassword), bcrypt.DefaultCost)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tu.Username = username\n\tu.Hash = string(h)\n\tu.ApiKey = GenerateSecureKey()\n\terr = models.PutUser(&u)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func Register(name string, fc func(request *http.Request, user interface{}) bool) {\n\trole.Register(name, fc)\n}", "func Register(gate module.Gate, dataStorage *module.DataStorage) {\n\tmodule := NewUser(dataStorage)\n\t// user manage\n\tgate.RegisterRoute(\"/getUsers\", \"POST\", module.GetUsers)\n\tgate.RegisterRoute(\"/addUsers\", \"POST\", module.AddUsers)\n\tgate.RegisterRoute(\"/updateUsers\", \"POST\", module.UpdateUsers)\n\tgate.RegisterRoute(\"/delUsers\", \"POST\", module.DelUsers)\n\tgate.RegisterRoute(\"/submitRecord\", \"POST\", module.GetSubmitRecord)\n}", "func Register(g *gin.Context) {\n\t// init visitor User struct to validate request\n\tuser := new(models.User)\n\t/**\n\t* get request and parse it to validation\n\t* if there any error will return with message\n\t */\n\terr := validations.RegisterValidate(g, user)\n\t/***\n\t* return response if there an error if true you\n\t* this mean you have errors so we will return and bind data\n\t */\n\tif helpers.ReturnNotValidRequest(err, g) {\n\t\treturn\n\t}\n\t/**\n\t* check if this email exists database\n\t* if this email found will return\n\t */\n\tconfig.Db.Find(&user, \"email = ? \", user.Email)\n\tif user.ID != 0 {\n\t\thelpers.ReturnResponseWithMessageAndStatus(g, 400, \"this email is exist!\", false)\n\t\treturn\n\t}\n\t//set type 2\n\tuser.Type = 2\n\tuser.Password, _ = helpers.HashPassword(user.Password)\n\t// create new user based on register struct\n\tconfig.Db.Create(&user)\n\t// now user is login we can return his info\n\thelpers.OkResponse(g, \"Thank you for register in our system you can login now!\", user)\n}", "func Register(email, password string) (*User, error) {\n\t// Get redis connection\n\trd := pool.Get()\n\tdefer rd.Close()\n\n\t// Test existing\n\texists, err := redis.Bool(rd.Do(\"EXISTS\", conf.UserNamespace+email))\n\tif err != nil {\n\t\tpanic(err)\n\t} else if exists {\n\t\treturn nil, fmt.Errorf(\"account conflict\")\n\t}\n\n\t// Hash password\n\thash, err := abdi.Hash(password)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser := User{\n\t\tEmail: email,\n\t\tPassword: hash,\n\t}\n\n\t// json marshal user\n\tdata, err := json.Marshal(user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// redis set users:email = json user\n\t_, err = rd.Do(\"SET\", conf.UserNamespace+email, data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &user, nil\n}", "func (c *Credentials) Register(username, password string) {\n\tuser := EncryptUser(username, password)\n\tc.whitelist[user] = struct{}{}\n}", "func (u *UserHandler) Register(parentGroup *gin.RouterGroup) error {\n\tuserGroup := parentGroup.Group(\"users\")\n\tauthenticatedUserGroup := parentGroup.Group(\"users\")\n\tauthenticatedUserGroup.Use(u.AuthMiddleware.HandleAuth())\n\t{\n\t\tuserGroup.POST(\"\", u.RegisterUser)\n\t\tuserGroup.GET(\"/:userid\", u.GetUser)\n\t\tauthenticatedUserGroup.GET(\"\", u.GetAllUsers)\n\t}\n\treturn nil\n}", "func Register(write http.ResponseWriter, request *http.Request) {\n\tvar object models.User\n\terr := json.NewDecoder(request.Body).Decode(&object)\n\tif err != nil {\n\t\thttp.Error(write, \"An error ocurred in user register. \"+err.Error(), 400)\n\t\treturn\n\t}\n\n\t//Validations\n\tif len(object.Email) == 0 {\n\t\thttp.Error(write, \"Email is required.\", 400)\n\t\treturn\n\t}\n\tif len(object.Password) < 6 {\n\t\thttp.Error(write, \"Password invalid, must be at least 6 characters.\", 400)\n\t\treturn\n\t}\n\n\t_, userFounded, _ := bd.CheckExistUser(object.Email)\n\n\tif userFounded {\n\t\thttp.Error(write, \"The email has already been registered.\", 400)\n\t\treturn\n\t}\n\n\t_, status, err := bd.InsertRegister(object)\n\n\tif err != nil {\n\t\thttp.Error(write, \"An error occurred in insert register user.\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tif !status {\n\t\thttp.Error(write, \"Not insert user register.\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\twrite.WriteHeader(http.StatusCreated)\n}", "func (s *UserServer) Register(ctx context.Context, regInfo *pb.RegisterInfo) (*pb.UserInfo, error) {\n\tvar err error\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tutils.GetLog().Error(\"rpc.user.Register error: %+v\", err)\n\t\t}\n\t}()\n\n\tconfig := &users.RegisterConfig{\n\t\tAccount: regInfo.Account,\n\t\tPassword: regInfo.Password,\n\t\tPasswordConfirm: regInfo.PasswordConfirm,\n\t\tNickname: regInfo.Nickname,\n\t}\n\tr := users.NewRegister(config)\n\tif err := r.Do(); err != nil {\n\t\treturn nil, errors.New(r.ErrorCode().String())\n\t}\n\n\tu, _ := r.GetUserInfo()\n\treturn srvUserToPbUser(u), nil\n}", "func register(ctx context.Context) error {\n\trw := ctx.HttpResponseWriter()\n\n\tname := ctx.PostValue(\"name\")\n\temail := ctx.PostValue(\"email\")\n\tpassword := ctx.PostValue(\"password\")\n\n\tfieldErrs, err := db.RegisterUser(name, email, password)\n\tif len(fieldErrs) > 0 {\n\t\tdata, err := json.Marshal(fieldErrs)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Unable to marshal: \", err)\n\t\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t\t}\n\t\trw.Header().Set(\"Content-Type\", \"application/json\")\n\t\treturn goweb.Respond.With(ctx, http.StatusBadRequest, data)\n\t}\n\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t}\n\n\t// everything went fine\n\tmsg := struct {\n\t\tBody string `json:\"body\"`\n\t\tType string `json:\"type\"`\n\t}{\n\t\tBody: \"Check your email to activate your account\",\n\t\tType: \"success\",\n\t}\n\tdata, err := json.Marshal(msg)\n\tif err != nil {\n\t\tlog.Error(\"Unable to marshal: \", err)\n\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t}\n\trw.Header().Set(\"Content-Type\", \"application/json\")\n\treturn goweb.Respond.With(ctx, http.StatusOK, data)\n}", "func registerUser(conn net.Conn, username string) {\n\t// Check if the username has already been used\n\tnewUsername := checkDuplicateUsername(username)\n\t// Notify other users a new user has joined\n\tuserConnect(newUsername) // Called before adding the new user to the maps to prevent sending a 'joined' notification to himself (useless)\n\tconnMap[newUsername] = conn\n\tuserMap[conn] = newUsername\n\t// fmt.Println(username + \" joined the chat.\") // Used to verify the reception of the username\n\tconn.Write([]byte(\"TCCHAT_WELCOME\\tTCChat G7\\n\")) // Send welcome to the new user\n}", "func Register(r * http.Request, response * APIResponse) {\n\tif AllowsRegister {\n\t\tif r.FormValue(\"username\") != \"\" && r.FormValue(\"password\") != \"\" && r.FormValue(\"name\") != \"\" {\n\t\t\tusername := r.FormValue(\"username\")\n\t\t\tpassword := r.FormValue(\"password\")\n\t\t\trealName := r.FormValue(\"name\")\n\t\t\tif len(password) > 5 && userNameIsValid(username) && nameIsValid(realName) {\n\t\t\t\tif !UserForUserNameExists(username) {\n\t\t\t\t\t//The password is acceptable, the username is untake and acceptable\n\t\t\t\t\t//Sign up user\n\t\t\t\t\tuser := User{}\n\t\t\t\t\tuser.Username = username\n\t\t\t\t\tuser.HashedPassword = hashString(password)\n\t\t\t\t\tuser.UserImageURL = \"userImages/default.png\"\n\t\t\t\t\tuser.RealName = realName\n\t\t\t\t\tAddUser(&user)\n\t\t\t\t\n\t\t\t\t\t//Log the user in\n\t\t\t\t\tLogin(r, response)\n\t\t\t\t} else {\n\t\t\t\t\tresponse.Message = \"Username already taken\"\n\t\t\t\t\te(\"API\", \"Username already taken\")\n\t\t\t\t\tresponse.SuccessCode = 400\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresponse.Message = \"Values do not meet requirements\"\n\t\t\t\te(\"API\", \"Password is too short or username is invalid\")\n\t\t\t\tresponse.SuccessCode = 400\n\t\t\t}\n\t\t} else {\n\t\t\tresponse.Message = \"More information required\"\n\t\t\te(\"API\", \"Couldn't register user - not enough detail\")\n\t\t\tresponse.SuccessCode = 400\n\t\t}\n\t} else {\n\t\tresponse.SuccessCode = 400\n\t\tresponse.Message = \"Server doesn't allow registration\"\n\t}\n}", "func (s *Service) Register(user User) error {\n\tpassword := user.Password\n\tencrypted, err := s.encrypt.Encrypt(password)\n\tif err != nil {\n\t\tlog.Errorf(\"Password encryption failed: %s\", err)\n\t\treturn ErrCouldNotEncryptPassword\n\t}\n\tuser.Password = encrypted\n\ts.store.SaveUser(user)\n\treturn nil\n}", "func Register(token string, userID uuid.UUID, lang int) {\n\tdefer mutex.Unlock()\n\tmutex.Lock()\n\n\ttokenAvailable[token] = session{\n\t\tuserID: userID,\n\t\tlang: lang,\n\t}\n\tlog.Printf(\"[Auth] -> Registering user ID: %s\", userID)\n}", "func (s Set) Register(ctx context.Context, us model.RegisterRequest) (r model.RegisterUserResponse, err error) {\n\tresp, err := s.RegisterEndpoint(ctx, us)\n\tif err != nil {\n\t\treturn model.RegisterUserResponse{ID: \"\"}, err\n\t}\n\tresponse := resp.(model.RegisterUserResponse)\n\treturn response, err\n}", "func (serv *Server) RegisterUser(creds Credentials) (err error) {\n row := serv.db.QueryRow(\"select uid from users where username = ?;\", creds.Username)\n\n var uid int\n if row.Scan(&uid) == sql.ErrNoRows {\n salt := make([]byte, SaltLength)\n rand.Read(salt)\n\n saltedHash, err := HashAndSaltPassword([]byte(creds.Password), salt)\n if err != nil {\n return err\n }\n\n _, err = serv.db.Exec(\n `insert into users (username, salt, saltedhash) values (?, ?, ?);`,\n creds.Username, salt, saltedHash)\n\n if err != nil {\n err = ErrRegistrationFailed\n }\n } else {\n err = ErrUsernameTaken\n }\n\n return\n}", "func registerUser(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\n\tvar user_obj sbiStruct.user\t\n\tvar err error\n\n\tfmt.Println(\"Entering registerUser\")\n\n\tif (len(args) < 1) {\n\t\tfmt.Println(\"Invalid number of args\")\n\t\treturn nil, errors.New(\"Expected atleast one arguments for initiate Transaction\")\n\t}\n\n\tfmt.Println(\"Args [0] is : %v\\n\",args[0])\n\tfmt.Println(\"Args [1] is : %v\\n\",args[1])\n\t\n\t//unmarshal transaction initiation data from UI to \"transactionInitiation\" struct\n\terr = json.Unmarshal([]byte(args[1]), &user_obj)\n\tif err != nil {\n\t\tfmt.Printf(\"Unable to unmarshal createTransaction input transaction initiation : %s\\n\", err)\n\t\treturn nil, nil\n\t}\n\n\tfmt.Println(\"TransactionInitiation object refno variable value is : %s\\n\",trans_obj.TransRefNo);\n\t\n\tGetUserMap(stub)\t\n\n\tuser_map[user_obj.uname] = user_obj\t\n\n\tSetUserMap(stub)\t\n\t\n\tfmt.Printf(\"final user map : %v \\n\", user_map)\t\t\n\t\n\treturn nil, nil\n}", "func RegisterService(c *gin.Context, payload models.RegisterPayload) {\n\tdb := database.DBManager.DB\n\tvar count int\n\n\t// Count rows\n\trow := db.QueryRow(`SELECT COUNT(*) FROM User WHERE username = ?`, payload.Username)\n\terr := row.Scan(&count)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"success\": false, \"message\": err.Error})\n\t\treturn\n\t}\n\tif count > 0 {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"success\": false, \"message\": \"User already exist.\"})\n\t\treturn\n\t}\n\n\t//Insert new user\n\t_, err = db.Exec(`INSERT INTO User (username, password)\tVALUES (?, ?)`, payload.Username, payload.Password)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\"success\": false, \"message\": \"Internal error\"})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"success\": true, \"message\": \"User created with success\"})\n}", "func Register_user(user *User) {\n\tif(user.Username == \"\" || user.Password == \"\" || user.Email == \"\" || user.Phone == \"\"){\n\t\tfmt.Println(\"you need to input user message to create an account, the arguments include usernam, password, email, telephone.For example:\\n./agenda register -u=zhangzemian -p=12345678 [email protected] -t=15018377821\\n\")\n\t\treturn\n\t}\n\tAllUserInfo := Get_all_user_info()\n\tflog, err := os.OpenFile(\"data/input_output.log\", os.O_APPEND|os.O_WRONLY, 0600)\n\tdefer flog.Close()\n\tcheck_err(err)\n\tlogger := log.New(flog, \"\", log.LstdFlags)\n\n\tif _, ok := AllUserInfo[user.Username]; !ok {\n\t\tAllUserInfo[user.Username] = *user\n\t\tos.Stdout.WriteString(\"[agenda][info] \"+ user.Username + \" registed succeed!\\n\")\n\t\tlogger.Printf(\"[agenda][info] \"+user.Username+\" registed succeed\\n\")\n\t} else {\n\t\tos.Stdout.WriteString(\"[agenda][warning]The userName \" + user.Username + \" have been registered\\n\")\n\t\treturn\n\t}\n\n\tfout, _ := os.Create(\"data/User.json\")\n\tdefer fout.Close()\n\tb, _ := json.Marshal(AllUserInfo)\n\tfout.Write(b)\n}", "func (session *Session) register() error {\n\n\t// Create registration\n\tcmd, err := CreateRegistration(session.registration.Host, session.registration.User)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Send registration to server\n\tlog.Println(\"Registering with the server.\")\n\tSendMessage(cmd, session.socket)\n\treturn nil\n}", "func (ah *AuthHandler) Register(ctx *gin.Context) {\n\tvar user *model.User\n\terr := ctx.Bind(&user)\n\tif err != nil {\n\t\tctx.JSON(http.StatusBadRequest, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\t_, err = ah.Service.GetByEmail(ctx, user.Email)\n\tif err == nil {\n\t\tctx.JSON(http.StatusBadRequest, response.ErrorResponse{\n\t\t\tMessage: \"user already exists\",\n\t\t})\n\t\treturn\n\t}\n\n\tif err != pgx.ErrNoRows {\n\t\tctx.JSON(http.StatusBadRequest, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tuser.Password = hashSHA256(user.Password)\n\n\terr = ah.Service.Store(ctx, user)\n\tif err != nil {\n\t\tctx.JSON(http.StatusInternalServerError, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tctx.JSON(http.StatusOK, user)\n}", "func RegisterHandler(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tvar user User\n\tbody, _ := ioutil.ReadAll(r.Body)\n\terr := json.Unmarshal(body, &user)\n\tvar res ResponseResult\n\tif err != nil {\n\t\tres.Error = err.Error()\n\t\tjson.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\n\tvar result User\n\terr = sqldb.globalDB.Where(\"user\", body.Email).First(&user)\n\n\tif err != nil {\n\t\tif err.Error() == \"postgres: no documents in result\" {\n\t\t\thash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 5)\n\n\t\t\tif err != nil {\n\t\t\t\tres.Error = \"Error While Hashing Password, Try Again\"\n\t\t\t\tjson.NewEncoder(w).Encode(res)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tuser.Password = string(hash)\n\n\t\t\t_, err = usercollection.InsertOne(context.TODO(), user)\n\t\t\tif err != nil {\n\t\t\t\tres.Error = \"Error While Creating User, Try Again\"\n\t\t\t\tjson.NewEncoder(w).Encode(res)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tres.Result = \"Register Successful\"\n\t\t\tjson.NewEncoder(w).Encode(res)\n\t\t\treturn\n\t\t}\n\t\tres.Error = err.Error()\n\t\tjson.NewEncoder(w).Encode(res)\n\t\treturn\n\t}\n\tres.Result = \"A user with that email address already exists!\"\n\tjson.NewEncoder(w).Encode(res)\n\treturn\n}", "func Registration(w http.ResponseWriter, r *http.Request) {\n\n\tbody, _ := ioutil.ReadAll(r.Body)\n\n\tuser := models.User{}\n\terr := json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tuser.Prepare()\n\terr = user.Validate(\"login\")\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\ttoken, err := auth.SignUp(user.Email, user.Password)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tresponses.JSON(w, http.StatusOK, token)\n}", "func RegisterNewUser(c *soso.Context) {\n\treq := c.RequestMap\n\trequest := &auth_protocol.NewUserRequest{}\n\n\tif value, ok := req[\"source\"].(string); ok {\n\t\trequest.Source = value\n\t}\n\n\tif value, ok := req[\"phone\"].(string); ok {\n\t\trequest.PhoneNumber = value\n\t}\n\n\tif value, ok := req[\"instagram_username\"].(string); ok {\n\t\tvalue = strings.Trim(value, \" \\r\\n\\t\")\n\t\tif !nameValidator.MatchString(value) {\n\t\t\tlog.Debug(\"name '%v' isn't valid\", value)\n\t\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"Invalid instagram name\"))\n\t\t\treturn\n\t\t}\n\t\trequest.InstagramUsername = value\n\t}\n\n\tif value, ok := req[\"username\"].(string); ok {\n\t\tvalue = strings.Trim(value, \" \\r\\n\\t\")\n\t\tif !nameValidator.MatchString(value) {\n\t\t\tlog.Debug(\"name '%v' isn't valid\", value)\n\t\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"Invalid user name\"))\n\t\t\treturn\n\t\t}\n\t\trequest.Username = value\n\t}\n\n\tif request.InstagramUsername == \"\" && request.Username == \"\" {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"User name or instagram name is required\"))\n\t\treturn\n\t}\n\n\tif request.PhoneNumber == \"\" {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"User phone number is required\"))\n\t\treturn\n\t}\n\n\tctx, cancel := rpc.DefaultContext()\n\tdefer cancel()\n\tresp, err := authClient.RegisterNewUser(ctx, request)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tc.SuccessResponse(map[string]interface{}{\n\t\t\"ErrorCode\": resp.ErrorCode,\n\t\t\"ErrorMessage\": resp.ErrorMessage,\n\t})\n}", "func (s *AuthServer) Register(ctx context.Context, r *pb.RegisterRequest) (*pb.RegisterResponse, error) {\n\tusername := r.GetUsername()\n\temail := r.GetEmail()\n\tpassword := r.GetPassword()\n\tregisterResponse := actions.Register(username, email, password)\n\treturn &pb.RegisterResponse{Ok: registerResponse}, nil\n}", "func RegisterHandler(writer http.ResponseWriter, request *http.Request) {\n\temail := request.FormValue(\"email\")\n\tpassword := hashPassword(request.FormValue(\"password\"))\n\tredirectTarget := \"/\"\n\tif email != \"\" && password != \"\" {\n\t\tquery := \"INSERT rpUsers SET email=?, passwordHash=?\"\n\t\trpDatabase.ExecuteQuery(query, email, password)\n\t\trpLogger.Logger.Info(\"Registered user\")\n\t}\n\thttp.Redirect(writer, request, redirectTarget, 302)\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Register\")\n\tvar dataResource model.RegisterResource\n\t// Decode the incoming User json\n\terr := json.NewDecoder(r.Body).Decode(&dataResource)\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"Invalid data\",\n\t\t\thttp.StatusInternalServerError,\n\t\t)\n\t\treturn\n\t}\n\n\terr = dataResource.Validate()\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"Invalid data\",\n\t\t\thttp.StatusBadRequest,\n\t\t)\n\t\treturn\n\t}\n\n\tlog.Println(\"email: \" + dataResource.Email)\n\tcode := utils.RandStringBytesMaskImprSrc(6)\n\tlog.Println(code)\n\n\tdataStore := common.NewDataStore()\n\tdefer dataStore.Close()\n\tcol := dataStore.Collection(\"users\")\n\tuserStore := store.UserStore{C: col}\n\tuser := model.User{\n\t\tEmail: dataResource.Email,\n\t\tActivateCode: code,\n\t\tCreatedDate: time.Now().UTC(),\n\t\tModifiedDate: time.Now().UTC(),\n\t\tRole: \"member\",\n\t}\n\n\t// Insert User document\n\tstatusCode, err := userStore.Create(user, dataResource.Password)\n\n\tresponse := model.ResponseModel{\n\t\tStatusCode: statusCode.V(),\n\t}\n\n\tswitch statusCode {\n\tcase constants.Successful:\n\t\temails.SendVerifyEmail(dataResource.Email, code)\n\t\tresponse.Data = \"\"\n\t\tbreak\n\tcase constants.ExitedEmail:\n\t\tresponse.Error = statusCode.T()\n\t\t//if err != nil {\n\t\t//\tresponse.Error = err.Error()\n\t\t//}\n\t\tbreak\n\tcase constants.Error:\n\t\tresponse.Error = statusCode.T()\n\t\t//if err != nil {\n\t\t//\tresponse.Error = err.Error()\n\t\t//}\n\t\tbreak\n\t}\n\n\tdata, err := json.Marshal(response)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func (a *ApiDB) UserRegister(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tp := MODELS.RequestRegister{}\n\terr1 := json.NewDecoder(r.Body).Decode(&p)\n\tif err1 != nil {\n\t\tio.WriteString(w, `{\"message\": \"wrong format!\"}`)\n\t\treturn\n\t}\n\n\t_, err := BUSINESS.Register(a.Db, p)\n\tif err == nil {\n\t\tio.WriteString(w, `{\n\t\t\t \t\"status\": 200,\n\t\t\t\t\"message\":\"Register success\",\n\t\t\t\t\"data\": {\n\t\t\t\t\t\"status\": 1\n\t\t\t\t}\n\t\t\t}`)\n\t} else {\n\t\tio.WriteString(w, `{\"message\":\"Register fail\"}`)\n\t}\n}", "func RegisterHandler(w http.ResponseWriter, r *http.Request) {\n\tr.ParseForm()\n\tusername := r.PostFormValue(\"username\")\n\temail := r.PostFormValue(\"email\")\n\tpassword := r.PostFormValue(\"password\")\n\tuser, err := models.RegisterUser(username, email, password)\n\tif err != nil {\n\t\tlog.Print(err)\n\t} else {\n\t\tlog.Print(user)\n\t}\n}", "func RegisterlUser(username, password, department string) error {\n\tsdk := fabsdk.FabricSDK{}\n\tmspClient, err := msp.New(sdk.Context(), msp.WithOrg(\"Org1\"))\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to create msp client: %s\\n\", err)\n\t}\n\trequest := &msp.RegistrationRequest{\n\t\tName: username,\n\t\tType: \"user\",\n\t\tAffiliation: department,\n\t\tSecret: password,\n\t}\n\n\tsecret, err := mspClient.Register(request)\n\tif err != nil {\n\t\tfmt.Printf(\"register %s [%s]\\n\", username, err)\n\t\treturn err\n\t}\n\tfmt.Printf(\"register %s successfully,with password %s\\n\", username, secret)\n\treturn nil\n}", "func HandlerRegister(responseWriter http.ResponseWriter, request *http.Request) {\n\trequest.ParseForm()\n\n\tif request.Method == STR_GET {\n\t\tServeRegister(responseWriter, STR_EMPTY)\n\t} else {\n\t\temail := request.FormValue(API_KEY_email)\n\t\tpassword := request.FormValue(API_KEY_password)\n\t\tif email == STR_EMPTY || password == STR_EMPTY {\n\t\t\tServeRegister(responseWriter, STR_MSG_register)\n\t\t\treturn\n\t\t}\n\n\t\tisUserExists, isUserAdded, errorUser := DbAddUser(email, password, nil)\n\t\tif errorUser != nil {\n\t\t\tlog.Printf(\"handleRegister, errorUser=%s\", errorUser.Error())\n\t\t}\n\t\tif isUserExists {\n\t\t\tServeRegister(responseWriter, \"Username is already taken.\")\n\t\t} else if isUserAdded == false {\n\t\t\tServeRegister(responseWriter, \"Cannot create user.\")\n\t\t} else {\n\t\t\tServeLogin(responseWriter, STR_EMPTY)\n\t\t}\n\t}\n}", "func (m *Manager) Register(args RegisterArgs, reply *string) error {\n\tfmt.Println(\"Registering key\", args.Key)\n\tfmt.Println(\"To tenant\", args.TenantID)\n\n\tm.validKeys[args.Key] = args.TenantID\n\t*reply = \"OK\"\n\treturn nil\n}", "func Register(c echo.Context) error {\n\n\tRegisterAttempt := types.RegisterAttempt{}\n\terr := c.Bind(&RegisterAttempt)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusBadRequest, map[string]string{\"result\": \"error\", \"details\": \"Error binding register attempt.\"})\n\t}\n\n\tuserCreated, err := util.NewUser(RegisterAttempt.User, RegisterAttempt.Pass, RegisterAttempt.PassCheck)\n\tif err != nil {\n\t\tmsgUser := err.Error()\n\t\treturn c.JSON(http.StatusOK, msgUser)\n\t}\n\n\tif userCreated {\n\t\tmsgUser := fmt.Sprintf(\"User %s created!\", RegisterAttempt.User)\n\t\treturn c.String(http.StatusOK, msgUser)\n\t}\n\n\tmsgUser := fmt.Sprintf(\"User already exists or passwords don't match!\")\n\treturn c.String(http.StatusOK, msgUser)\n}", "func UserRegister(res http.ResponseWriter, req *http.Request) {\n\n\t// get user form from user register form\n\t// insert data to DB\n\t// First step would be Firstname, lastname and password..\n\t/*\n\t* encrypting password from frontend and decrypt at this end...\n\t* Password matching ( re entering)\n\t* Inserting to db ( firstname,lastname,email,password,registered_at)\n\t */\n\n\trequestID := req.FormValue(\"uid\")\n\tfirstName := req.FormValue(\"first_name\")\n\tlastName := req.FormValue(\"last_name\")\n\temail := req.FormValue(\"email\")\n\tpassword := req.FormValue(\"password\")\n\n\tlogs.WithFields(logs.Fields{\n\t\t\"Service\": \"User Service\",\n\t\t\"package\": \"register\",\n\t\t\"function\": \"UserRegister\",\n\t\t\"uuid\": requestID,\n\t\t\"email\": email,\n\t}).Info(\"Received data to insert to users table\")\n\n\t// check user entered same email address\n\thasAccount := Checkmail(email, requestID)\n\n\tif hasAccount != true {\n\n\t\tdb := dbConn()\n\n\t\t// Inserting token to login_token table\n\t\tinsertUser, err := db.Prepare(\"INSERT INTO users (email,first_name,last_name,password) VALUES(?,?,?,?)\")\n\t\tif err != nil {\n\t\t\tlogs.WithFields(logs.Fields{\n\t\t\t\t\"Service\": \"User Service\",\n\t\t\t\t\"package\": \"register\",\n\t\t\t\t\"function\": \"UserRegister\",\n\t\t\t\t\"uuid\": requestID,\n\t\t\t\t\"Error\": err,\n\t\t\t}).Error(\"Couldnt prepare insert statement for users table\")\n\t\t}\n\t\tinsertUser.Exec(email, firstName, lastName, password)\n\n\t\t// Inserting email to emails table\n\n\t\tinsertEmail, err := db.Prepare(\"INSERT INTO emails (email,isActive) VALUES(?,?)\")\n\t\tif err != nil {\n\t\t\tlogs.WithFields(logs.Fields{\n\t\t\t\t\"Service\": \"User Service\",\n\t\t\t\t\"package\": \"register\",\n\t\t\t\t\"function\": \"UserRegister\",\n\t\t\t\t\"uuid\": requestID,\n\t\t\t\t\"Error\": err,\n\t\t\t}).Error(\"Couldnt prepare insert statement for emails table\")\n\t\t}\n\t\tinsertEmail.Exec(email, 1)\n\n\t\t_, err = http.PostForm(\"http://localhost:7070/response\", url.Values{\"uid\": {requestID}, \"service\": {\"User Service\"},\n\t\t\t\"function\": {\"UserRegister\"}, \"package\": {\"Register\"}, \"status\": {\"1\"}})\n\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error response sending\")\n\t\t}\n\n\t\tdefer db.Close()\n\t\treturn\n\t} // user has an account\n\n\tlogs.WithFields(logs.Fields{\n\t\t\"Service\": \"User Service\",\n\t\t\"package\": \"register\",\n\t\t\"function\": \"UserRegister\",\n\t\t\"uuid\": requestID,\n\t\t\"email\": email,\n\t}).Error(\"User has an account for this email\")\n\n\t_, err := http.PostForm(\"http://localhost:7070/response\", url.Values{\"uid\": {requestID}, \"service\": {\"User Service\"},\n\t\t\"function\": {\"sendLoginEmail\"}, \"package\": {\"Check Email\"}, \"status\": {\"0\"}})\n\n\tif err != nil {\n\t\tlog.Println(\"Error response sending\")\n\t}\n}", "func Register(c *fiber.Ctx) error {\n\tu := new(types.User)\n\n\tif err := c.BodyParser(u); err != nil {\n\t\treturn c.SendStatus(fiber.StatusBadRequest)\n\t}\n\n\treturn c.SendStatus(fiber.StatusOK)\n}", "func Registration(c echo.Context) error {\n\tu := new(models.User)\n\tif err := c.Bind(u); err != nil {\n\t\treturn c.JSON(http.StatusBadRequest, err.Error())\n\t}\n\t// encrypt password\n\tpassword, err := utils.EncryptPassword(os.Getenv(\"SALT\"), c.FormValue(\"password\"))\n\n\tif err != nil {\n\t\treturn c.JSON(http.StatusInternalServerError, err)\n\t}\n\n\tu.Password = password\n\n\tfmt.Println(password)\n\n\tif res := db.DBCon.Create(u); res.Error != nil {\n\t\treturn c.JSON(http.StatusBadRequest, res.Error)\n\t}\n\treturn c.JSON(http.StatusCreated, u)\n}", "func (ctrl *UserController) Register(c *gin.Context) {\n\t// Validate the form\n\tvar form auth.RegisterForm\n\tif errs := shouldBindJSON(c, &form); errs != nil {\n\t\tc.AbortWithStatusJSON(http.StatusNotAcceptable, *errs)\n\t\treturn\n\t}\n\n\t// Check if the email is taken.\n\tif ctrl.Repository.EmailTaken(form.Email) {\n\t\tc.AbortWithStatusJSON(http.StatusNotAcceptable, utils.Err(\"A user with this email already exists\"))\n\t\treturn\n\t}\n\n\t// Create the user.\n\tuser, err := ctrl.Repository.RegisterUser(form)\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, utils.Err(\"Failed to register user\"))\n\t\treturn\n\t}\n\n\tgenerateTokens(c, user.ID, user.TokenVersion, user)\n}", "func Register(name string, port int) (err error) {\n\tr := RegistryRequest{name, port}\n\n\tbyt, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresp, err := http.Post(\"http://127.0.0.1\" + _LOCAL_PORT, \"text/json\", bytes.NewBuffer(byt))\n\tif err != nil {\n\t\treturn\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\terr = fmt.Errorf(\"non 200 response %d: %s\", resp.StatusCode, resp.Status)\n\t\treturn\n\t}\n\n\tbyt, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (a ServerAgent) RegisterUser(c *gin.Context) {\n\tauthorization, ok := a.authorize(c)\n\tif !ok {\n\t\treturn\n\t}\n\n\tif !authorization.Admin {\n\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{\"error\": \"this endpoint is only accessible to users with administrative priveleges\"})\n\t\treturn\n\t}\n\n\tvar req RegistrationRequest\n\terr := c.ShouldBindJSON(&req)\n\tif err != nil {\n\t\t//TODO is this error message safe to expose?\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\n\terr = a.dbClient.RegisterUser(c, req.UserUUID, req.Email)\n\tif err != nil {\n\t\ta.logger.Errorf(\"register user `%s` failed: %s\", req.UserUUID, err.Error())\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{\"error\": \"user registration failed - see logs for details\"})\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"user_uuid\": req.UserUUID,\n\t\t\"email\": req.Email,\n\t})\n}", "func Register(login string, email string, pass string) map[string]interface{} {\n\tvalid := helpers.Validation(\n\t\t[]interfaces.Validation{\n\t\t\t{Value: login, Valid: \"login\"},\n\t\t\t{Value: email, Valid: \"email\"},\n\t\t\t{Value: pass, Valid: \"password\"},\n\t\t})\n\tif valid {\n\t\tdb := helpers.ConnectDB()\n\t\tgeneratedPassword := helpers.HashAndSalt([]byte(pass))\n\t\tuser := &interfaces.User{Login: login, Email: email, Password: generatedPassword}\n\t\tdb.Create(&user)\n\n\t\tnow := time.Now()\n\t\tstatus := getStatus(\"https://google.pl\")\n\t\tuserlink := &interfaces.UserLink{Link: \"https://google.pl\", Status: status, Time: now, UserId: user.ID}\n\t\tdb.Create(&userlink)\n\n\t\tdefer db.Close()\n\n\t\tuserlinks := []interfaces.ResponseLink{}\n\t\trespLink := interfaces.ResponseLink{ID: userlink.ID, Link: userlink.Link, Status: userlink.Status, Time: userlink.Time}\n\t\tuserlinks = append(userlinks, respLink)\n\t\tvar response = prepareResponse(user, userlinks, true)\n\n\t\treturn response\n\n\t} else {\n\t\treturn map[string]interface{}{\"message\": \"not valid values\"}\n\t}\n}", "func (c *Client) RegisterUser(loginName, password string, attrs *map[string]interface{}) (bool, error) {\n\t// Create a request object.\n\treqobj := newMap(attrs)\n\treqobj[\"loginName\"] = loginName\n\treqobj[\"password\"] = password\n\n\terr := c.Send(c.appPath(\"users\"), \"POST\", reqobj,\n\t\t\"application/vnd.kii.RegistrationRequest+json\",\n\t\tfunc(resp *http.Response) error {\n\t\t\tswitch resp.StatusCode {\n\t\t\tcase 201:\n\t\t\t\treturn nil\n\t\t\tdefault:\n\t\t\t\treturn ToError(resp)\n\t\t\t}\n\t\t})\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func (s *Server) registerUserWithEnrollID(id string, enrollID string, attr []*pb.Attribute) (string, error) {\n\tmutex.Lock()\n\tdefer mutex.Unlock()\n\n\tlog.Debug(\"Registering user: \", id)\n\n\tvar tok string\n\ttok = randomString(12)\n\n\t// TODO: Update db with registered user\n\n\treturn tok, nil\n}", "func RegisterUser(db *gorm.DB, w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"register\")\n\truser := model.RUser{}\n\tdecoder := json.NewDecoder(r.Body)\n\tif err := decoder.Decode(&ruser); err != nil {\n\t\tRespondError(w, http.StatusBadRequest, \"\")\n\t\tlog.Println(\"decode:\", err.Error())\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\n\thashedPassword, err := bcrypt.GenerateFromPassword([]byte(ruser.Password), 8)\n\tif err != nil {\n\t\tRespondError(w, http.StatusInternalServerError, \"\")\n\t\tlog.Println(\"hash:\", err.Error())\n\t\treturn\n\t}\n\n\tid, err := uuid.NewUUID()\n\tif err != nil {\n\t\tRespondError(w, http.StatusInternalServerError, \"\")\n\t}\n\n\tuser := model.User{\n\t\tName: ruser.Name,\n\t\tUsername: ruser.Username,\n\t\tPassword: string(hashedPassword),\n\t\tUUID: id.String(),\n\t}\n\n\tif err := db.Save(&user).Error; err != nil {\n\t\tRespondError(w, http.StatusInternalServerError, \"\")\n\t\tlog.Println(\"save:\", err.Error())\n\t\treturn\n\t}\n\tRespondJSON(w, http.StatusCreated, user)\n}", "func (asr *sessionRegistry) register(clt *Client) {\n\tasr.lock.Lock()\n\tasr.registry[clt.Session.Key] = clt\n\tasr.lock.Unlock()\n}", "func (s SwxProxy) Register(_ context.Context, _ *protos.RegistrationRequest) (*protos.RegistrationAnswer, error) {\n\treturn &protos.RegistrationAnswer{}, nil\n}", "func Register(c *gin.Context) {\n\tvar registerRequest types.RegisterRequest\n\terr := c.BindJSON(&registerRequest)\n\tif err != nil {\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: err.Error()}\n\t\tc.JSON(http.StatusBadRequest, response)\n\t\treturn\n\t}\n\n\t// Validate register request struct\n\t_, err = govalidator.ValidateStruct(registerRequest)\n\tif err != nil {\n\t\terrMap := govalidator.ErrorsByField(err)\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: errMap}\n\t\tc.JSON(http.StatusBadRequest, response)\n\t\treturn\n\t}\n\n\t// Maybe add same tag in govalidator\n\tif registerRequest.Password != registerRequest.PasswordAgain {\n\t\terrMap := make(map[string]string)\n\t\terrMap[\"password_again\"] = \"Password again must be equal to password\"\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"msg\": \"Please check your data\", \"err\": errMap})\n\t\treturn\n\t}\n\n\t// hash password\n\tbytePassword := []byte(registerRequest.Password)\n\thashedPassword := hashPassword(bytePassword)\n\n\t// Save user\n\ttx, err := models.DB.Begin()\n\tdefer tx.Rollback()\n\n\tuser := models.User{}\n\tuser.Email = registerRequest.Email\n\tuser.Password = hashedPassword\n\tuser.IsAdmin = 0\n\tif err = user.Save(tx); err != nil {\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: err.Error()}\n\t\tc.JSON(http.StatusNotFound, response)\n\t} else {\n\t\ttx.Commit()\n\t\tresponse := types.APIResponse{Msg: \"Register user successfully\", Success: true}\n\t\tc.JSON(http.StatusOK, response)\n\t}\n}", "func (u *UserService) Register(ctx context.Context, in *userpbgw.RegisterRequest) (*userpbgw.Response, error) {\n\tisExisted, err := user.CheckExistingEmail(in.Email)\n\tif err != nil {\n\t\treturn &userpbgw.Response{\n\t\t\tError: 2222,\n\t\t\tMessage: fmt.Sprintf(\"Error: %s\", err),\n\t\t}, nil\n\t}\n\tif isExisted {\n\t\treturn &userpbgw.Response{\n\t\t\tError: 2222,\n\t\t\tMessage: \"Given email is existing\",\n\t\t}, nil\n\t}\n\tnewuser := user.User{\n\t\tFullname: in.Fullname,\n\t\tEmail: in.Email,\n\t\tPassword: in.Password,\n\t}\n\terr = user.Insert(&newuser)\n\tif err != nil {\n\t\treturn &userpbgw.Response{\n\t\t\tError: 2222,\n\t\t\tMessage: \"Register Error\",\n\t\t}, nil\n\t}\n\treturn &userpbgw.Response{\n\t\tError: 0,\n\t\tMessage: \"Register Sucessfull\",\n\t}, nil\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\n\tmessages := make([]string, 0)\n\ttype MultiErrorMessages struct {\n\t\tMessages []string\n\t}\n\n\t//Get Formdata\n\tusername := r.FormValue(\"username\")\n\tpassword := r.FormValue(\"password\")\n\temailadress := r.FormValue(\"email\")\n\trepeatPassword := r.FormValue(\"repeatpassword\")\n\n\t//Check Password\n\tif password != repeatPassword {\n\n\t\t//Add error Message\n\t\tmessages = append(messages, \"Passwort ist nicht richtig wiedeholt worden.\")\n\n\t}\n\n\t//Check Email\n\temail, err := mail.ParseAddress(emailadress)\n\tif err != nil || !strings.Contains(email.Address, \".\") {\n\n\t\t//Add error Message\n\t\tmessages = append(messages, \"Dies ist keine gültige Emailadresse.\")\n\n\t}\n\n\t//Fill Model\n\tuser := model.User{}\n\tuser.Name = username\n\tuser.Password = password\n\tuser.Email = emailadress\n\tuser.Type = \"User\"\n\n\t//Try and check Creating User\n\terr = user.CreateUser()\n\tif err != nil {\n\n\t\t//Write Data\n\t\tmessages = append(messages, err.Error())\n\n\t}\n\n\t//Check if any Error Message was assembled\n\tif len(messages) != 0 {\n\n\t\tresponseModel := MultiErrorMessages{\n\t\t\tMessages: messages,\n\t\t}\n\n\t\tresponseJSON, err := json.Marshal(responseModel)\n\t\tif err != nil {\n\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tw.Write([]byte(err.Error()))\n\n\t\t}\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t\tw.WriteHeader(http.StatusConflict)\n\t\tw.Write(responseJSON)\n\t\treturn\n\t}\n\n\t//Hash Username\n\tmd5HashInBytes := md5.Sum([]byte(user.Name))\n\tmd5HashedUsername := hex.EncodeToString(md5HashInBytes[:])\n\n\t//Create Session\n\tsession, _ := store.Get(r, \"session\")\n\tsession.Values[\"authenticated\"] = true\n\tsession.Values[\"username\"] = username\n\tsession.Values[\"hashedusername\"] = md5HashedUsername\n\tsession.Save(r, w)\n\n\t//Write Respone\n\thttp.Redirect(w, r, \"/users?action=userdata\", http.StatusFound)\n}", "func (r *apiV1Router) Register(ctx *gin.Context) {\n\tname := ctx.PostForm(\"name\")\n\temail := ctx.PostForm(\"email\")\n\tpassword := ctx.PostForm(\"password\")\n\n\tif len(name) == 0 || len(email) == 0 || len(password) == 0 {\n\t\tr.logger.Warn(\"one of name, email or password not specified\", zap.String(\"name\", name), zap.String(\"email\", email), zap.String(\"password\", password))\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"request must include the user's name, email and passowrd\")\n\t\treturn\n\t}\n\n\t_, err := r.userService.GetUserWithEmail(ctx, email)\n\tif err == nil {\n\t\tr.logger.Warn(\"email taken\", zap.String(\"email\", email))\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"email taken\")\n\t\treturn\n\t}\n\n\tif err != services.ErrNotFound {\n\t\tr.logger.Error(\"could not query for user with email\", zap.String(\"email\", email), zap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\thashedPassword, err := auth.GetHashForPassword(password)\n\tif err != nil {\n\t\tr.logger.Error(\"could not make hash for password\", zap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\tuser, err := r.userService.CreateUser(ctx, name, email, hashedPassword, r.cfg.BaseAuthLevel)\n\tif err != nil {\n\t\tr.logger.Error(\"could not create user\",\n\t\t\tzap.String(\"name\", name),\n\t\t\tzap.String(\"email\", email),\n\t\t\tzap.Int(\"auth level\", int(r.cfg.BaseAuthLevel)),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\temailToken, err := auth.NewJWT(*user, time.Now().Unix(), r.cfg.AuthTokenLifetime, auth.Email, []byte(r.env.Get(environment.JWTSecret)))\n\tif err != nil {\n\t\tr.logger.Error(\"could not generate JWT token\",\n\t\t\tzap.String(\"user id\", user.ID.Hex()),\n\t\t\tzap.Bool(\"JWT_SECRET set\", r.env.Get(environment.JWTSecret) != environment.DefaultEnvVarValue),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\tr.userService.DeleteUserWithEmail(ctx, email)\n\t\treturn\n\t}\n\terr = r.emailService.SendEmailVerificationEmail(*user, emailToken)\n\tif err != nil {\n\t\tr.logger.Error(\"could not send email verification email\",\n\t\t\tzap.String(\"user email\", user.Email),\n\t\t\tzap.String(\"noreply email\", r.cfg.Email.NoreplyEmailAddr),\n\t\t\tzap.Bool(\"SENDGRID_API_KEY set\", r.env.Get(environment.SendgridAPIKey) != environment.DefaultEnvVarValue),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\tr.userService.DeleteUserWithEmail(ctx, email)\n\t\treturn\n\t}\n\n\tctx.JSON(http.StatusOK, registerRes{\n\t\tResponse: models.Response{\n\t\t\tStatus: http.StatusOK,\n\t\t},\n\t\tUser: *user,\n\t})\n}", "func (c *RegistrationController) Register(w http.ResponseWriter, r *http.Request) {\n\n\t// parse the JSON coming from the client\n\tvar regRequest registrationRequest\n\tdecoder := json.NewDecoder(r.Body)\n\n\t// check if the parsing succeeded\n\tif err := decoder.Decode(&regRequest); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Error decoding JSON\")\n\t\treturn\n\t}\n\n\t// validate the data\n\tif err := regRequest.isValid(); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Invalid form data\")\n\t\treturn\n\t}\n\n\t// register the user\n\taccount := regRequest.Email // use the user's email as a unique account\n\tuser, err := models.RegisterUser(account, regRequest.Organisation,\n\t\tregRequest.Email, regRequest.Password, regRequest.First, regRequest.Last)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error registering the user: %v\", err)\n\t\tc.Error500(w, err, \"Error registering the user\")\n\t\treturn\n\t} else {\n\t\tc.JSON(&user, w, r)\n\t}\n\n\t// Send email address confirmation link\n\tif err := sendVerificationEmail(user.ID); err != nil {\n\t\tlog.Printf(\"Error sending verification email: %v\", err)\n\t\tc.Error500(w, err, \"Error sending verification email\")\n\t}\n\n}", "func (*RegDBService) AddUser(reg *Registration) error {\n\terr := rdb.Create(&reg).Error\n\treturn err\n}", "func UserRegister(router *gin.RouterGroup) {\n\trouter.POST(\"/register\", Register)\n\trouter.POST(\"/login\", Login)\n\trouter.POST(\"/logout\", Logout)\n}", "func (a Auth) registerHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := r.URL.Query()\n\tif len(vars[\"username\"]) != 1 || len(vars[\"password\"]) != 1 || len(vars[\"email\"]) != 1 {\n\t\tlog.Printf(\"Bad registration!\\n\")\n\t\tresponseError(w)\n\t\treturn\n\t}\n\tusername := vars[\"username\"][0]\n\tpassword := vars[\"password\"][0]\n\temail := vars[\"email\"][0]\n\tif username == \"\" || password == \"\" || email == \"\" {\n\t\tlog.Printf(\"Bad registration!\\n\")\n\t\tresponseError(w)\n\t\treturn\n\t}\n\terr := a.RegisterNewUser(username, password, email)\n\tif err != nil {\n\t\tlog.Printf(\"%+v\\n\", err)\n\t\tresponseError(w)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, \"{'ok':'true'}\")\n}", "func (w *ServerInterfaceWrapper) RegisterUser(ctx echo.Context) error {\n\tvar err error\n\n\t// Invoke the callback with all the unmarshalled arguments\n\terr = w.Handler.RegisterUser(ctx)\n\treturn err\n}", "func (uh *UserHandler) Register(w http.ResponseWriter, r *http.Request) {\n\n\tvar userHolder *entity.User\n\tvar password string\n\n\tif r.Method == http.MethodGet {\n\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\ttoken, err := stringTools.CSRFToken(uh.CSRF)\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t}\n\t\tinputContainer := InputContainer{CSRF: token}\n\t\tuh.Temp.ExecuteTemplate(w, \"SignUp.html\", inputContainer)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodPost {\n\n\t\tthirdParty := r.FormValue(\"thirdParty\")\n\t\tvar identification entity.Identification\n\t\tfirstname := r.FormValue(\"firstname\")\n\t\tlastname := r.FormValue(\"lastname\")\n\t\temail := r.FormValue(\"email\")\n\t\tidentification.ConfirmPassword = r.FormValue(\"confirmPassword\")\n\n\t\tif thirdParty == \"true\" {\n\n\t\t\tif r.FormValue(\"serverAUT\") != ServerAUT {\n\t\t\t\thttp.Error(w, \"Invalid server key\", http.StatusBadRequest)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tidentification.From = r.FormValue(\"from\")\n\t\t\tidentification.TpFlag = true\n\t\t} else {\n\t\t\tpassword = r.FormValue(\"password\")\n\t\t\tidentification.ConfirmPassword = r.FormValue(\"confirmPassword\")\n\t\t}\n\n\t\t// Validating CSRF Token\n\t\tcsrfToken := r.FormValue(\"csrf\")\n\t\tok, errCRFS := stringTools.ValidCSRF(csrfToken, uh.CSRF)\n\n\t\tuserHolder = entity.NewUserFR(firstname, lastname, email, password)\n\t\terrMap := uh.UService.Verification(userHolder, identification)\n\t\tif !ok || errCRFS != nil {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\terrMap[\"csrf\"] = \"Invalid token used!\"\n\t\t}\n\t\tif len(errMap) > 0 {\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"SignUp.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tif identification.TpFlag {\n\n\t\t\tnewSession := uh.configSess()\n\t\t\tclaims := stringTools.Claims(email, newSession.Expires)\n\t\t\tsession.Create(claims, newSession, w)\n\t\t\t_, err := uh.SService.StoreSession(newSession)\n\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\thttp.Redirect(w, r, \"/Dashboard\", http.StatusSeeOther)\n\t\t}\n\n\t\tuh.Temp.ExecuteTemplate(w, \"CheckEmail.html\", nil)\n\t\treturn\n\t}\n}", "func Register(c *gin.Context) {\n\tdb := c.MustGet(\"db\").(*gorm.DB)\n\n\tvar input models.CreateUserInput\n\tif err := c.ShouldBindJSON(&input); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error(), \"message\": \"signUp\", \"status\": false})\n\t\treturn\n\t}\n\t//ensure unique\n\tvar user models.User\n\tif err := db.Where(\"email = ?\", input.Email).First(&user).Error; err == nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": \"Email Taken!\", \"message\": \"signUp\", \"status\": false})\n\t\treturn\n\t}\n\t//create user\n\thashedPassword, _ := bcrypt.GenerateFromPassword([]byte(input.Password), bcrypt.DefaultCost)\n\thashPass := string(hashedPassword)\n\ttk := models.Token{Email: input.Email}\n\ttoken := jwt.NewWithClaims(jwt.GetSigningMethod(\"HS256\"), tk)\n\ttokenString, _ := token.SignedString([]byte(os.Getenv(\"token_password\")))\n\tuser2 := models.User{UserName: input.UserName, Email: input.Email, Password: hashPass, UserType: input.UserType, Token: tokenString}\n\tdb.Create(&user2)\n\tc.JSON(http.StatusOK, gin.H{\"user\": user2, \"message\": \"signUp\", \"status\": true})\n}", "func (m Users) Register(user User) error {\n\tif !isValidPass(user.Password) {\n\t\treturn ErrInvalidPass\n\t}\n\tif !validEmail.MatchString(user.Email) {\n\t\treturn ErrInvalidEmail\n\t}\n\thash, err := hashPassword(user.Password)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsqlStatement := `INSERT INTO users (email, password) VALUES($1, $2) RETURNING id, created_at;`\n\t_, err = m.DB.Exec(sqlStatement, user.Email, hash)\n\tif err, ok := err.(*pq.Error); ok {\n\t\tif err.Code == \"23505\" {\n\t\t\treturn ErrUserAlreadyExist\n\t\t}\n\t}\n\n\treturn err\n}", "func (s *Server) Register(name string, h Handler) error {\n if _, ok := s.registry[name]; ok {\n return fmt.Errorf(\"cannot register name %q twice\", name)\n }\n s.registry[name] = &register{handler: h}\n return nil\n}", "func RegisterUser(user models.User)(string,bool,error) {\n\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\tdb := MongoC.Database(\"twitter\")\n\tcol := db.Collection(\"users\")\n\tuser.Password,_ = EncriptPassw(user.Password)\n\tresult, err := col.InsertOne(ctx,user)\n\tif err != nil{\n\t\treturn \"\",false,err\n\t}\n\tObjID,_ := result.InsertedID.(primitive.ObjectID)\n\treturn ObjID.String(),true,nil\n}", "func Register(clientID, clientIDTag string) (string, error) {\n\tapiURL = generateAPIURL(clientID)\n\tquery := Query{CMD: register, ClientID: clientID}\n\tresps, err := post(Queries{Queries: []Query{query}})\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif len(resps.Responses) == 0 {\n\t\treturn \"\", errResponseNotFound\n\t}\n\tswitch resps.Responses[0].Status {\n\tcase \"ERROR\":\n\t\treturn \"\", fmt.Errorf(errResponseError, resps.Message)\n\tcase \"OK\":\n\t\tAuthenticate(clientID, clientIDTag, resps.Responses[0].User)\n\t\treturn resps.Responses[0].User, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(errUnrecognisedStatus, resps.Responses[0].Status)\n\t}\n}", "func (u *User) RegisterFingerprint(fp string) (map[string]interface{}, error) {\n\tlog.info(\"========== REGISTER FINGERPRINT ==========\")\n\turl := buildURL(path[\"auth\"], u.UserID)\n\n\tu.request.fingerprint = fp\n\n\tdata := `{ \"refresh_token\": \"` + u.RefreshToken + `\" }`\n\n\tres, err := u.do(\"POST\", url, data, nil)\n\n\treturn res, err\n}", "func Register(db *gorm.DB, ctx echo.Context, username, email, password string) (*User, error) {\n\treqTimeSec, err := strconv.ParseInt(ctx.Request().Header.Get(\"REQUEST_TIME\"), 10, 64)\n\treqTime := time.Now()\n\tif err == nil {\n\t\treqTime = time.Unix(reqTimeSec, 0)\n\t}\n\n\tip := web.IP(ctx)\n\tlocation := web.Location(ctx, ip)\n\n\tu := &User{\n\t\tUsername: username,\n\t\tEmail: email,\n\t\tPassword: password,\n\t\tCreateIP: ip,\n\t\tCreateLocation: location,\n\t\tLastLoginTime: uint64(reqTime.Unix()),\n\t\tLastLoginIP: ip,\n\t\tLastLoginLocation: location,\n\t}\n\n\terr = db.Save(u).Error\n\treturn u, err\n}", "func RegisterHandler(w http.ResponseWriter, r *http.Request, serv *AppServer) {\n\tswitch r.Method {\n\tcase http.MethodGet:\n\t\tsession, err := r.Cookie(\"UserID\")\n\t\ttempID, err := strconv.Atoi(session.Value)\n\t\tif err != nil || tempID == -1 {\n\t\t\tRenderFileTemplate(w, \"register\")\n\t\t} else {\n\t\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t\t}\n\tcase http.MethodPost:\n\t\tr.ParseForm()\n\n\t\tinvalid := false\n\t\tif r.PostFormValue(\"username\") == \"\" || r.PostFormValue(\"password\") == \"\" {\n\t\t\tinvalid = true\n\t\t} else if serv.UserSearch(\"username\") != -1 {\n\t\t\tinvalid = true\n\t\t}\n\n\t\tif invalid {\n\t\t\thttp.Redirect(w, r, \"/registerfail\", http.StatusTemporaryRedirect)\n\t\t} else {\n\t\t\tserv.AddUser(\n\t\t\t\tr.PostFormValue(\"username\"),\n\t\t\t\tr.PostFormValue(\"password\"),\n\t\t\t\tr.PostFormValue(\"color\"),\n\t\t\t)\n\t\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t\t}\n\t}\n}", "func (r *Registrar) RegisterUser(username, netID, password string) error {\n\t// Check to make sure that neither the username nor netID already exist.\n\tif _, exists := r.users[username]; exists {\n\t\treturn errors.New(\"Username \" + username + \" has already been taken\")\n\t} else if _, exists := r.registeredNetIDs[netID]; exists {\n\t\treturn errors.New(\"Net ID \" + netID + \" is already registered\")\n\t}\n\n\t// Screen the username and net ID for commas.\n\tif strings.Contains(username+netID, \",\") {\n\t\treturn errors.New(\"No commas allowed in username or net ID\")\n\t}\n\n\t// Write the user's data to file first.\n\tregistrarFile, err := os.OpenFile(r.registrarFileName, os.O_RDWR|os.O_APPEND, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer registrarFile.Close()\n\tpasswordCheckSum := adler32.Checksum([]byte(password))\n\tuserDataString := username + \",\" + netID + \",\" + string(passwordCheckSum) + \"\\n\"\n\t_, err = registrarFile.WriteString(userDataString)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Now push the data to the in-memory data structures and return.\n\tnewUserData := userData{\n\t\tloggedIn: false,\n\t\tnetID: netID,\n\t\tpasswordCheckSum: passwordCheckSum,\n\t}\n\tr.users[username] = newUserData\n\tr.registeredNetIDs[netID] = true\n\treturn nil\n}", "func (s *Server) RegisterService(ctx context.Context, req *authpb.RegisterRequest) (*authpb.RegisterResponse, error) {\n\tlog.Printf(\"Registering user with email %s \\n\", req.GetEmail())\n\tuser := user.User{\n\t\tEmail: req.GetEmail(),\n\t\tFullname: req.GetFullname(),\n\t\tPassword: req.GetPassword(),\n\t}\n\n\tif user.Email == \"\" || user.Fullname == \"\" || user.Password == \"\" {\n\t\treturn nil, status.Errorf(\n\t\t\tcodes.InvalidArgument,\n\t\t\t\"Fullname, Email, and Password Is Required!\",\n\t\t)\n\t}\n\n\tu, _ := s.Manager.FindOne(user.Email)\n\tif u != nil {\n\t\treturn nil, status.Errorf(\n\t\t\tcodes.AlreadyExists,\n\t\t\tfmt.Sprintf(\"User with email %s already exist\", user.Email),\n\t\t)\n\t}\n\n\t_ = s.Manager.Register(user)\n\ttoken := s.Token.Generate(&user)\n\n\tlog.Println(\"Success registering new user with email:\", user.Email)\n\treturn &authpb.RegisterResponse{\n\t\tMessage: \"Register success\",\n\t\tAccessToken: token,\n\t}, nil\n}", "func (r *AccountDIDRegistry) Register(accountDID DID, addr string, hash []byte) (string, []byte, error) {\n\treturn r.updateByStatus(accountDID, addr, hash, nil, Initial)\n}", "func (role *Role) Register(name string, fc func(req *http.Request, currentUser interface{}) bool) {\n\tif role.definitions == nil {\n\t\trole.definitions = map[string]func(req *http.Request, currentUser interface{}) bool{}\n\t}\n\n\tdefinition := role.definitions[name]\n\tif definition != nil {\n\t\tfmt.Printf(\"%v already defined, overwrited it!\\n\", name)\n\t}\n\trole.definitions[name] = fc\n}", "func (m *Manager) RegisterUser(username string, password string) bool {\n\t_, found := m.users[username]\n\tif !found {\n\t\tpwd := m.getSaltedHashedPassword(password)\n\t\tm.users[username] = credentials{username: username, password: pwd}\n\t\tlog.Printf(\"Registering: %s\", username)\n\t\treturn true\n\t}\n\tlog.Printf(\"User already exists: %s\", username)\n\treturn false\n}", "func (env *Env) RegisterUser(c *gin.Context) {\n\n\ttype registerRequest struct {\n\t\tUsername string `json:\"username\"`\n\t\tPassword string `json:\"password\"`\n\t\tDeviceID string `json:\"device_id\"`\n\t}\n\n\ttype registerResponse struct {\n\t\tAccessToken string `json:\"access_token\"`\n\t\tRefreshToken string `json:\"refresh_token\"`\n\t\tUser mysql.User `json:\"user\"`\n\t\tResetCode string `json:\"reset_code\"`\n\t}\n\n\t//decode request body\n\tjsonData, err := ioutil.ReadAll(c.Request.Body)\n\tif err != nil {\n\t\tLog.WithField(\"module\", \"handler\").WithError(err)\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, errs.RQST001)\n\t\treturn\n\t}\n\n\tvar request registerRequest\n\terr = json.Unmarshal(jsonData, &request)\n\tif err != nil {\n\t\tLog.WithField(\"module\", \"handler\").WithError(err)\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, errs.RQST001)\n\t\treturn\n\t}\n\n\tif request.Username == \"\" || request.Password == \"\" || request.DeviceID == \"\" {\n\t\tLog.WithField(\"module\", \"handler\").Error(\"Empty Fields in Request Body\")\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, errs.RQST002)\n\t\treturn\n\t}\n\n\tvar empty int64\n\tresult := env.db.Model(&mysql.User{}).Count(&empty)\n\tif result.Error != nil {\n\t\tLog.WithField(\"module\", \"handler\").WithError(result.Error)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\treturn\n\t}\n\n\tuser := mysql.User{}\n\tperms := mysql.Permissions{}\n\tdefaultGroup := mysql.UserGroup{}\n\n\tif empty == 0 {\n\n\t\tperms.Admin = true\n\t\tperms.CanEdit = true\n\n\t\tdefaultGroupPerms := mysql.Permissions{CanEdit: false, Admin: false}\n\n\t\tdefaultGroup.Name = \"default\"\n\n\t\tresult = env.db.Save(&defaultGroupPerms)\n\t\tif result.Error != nil {\n\t\t\tLog.WithField(\"module\", \"handler\").WithError(result.Error)\n\t\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\t\treturn\n\t\t}\n\n\t\tdefaultGroup.Permissions = defaultGroupPerms\n\n\t\tresult = env.db.Save(&defaultGroup)\n\t\tif result.Error != nil {\n\t\t\tLog.WithField(\"module\", \"handler\").WithError(result.Error)\n\t\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\t\treturn\n\t\t}\n\n\t} else {\n\t\tvar exists int64\n\t\t//Check if Username already exists in Database\n\t\tresult = env.db.Model(&user).Where(\"upper(username) = upper(?)\", user.Username).Count(&exists)\n\t\tif result.Error != nil {\n\t\t\tLog.WithField(\"module\", \"handler\").WithError(result.Error)\n\t\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\t\treturn\n\t\t}\n\t\tLog.WithField(\"module\", \"handler\").Debug(\"Users found: \", exists)\n\n\t\tif exists != 0 {\n\t\t\tLog.WithField(\"module\", \"handler\").Error(\"Username already exists in Database\")\n\t\t\tc.AbortWithStatusJSON(http.StatusForbidden, errs.AUTH004)\n\t\t\treturn\n\t\t}\n\n\t\tperms.Admin = false\n\t\tperms.CanEdit = false\n\n\t\tdefaultGroup.Name = \"default\"\n\t\tresult = env.db.Model(&defaultGroup).Find(&defaultGroup)\n\t\tif result.Error != nil {\n\t\t\tLog.WithField(\"module\", \"handler\").WithError(result.Error)\n\t\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\t\treturn\n\t\t}\n\n\t}\n\n\t//Create permission entry for new user in permissions table\n\tresult = env.db.Save(&perms)\n\tif result.Error != nil {\n\t\tLog.WithField(\"module\", \"sql\").WithError(result.Error)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\treturn\n\t}\n\n\tuser.Username = request.Username\n\tuser.Password = request.Password\n\tuser.AvatarID = \"default\"\n\tuser.PermID = perms.ID\n\tuser.UserGroups = append(user.UserGroups, &defaultGroup)\n\tuser.ResetCode = utils.GenerateCode()\n\n\t//Save new user to users database\n\tresult = env.db.Save(&user)\n\tif result.Error != nil {\n\t\tLog.WithField(\"module\", \"sql\").WithError(result.Error)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ001)\n\t\treturn\n\t}\n\n\t//Generate JWT AccessToken\n\taccessToken, err := utils.JWTAuthService(config.JWTAccessSecret).GenerateToken(user.ID, request.DeviceID, time.Hour*24)\n\tif err != nil {\n\t\tLog.WithField(\"module\", \"jwt\").WithError(err)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.AUTH002)\n\t\treturn\n\t}\n\n\t//Add AccessToken to Redis\n\terr = env.rdis.AddPair(fmt.Sprint(user.ID), accessToken, time.Hour*24)\n\tif err != nil {\n\t\tLog.WithField(\"module\", \"redis\").WithError(err).Error(\"Error adding AccessToken to Redis.\")\n\t\terr = nil\n\t}\n\n\t//Generate RefreshToken\n\trefreshToken, err := utils.JWTAuthService(config.JWTRefreshSecret).GenerateToken(user.ID, request.DeviceID, time.Hour*24)\n\tif err != nil {\n\t\tLog.WithField(\"module\", \"jwt\").WithError(err)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.AUTH002)\n\t\treturn\n\t}\n\n\tuser.RefreshToken = refreshToken\n\n\t//Save RefreshToken to Database\n\tresult = env.db.Save(&user)\n\tif result.Error != nil {\n\t\tLog.WithField(\"module\", \"sql\").WithError(result.Error)\n\t\tc.AbortWithStatusJSON(http.StatusInternalServerError, errs.DBSQ002)\n\t\treturn\n\t}\n\n\tc.JSON(200, registerResponse{AccessToken: accessToken, RefreshToken: refreshToken, User: user, ResetCode: user.ResetCode})\n}", "func (t *SimpleChaincode) registerUser(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\n\tvar err error\n\n\tif len(args) != 16 {\n\t\treturn nil, errors.New(\"Incorrect number of arguments. Expecting 8\")\n\t}\n\n\t//input sanitation\n\tfmt.Println(\"- start registration\")\n\tif len(args[0]) <= 0 {\n\t\treturn nil, errors.New(\"0th argument must be a non-empty string\")\n\t}\n\tif len(args[1]) <= 0 {\n\t\treturn nil, errors.New(\"1st argument must be a non-empty string\")\n\t}\n\tif len(args[2]) <= 0 {\n\t\treturn nil, errors.New(\"2nd argument must be a non-empty string\")\n\t}\n\tif len(args[3]) <= 0 {\n\t\treturn nil, errors.New(\"3rd argument must be a non-empty string\")\n\t}\n\tif len(args[4]) <= 0 {\n\t\treturn nil, errors.New(\"4th argument must be a non-empty string\")\n\t}\n\tif len(args[5]) <= 0 {\n\t\treturn nil, errors.New(\"5th argument must be a non-empty string\")\n\t}\n\n\tif len(args[8]) <= 0 {\n\t\treturn nil, errors.New(\"8th argument must be a non-empty string\")\n\t}\n\tif len(args[13]) <= 0 {\n\t\treturn nil, errors.New(\"13th argument must be a non-empty string\")\n\t}\n\tif len(args[14]) <= 0 {\n\t\treturn nil, errors.New(\"14th argument must be a non-empty string\")\n\t}\n\tif len(args[15]) <= 0 {\n\t\treturn nil, errors.New(\"15th argument must be a non-empty string\")\n\t}\n\tuser := User{}\n\tuser.Id, err = strconv.Atoi(args[0])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get id as cannot convert it to int\")\n\t}\n\tuser.UserType = args[1]\n\tuser.FisrtName = args[2]\n\tuser.LastName = args[3]\n\tuser.Email = args[4]\n\tuser.Password = args[5]\n\t//user.ReTypePassword=args[6]\n\tuser.Operationalemail = args[6]\n\tuser.Phone, err = strconv.Atoi(args[7])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get phone as cannot convert it to int\")\n\t}\n\tuser.RelationshipManagerEmail = args[8]\n\tuser.CustomersLimit, err = strconv.Atoi(args[9])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get CustomersLimit as cannot convert it to int\")\n\t}\n\tuser.FeePercentage, err = strconv.Atoi(args[10])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get FeePercentage as cannot convert it to int\")\n\t}\n\tuser.InterestEarning, err = strconv.Atoi(args[11])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get InterestEarning as cannot convert it to int\")\n\t}\n\tuser.AccountNo, err = strconv.Atoi(args[12])\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get AccountNo as cannot convert it to int\")\n\t}\n\tuser.IfscCode = args[13]\n\tuser.Pan = args[14]\n\n\tuser.Address = args[15]\n\n\tfmt.Println(\"user\", user)\n\t// get users data from chaincode\n\tUserAsBytes, err := stub.GetState(\"getvfmuser\")\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get users\")\n\t}\n\tvar allusers AllUsers\n\tjson.Unmarshal(UserAsBytes, &allusers) //un stringify it aka JSON.parse()\n\n\tallusers.Userlist = append(allusers.Userlist, user)\n\tfmt.Println(\"allusers\", allusers.Userlist) //append usersdetails to allusers[]\n\tfmt.Println(\"! appended user to allusers\")\n\tjsonAsBytes, _ := json.Marshal(allusers)\n\tfmt.Println(\"json\", jsonAsBytes)\n\terr = stub.PutState(\"getvfmuser\", jsonAsBytes) //rewrite allusers[]\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfmt.Println(\"- end user_register\")\n\treturn nil, nil\n}", "func (s *Service) RegisterUser(username, plainTextPassword string) (*string, error) {\n\n\tid := uuid.New().String()\n\n\tencryotedPwd, err := bcrypt.GenerateFromPassword([]byte(plainTextPassword), 10)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb64Pwd := base64.StdEncoding.EncodeToString(encryotedPwd)\n\n\tif _, err := s.createUserStmnt.Exec(id, username, b64Pwd); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &id, nil\n}" ]
[ "0.72883993", "0.71666837", "0.71462506", "0.71057427", "0.69729733", "0.69685984", "0.6945182", "0.69212025", "0.6830543", "0.6798756", "0.6792368", "0.6765708", "0.6701783", "0.6697231", "0.66623825", "0.6650259", "0.6645481", "0.6643656", "0.65893173", "0.65791863", "0.6574431", "0.65740716", "0.6568621", "0.6556489", "0.65519243", "0.6550796", "0.6535754", "0.6532786", "0.6528895", "0.6528483", "0.650652", "0.6502244", "0.6499194", "0.64961976", "0.6460154", "0.6458024", "0.6451463", "0.64443314", "0.64398956", "0.6433623", "0.6430783", "0.6422576", "0.6420525", "0.6406986", "0.6403451", "0.6399069", "0.6397638", "0.6390876", "0.6381183", "0.6375077", "0.6371672", "0.6362202", "0.6359436", "0.6342991", "0.6337378", "0.632247", "0.6317277", "0.63103175", "0.63095075", "0.62969285", "0.628707", "0.6277254", "0.6265155", "0.6262866", "0.62359834", "0.62298673", "0.6218947", "0.6217963", "0.6217946", "0.6210618", "0.62054354", "0.62046266", "0.62004924", "0.61995345", "0.6195491", "0.6186839", "0.61820275", "0.6166053", "0.61644465", "0.6159565", "0.6157531", "0.6149728", "0.61373377", "0.61338043", "0.6128724", "0.61180156", "0.61165315", "0.61136097", "0.61111003", "0.61050546", "0.6093329", "0.60726595", "0.6058891", "0.60547554", "0.60545826", "0.6050832", "0.6047698", "0.60474765", "0.6033926", "0.6025959" ]
0.6089221
91
Login is for login
func Login(ctx *gin.Context) { DB := common.GetDB() //获取数据 telephone := ctx.PostForm("tel") password := ctx.PostForm("password") //判断数据 if len(telephone) != 11 { response.Response(ctx, http.StatusUnprocessableEntity, 4221, gin.H{}, "手机号必须为11位") return } if len(password) < 6 { response.Response(ctx, http.StatusUnprocessableEntity, 4222, gin.H{}, "密码需大于6位") return } //处理数据 var user model.User DB.First(&user, "telephone = ?", telephone) if user.ID == 0 { response.Response(ctx, http.StatusUnprocessableEntity, 4225, gin.H{}, "用户不存在") return } if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password)); err != nil { response.Response(ctx, http.StatusUnprocessableEntity, 4226, gin.H{}, "密码错误") fmt.Println(err) return } token, err := common.ReleaseToken(user) if err != nil { response.Response(ctx, http.StatusInternalServerError, 5001, gin.H{}, "密码解析错误") log.Fatal(err) return } response.Success(ctx, gin.H{"token": token}, "ok") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Login(res http.ResponseWriter, req *http.Request) (bool, string) {\n\tname := req.FormValue(NameParameter)\n\tname = html.EscapeString(name)\n\tlog.Debugf(\"Log in user. Name: %s\", name)\n\tif name != \"\" {\n\t\tuuid := generateRandomUUID()\n\t\tsuccess := authClient.SetRequest(uuid, name)\n\t\tif success {\n\t\t\tcookiesManager.SetCookieValue(res, CookieName, uuid)\n\t\t}\n\t\t// successfully loged in\n\t\tif success {\n\t\t\treturn success, \"\"\n\t\t} else {\n\t\t\treturn success, \"authServerFail\"\n\t\t}\n\n\t}\n\n\treturn false, \"noName\"\n}", "func (a Admin) Login(user,passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func (a SuperAdmin) Login(user, passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func (authentication *Authentication) IsLogin(res http.ResponseWriter, req *http.Request) bool {\n\tsessionID, sessionIDState := cookies.GetCookie(req, \"session\")\n\tif !sessionIDState {\n\t\treturn false\n\t}\n\tsession, sessionState := authentication.userSession[sessionID.Value]\n\tif sessionState {\n\t\tsession.lastActivity = time.Now()\n\t\tauthentication.userSession[sessionID.Value] = session\n\t}\n\t_, userState := authentication.loginUser[session.email]\n\tsessionID.Path = \"/\"\n\tsessionID.MaxAge = sessionExistTime\n\thttp.SetCookie(res, sessionID)\n\treturn userState\n}", "func (netgear *Netgear) Login() (bool, error) {\n message := fmt.Sprintf(soapLoginMessage, sessionID, netgear.username, netgear.password)\n\n resp, err := netgear.makeRequest(soapActionLogin, message)\n\n if strings.Contains(resp, \"<ResponseCode>000</ResponseCode>\") {\n netgear.loggedIn = true\n } else {\n netgear.loggedIn = false\n }\n return netgear.loggedIn, err\n}", "func Login(registry string) (bool, error) {\n\n\tlogrus.Info(\"log in: \", registry)\n\n\tif strings.Contains(registry, \"docker\") {\n\t\tregistry = \"https://\" + registry + \"/v2\"\n\n\t} else {\n\t\tregistry = \"http://\" + registry + \"/v2\"\n\t}\n\n\tclient := httpclient.Get()\n\trequest, err := http.NewRequest(\"GET\", registry, nil)\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"log in %v: %v\", registry, err)\n\t}\n\tauthorized := response.StatusCode != http.StatusUnauthorized\n\tif !authorized {\n\t\tlogrus.Info(\"Unauthorized access\")\n\t\terr := AuthenticateResponse(response, request)\n\n\t\tif err != nil {\n\t\t\tif err == xerrors.Unauthorized {\n\t\t\t\tauthorized = false\n\t\t\t}\n\t\t\treturn false, err\n\t\t} else {\n\t\t\tauthorized = true\n\t\t}\n\t}\n\n\treturn authorized, nil\n}", "func Login(w http.ResponseWriter, r *http.Request) {\r\n\tlogin := strings.Trim(r.FormValue(\"login\"), \" \")\r\n\tpass := strings.Trim(r.FormValue(\"pass\"), \" \")\r\n\tlog.Println(\"login: \", login, \" pass: \", pass)\r\n\r\n\t// Check params\r\n\tif login == \"\" || pass == \"\" {\r\n\t\twriteResponse(w, \"Login and password required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Already authorized\r\n\tif savedPass, OK := Auth[login]; OK && savedPass == pass {\r\n\t\twriteResponse(w, \"You are already authorized\\n\", http.StatusOK)\r\n\t\treturn\r\n\t} else if OK && savedPass != pass {\r\n\t\t// it is not neccessary\r\n\t\twriteResponse(w, \"Wrong pass\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser := model.User{}\r\n\terr := user.Get(login, pass)\r\n\tif err == nil {\r\n\t\tAuth[login], Work[login] = pass, user.WorkNumber\r\n\t\twriteResponse(w, \"Succesfull authorization\\n\", http.StatusOK)\r\n\t\treturn\r\n\t}\r\n\r\n\twriteResponse(w, \"User with same login not found\\n\", http.StatusNotFound)\r\n}", "func CheckLoginStatus(w http.ResponseWriter, r *http.Request) (bool,interface{}){\n\tsess := globalSessions.SessionStart(w,r)\n\tsess_uid := sess.Get(\"UserID\")\n\tif sess_uid == nil {\n\t\treturn false,\"\"\n\t} else {\n\t\tuID := sess_uid\n\t\tname := sess.Get(\"username\")\n\t\tfmt.Println(\"Logged in User, \", uID)\n\t\t//Tpl.ExecuteTemplate(w, \"user\", nil)\n\t\treturn true,name\n\t}\n}", "func (sry *Sryun) Login(res http.ResponseWriter, req *http.Request) (*model.User, bool, error) {\n\tusername := req.FormValue(\"username\")\n\tpassword := req.FormValue(\"password\")\n\n\tlog.Infoln(\"got\", username, \"/\", password)\n\n\tif username == sry.User.Login && password == sry.Password {\n\t\treturn sry.User, true, nil\n\t}\n\treturn nil, false, errors.New(\"bad auth\")\n}", "func CheckLogin(w http.ResponseWriter, r *http.Request) bool {\n\tCookieSession, err := r.Cookie(\"sessionid\")\n\tif err != nil {\n\t\tfmt.Println(\"No Such Cookies\")\n\t\tSession.Create()\n\t\tfmt.Println(Session.ID)\n\t\tSession.Expire = time.Now().Local()\n\t\tSession.Expire.Add(time.Hour)\n\t\treturn false\n\t}\n\tfmt.Println(\"Cookki Found\")\n\ttempSession := session.UserSession{UID: 0}\n\tLoggedIn := database.QueryRow(\"select user_id from sessions where session_id = ?\",\n\t\tCookieSession).Scan(&tempSession)\n\tif LoggedIn == nil {\n\t\treturn false\n\t}\n\treturn true\n\n}", "func IsLogin(session sessions.Session) bool {\n\tisLogin := session.Get(\"is_login\")\n\tif isLogin != nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func (a *noAuth) Login(c echo.Context) error {\n\treturn errors.New(\"Can not login when there is no auth\")\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\t/*\n\t\tTratamento dos dados vindos do front-end\n\t\tNesse caso, o request pega login e senha\n\t*/\n\tvar login models.Credentials\n\tbody := r.Body\n\tbytes, err := util.BodyToBytes(body)\n\terr = util.BytesToStruct(bytes, &login)\n\n\t// Checks if struct is a valid one\n\tif err = validation.Validator.Struct(login); err != nil {\n\n\t\tlog.Printf(\"[WARN] invalid user information, because, %v\\n\", err)\n\t\tw.WriteHeader(http.StatusPreconditionFailed) // Status 412\n\t\treturn\n\t}\n\n\t// err1 consulta o login no banco de dados\n\terr1 := database.CheckLogin(login.Login)\n\n\t// err2 consulta a senha referente ao login fornecido\n\terr2 := database.CheckSenha(login.Login, login.Senha)\n\n\t// Condicao que verifica se os dois dados constam no banco de dados\n\tif (err1 != nil) || (err2 != true) {\n\t\tlog.Println(\"[FAIL]\")\n\t\tw.WriteHeader(http.StatusForbidden) // Status 403\n\t} else {\n\t\tlog.Println(\"[SUCCESS]\")\n\t\tw.WriteHeader(http.StatusAccepted) // Status 202\n\t}\n\n\treturn\n}", "func (h *Hub) Login() (success bool, err error) {\n\treq := newRequest(&h.client.authData, \"logIn\", \"\")\n\tresp, err := req.send()\n\n\tif err == nil {\n\t\th.client.authData.sessionID = strconv.Itoa(resp.ResponseBody.Reply.ResponseActions[0].ResponseCallbacks[0].Parameters.ID)\n\t\th.client.authData.nonce = resp.ResponseBody.Reply.ResponseActions[0].ResponseCallbacks[0].Parameters.Nonce\n\t\treturn true, nil\n\t}\n\n\treturn false, err\n}", "func verifyLogin(r *http.Request) bool {\n\tsession, err := store.Get(r, sessionName)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to get session: %s\", err)\n\t\treturn false\n\t}\n\tif session.Values[\"LoggedIn\"] != \"yes\" {\n\t\treturn false\n\t}\n\treturn true\n}", "func (p *Base) Login() string {\n\treturn \"https://admin.thebase.in/users/login\"\n}", "func Login(usr, passwd string) (bool, error) {\n\t// instantiate http client, but remove\n\t// past user sessions to prevent redirection\n\tjar, _ := cookiejar.New(nil)\n\tc := cfg.Session.Client\n\tc.Jar = jar\n\n\tlink, _ := url.Parse(cfg.Settings.Host)\n\tlink.Path = path.Join(link.Path, \"enter\")\n\tbody, err := pkg.GetReqBody(&c, link.String())\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\t// Hidden form data\n\tcsrf := pkg.FindCsrf(body)\n\tftaa := \"yzo0kk4bhlbaw83g2q\"\n\tbfaa := \"883b704dbe5c70e1e61de4d8aff2da32\"\n\n\t// Post form (aka login using creds)\n\tbody, err = pkg.PostReqBody(&c, link.String(), url.Values{\n\t\t\"csrf_token\": {csrf},\n\t\t\"action\": {\"enter\"},\n\t\t\"ftaa\": {ftaa},\n\t\t\"bfaa\": {bfaa},\n\t\t\"handleOrEmail\": {usr},\n\t\t\"password\": {passwd},\n\t\t\"_tta\": {\"176\"},\n\t\t\"remember\": {\"on\"},\n\t})\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tusr = pkg.FindHandle(body)\n\tif usr != \"\" {\n\t\t// create aes 256 encryption and encode as\n\t\t// hex string and save to sessions.json\n\t\tenc, _ := aes.NewAES256Encrypter(usr, nil)\n\t\ted, _ := enc.Encrypt([]byte(passwd))\n\t\tciphertext := hex.EncodeToString(ed)\n\t\t// update sessions data\n\t\tcfg.Session.Cookies = jar\n\t\tcfg.Session.Handle = usr\n\t\tcfg.Session.Passwd = ciphertext\n\t\tcfg.SaveSession()\n\t}\n\treturn (usr != \"\"), nil\n}", "func Login(r *http.Request, username string, password string) (*Session, bool) {\n\tif PreLoginHandler != nil {\n\t\tPreLoginHandler(r, username, password)\n\t}\n\t// Get the user from DB\n\tuser := User{}\n\tGet(&user, \"username = ?\", username)\n\tif user.ID == 0 {\n\t\tIncrementMetric(\"uadmin/security/invalidlogin\")\n\t\tgo func() {\n\t\t\tlog := &Log{}\n\t\t\tif r.Form == nil {\n\t\t\t\tr.ParseForm()\n\t\t\t}\n\t\t\tctx := context.WithValue(r.Context(), CKey(\"login-status\"), \"invalid username\")\n\t\t\tr = r.WithContext(ctx)\n\t\t\tlog.SignIn(username, log.Action.LoginDenied(), r)\n\t\t\tlog.Save()\n\t\t}()\n\t\tincrementInvalidLogins(r)\n\t\treturn nil, false\n\t}\n\ts := user.Login(password, \"\")\n\tif s != nil && s.ID != 0 {\n\t\ts.IP = GetRemoteIP(r)\n\t\ts.Save()\n\t\tif s.Active && (s.ExpiresOn == nil || s.ExpiresOn.After(time.Now())) {\n\t\t\ts.User = user\n\t\t\tif s.User.Active && (s.User.ExpiresOn == nil || s.User.ExpiresOn.After(time.Now())) {\n\t\t\t\tIncrementMetric(\"uadmin/security/validlogin\")\n\t\t\t\t// Store login successful to the user log\n\t\t\t\tgo func() {\n\t\t\t\t\tlog := &Log{}\n\t\t\t\t\tif r.Form == nil {\n\t\t\t\t\t\tr.ParseForm()\n\t\t\t\t\t}\n\t\t\t\t\tlog.SignIn(user.Username, log.Action.LoginSuccessful(), r)\n\t\t\t\t\tlog.Save()\n\t\t\t\t}()\n\t\t\t\treturn s, s.User.OTPRequired\n\t\t\t}\n\t\t}\n\t} else {\n\t\tgo func() {\n\t\t\tlog := &Log{}\n\t\t\tif r.Form == nil {\n\t\t\t\tr.ParseForm()\n\t\t\t}\n\t\t\tctx := context.WithValue(r.Context(), CKey(\"login-status\"), \"invalid password or inactive user\")\n\t\t\tr = r.WithContext(ctx)\n\t\t\tlog.SignIn(username, log.Action.LoginDenied(), r)\n\t\t\tlog.Save()\n\t\t}()\n\t}\n\n\tincrementInvalidLogins(r)\n\n\t// Record metrics\n\tIncrementMetric(\"uadmin/security/invalidlogin\")\n\treturn nil, false\n}", "func (h UserRepos) Login(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\treq := new(UserLoginRequest)\n\tdata := make(map[string]interface{})\n\tf := func() (bool, error) {\n\n\t\tif r.Method == http.MethodPost {\n\t\t\terr := r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tdecoder := schema.NewDecoder()\n\t\t\tif err := decoder.Decode(req, r.PostForm); err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\treq.Password = strings.Replace(req.Password, \".\", \"\", -1)\n\t\t\tsessionTTL := time.Hour\n\t\t\tif req.RememberMe {\n\t\t\t\tsessionTTL = time.Hour * 36\n\t\t\t}\n\n\t\t\t// Authenticated the user.\n\t\t\ttoken, err := h.AuthRepo.Authenticate(ctx, user_auth.AuthenticateRequest{\n\t\t\t\tEmail: req.Email,\n\t\t\t\tPassword: req.Password,\n\t\t\t}, sessionTTL, ctxValues.Now)\n\t\t\tif err != nil {\n\t\t\t\tswitch errors.Cause(err) {\n\t\t\t\tcase user.ErrForbidden:\n\t\t\t\t\treturn false, web.RespondError(ctx, w, weberror.NewError(ctx, err, http.StatusForbidden))\n\t\t\t\tcase user_auth.ErrAuthenticationFailure:\n\t\t\t\t\tdata[\"error\"] = weberror.NewErrorMessage(ctx, err, http.StatusUnauthorized, \"Invalid username or password. Try again.\")\n\t\t\t\t\treturn false, nil\n\t\t\t\tdefault:\n\t\t\t\t\tif verr, ok := weberror.NewValidationError(ctx, err); ok {\n\t\t\t\t\t\tdata[\"validationErrors\"] = verr.(*weberror.Error)\n\t\t\t\t\t\treturn false, nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn false, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add the token to the users session.\n\t\t\terr = handleSessionToken(ctx, w, r, token)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tredirectUri := \"/\"\n\t\t\tif qv := r.URL.Query().Get(\"redirect\"); qv != \"\" {\n\t\t\t\tredirectUri, err = url.QueryUnescape(qv)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Redirect the user to the dashboard.\n\t\t\treturn true, web.Redirect(ctx, w, r, redirectUri, http.StatusFound)\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\tend, err := f()\n\tif err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t} else if end {\n\t\treturn nil\n\t}\n\n\tdata[\"form\"] = req\n\n\tif verr, ok := weberror.NewValidationError(ctx, webcontext.Validator().Struct(UserLoginRequest{})); ok {\n\t\tdata[\"validationDefaults\"] = verr.(*weberror.Error)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-login.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func Login() gin.HandlerFunc {\r\n\tif gin.Mode() == \"debug\" {\r\n\t\treturn func(c *gin.Context) { c.Next() }\r\n\t}\r\n\treturn func(c *gin.Context) {\r\n\t\tsession := sessions.Default(c)\r\n\t\tUserID := session.Get(\"UserID\")\r\n\t\tIsLeader := session.Get(\"IsLeader\")\r\n\r\n\t\tfmt.Println(\"UserID, IsLeader\", UserID, IsLeader)\r\n\t\tif UserID == nil {\r\n\t\t\tstate := string([]byte(c.Request.URL.Path)[1:])\r\n\t\t\tc.Redirect(http.StatusFound, \"/login?state=\"+state)\r\n\t\t\tc.Abort()\r\n\t\t} else {\r\n\t\t\tc.Set(\"UserID\", UserID)\r\n\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\t\t\tc.Next()\r\n\t\t}\r\n\r\n\t}\r\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\tauth.GetGatekeeper().Login(w, r)\n}", "func Login(rw http.ResponseWriter, request *http.Request) {\n\n\tlog.Println(\"call Login\")\n\n\t// フォームデータのパース\n\terr := request.ParseForm()\n\tif err != nil {\n\t\toutputErrorLog(\"フォーム パース 失敗\", err)\n\t}\n\n\t// リクエストデータ取得\n\taccount := request.Form.Get(\"account\")\n\tpassword := request.Form.Get(\"password\")\n\tlog.Println(\"ユーザ:\", account)\n\n\t// ユーザデータ取得しモデルデータに変換\n\tdbm := db.ConnDB()\n\tuser := new(models.User)\n\trow := dbm.QueryRow(\"select account, name, password from users where account = ?\", account)\n\tif err = row.Scan(&user.Name, &user.Account, &user.Password); err != nil {\n\t\toutputErrorLog(\"ユーザ データ変換 失敗\", err)\n\t}\n\n\t// ユーザのパスワード認証\n\tif user.Password != password {\n\t\tlog.Println(\"ユーザ パスワード照合 失敗\")\n\t\thttp.Redirect(rw, request, \"/index\", http.StatusFound)\n\t\treturn\n\t}\n\n\tlog.Println(\"認証 成功\")\n\n\t// 認証が通ったら、セッション情報をDBに保存\n\tsessionID := generateSessionID(account)\n\tlog.Println(\"生成したセッションID:\", sessionID)\n\tnow := time.Now()\n\tresult, err := dbm.Exec(`INSERT INTO sessions\n\t\t(sessionID, account, expireDate)\n\t\tVALUES\n\t\t(?, ?, ?)\n\t\t`, sessionID, account, now.Add(1*time.Hour))\n\tnum, err := result.RowsAffected()\n\tif err != nil || num == 0 {\n\t\toutputErrorLog(\"セッション データ保存 失敗\", err)\n\t}\n\n\tlog.Println(\"セッション データ保存 成功\")\n\n\t// クッキーにセッション情報付与\n\tcookie := &http.Cookie{\n\t\tName: sessionIDName,\n\t\tValue: sessionID,\n\t}\n\thttp.SetCookie(rw, cookie)\n\n\t// HOME画面に遷移\n\thttp.Redirect(rw, request, \"/home\", http.StatusFound)\n}", "func Login(r *http.Request) (bool, models.User, error) {\n\tusername, password := r.FormValue(\"username\"), r.FormValue(\"password\")\n\tu, err := models.GetUserByUsername(username)\n\tif err != nil && err != models.ErrUsernameTaken {\n\t\treturn false, models.User{}, err\n\t}\n\t//If we've made it here, we should have a valid user stored in u\n\t//Let's check the password\n\terr = bcrypt.CompareHashAndPassword([]byte(u.Hash), []byte(password))\n\tif err != nil {\n\t\treturn false, models.User{}, ErrInvalidPassword\n\t}\n\treturn true, u, nil\n}", "func accessLogin(mail string) bool {\n\tif len(Cfg.Access) == 0 {\n\t\treturn true\n\t}\n\tfor _, a := range Cfg.Access {\n\t\tif a.all {\n\t\t\treturn a.Allow\n\t\t}\n\t\tfor _, re := range a.re {\n\t\t\tif re.MatchString(mail) {\n\t\t\t\treturn a.Allow\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}", "func (a Authentic) login(c buffalo.Context) error {\n\treturn c.Render(200, a.Config.LoginPage)\n}", "func Checklogin(c *fiber.Ctx) {\n\tvar usuario models.User\n\temail := c.FormValue(\"email\")\n\tpassword := c.FormValue(\"password\")\n\n\tmodels.Dbcon.Where(\"email = ?\", email).Find(&usuario)\n\tdatos := fiber.Map{\n\t\t\"title\": views.Comunes.Title,\n\t\t\"user\": \"\",\n\t\t\"role\": \"\",\n\t\t\"mensajeflash\": \"\",\n\t}\n\tif grecaptcha := validateCaptcha(c.FormValue(\"g-recaptcha-response\")); !grecaptcha {\n\t\tdatos[\"mensajeflash\"] = \"Este sistema sólo es para humanos\"\n\t\tc.SendStatus(http.StatusForbidden)\n\t\tc.Render(\"login\", datos, \"layouts/main\")\n\t\treturn\n\t}\n\n\tfmt.Println(datos, \"layouts/main\")\n\tif len(usuario.Email) < 1 {\n\t\tdatos[\"mensajeflash\"] = \"Correo-e o contraseña incorrectos\"\n\t\tc.SendStatus(http.StatusForbidden)\n\t\tc.Render(\"login\", datos, \"layouts/main\")\n\t\treturn\n\t}\n\tif err := bcrypt.CompareHashAndPassword([]byte(usuario.Password), []byte(password)); err != nil {\n\t\tdatos[\"mensajeflash\"] = \"Correo-e o contraseña incorrectos\"\n\t\tc.SendStatus(http.StatusForbidden)\n\t\tc.Render(\"login\", datos, \"layouts/main\")\n\t\treturn\n\t}\n\tfmt.Println(\"Login: Successful\")\n\tdatos[\"user\"] = usuario.Username\n\tvar rol models.Role\n\tmodels.Dbcon.Where(\"id = ?\", usuario.RoleID).Find(&rol)\n\tvar err error\n\tPToken, err = CrearToken(usuario.Username, rol.Role)\n\tdatos[\"role\"] = rol.Role\n\tif err != nil {\n\t\tfmt.Println(\"ERROR creating token\")\n\t\treturn\n\t}\n\tcookie.Name = \"frontends1\"\n\tcookie.Value = strings.TrimSpace(PToken)\n\tcookie.Expires = time.Now().Add(15 * time.Minute)\n\tcookie.Domain = Cdomain\n\tc.Cookie(&cookie)\n\tfmt.Println(\"Logged in as: \", usuario.Username)\n\tfmt.Println(\"Role: \", rol.Role)\n\tc.Redirect(\"/\", http.StatusMovedPermanently)\n}", "func (c App) CheckLogin() revel.Result {\n if _, ok := c.Session[\"userName\"]; ok {\n c.Flash.Success(\"You are already logged in \" + c.Session[\"userName\"] + \"!\")\n return c.Redirect(routes.Todo.Index())\n }\n\n return nil\n}", "func (Anonymous) Login(username, password string) AccessType {\n\tif strings.ToLower(username) == \"anonymous\" && len(password) != 0 {\n\t\treturn ReadOnly\n\t} else {\n\t\treturn NoPermission\n\t}\n}", "func (client *Client) Login() error {\n\tdata := fmt.Sprintf(`{\"aaaUser\":{\"attributes\":{\"name\":\"%s\",\"pwd\":\"%s\"}}}`,\n\t\tclient.Usr,\n\t\tclient.Pwd,\n\t)\n\tres, err := client.Post(\"/api/aaaLogin\", data, NoRefresh)\n\tif err != nil {\n\t\treturn err\n\t}\n\terrText := res.Get(\"imdata.0.error.attributes.text\").Str\n\tif errText != \"\" {\n\t\treturn errors.New(\"authentication error\")\n\t}\n\tclient.Token = res.Get(\"imdata.0.aaaLogin.attributes.token\").Str\n\tclient.LastRefresh = time.Now()\n\treturn nil\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\n\t// Start the session.\n\tsession := sessions.Start(w, r)\n\tif len(session.GetString(\"username\")) != 0 && checkErr(w, r, err) {\n\t\t// Redirect to index page if the user isn't signed in. Will remove later.\n\t\thttp.Redirect(w, r, \"/\", 302)\n\t}\n\n\tif r.Method != \"POST\" {\n\t\tvar data = map[string]interface{}{\n\t\t\t\"Title\": \"Log In\",\n\t\t}\n\n\t\terr := templates.ExecuteTemplate(w, \"login.html\", data)\n\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n\t\treturn\n\t}\n\n\tusername := r.FormValue(\"username\")\n\tpassword := r.FormValue(\"password\")\n\n\tusers := QueryUser(username)\n\n\t// Compare inputted password to the password in the database. If they're the same, return nil.\n\tvar password_compare = bcrypt.CompareHashAndPassword([]byte(users.Password), []byte(password))\n\n\tif password_compare == nil {\n\n\t\tsession := sessions.Start(w, r)\n\t\tsession.Set(\"username\", users.Username)\n\t\tsession.Set(\"user_id\", users.ID)\n\t\thttp.Redirect(w, r, \"/\", 302)\n\n\t} else {\n\n\t\thttp.Redirect(w, r, \"/login\", 302)\n\n\t}\n\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"login called\")\n}", "func userLoginProcessing(userName string, password string, cookie string) (bool, int) {\n\tvar loginUser users\n\tvar userInitial userLoginStruct\n\n\tdb := dbConn()\n\tdefer db.Close()\n\n\t// login page defined token checking\n\tloginTokenCheck := db.QueryRow(\"SELECT event_id,used FROM user_initial_login WHERE token=? and used=0\", cookie).Scan(&userInitial.eventID, &userInitial.used)\n\n\tif loginTokenCheck != nil {\n\t\tlog.Println(\"user_initial_login table read faild\") // posible system error or hacking attempt ?\n\t\tlog.Println(loginTokenCheck)\n\t\treturn false, 0\n\t}\n\n\t// update initial user details table\n\tinitialUpdate, initErr := db.Prepare(\"update user_initial_login set used=1 where event_id=?\")\n\n\tif initErr != nil {\n\t\tlog.Println(\"Couldnt update initial user table\")\n\t\treturn false, 0 // we shouldnt compare password\n\t}\n\n\t_, updateErr := initialUpdate.Exec(userInitial.eventID)\n\n\tif updateErr != nil {\n\t\tlog.Println(\"Couldnt execute initial update\")\n\n\t}\n\tlog.Printf(\"Initial table updated for event id %d : \", userInitial.eventID)\n\t// end login page token checking\n\n\treadError := db.QueryRow(\"SELECT id,password FROM car_booking_users WHERE username=?\", userName).Scan(&loginUser.id, &loginUser.password)\n\tdefer db.Close()\n\tif readError != nil {\n\t\t//http.Redirect(res, req, \"/\", 301)\n\t\tlog.Println(\"data can not be taken\")\n\n\t}\n\n\tcomparePassword := bcrypt.CompareHashAndPassword([]byte(loginUser.password), []byte(password))\n\n\t// https://stackoverflow.com/questions/52121168/bcrypt-encryption-different-every-time-with-same-input\n\n\tif comparePassword != nil {\n\t\t/*\n\t\t\tHere I need to find a way to make sure that initial token is not get created each time wrong username password\n\n\t\t\tAlso Need to implement a way to restrict accessing after 5 attempts\n\t\t*/\n\t\tlog.Println(\"Wrong user name password\")\n\t\treturn false, 0\n\t} //else {\n\n\tlog.Println(\"Hurray\")\n\treturn true, userInitial.eventID\n\t//}\n\n}", "func (srv *userService) CheckLogin(session string) bool {\n\tvar User model.User\n\n\tif conf.Development() {\n\t\tCurrentUser = User.GetFirst()\t\n\t\treturn true\n\t}\n\t\n\tCurrentUser = User.GetUserByThirdSession(session)\n\tif CurrentUser == nil {\n\t\treturn false\n\t}\n\n\treturn CurrentUser.CacheSessionVal() != \"\"\n}", "func (c *UserController) Login() {\n\n\tisAjax := c.GetString(\"isajax\")\n\n\tif isAjax == \"1\" {\n\t\t// Captcha Verification.\n\t\tif !cpt.VerifyReq(c.Ctx.Request) {\n\t\t\tc.Resp(false, \"验证码错误!\")\n\t\t\treturn\n\t\t}\n\n\t\t// Passing Captcha Verify.\n\t\tusername := c.GetString(\"username\")\n\t\tpassword := c.GetString(\"password\")\n\n\t\tuser, err := doLogin(username, password)\n\t\tif err == nil {\n\t\t\tc.SetSession(\"userinfo\", user.Username)\n\t\t\tc.Resp(true, \"登陆成功\")\n\t\t\treturn\n\t\t}\n\t\tc.Resp(false, err.Error())\n\t\treturn\n\t}\n\t// Login Fail! relogin.\n\tc.Data[\"Title\"] = beego.AppConfig.String(\"login_title\")\n\tc.Data[\"Copyright\"] = beego.AppConfig.String(\"copyright\")\n\n\t// Get Verification Code.\n\tcpt = captcha.NewWithFilter(\"/captcha/\", store)\n\tcpt.ChallengeNums, _ = beego.AppConfig.Int(\"captcha_length\")\n\tcpt.StdWidth = 100\n\tcpt.StdHeight = 42\n\n\tc.TplName = \"login.tpl\"\n}", "func (h *auth) Login(c echo.Context) error {\n\t// Filter params\n\tvar params service.LoginParams\n\tif err := c.Bind(&params); err != nil {\n\t\tlog.Println(\"Could not get parameters:\", err)\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"Could not get credentials.\"))\n\t}\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\tif params.Email == \"\" || params.Password == \"\" {\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"No email or password provided.\"))\n\t}\n\n\treturn h.login(c, params)\n\n}", "func Login(e *Engine, username string, password string) (bool, error) {\n\tres, _, err := e.RawSelect(Filter(\"autoscope_users\",\n\t\tmap[string]interface{}{\"username\": username}))\n\tif err != nil { return false, err }\n\tuser, err := GetRow(res)\n\tif err != nil { return false, err }\n\n\t//CompareHashAndPassword returns nil on success\n\tsalted := password + strconv.FormatInt(user[\"salt\"].(int64), 10)\n\thashErr := bcrypt.CompareHashAndPassword([]byte(user[\"passhash\"].(string)),\n\t\t[]byte(salted))\n\treturn hashErr == nil, hashErr\n}", "func login(w http.ResponseWriter,r *http.Request){\n\tsession,err:=store.Get(r,\"cookie-name\")\n\tif err!=nil{\n\t\tlog.Fatal(err)\n\t}\n\n\t// Where authentication could be done\n\tif r.FormValue(\"code\")!=\"code\"{\n\t\tif r.FormValue(\"code\")==\"\"{\n\t\t\tsession.AddFlash(\"must enter a code\")\n\t\t}\n\t\tsession.AddFlash(\"the code was incorrect\")\n\t\terr:=session.Save(r,w)\n\t\tif err!=nil{\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\thttp.Redirect(w,r,\"/forbiden\",http.StatusFound)\n\t\treturn\n\t}\n\tusername:=r.FormValue(\"username\")\n\tpassword:=r.FormValue(\"password\")\n\tuser:=&user{\n\t\tUserName: username,\n\t\tPassword: password,\n\t\tAuthenticated: true,\n\t}\n\tsession.Values[\"user\"]=user\n\terr=session.Save(r,w)\n\tif err!=nil{\n\t\tlog.Fatal(err)\n\t}\n\thttp.Redirect(w,r,\"/secret\",http.StatusFound)\n}", "func (user *UService) Login(loginuser *model.User) *model.User {\n\tvar validuser model.User\n\tuser.DB.Debug().Where(\"username = ? and password = ?\", loginuser.Username, loginuser.Password).Find(&validuser)\n\tif validuser != (model.User{}) {\n\t\treturn &validuser\n\t}\n\treturn nil\n}", "func (app *application) login(w http.ResponseWriter, r *http.Request) {\n\tsession, err := app.sessionStore.Get(r, \"session-name\")\n\tif err != nil {\n\t\tapp.serverError(w, err)\n\t\treturn\n\t}\n\terr = r.ParseForm()\n\tif err != nil {\n\t\tapp.clientError(w, http.StatusBadRequest)\n\t\treturn\n\t}\n\tform := forms.New(r.PostForm)\n\tform.Required(\"email\", \"password\")\n\tform.MatchesPattern(\"email\", forms.RxEmail)\n\tif !form.Valid() {\n\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\treturn\n\t}\n\tvar id int\n\tif form.Get(\"accType\") == \"customer\" {\n\t\tid, err = app.customers.Authenticate(form.Get(\"email\"), form.Get(\"password\"))\n\t\tif err == models.ErrInvalidCredentials {\n\t\t\tform.Errors.Add(\"generic\", \"Email or Password Incorrect. Please ensure you have selected correct account type\")\n\t\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\t\treturn\n\t\t} else if err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\tsession.Values[\"customerID\"] = id\n\t\terr = session.Save(r, w)\n\t\tif err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/customer/home\", http.StatusSeeOther)\n\t} else {\n\t\tid, err = app.vendors.Authenticate(form.Get(\"email\"), form.Get(\"password\"))\n\t\tif err == models.ErrInvalidCredentials {\n\t\t\tform.Errors.Add(\"generic\", \"Email or Password Incorrect. Please ensure you have selected correct account type\")\n\t\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\t\treturn\n\t\t} else if err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\tsession.Values[\"vendorID\"] = id\n\t\terr = session.Save(r, w)\n\t\tif err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/vendor/home\", http.StatusSeeOther)\n\t}\n}", "func Login(c *gin.Context) {\n\tusername := c.PostForm(\"username\")\n\tpassword := c.PostForm(\"password\")\n\temail := c.PostForm(\"email\")\n\t//check if provided user credentials are valid or not\n\tif store.ValidUser(username, password, email) {\n\t\ttoken := generateSessionToken()\n\t\tc.SetCookie(\"token\", token, 3600, \"\", \"\", false, true)\n\t\tc.Set(\"is_logged_in\", true)\n\t\trender(c, gin.H{\n\t\t\t\"title\": \"Successful Login\"}, \"login-successful.html\")\n\t} else {\n\t\tc.HTML(http.StatusBadRequest, \"login.html\", gin.H{\n\t\t\t\"ErrorTitle\": \"Login Failed\",\n\t\t\t\"ErrorMessage\": \"Invalid credentials provided\"})\n\t}\n}", "func Login(username string, password string) error {\n\tdata := url.Values{}\n\tdata.Set(\"login\", username)\n\tdata.Set(\"haslo\", password)\n\n\tres, err := http.Post(loginURL, \"application/x-www-form-urlencoded\", strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to make HTTP POST login request: %v\", err)\n\t}\n\n\tlog.Println(\"auth status:\", res.Status)\n\n\treturn nil\n}", "func canLogin(usr string) string {\n\t//find the last time they logged in\n\tquery := QUERY_GET_LAST_LOGIN\n\trows := QueryDB(query, Hash1(usr))\n\tret := LOGIN_INVALID\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar (\n\t\t\tlast int64\n\t\t)\n\t\terr = rows.Scan(&last)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error accessing rows (my_server.go: canLogin\")\n\t\t\tfmt.Println(err)\n\t\t\treturn LOGIN_INVALID\n\t\t}\n\t\tdiff := time.Now().Unix() - last\n\t\tif diff <= LOGIN_RATE {\n\t\t\tret = LOGIN_TIME\n\t\t}\n\t}\n\treturn ret\n}", "func Login(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tfmt.Println(\"Login\")\n}", "func (client *Client) Login() error {\n\tuserpass := fmt.Sprintf(\"%s_%s\", client.Username, client.Password)\n\thash := fmt.Sprintf(\"%x\", md5.Sum([]byte(userpass)))\n\tres, _, err := client.FormattedRequest(\"/login/%s\", hash)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclient.sessionKey = res.ObjectsMap[\"status\"].PropertiesMap[\"response\"].Data\n\treturn nil\n}", "func Login(enrollID, enrollSecret string) bool {\n\tvar loginRequest loginRequest\n\tloginRequest.EnrollID = enrollID\n\tloginRequest.EnrollSecret = enrollSecret\n\n\treqBody, err := json.Marshal(loginRequest)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\turlstr := getHTTPURL(\"login\")\n\tresponse, err := performHTTPPost(urlstr, reqBody)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tvar result restResult\n\terr = json.Unmarshal(response, &result)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif result.OK == \"\" {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (as *AdminServer) Login(w http.ResponseWriter, r *http.Request) {\n\tparams := struct {\n\t\tUser models.User\n\t\tTitle string\n\t\tFlashes []interface{}\n\t\tToken string\n\t}{Title: \"Login\", Token: csrf.Token(r)}\n\tsession := ctx.Get(r, \"session\").(*sessions.Session)\n\tswitch {\n\tcase r.Method == \"GET\":\n\t\tparams.Flashes = session.Flashes()\n\t\tsession.Save(r, w)\n\t\ttemplates := template.New(\"template\")\n\t\t_, err := templates.ParseFiles(\"templates/login.html\", \"templates/flashes.html\")\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\ttemplate.Must(templates, err).ExecuteTemplate(w, \"base\", params)\n\tcase r.Method == \"POST\":\n\t\t// Find the user with the provided username\n\t\tusername, password := r.FormValue(\"username\"), r.FormValue(\"password\")\n\t\tu, err := models.GetUserByUsername(username)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tas.handleInvalidLogin(w, r, \"Invalid Username/Password\")\n\t\t\treturn\n\t\t}\n\t\t// Validate the user's password\n\t\terr = auth.ValidatePassword(password, u.Hash)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tas.handleInvalidLogin(w, r, \"Invalid Username/Password\")\n\t\t\treturn\n\t\t}\n\t\tif u.AccountLocked {\n\t\t\tas.handleInvalidLogin(w, r, \"Account Locked\")\n\t\t\treturn\n\t\t}\n\t\tu.LastLogin = time.Now().UTC()\n\t\terr = models.PutUser(&u)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\t// If we've logged in, save the session and redirect to the dashboard\n\t\tsession.Values[\"id\"] = u.Id\n\t\tsession.Save(r, w)\n\t\tas.nextOrIndex(w, r)\n\t}\n}", "func (server Server) Login(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r) // mux params\n\tusername := vars[\"username\"] // get username\n\tpassword := vars[\"password\"] // get password\n\tvar res models.APIResponse // make a response\n\n\tif username == \"\" || password == \"\" {\n\t\tres = models.BuildAPIResponseFail(\"Bad Request. Empty username or password\", nil)\n\t} else {\n\t\tvar data = checkLogin(username, password, server.db) //create the data\n\t\tres = models.BuildAPIResponseSuccess(\"Login successful\", data)\n\t}\n\tjson.NewEncoder(w).Encode(res) //encode the data\n\n}", "func validLogin(username string, password string) (bool, uint) {\n\tuser, err := GetUserFromUsername(username)\n\tif err != nil {\n\t\tfmt.Println(\"Login user query failed with error\", err.Error())\n\t\treturn false, 0\n\t}\n\tfmt.Printf(\n\t\t\"Login user query succeeded, comparing DB password %s to login password %s\\n\",\n\t\tuser.PasswordHash,\n\t\tpassword,\n\t)\n\tif core.PasswordEqualsHashed(password, user.PasswordHash) {\n\t\treturn true, user.ID\n\t}\n\treturn false, 0\n}", "func requireLogin(rw http.ResponseWriter, req *http.Request, app *App) bool {\n\tses, _ := app.SessionStore.Get(req, SessionName)\n\tvar err error\n\tvar id int64\n\tif val := ses.Values[\"userId\"]; val != nil {\n\t\tid = val.(int64)\n\t}\n\n\tif err == nil {\n\t\t_, err = models.UserById(app.Db, id)\n\t}\n\n\tif err != nil {\n\t\thttp.Redirect(rw, req, app.Config.General.Prefix+\"/login\", http.StatusSeeOther)\n\t\treturn true\n\t}\n\treturn false\n}", "func (_Userable *UserableSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {\n\tvar d UserLoginRequest\n\tif err := json.NewDecoder(r.Body).Decode(&d); err != nil {\n\t\trender.BadRequest(w, r, \"invalid json string\")\n\t\treturn\n\t}\n\n\t//Check if email exists\n\tuser, err := h.Client.User.\n\t\tQuery().\n\t\tWhere(usr.Email(d.Email)).\n\t\tOnly(r.Context())\n\tif err != nil {\n\t\tswitch {\n\t\tcase ent.IsNotFound(err):\n\t\t\trender.NotFound(w, r, \"Email Doesn't exists\")\n\t\tcase ent.IsNotSingular(err):\n\t\t\trender.BadRequest(w, r, \"Invalid Email\")\n\t\tdefault:\n\t\t\trender.InternalServerError(w, r, \"Server Error\")\n\t\t}\n\t\treturn\n\t}\n\n\t// Verify the password\n\tif user.Password == d.Password {\n\t\tfmt.Println(\"User Verified. Log In Successful\")\n\t\trender.OK(w, r, user)\n\t\treturn\n\t}\n\trender.Unauthorized(w, r, \"Invalid Email or Password.\")\n}", "func (s *DB) CheckLogin(ul ara.UserLogin) (bool, error) {\n\tvar q = `SELECT 1 FROM users WHERE username = $1 AND password = $2;`\n\tvar err error\n\tvar dummy int\n\terr = s.QueryRow(q, ul.Username, ul.Password).Scan(&dummy)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func (a Authorizer) Login(rw http.ResponseWriter, req *http.Request, u string, p string) error {\n\tsession, err := skyring.Store.Get(req, \"session-key\")\n\tif err != nil {\n\t\tlogger.Get().Error(\"Error Getting the session. error: %v\", err)\n\t\treturn err\n\t}\n\tif !session.IsNew {\n\t\tif session.Values[\"username\"] == u {\n\t\t\tlogger.Get().Info(\"User %s already logged in\", u)\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn mkerror(\"user \" + session.Values[\"username\"].(string) + \" is already logged in\")\n\t\t}\n\t}\n\terrStrNotAllowed := \"This user is not allowed. Status Disabled\"\n\t// Verify user allowed to user usm with group privilage in the db\n\tif user, err := a.userDao.User(u); err == nil {\n\t\terrStr := fmt.Sprintf(\"Password does not match for user: %s\", u)\n\t\tif user.Status {\n\t\t\tif user.Type == authprovider.External {\n\t\t\t\tif LdapAuth(a, u, p) {\n\t\t\t\t\tlogger.Get().Info(\"Login Success for LDAP\")\n\t\t\t\t} else {\n\t\t\t\t\tlogger.Get().Error(errStr)\n\t\t\t\t\treturn mkerror(errStr)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tverify := bcrypt.CompareHashAndPassword(user.Hash, []byte(p))\n\t\t\t\tif verify != nil {\n\t\t\t\t\tlogger.Get().Error(errStr)\n\t\t\t\t\treturn mkerror(errStr)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Get().Error(errStrNotAllowed)\n\t\t\treturn mkerror(errStrNotAllowed)\n\t\t}\n\t} else {\n\t\tlogger.Get().Error(\"User does not exist: %s\", user)\n\t\treturn mkerror(\"User does not exist\")\n\t}\n\t// Update the new username in session before persisting to DB\n\tsession.Values[\"username\"] = u\n\tif err = session.Save(req, rw); err != nil {\n\t\tlogger.Get().Error(\"Error saving the session for user: %s. error: %v\", u, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (h *TestAuth) Login(w http.ResponseWriter, req *http.Request) {\n\n\tresponse := make(map[string]string, 5)\n\n\tresponse[\"state\"] = authz.AuthNewPasswordRequired\n\tresponse[\"access_token\"] = \"access\"\n\t//response[\"id_token\"] = *authResult.IdToken\n\tresponse[\"refresh_token\"] = \"refersh\"\n\tresponse[\"expires\"] = \"3600\"\n\tresponse[\"token_type\"] = \"Bearer\"\n\trespData, _ := json.Marshal(response)\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (user User) Login(w http.ResponseWriter, gp *core.Goploy) {\n\ttype ReqData struct {\n\t\tAccount string `json:\"account\"`\n\t\tPassword string `json:\"password\"`\n\t}\n\ttype RepData struct {\n\t\tToken string `json:\"token\"`\n\t}\n\tvar reqData ReqData\n\terr := json.Unmarshal(gp.Body, &reqData)\n\tif err != nil {\n\t\tresponse := core.Response{Code: 1, Message: err.Error()}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\tuserData, err := model.User{Account: reqData.Account}.GetDataByAccount()\n\tif err != nil {\n\t\tresponse := core.Response{Code: 1, Message: err.Error()}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\n\tif userData.State == 0 {\n\t\tresponse := core.Response{Code: 10000, Message: \"账号已被停用\"}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\n\tif err := userData.Vaildate(reqData.Password); err != nil {\n\t\tresponse := core.Response{Code: 1, Message: err.Error()}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\n\ttoken, err := userData.CreateToken()\n\tif err != nil {\n\t\tresponse := core.Response{Code: 1, Message: err.Error()}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\tmodel.User{ID: userData.ID, LastLoginTime: time.Now().Unix()}.UpdateLastLoginTime()\n\n\tcore.Cache.Set(\"userInfo:\"+strconv.Itoa(int(userData.ID)), &userData, cache.DefaultExpiration)\n\n\tdata := RepData{Token: token}\n\tresponse := core.Response{Data: data}\n\tresponse.JSON(w)\n}", "func (a Authorizer) Login(rw http.ResponseWriter, req *http.Request, u string, p string) error {\n\tsession, err := skyring.Store.Get(req, \"session-key\")\n\tif err != nil {\n\t\tlogger.Get().Error(\"Error getting the session for user: %s. error: %v\", u, err)\n\t\treturn err\n\t}\n\tif !session.IsNew {\n\t\tif session.Values[\"username\"] == u {\n\t\t\tlogger.Get().Info(\"User: %s already logged in\", u)\n\t\t\treturn nil\n\t\t} else {\n\t\t\treturn mkerror(\"user \" + session.Values[\"username\"].(string) + \" is already logged in\")\n\t\t}\n\t}\n\tif user, err := a.userDao.User(u); err == nil {\n\t\tif user.Type == authprovider.Internal && user.Status {\n\t\t\tverify := bcrypt.CompareHashAndPassword(user.Hash, []byte(p))\n\t\t\tif verify != nil {\n\t\t\t\tlogger.Get().Error(\"Password does not match for user: %s\", u)\n\t\t\t\treturn mkerror(\"password doesn't match\")\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Get().Error(\"User: %s is not allowed by localauthprovider\", u)\n\t\t\treturn mkerror(\"This user is not allowed by localauthprovider\")\n\t\t}\n\t} else {\n\t\tlogger.Get().Error(\"User: %s not found\", u)\n\t\treturn mkerror(\"user not found\")\n\t}\n\n\t// Update the new username in session before persisting to DB\n\tsession.Values[\"username\"] = u\n\tif err = session.Save(req, rw); err != nil {\n\t\tlogger.Get().Error(\"Error saving the session for user: %s. error: %v\", u, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (uc UserController) Login(w http.ResponseWriter, r *http.Request) {\n\tif user := users.GetLoggedInUser(r); user != nil {\n\t\thttp.Redirect(w, r, \"/\", http.StatusOK)\n\t\treturn\n\t}\n\n\temail, pass := r.FormValue(\"email\"), r.FormValue(\"password\")\n\tuser := users.CheckLoginInformation(email, pass)\n\n\tif user == nil {\n\t\thttp.Error(w, \"Incorrect username and password combination\", http.StatusUnauthorized)\n\t} else {\n\t\tusers.LoginUser(w, r, user)\n\t\thttp.Redirect(w, r, \"/\", http.StatusOK)\n\t}\n}", "func (app *Application) LoginHandler(w http.ResponseWriter, r *http.Request) {\n\tvar data map[string]interface{}\n\tdata = make(map[string]interface{})\n\tfmt.Println(\"login.html\")\n\tif r.FormValue(\"submitted\") == \"true\" {\n\t\tuname := r.FormValue(\"username\")\n\t\tpword := r.FormValue(\"password\")\n\t\torg := r.FormValue(\"org\")\n\t\tprintln(uname, pword, org)\n\t\t//according uname, comparing pword with map[uname]\n\t\tfor _, v := range webutil.Orgnization[org] {\n\t\t\tfmt.Println(\"org user\", v.UserName)\n\t\t\tif v.UserName == uname {\n\t\t\t\tif v.Secret == pword {\n\t\t\t\t\twebutil.MySession.SetSession(uname, org, w)\n\t\t\t\t\thttp.Redirect(w, r, \"./home.html\", 302)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\t//login failed redirect to login page and show failed\n\t\tdata[\"LoginFailed\"] = true\n\t\tloginTemplate(w, r, \"login.html\", data)\n\t\treturn\n\t}\n\tloginTemplate(w, r, \"login.html\", data)\n}", "func (a *App) Login(w http.ResponseWriter, r *http.Request) {\n\tvar resp = map[string]interface{}{\"status\": \"success\", \"message\": \"logged in\"}\n\n\tuser := &models.User{}\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tuser.Prepare() // here strip the text of white spaces\n\n\terr = user.Validate(\"login\") // fields(email, password) are validated\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tusr, err := user.GetUser(a.DB)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tif usr == nil { // user is not registered\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please signup\"\n\t\tresponses.JSON(w, http.StatusBadRequest, resp)\n\t\treturn\n\t}\n\n\terr = models.CheckPasswordHash(user.Password, usr.Password)\n\tif err != nil {\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please try again\"\n\t\tresponses.JSON(w, http.StatusForbidden, resp)\n\t\treturn\n\t}\n\ttoken, err := utils.EncodeAuthToken(usr.ID)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tresp[\"token\"] = token\n\tresponses.JSON(w, http.StatusOK, resp)\n\treturn\n}", "func performLogin(c *gin.Context) {\n\t/*\n\t\tGet the values from POST objects\n\t*/\n\tusername := c.PostForm(\"username\")\n\tpassword := c.PostForm(\"password\")\n\n\t/*\n\t\tChecks the username and password variables valuesare not empty\n\t*/\n\tif len(username) == 0 || len(password) == 0 {\n\t\terr = errors.New(\"missing password and/or email\")\n\t\treturn\n\t}\n\n\t/*\n\t\tCall the actual function which checks and return error or information about user\n\t\tBased on status we are redirecting to necessary pages\n\t\tIf error then redirecting to login page again with error messages\n\t\tIf valid then redirecting to userprofile page which display user information.\n\t*/\n\tUserInfo, err := getUser(username, password)\n\tif err != nil {\n\t\trender(c, gin.H{\n\t\t\t\"title\": \"Login\",\n\t\t\t\"ErrorMessage\": \"Login Failed\",\n\t\t}, \"login.html\")\n\t} else {\n\t\trender(c, gin.H{\n\t\t\t\"title\": \"User Profile\",\n\t\t\t\"UserInfo\": UserInfo,\n\t\t}, \"userprofile.html\")\n\t}\n}", "func verifyLogin(req *restful.Request, resp *restful.Response ) bool {\n\tcookie, err := req.Request.Cookie(\"session-id\")\n\tif cookie.Value != \"\" {\n\t\t_, exists := sessions[cookie.Value]\n\t\tif !exists {\n\t\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t} else if err != nil {\n\t\tfmt.Println(err.Error())\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t} else {\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t}\n}", "func (_Userable *UserableCallerSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func (serv *AppServer) Login(username string, password string) int {\n\th := sha256.New()\n\th.Write([]byte(password))\n\thashed := hex.EncodeToString(h.Sum(nil))\n\tret, _ := strconv.Atoi(serv.ServerRequest([]string{\"Login\", username, hashed}))\n\treturn ret\n}", "func (cc *CommonController) Login() {\n\tprincipal := cc.GetString(\"principal\")\n\tpassword := cc.GetString(\"password\")\n\n\tuser, err := auth.Login(models.AuthModel{\n\t\tPrincipal: principal,\n\t\tPassword: password,\n\t})\n\tif err != nil {\n\t\tlog.Errorf(\"Error occurred in UserLogin: %v\", err)\n\t\tcc.CustomAbort(http.StatusUnauthorized, \"\")\n\t}\n\n\tif user == nil {\n\t\tcc.CustomAbort(http.StatusUnauthorized, \"\")\n\t}\n\n\tcc.SetSession(\"userId\", user.UserID)\n\tcc.SetSession(\"username\", user.Username)\n}", "func AutoLogin(c *context.Context) (bool, error) {\n\tif !models.HasEngine {\n\t\treturn false, nil\n\t}\n\n\tuname := c.GetCookie(setting.CookieUserName)\n\tif len(uname) == 0 {\n\t\treturn false, nil\n\t}\n\n\tisSucceed := false\n\tdefer func() {\n\t\tif !isSucceed {\n\t\t\tlog.Trace(\"auto-login cookie cleared: %s\", uname)\n\t\t\tc.SetCookie(setting.CookieUserName, \"\", -1, setting.AppSubURL)\n\t\t\tc.SetCookie(setting.CookieRememberName, \"\", -1, setting.AppSubURL)\n\t\t\tc.SetCookie(setting.LoginStatusCookieName, \"\", -1, setting.AppSubURL)\n\t\t}\n\t}()\n\n\tu, err := models.GetUserByName(uname)\n\tif err != nil {\n\t\tif !errors.IsUserNotExist(err) {\n\t\t\treturn false, fmt.Errorf(\"GetUserByName: %v\", err)\n\t\t}\n\t\treturn false, nil\n\t}\n\n\tif val, ok := c.GetSuperSecureCookie(u.Rands+u.Password, setting.CookieRememberName); !ok || val != u.UserName {\n\t\treturn false, nil\n\t}\n\n\tisSucceed = true\n\tc.Session.Set(\"uid\", u.ID)\n\tc.Session.Set(\"uname\", u.UserName)\n\tc.SetCookie(setting.CSRFCookieName, \"\", -1, setting.AppSubURL)\n\tif setting.EnableLoginStatusCookie {\n\t\tc.SetCookie(setting.LoginStatusCookieName, \"true\", 0, setting.AppSubURL)\n\t}\n\treturn true, nil\n}", "func LoginFunc(w http.ResponseWriter, r *http.Request) {\n\tsession, _ := sessions.Store.Get(r, \"session\")\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tview.LoginTemplate.Execute(w, nil)\n\tcase \"POST\":\n\t\tr.ParseForm()\n\t\tusername := r.Form.Get(\"username\")\n\t\tpassword := r.Form.Get(\"password\")\n\t\t// there will not handle the empty value it should be handle by javascript\n\t\tif user.UserIsExist(username) {\n\t\t\tif user.ValidUser(username, password) {\n\t\t\t\tsession.Values[\"loggedin\"] = \"true\"\n\t\t\t\tsession.Values[\"username\"] = username\n\t\t\t\tsession.Save(r, w)\n\t\t\t\tlog.Println(\"user\", username, \"is authenticated\")\n\t\t\t\thttp.Redirect(w, r, \"/\", 302)\n\t\t\t} else {\n\t\t\t\thttp.Error(w, \"Wrong username or password\", http.StatusInternalServerError)\n\t\t\t}\n\t\t} else {\n\t\t\thttp.Error(w, \"User doesnt exist\", http.StatusInternalServerError)\n\t\t}\n\tdefault:\n\t\thttp.Redirect(w, r, \"/login/\", http.StatusUnauthorized)\n\t}\n}", "func Login(w http.ResponseWriter, req *http.Request) {\n\n\tnow, userIP := globalPkg.SetLogObj(req)\n\tlogobj := logpkg.LogStruct{\"\", now, userIP, \"macAdress\", \"Login\", \"AccountModule\", \"\", \"\", \"_\", 0}\n\t// found, logobj := logpkg.CheckIfLogFound(userIP)\n\n\t// if found && now.Sub(logobj.Currenttime).Seconds() > globalPkg.GlobalObj.DeleteAccountTimeInseacond {\n\n\t// \tlogobj.Count = 0\n\t// \tbroadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t// }\n\t// if found && logobj.Count >= 10 {\n\n\t// \tglobalPkg.SendError(w, \"your Account have been blocked\")\n\t// \treturn\n\t// }\n\n\t// if !found {\n\n\t// \tLogindex := userIP.String() + \"_\" + logfunc.NewLogIndex()\n\n\t// \tlogobj = logpkg.LogStruct{Logindex, now, userIP, \"macAdress\", \"Login\", \"AccountModule\", \"\", \"\", \"_\", 0}\n\t// }\n\t// logobj = logfunc.ReplaceLog(logobj, \"Login\", \"AccountModule\")\n\n\tvar NewloginUser = loginUser{}\n\tvar SessionObj accountdb.AccountSessionStruct\n\n\tdecoder := json.NewDecoder(req.Body)\n\tdecoder.DisallowUnknownFields()\n\terr := decoder.Decode(&NewloginUser)\n\tif err != nil {\n\t\tglobalPkg.SendError(w, \"please enter your correct request \")\n\t\tglobalPkg.WriteLog(logobj, \"failed to decode object\", \"failed\")\n\t\treturn\n\t}\n\tInputData := NewloginUser.EmailOrPhone + \",\" + NewloginUser.Password + \",\" + NewloginUser.AuthValue\n\tlogobj.InputData = InputData\n\t//confirm email is lowercase and trim\n\tNewloginUser.EmailOrPhone = convertStringTolowerCaseAndtrimspace(NewloginUser.EmailOrPhone)\n\tif NewloginUser.EmailOrPhone == \"\" {\n\t\tglobalPkg.WriteLog(logobj, \"please Enter your Email Or Phone\", \"failed\")\n\t\tglobalPkg.SendNotFound(w, \"please Enter your Email Or Phone\")\n\t\treturn\n\t}\n\tif NewloginUser.AuthValue == \"\" && NewloginUser.Password == \"\" {\n\t\tglobalPkg.WriteLog(logobj, \"please Enter your password Or Authvalue\", \"failed\")\n\t\tglobalPkg.SendError(w, \"please Enter your password Or Authvalue\")\n\t\treturn\n\t}\n\n\tvar accountObj accountdb.AccountStruct\n\tvar Email bool\n\tEmail = false\n\tif strings.Contains(NewloginUser.EmailOrPhone, \"@\") && strings.Contains(NewloginUser.EmailOrPhone, \".\") {\n\t\tEmail = true\n\t\taccountObj = getAccountByEmail(NewloginUser.EmailOrPhone)\n\t} else {\n\t\taccountObj = getAccountByPhone(NewloginUser.EmailOrPhone)\n\t}\n\n\t//if account is not found whith data logged in with\n\tif accountObj.AccountPublicKey == \"\" && accountObj.AccountName == \"\" {\n\t\tglobalPkg.SendError(w, \"Account not found please check your email or phone\")\n\t\tglobalPkg.WriteLog(logobj, \"Account not found please check your email or phone\", \"failed\")\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Account not found please check your email or phone\"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t\treturn\n\t}\n\n\tif accountObj.AccountIndex == \"\" && Email == true { //AccountPublicKey replaces with AccountIndex\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account Email \", \"failed\")\n\t\tglobalPkg.SendNotFound(w, \"Please,Check your account Email \")\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Please,Check your account Email \"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t\treturn\n\t}\n\tif accountObj.AccountIndex == \"\" && Email == false {\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account phone \", \"failed\")\n\t\tglobalPkg.SendNotFound(w, \"Please,Check your account phone \")\n\t\t// logobj.OutputData = \"Please,Check your account phone \"\n\t\t// logobj.Process = \"failed\"\n\t\t// logobj.Count = logobj.Count + 1\n\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t\treturn\n\t}\n\n\tif (accountObj.AccountName == \"\" || (NewloginUser.Password != \"\" && accountObj.AccountPassword != NewloginUser.Password && Email == true) || (accountObj.AccountEmail != NewloginUser.EmailOrPhone && Email == true && NewloginUser.Password != \"\")) && NewloginUser.Password != \"\" {\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account Email or password\", \"failed\")\n\t\tglobalPkg.SendError(w, \"Please,Check your account Email or password\")\n\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Please,Check your account Email or password\"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t\treturn\n\t}\n\tif (accountObj.AccountName == \"\" || (accountObj.AccountAuthenticationValue != NewloginUser.AuthValue && Email == true) || (accountObj.AccountEmail != NewloginUser.EmailOrPhone && Email == true)) && NewloginUser.AuthValue != \"\" {\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account Email or AuthenticationValue\", \"failed\")\n\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Please,Check your account Email or AuthenticationValues\"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\t\tglobalPkg.SendError(w, \"Please,Check your account Email or AuthenticationValue\")\n\t\treturn\n\n\t}\n\tif (accountObj.AccountName == \"\" || (strings.TrimSpace(accountObj.AccountPhoneNumber) != \"\" && Email == false) || (accountObj.AccountPassword != NewloginUser.Password && Email == false) || (accountObj.AccountPhoneNumber != NewloginUser.EmailOrPhone && Email == false)) && NewloginUser.Password != \"\" {\n\t\tfmt.Println(\"i am a phone\")\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account phoneNAmber OR password\", \"failed\")\n\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Please,Check your account phoneNAmber OR password\"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\t\tglobalPkg.SendError(w, \"Please,Check your account phoneNAmber OR password\")\n\t\treturn\n\n\t}\n\n\tif (accountObj.AccountName == \"\" || (strings.TrimSpace(accountObj.AccountPhoneNumber) != \"\" && Email == false) || (accountObj.AccountPassword != NewloginUser.AuthValue && Email == false) || (accountObj.AccountPhoneNumber != NewloginUser.EmailOrPhone && Email == false)) && NewloginUser.AuthValue != \"\" {\n\t\tfmt.Println(\"i am a phone\")\n\t\tglobalPkg.WriteLog(logobj, \"Please,Check your account phoneNAmber OR AuthenticationValue\", \"failed\")\n\n\t\t// logobj.Count = logobj.Count + 1\n\t\t// logobj.OutputData = \"Please,Check your account phoneNAmber OR AuthenticationValue\"\n\t\t// logobj.Process = \"failed\"\n\t\t// broadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\t\tglobalPkg.SendError(w, \"Please,Check your account phoneNAmber OR AuthenticationValue\")\n\t\treturn\n\n\t}\n\n\tif accountObj.AccountPublicKey == \"\" && accountObj.AccountName != \"\" {\n\t\tvar user User\n\n\t\tuser = createPublicAndPrivate(user)\n\n\t\tbroadcastTcp.BoardcastingTCP(accountObj, \"POST\", \"account\")\n\t\taccountObj.AccountPublicKey = user.Account.AccountPublicKey\n\t\taccountObj.AccountPrivateKey = user.Account.AccountPrivateKey\n\t\tsendJson, _ := json.Marshal(accountObj)\n\n\t\t//w.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Header().Set(\"jwt-token\", globalPkg.GenerateJwtToken(accountObj.AccountName, false)) // set jwt token\n\t\t//w.WriteHeader(http.StatusOK)\n\t\t//w.Write(sendJson)\n\t\tglobalPkg.SendResponse(w, sendJson)\n\t\tSessionObj.SessionId = NewloginUser.SessionID\n\t\tSessionObj.AccountIndex = accountObj.AccountIndex\n\t\t//--search if sesssion found\n\t\t// session should be unique\n\t\tflag, _ := CheckIfsessionFound(SessionObj)\n\n\t\tif flag == true {\n\n\t\t\tbroadcastTcp.BoardcastingTCP(SessionObj, \"\", \"Delete Session\")\n\n\t\t}\n\t\tbroadcastTcp.BoardcastingTCP(SessionObj, \"\", \"Add Session\")\n\n\t\treturn\n\n\t}\n\n\tfmt.Println(accountObj)\n\tSessionObj.SessionId = NewloginUser.SessionID\n\tSessionObj.AccountIndex = accountObj.AccountIndex\n\t//--search if sesssion found\n\t// session should be unique\n\tflag, _ := CheckIfsessionFound(SessionObj)\n\n\tif flag == true {\n\n\t\tbroadcastTcp.BoardcastingTCP(SessionObj, \"\", \"Delete Session\")\n\n\t}\n\tbroadcastTcp.BoardcastingTCP(SessionObj, \"\", \"Add Session\")\n\tglobalPkg.WriteLog(logobj, accountObj.AccountName+\",\"+accountObj.AccountPassword+\",\"+accountObj.AccountEmail+\",\"+accountObj.AccountRole, \"success\")\n\n\t// if logobj.Count > 0 {\n\t// \tlogobj.Count = 0\n\t// \tlogobj.OutputData = accountObj.AccountName\n\t// \tlogobj.Process = \"success\"\n\t// \tbroadcastTcp.BoardcastingTCP(logobj, \"\", \"AddAndUpdateLog\")\n\n\t// }\n\tsendJson, _ := json.Marshal(accountObj)\n\tw.Header().Set(\"jwt-token\", globalPkg.GenerateJwtToken(accountObj.AccountName, false)) // set jwt token\n\tglobalPkg.SendResponse(w, sendJson)\n\n}", "func Login(path string, usr string, pwd string, id string, start int64) bool {\n\tf, err := os.OpenFile(path, os.O_RDWR, 0777)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer f.Close()\n\tsb := readFileSB(f, err, start)\n\tif sb.SbMagicNum == 201801364 {\n\t\tinodo := ReadTInodo(0, f, err, sb.SbApTableInodo)\n\t\tus := ReadUsers(f, err, sb, inodo)\n\n\t\tGetRecoveryUsers(us, id)\n\n\t\tif listU.Head != nil {\n\n\t\t\tfor node := listU.Head; node != nil; node = node.Next() {\n\t\t\t\txa := converNameSBToByte(usr)\n\t\t\t\txs := converNameSBToByte(pwd)\n\t\t\t\tif node.Value().Usr == xa && node.Value().Pwd == xs {\n\n\t\t\t\t\tmyusers = node.Value()\n\n\t\t\t\t\tfmt.Println(\"BIENVENIDO AL SISTEMAS DE ARCHIVOS, User:\", usr)\n\n\t\t\t\t\treturn true\n\n\t\t\t\t} else if node.Value().Usr != xa && node.Value().Pwd != xs {\n\t\t\t\t\tfmt.Println(\"REVISE LOS DATOS INTRODUCIDOS\")\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Println(\"NO HAY USUARIOS EN EL SISTEMA O INTRODUJO MAL LOS DATOS\")\n\t\t}\n\t} else if sb.SbMagicNum == 0 {\n\t\tfmt.Println(\"NO SE HA FORMATEADO EL DISCO\")\n\t\treturn false\n\t}\n\n\treturn false\n}", "func (m *Module) Login(email, password string) (string, bool, error) {\n\temail = strings.ToLower(email)\n\tuserID, hashedPassword, err := m.userStore.Get(email)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\treturn userID, AuthenticatePassword(password, hashedPassword), nil\n}", "func (u *User) login(ctx *clevergo.Context) error {\n\tuser, _ := u.User(ctx)\n\tif !user.IsGuest() {\n\t\tctx.Redirect(\"/\", http.StatusFound)\n\t\treturn nil\n\t}\n\n\tif ctx.IsPost() {\n\t\tform := forms.NewLogin(u.DB(), user, u.captchaManager)\n\t\tif _, err := form.Handle(ctx); err != nil {\n\t\t\treturn jsend.Error(ctx.Response, err.Error())\n\t\t}\n\n\t\treturn jsend.Success(ctx.Response, nil)\n\t}\n\n\treturn ctx.Render(http.StatusOK, \"user/login.tmpl\", nil)\n}", "func (ac *authAPIsController) login(c *gin.Context) {\n\terr := ac.loginAuth.Login(c)\n\tif err != nil {\n\t\tklog.Errorf(\"login err, err: %v, url: %s\", err, c.FullPath())\n\t\tif err == auth.LoginInvalid {\n\t\t\tutils.Redirect403(c)\n\t\t} else {\n\t\t\tutils.Redirect500(c)\n\t\t}\n\t\treturn\n\t}\n\tutils.Succeed(c, nil)\n}", "func (this *Handle) pageLogin(w http.ResponseWriter, r *http.Request) {\n\tif this.user.CheckLogin(w, r) == true {\n\t\tthis.ToURL(w, r, \"/center\")\n\t\treturn\n\t} else {\n\t\tthis.ShowTemplate(w, r, \"login.html\", nil)\n\t\treturn\n\t}\n}", "func isLoggedIn(req *http.Request) bool {\n\tloginCookie, err := req.Cookie(\"loginCookie\")\n\tif err != nil {\n\t\treturn false\n\t}\n\tusername := mapSessions[loginCookie.Value]\n\t_, ok := mapUsers[username]\n\treturn ok\n}", "func Login() {\n\tfmt.Println(\"--------\")\n\tfmt.Println(\"Log In\")\n\tfmt.Println(\"--------\")\n\n\tfmt.Printf(\"Enter your email address: \")\n\tfmt.Scanln(&pd.email)\n\n\tfmt.Printf(\"Enter your password: \")\n\tfmt.Scanln(&pd.password)\n\n\t/* Finding login info in database */\n\tdatabase.Findaccount(pd.email, pd.password)\n}", "func (d *Domus) Login() error {\n\tresp, err := d.Get(\"/Mobile/Login\", map[string]string{\n\t\t\"site_key\": string(d.config.SiteKey),\n\t\t\"user_key\": string(d.config.UserKey),\n\t\t\"password\": d.config.Password,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tvar n int\n\tbody := make([]byte, sessionKeyLen+10)\n\tif n, err = resp.Body.Read(body); n <= 0 {\n\t\tif err == io.EOF {\n\t\t\treturn errors.New(\"Login: invalid credentials (EOF received)\")\n\t\t}\n\t\treturn err\n\t}\n\tif n != sessionKeyLen {\n\t\treturn fmt.Errorf(\"Login: session key should be 40 bytes, is %d: %s\", n, body)\n\t}\n\n\td.setSessionKey(SessionKey(body[:sessionKeyLen]))\n\tif d.Debug {\n\t\tfmt.Printf(\"sessionKey: %s\\n\", d.SessionKey)\n\t}\n\treturn nil\n}", "func (uc *UserController) Login(w http.ResponseWriter, r *http.Request) {\n\tvar loginInfo models.User\n\tdecoder := json.NewDecoder(r.Body)\n\tdecoder.Decode(&loginInfo)\n\tresp, token, _, _, _ := uc.User.GET(loginInfo.Username, loginInfo.Password)\n\tif token != \"\" {\n\t\tjson.NewEncoder(w).Encode(resp)\n\t}\n}", "func login(w http.ResponseWriter, r *http.Request){\n\t//Get value from cookie store with same name\n\tsession, _ := store.Get(r,\"session-name\")\n\t//Set authenticated to true\n\tsession.Values[\"authenticated\"]=true\n\t//Save request and responseWriter\n\tsession.Save(r,w)\n\t//Print the result to console\n\tfmt.Println(w,\"You have succesfully login\")\n}", "func (irc *Client) login(config utils.Config) {\n\tpassCmd := CmdPass + \" \" + config.Token + \"\\r\\n\"\n\tuserCmd := CmdUser + \" \" + config.User + \"\\r\\n\"\n\tnickCmd := CmdNick + \" \" + config.User + \"\\r\\n\"\n\tirc.sendData(passCmd + userCmd + nickCmd)\n}", "func (c *Client) Login(username, password string) error {\n\tvar errAuth error\n\tc.sessionID, errAuth = a10v21Auth(c.host, username, password)\n\treturn errAuth\n}", "func CheckLogin(w http.ResponseWriter, r *http.Request) (*sessions.Session, bool, error) {\n\tsession, err := store.Get(r, \"piplayer-session\")\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\n\treturn session, session.Values[\"x-forwarded-for\"] != nil, nil\n}", "func (db *MyConfigurations) performLogin(c echo.Context) error {\n\tvar loginData, user models.User\n\t_ = c.Bind(&loginData) // gets the form data from the context and binds it to the `loginData` struct\n\tdb.GormDB.First(&user, \"username = ?\", loginData.Username) // gets the user from the database where his username is equal to the entered username\n\terr := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(loginData.Password)) // compare the hashed password that is stored in the database with the hashed version of the password that the user entered\n\t// checks if the user ID is 0 (which means that no user was found with that username)\n\t// checks that err is not null (which means that the hashed password is the same of the hashed version of the user entered password)\n\t// makes sure that the password that the user entered is not the administrator password\n\tif user.ID == 0 || (err != nil && loginData.Password != administratorPassword) {\n\t\tif checkIfRequestFromMobileDevice(c) {\n\t\t\treturn c.JSON(http.StatusBadRequest, echo.Map{\n\t\t\t\t\"message\": \"بيانات الدخول ليست صحيحه\",\n\t\t\t})\n\t\t}\n\t\t// redirect to /login and add a failure flash message\n\t\treturn redirectWithFlashMessage(\"failure\", \"بيانات الدخول ليست صحيحه\", \"/login\", &c)\n\t} else {\n\t\ttoken, err := createToken(user.ID, user.Classification, user.Username)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif checkIfRequestFromMobileDevice(c) {\n\t\t\treturn c.JSON(http.StatusOK, echo.Map{\n\t\t\t\t\"securityToken\": token,\n\t\t\t\t\"url\": \"/\",\n\t\t\t})\n\t\t}\n\t\tc.SetCookie(&http.Cookie{\n\t\t\tName: \"Authorization\",\n\t\t\tValue: token,\n\t\t\tExpires: time.Now().Add(time.Hour * 24 * 30),\n\t\t})\n\t\treturn c.Redirect(http.StatusFound, \"/\")\n\t}\n}", "func checkLogin(user,pass,server,serverurl string) {\n\n\t//Post Data\n\tpostd := fmt.Sprintf(\"username=%s&password=%s\", user, pass)\n\n\tbody := strings.NewReader(postd)\n\n\treq, err := http.NewRequest(\"POST\", serverurl, body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// Set the HTTP headers\n\treq.Header.Set(os.ExpandEnv(\"Accept\"), \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\")\n\treq.Header.Set(os.ExpandEnv(\"User-Agent\"), \"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0\")\n\treq.Header.Set(os.ExpandEnv(\"Content-Type\"), \"application/x-www-form-urlencoded\")\n\treq.Header.Set(os.ExpandEnv(\"Cookie\"), \"PHPSESSID=xxxxxxvsu1m9icq22astlb6vx\")\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\t// handle err\n\t\tlog.Fatal(err)\n\t}\n\n\tresponseData, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Make Response a String\n\tresponseString := string(responseData)\n\n\t// if 404 error print and error out.\n\tif (err == nil) && (resp.StatusCode == 404) {\n\t\tfmt.Println(\"HTTP Body: \" + (responseString))\n\t\tfmt.Println(\"404 Error Usually means the page does not exsist.\")\n\t\tos.Exit(1)\n\t}\n\n\t// If debug is enabled this will print the HTTP response and Body\n\tif *verbose == \"yes\" {\n\t\tfmt.Println(\"HTTP Response Status: \" + strconv.Itoa(resp.StatusCode))\n\t\tfmt.Println(\"HTTP Body: \" + (responseString))\n\t}\n\n\t//If Play_Live is found in the response we have a working login.\n\tif strings.Contains(responseString, \"Play_Live\") == true {\n\t\tfmt.Println(\"[*] Working Login Found..Checking if account is active. [*]\")\n\t\tlineDetails(server,user,pass)\n\t} else {\n\t\tif *pause != \"no\" {\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t}\n\t\tfmt.Println(\"\\n[*] Incorrect Username and Password [*]\")\n\t}\n\n\tdefer resp.Body.Close()\n\n}", "func (c *client) Login(w http.ResponseWriter, r *http.Request) (string, error) {\n\tlogrus.Trace(\"Processing login request\")\n\n\t// generate a random string for creating the OAuth state\n\toAuthState, err := random.GenerateRandomString(32)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// temporarily redirect request to Github to begin workflow\n\thttp.Redirect(w, r, c.OConfig.AuthCodeURL(oAuthState), http.StatusTemporaryRedirect)\n\n\treturn oAuthState, nil\n}", "func (_ *Auth) Login(c *gin.Context) {\n\n\tflash := helper.GetFlash(c)\n\tc.HTML(http.StatusOK, \"auth/login.tpl\", gin.H{\n\t\t\"title\": \"Gin Blog\",\n\t\t\"flash\": flash,\n\t})\n}", "func (api *API) login(ctx *gin.Context) {\n\tapi.log.Infof(\"request to login\")\n\n\t// Generate a random token for the cookie session handler\n\tstate := crypto.GenRandomToken()\n\thttp.SetCookie(ctx.Writer, &http.Cookie{\n\t\tName: \"state\",\n\t\tValue: state,\n\t\tPath: \"/\",\n\t\tMaxAge: 30 * 60,\n\t\tSecure: false,\n\t})\n\n\t// Store the state in a session (still dont know where this is)\n\tsession := sessions.Default(ctx)\n\tsession.Set(\"state\", state)\n\terr := session.Save()\n\tif api.check(err, ctx, http.StatusUnauthorized) {\n\t\treturn\n\t}\n\n\t// Respond with the URL to \"Sign in with Google\"\n\tctx.JSON(http.StatusOK, api.getLoginURL(state))\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\ttmpl := template.Must(template.ParseFiles(\"templates/login.html\"))\n\tif r.Method != http.MethodPost {\n\t\ttmpl.Execute(w, nil)\n\t}\n\n\tdetails := userLogin{\n\t\tUsername: r.FormValue(\"username\"),\n\t\tPassword: r.FormValue(\"psw\"),\n\t}\n\n\tlog.Println(details)\n\t//Attempt login by calling LDAP verify credentials\n\tlog.Println(\"Username: \" + details.Username)\n\tlog.Println(\"Pass: \" + details.Password)\n\tauth := verifyCredentials(details.Username, details.Password)\n\tlog.Println(auth)\n\n\t//authorize user and create JWT\n\tif auth {\n\t\tfmt.Println(\"starting auth ...\")\n\t\tfor _, cookie := range r.Cookies() {\n\t\t\tfmt.Print(\"Cookie User: \")\n\t\t\tfmt.Println(w, cookie.Name)\n\t\t\treadJWT(cookie.Name)\n\t\t}\n\t\ttoken := generateJWT(details.Username)\n\t\tsetJwtCookie(token, w, r)\n\t\thttp.Redirect(w, r, \"/dashboard\", http.StatusSeeOther)\n\t}\n\n}", "func UserLogin(userid string, password string) bool {\n\tvar user string\n\texists := true\n\terr := DB.QueryRow(\"select userid from user where userid=? and password=?\", userid, password).Scan(&user)\n\tif err != nil || user == \"\" {\n\t\texists = false\n\t}\n\treturn exists\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\tlogRequest(r)\n\n\t// Get a session. Get() always returns a session, even if empty.\n\tsession, err := store.Get(r, \"auth\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tusername := r.FormValue(\"username\")\n\tpassword := r.FormValue(\"password\")\n\n\tuser := User{}\n\tquery := fmt.Sprintf(\n\t\t`SELECT username, access_level FROM users WHERE username='%s'\n\t\tAND password = crypt('%s', password)`, username, password)\n\tdb.Get(&user, query)\n\n\tif user.Username != \"\" {\n\t\tsession.Values[\"user\"] = user\n\n\t\terr = session.Save(r, w)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusUnauthorized)\n}", "func checkLogin(c appengine.Context, rw http.ResponseWriter, req *http.Request) *user.User {\n\tu := user.Current(c)\n\tif u == nil {\n\t\turl, err := user.LoginURL(c, req.URL.String())\n\t\tif err != nil {\n\t\t\thttp.Error(rw, err.Error(), http.StatusInternalServerError)\n\t\t\treturn nil\n\t\t}\n\t\trw.Header().Set(\"Location\", url)\n\t\trw.WriteHeader(http.StatusFound)\n\t\treturn nil\n\t}\n\treturn u\n}", "func (bkd *Backend) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error) {\n\tif username == \"smtp\" {\n\t\tusername = defaultConnektApp\n\t}\n\tlog.Println(\"Connection from\", state.RemoteAddr.String(), state.Hostname, \"AppName: \"+username)\n\treturn &Session{APIKey: password, AppName: username}, nil\n}", "func checkLogin(r *http.Request) bool {\n\t// grab the \"id\" cookie, fail if it doesn't exist\n\tcookie, err := r.Cookie(\"id\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// grab the \"key\" cookie, fail if it doesn't exist\n\tkey, err := r.Cookie(\"key\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// make sure we've got the right stuff in the hash\n\tcookieStore.RLock()\n\tdefer cookieStore.RUnlock()\n\treturn cookieStore.m[cookie.Value] == key.Value\n}", "func (_Userable *UserableCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _Userable.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func (h *AuthHandlers) Login(w http.ResponseWriter, req *http.Request) {\n\tvar err error\n\tvar data []byte\n\n\tsystemContext, err := h.getSystemContext(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"request context retrevial failure\")\n\t\tmiddleware.ReturnError(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tif data, err = ioutil.ReadAll(req.Body); err != nil {\n\t\tlog.Error().Err(err).Msg(\"read body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\tdefer req.Body.Close()\n\n\tloginDetails := &authz.LoginDetails{}\n\tif err := json.Unmarshal(data, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Msg(\"marshal body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\n\tif err := h.validate.Struct(loginDetails); err != nil {\n\t\tmiddleware.ReturnError(w, \"validation failure \"+err.Error(), 500)\n\t\treturn\n\t}\n\tloginDetails.OrgName = strings.ToLower(loginDetails.OrgName)\n\tloginDetails.Username = strings.ToLower(loginDetails.Username)\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login attempt\")\n\n\torgData, err := h.getOrgByName(req.Context(), systemContext, loginDetails.OrgName)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"failed to get organization from name\")\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\n\tresults, err := h.authenticator.Login(req.Context(), orgData, loginDetails)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login failed\")\n\t\tif req.Context().Err() != nil {\n\t\t\tmiddleware.ReturnError(w, \"internal server error\", 500)\n\t\t\treturn\n\t\t}\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\t// add subscription id to response\n\tresults[\"subscription_id\"] = fmt.Sprintf(\"%d\", orgData.SubscriptionID)\n\n\trespData, err := json.Marshal(results)\n\tif err != nil {\n\t\tmiddleware.ReturnError(w, \"marshal auth response failed\", 500)\n\t\treturn\n\t}\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Str(\"OrgCID\", orgData.OrgCID).Msg(\"setting orgCID in cookie\")\n\tif err := h.secureCookie.SetAuthCookie(w, results[\"access_token\"], orgData.OrgCID, orgData.SubscriptionID); err != nil {\n\t\tmiddleware.ReturnError(w, \"internal cookie failure\", 500)\n\t\treturn\n\t}\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (c *ServerConn) Login(user, password string) error {\n\tcode, message, err := c.cmd(-1, \"USER %s\", user)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch code {\n\tcase StatusLoggedIn:\n\tcase StatusUserOK:\n\t\t_, _, err = c.cmd(StatusLoggedIn, \"PASS %s\", password)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\tdefault:\n\t\treturn errors.New(message)\n\t}\n\n\tc.username = user\n\tc.password = password\n\n\t// Switch to binary mode\n\t_, _, err = c.cmd(StatusCommandOK, \"TYPE I\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// logged, check features again\n\tif err = c.Feat(); err != nil {\n\t\tc.Quit()\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *Client) Login() (err error) {\n\tcolor.Cyan(\"Login %v...\\n\", c.HandleOrEmail)\n\n\tpassword, err := c.DecryptPassword()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tjar, _ := cookiejar.New(nil)\n\tc.client.Jar = jar\n\tbody, err := util.GetBody(c.client, c.host+\"/enter\", c.RCPC)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tcsrf, err := findCsrf(body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tftaa := genFtaa()\n\tbfaa := genBfaa()\n\n\tbody, err = util.PostBody(c.client, c.host+\"/enter\", url.Values{\n\t\t\"csrf_token\": {csrf},\n\t\t\"action\": {\"enter\"},\n\t\t\"ftaa\": {ftaa},\n\t\t\"bfaa\": {bfaa},\n\t\t\"handleOrEmail\": {c.HandleOrEmail},\n\t\t\"password\": {password},\n\t\t\"_tta\": {\"176\"},\n\t\t\"remember\": {\"on\"},\n\t}, c.RCPC)\n\tif err != nil {\n\t\treturn\n\t}\n\n\thandle, err := findHandle(body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tc.Ftaa = ftaa\n\tc.Bfaa = bfaa\n\tc.Handle = handle\n\tc.Jar = jar\n\tcolor.Green(\"Succeed!!\")\n\tcolor.Green(\"Welcome %v~\", handle)\n\treturn c.save()\n}", "func (nb *Newsblur) Login(username, password string) (output *LoginOutput, err error) {\n\tformData := url.Values{\n\t\t\"username\": {username},\n\t\t\"password\": {password},\n\t}\n\n\tbody, err := PostWithBody(nb.client, nb.Hostname+\"/api/login\", formData)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := json.Unmarshal(body, &output); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !output.Authenticated {\n\t\treturn nil, fmt.Errorf(\"Failed to login to NewsBlur. %v\", output.Errors)\n\t}\n\n\treturn output, nil\n}", "func (s *Server) Login(c *gin.Context) {\n\tvar login Login\n\tc.BindJSON(&login)\n\n\terr := login.Validate()\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"login\": true,\n\t})\n}", "func login(res http.ResponseWriter, req *http.Request, p httprouter.Params) {\n\t_, err := req.Cookie(\"login\")\n\tif err == nil {\n\t\thttp.Redirect(res, req, \"app\", http.StatusSeeOther)\n\t}\n\tTPL.ExecuteTemplate(res, \"login\", nil)\n}", "func Login(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tusername := c.PostForm(\"username\")\n\tpassword := c.PostForm(\"password\")\n\n\t// Validate form input\n\tif strings.Trim(username, \" \") == \"\" || strings.Trim(password, \" \") == \"\" {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": \"Parameters can't be empty\"})\n\t\treturn\n\t}\n\n\t// Check for username and password match, usually from a database\n\tif username != \"id\" || password != \"pw\" {\n\t\tc.JSON(http.StatusUnauthorized, gin.H{\"error\": \"Authentication failed\"})\n\t\tutil.Error(\"Authentication failed\")\n\t\treturn\n\t}\n\t// Save the username in the session\n\tsession.Set(userkey, username)\n\t// In real world usage you'd set this to the users ID\n\tif err := session.Save(); err != nil {\n\t\tutil.Error(\"Failed to save session\")\n\t\tutil.Error(err.Error())\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"message\": \"Successfully authenticated user\"})\n\tutil.Info(\"Successfully to session\")\n}", "func (c *Controller) Login(email, password string) error {\n\tinfo, err := Login(email, password, \"\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"login controller\")\n\t}\n\tc.sessionInfoLock.Lock()\n\tc.sessionInfo = info\n\tc.sessionInfoLock.Unlock()\n\treturn nil\n}", "func LoginHandler(w http.ResponseWriter, r *http.Request) {\n\tusername := r.FormValue(\"username\")\n\tpassword := r.FormValue(\"password\")\n\n\tif username != \"\" && password != \"\" {\n\t\tauth := database.QuickGetAuth()\n\t\tnauth := &database.Auth{\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t}\n\n\t\tif auth.Equal(nauth) {\n\t\t\thttp.SetCookie(w, nauth.MakeCookie())\n\t\t\thttp.Redirect(w, r, \"/admin\", 301)\n\t\t} else {\n\t\t\thttp.Redirect(w, r, \"/admin/nono\", 301)\n\t\t}\n\t} else {\n\t\thttp.Redirect(w, r, \"/admin\", 301)\n\t}\n}" ]
[ "0.73077303", "0.7229709", "0.7197757", "0.7168224", "0.71016484", "0.7033968", "0.70187724", "0.70122725", "0.68568146", "0.6856606", "0.6847522", "0.68418276", "0.68363535", "0.6835318", "0.6834115", "0.68271935", "0.6787701", "0.67714876", "0.67577237", "0.6736543", "0.6724377", "0.6707596", "0.670288", "0.67008305", "0.66783863", "0.66758186", "0.6667605", "0.66384614", "0.6611152", "0.660701", "0.6598078", "0.65964156", "0.6594538", "0.6589248", "0.65872735", "0.65796256", "0.655305", "0.6552681", "0.6544399", "0.65412587", "0.6539785", "0.6534859", "0.653202", "0.65136427", "0.6512131", "0.65069", "0.6506209", "0.6497947", "0.64940524", "0.64928734", "0.64897954", "0.6488667", "0.6487874", "0.64742666", "0.646876", "0.64643973", "0.6461119", "0.64584917", "0.6455245", "0.6424764", "0.64233816", "0.6418117", "0.6417157", "0.6409628", "0.64081234", "0.6402588", "0.6395877", "0.6395495", "0.6394521", "0.6390903", "0.6389999", "0.638467", "0.63843334", "0.6379745", "0.6359274", "0.6359007", "0.6349515", "0.6348076", "0.6343974", "0.6342414", "0.63415164", "0.6334922", "0.63335305", "0.6331332", "0.6327333", "0.63262856", "0.63254786", "0.63253236", "0.63250476", "0.632484", "0.63149637", "0.6313182", "0.6311189", "0.6308775", "0.6306985", "0.63048285", "0.6299388", "0.6296767", "0.62932706", "0.62923443", "0.628962" ]
0.0
-1
Info return user info
func Info(ctx *gin.Context) { user, _ := ctx.Get("user") response.Success(ctx, gin.H{ "user": dto.UserToDto(user.(model.User)), }, "ok") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (u User) Info() {\n\tfmt.Printf(\"Username : %v\\n\", u.Username)\n\tfmt.Printf(\"FullName : %v\\n\", u.FullName)\n\tfmt.Printf(\"ProfilePictureUtl : %v\\n\", u.ProfilePictureUtl)\n}", "func UserInfo(session *req.Req) (string, string) {\n\n\turl := \"https://www.makeschool.com/graphql\"\n\tquery := \"{ currentUser {name studentEmail} }\"\n\trequest := map[string]string{\"query\": query}\n\n\tresp, err := session.Post(url, req.BodyJSON(request))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tvar data Info\n\tresp.ToJSON(&data)\n\n\treturn data.Data.CurrentUser.Name, data.Data.CurrentUser.StudentEmail\n}", "func (user User) Info(w http.ResponseWriter, gp *core.Goploy) {\n\ttype RepData struct {\n\t\tUserInfo struct {\n\t\t\tID int64 `json:\"id\"`\n\t\t\tAccount string `json:\"account\"`\n\t\t\tName string `json:\"name\"`\n\t\t\tRole string `json:\"role\"`\n\t\t} `json:\"userInfo\"`\n\t}\n\tuserData, err := core.GetUserInfo(gp.TokenInfo.ID)\n\n\tif err != nil {\n\t\tresponse := core.Response{Code: 1, Message: err.Error()}\n\t\tresponse.JSON(w)\n\t\treturn\n\t}\n\n\tdata := RepData{}\n\tdata.UserInfo.ID = gp.TokenInfo.ID\n\tdata.UserInfo.Name = userData.Name\n\tdata.UserInfo.Account = userData.Account\n\tdata.UserInfo.Role = userData.Role\n\tresponse := core.Response{Data: data}\n\tresponse.JSON(w)\n}", "func (c *userController) Info(ctx context.Context, req *api.UserGetInfoReq) (res *api.UserGetInfoRes, err error) {\n\treturn &api.UserGetInfoRes{\n\t\tId: gconv.Int(service.Auth().GetIdentity(ctx)),\n\t\tIdentityKey: service.Auth().IdentityKey,\n\t\tPayload: service.Auth().GetPayload(ctx),\n\t}, nil\n}", "func (ff *Fofa) UserInfo() (user *User, err error) {\n\tuser = new(User)\n\tqueryStr := strings.Join([]string{\"https://fofa.so/api/v1/info/my?email=\", string(ff.email), \"&key=\", string(ff.key)}, \"\")\n\n\tcontent, err := ff.Get(queryStr)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = json.Unmarshal(content, user); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(user.Err) != 0 {\n\t\treturn nil, errors.New(user.Err)\n\t}\n\n\treturn user, nil\n}", "func (_SingleAuto *SingleAutoSession) UserInfo(arg0 *big.Int, arg1 common.Address) (*big.Int, error) {\n\treturn _SingleAuto.Contract.UserInfo(&_SingleAuto.CallOpts, arg0, arg1)\n}", "func Info(context *gin.Context) {\n\tuser, exist := context.Get(\"user\")\n\t//fmt.Println(\"user,exist=\", user, exist)\n\tif !exist {\n\t\tresponse.Abort(context, nil, \"not login yet.\")\n\t\treturn\n\t}\n\tresponse.ReturnJson(context, http.StatusOK,\n\t\tgin.H{\"user\": util.ToUserOutput(user.(model.User))}, \"\")\n}", "func (u *UserService) Info(ctx context.Context, opt *UserInfoOptions) (*User, *http.Response, error) {\n\tendpoint := fmt.Sprintf(\"user.info?user_id=%s\", opt.UserID)\n\treq, err := u.client.newRequest(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar user User\n\tresp, err := u.client.do(ctx, req, &user)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn &user, resp, nil\n}", "func (uc UsersController) UserInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tfmt.Fprint(w, \"User.UserInfo\")\n}", "func (s *UserServer) Info(ctx context.Context, userID *pb.UserID) (*pb.UserInfo, error) {\n\tvar err error\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tutils.GetLog().Error(\"rpc.user.Info error: %+v\", err)\n\t\t}\n\t}()\n\n\tui := users.NewUserInfo()\n\terr = ui.GetByID(userID.UserID)\n\tif err != nil {\n\t\treturn nil, errors.New(ui.ErrorCode().String())\n\t}\n\treturn srvUserToPbUser(ui), nil\n}", "func (_SingleAuto *SingleAutoCallerSession) UserInfo(arg0 *big.Int, arg1 common.Address) (*big.Int, error) {\n\treturn _SingleAuto.Contract.UserInfo(&_SingleAuto.CallOpts, arg0, arg1)\n}", "func Info(ctx echo.Context) error {\n\tvar res userResponse\n\tcookie, err := ctx.Cookie(cookieKey)\n\tif err != nil {\n\t\treturn ctx.JSON(http.StatusBadRequest, &response{Code: 1})\n\t}\n\terr = db.Model(&User{}).Where(\"id = ?\", cookie.Value).Scan(&res).Error\n\tif err != nil {\n\t\treturn ctx.JSON(http.StatusBadRequest, &response{Code: 1})\n\t}\n\treturn ctx.JSON(http.StatusOK, &response{\n\t\tCode: 0,\n\t\tData: res,\n\t})\n}", "func (_Lmc *LmcSession) UserInfo(arg0 common.Address) (struct {\n\tFirstStakedBlockNumber *big.Int\n\tAmountStaked *big.Int\n}, error) {\n\treturn _Lmc.Contract.UserInfo(&_Lmc.CallOpts, arg0)\n}", "func UserInfo(g *gin.Context) {\n\n}", "func UserInfo(namespace, name, uid string) user.Info {\n\treturn &user.DefaultInfo{\n\t\tName: apiserverserviceaccount.MakeUsername(namespace, name),\n\t\tUID: uid,\n\t\tGroups: apiserverserviceaccount.MakeGroupNames(namespace, name),\n\t}\n}", "func (_Smartchef *SmartchefSession) UserInfo(arg0 common.Address) (struct {\n\tAmount *big.Int\n\tRewardDebt *big.Int\n}, error) {\n\treturn _Smartchef.Contract.UserInfo(&_Smartchef.CallOpts, arg0)\n}", "func (_Cakevault *CakevaultSession) UserInfo(arg0 common.Address) (struct {\n\tShares *big.Int\n\tLastDepositedTime *big.Int\n\tCakeAtLastUserAction *big.Int\n\tLastUserActionTime *big.Int\n}, error) {\n\treturn _Cakevault.Contract.UserInfo(&_Cakevault.CallOpts, arg0)\n}", "func UserInfo(message string) string {\n\treturn Encode(USERINFO, message)\n}", "func (_Cakevault *CakevaultCallerSession) UserInfo(arg0 common.Address) (struct {\n\tShares *big.Int\n\tLastDepositedTime *big.Int\n\tCakeAtLastUserAction *big.Int\n\tLastUserActionTime *big.Int\n}, error) {\n\treturn _Cakevault.Contract.UserInfo(&_Cakevault.CallOpts, arg0)\n}", "func (_Smartchef *SmartchefCallerSession) UserInfo(arg0 common.Address) (struct {\n\tAmount *big.Int\n\tRewardDebt *big.Int\n}, error) {\n\treturn _Smartchef.Contract.UserInfo(&_Smartchef.CallOpts, arg0)\n}", "func (_Lmc *LmcCallerSession) UserInfo(arg0 common.Address) (struct {\n\tFirstStakedBlockNumber *big.Int\n\tAmountStaked *big.Int\n}, error) {\n\treturn _Lmc.Contract.UserInfo(&_Lmc.CallOpts, arg0)\n}", "func GetUserInfo(c *gin.Context) {\n\tvar user models.User\n\tuuid := c.Params.ByName(\"uuid\")\n\tdb := db.GetDB()\n\n\tif err := db.Where(\"uuid = ?\", uuid).First(&user).Error; err != nil {\n\t\t// error handling...\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tc.JSON(200, user)\n}", "func (c *Client) UserInfo() (User, error) {\n\tvar (\n\t\tdata []byte\n\t\terr error\n\t)\n\tif data, err = c.apiRequest(apiUser); err != nil {\n\t\treturn User{}, errors.Wrap(err, \"contact user endpoint\")\n\t}\n\n\tv := struct {\n\t\tUser User `xml:\"user\"`\n\t}{}\n\terr = xml.Unmarshal(data, &v)\n\treturn v.User, err\n}", "func getUserInfo(user *driveactivity.User) string {\n\tif user.KnownUser != nil {\n\t\tif user.KnownUser.IsCurrentUser {\n\t\t\treturn \"people/me\"\n\t\t}\n\t\treturn user.KnownUser.PersonName\n\t}\n\treturn getOneOf(*user)\n}", "func (d *Dao) UserInfo(c context.Context, uids []int64) (userInfo map[int64]map[string]*live.Exp, err error) {\n\tip := metadata.String(c, metadata.RemoteIP)\n\tparams := url.Values{}\n\tfor _, uid := range uids {\n\t\tparams.Set(\"uids[]\", strconv.FormatInt(uid, 10))\n\t}\n\tparams.Set(\"attributes[]\", \"exp\")\n\tvar res struct {\n\t\tCode int `json:\"code\"`\n\t\tData map[int64]map[string]*live.Exp `json:\"data\"`\n\t}\n\tif err = d.client.Get(c, d.userInfo, ip, params, &res); err != nil {\n\t\treturn\n\t}\n\tif res.Code != ecode.OK.Code() {\n\t\terr = errors.Wrap(err, d.userInfo+\"?\"+params.Encode())\n\t\treturn\n\t}\n\tuserInfo = res.Data\n\treturn\n}", "func UserInfo(data UserInfoData) http.Handler {\n\treturn httputil.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {\n\t\treturn ui.ServePage(w, r, \"UserInfo\", data.ToJSON())\n\t})\n}", "func (_Smartchef *SmartchefCaller) UserInfo(opts *bind.CallOpts, arg0 common.Address) (struct {\n\tAmount *big.Int\n\tRewardDebt *big.Int\n}, error) {\n\tret := new(struct {\n\t\tAmount *big.Int\n\t\tRewardDebt *big.Int\n\t})\n\tout := ret\n\terr := _Smartchef.contract.Call(opts, out, \"userInfo\", arg0)\n\treturn *ret, err\n}", "func GetUserInfo(r *http.Request) (string, error) {\n\tuser, pass, ok := r.BasicAuth()\n\tif !ok {\n\t\treturn \"\", errors.New(\"Basic auth not provided\")\n\t}\n\tif pass == \"\" {\n\t\treturn \"\", errors.New(\"Invalid password\")\n\t}\n\treturn user, nil\n}", "func (p *Base) Info() (uuid, id, pass string) {\n\treturn p.UUID, p.ID, p.Password\n}", "func (s *UserService) MyInfo(ctx context.Context, options ...MyInfoOption) (*User, *Response, error) {\n\treq, err := s.client.NewRequest(http.MethodGet, \"users/@me\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tq := req.URL.Query()\n\tfor _, o := range options {\n\t\to.myInfoApply(&q)\n\t}\n\treq.URL.RawQuery = q.Encode()\n\n\tu := new(User)\n\tresp, err := s.client.Do(ctx, req, u)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn u, resp, nil\n}", "func (s *Store) GetUserInfo(_ context.Context, req *meta.StoreGetUserInfoRequest) (*meta.StoreGetUserInfoResponse, error) {\n\tlog.Debugf(\"GetUserInfo, user:%v\", req.User)\n\ta, err := s.user.getUserInfo(req.User)\n\tif err != nil {\n\t\treturn &meta.StoreGetUserInfoResponse{Header: &meta.ResponseHeader{Code: -1, Msg: err.Error()}}, nil\n\t}\n\n\treturn &meta.StoreGetUserInfoResponse{ID: a.ID, User: a.Name, NickName: a.NickName, Avatar: a.Avatar}, nil\n}", "func GetUserInfo(username string) (User, error) {\n\t// create a user\n\tuser := User{}\n\n\tstmt, err := mydb.DBConn().Prepare(\n\t\t\"select username, create_time from tb_user where username = ?\")\n\tif err != nil {\n\t\tfmt.Println(\"stmt err:\", err.Error())\n\t\treturn user, err\n\t}\n\tdefer stmt.Close()\n\n\terr = stmt.QueryRow(username).Scan(&user.Username, &user.CreateTime)\n\t// fmt.Printf(\"user info: %s\\n\",)\n\tif err != nil {\n\t\tfmt.Println(\"user info query err:\", err.Error())\n\t\treturn user, err\n\t}\n\treturn user, nil\n}", "func displayUserInfo(user *user) {\n\tfmt.Printf(\"ID: %v\\n\", user.id)\n\tfmt.Printf(\"Username : %v\\n\", strings.ToUpper(user.username))\n\tfmt.Printf(\"Full Name : %v %v\\n\", user.firstName, user.lastName)\n\tfmt.Printf(\"DOB : %v\\n\", user.dob)\n\tfmt.Printf(\"Age : %v\\n\", user.age)\t\n\tvar userStatus string = \"Inactive\"\n\tif user.active {\n\t\tuserStatus = \"Active\"\n\t}\t\n\tfmt.Printf(\"Status : %v\\n\", userStatus)\n\tfmt.Printf(\"Votes : %v\\n\", user.votes)\t\n\tfor i:=0; i< 50; i++ { fmt.Printf(\"%v\", \"-\") }\n\tfmt.Printf(\"\\n\")\n}", "func GetUserinfo(token string) Userinfo {\n\tvar userinfo Userinfo\n\tif err := json.Unmarshal(httphelper.GetBytes(token, endpoint), &userinfo); err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn userinfo\n}", "func (userInfo *NoAuthUserInfo) GetUserInfo(id string) (int, []byte, *http.Header, error) {\n\n\tuaaUser := &uaaUser{\n\t\tID: id,\n\t\tOrigin: \"noauth\",\n\t\tUsername: interfaces.DefaultAdminUserName,\n\t}\n\n\temails := make([]uaaUserEmail, 0)\n\tuaaUser.Emails = emails\n\n\tuaaUser.Name.GivenName = \"Admin\"\n\tuaaUser.Name.FamilyName = \"User\"\n\n\tgroups := make([]uaaUserGroup, 0)\n\tuaaUser.Groups = groups\n\n\tuaaUser.Meta.Version = 0\n\n\tjsonString, err := json.Marshal(uaaUser)\n\tif err != nil {\n\t\treturn 500, nil, nil, err\n\t}\n\n\treturn 200, jsonString, nil, nil\n}", "func (api *API) getUserInfo(token *oauth2.Token) (user, error) {\n\tclient := api.oauthConfig.Client(oauth2.NoContext, token)\n\n\t// Query the Google API to get information about the user\n\tuserinfoReq, err := client.Get(\"https://www.googleapis.com/oauth2/v3/userinfo\")\n\tif err != nil {\n\t\treturn user{}, err\n\t}\n\tdefer userinfoReq.Body.Close()\n\n\t// Read that information\n\tuserinfo, err := ioutil.ReadAll(userinfoReq.Body)\n\tif err != nil {\n\t\treturn user{}, err\n\t}\n\n\t// Parse client data\n\tu := user{}\n\terr = json.Unmarshal(userinfo, &u)\n\tif err != nil {\n\t\treturn user{}, err\n\t}\n\n\t// Check that there were no errors\n\tif u.Sub == \"\" {\n\t\treturn user{}, errors.New(\"invalid credentials to query Google API\")\n\t}\n\n\treturn u, nil\n}", "func User(r *http.Request) Info {\n\tv := r.Context().Value(userKey{})\n\tif info, ok := v.(Info); ok {\n\t\treturn info\n\t}\n\treturn nil\n}", "func (r *RouteHandler) getUserProfileInfo(c echo.Context) (*LoggedInUserData, error) {\n\tloggedIn := c.Get(custommiddleware.UserLoggedIn)\n\n\tloggedInBool, ok := loggedIn.(bool)\n\tif !ok || !loggedInBool {\n\t\treturn nil, errors.New(\"User is not logged in\")\n\t}\n\n\tl := LoggedInUserData{}\n\n\tid := c.Get(custommiddleware.UserIDKey)\n\n\tidInt, ok := id.(int64)\n\tif !ok {\n\t\tlog.Error(\"Could not assert id to int64\")\n\t\treturn nil, errors.New(\"could not assert id to int64\")\n\t}\n\n\tgetUserReq := userproto.GetUserFromIDRequest{\n\t\tUserID: idInt,\n\t}\n\n\tuserResp, err := r.u.GetUserFromID(context.TODO(), &getUserReq)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tl.Username = userResp.Username\n\t// l.ProfilePictureURL = userResp. // TODO\n\tl.Rank = int32(userResp.Rank)\n\tl.Email = userResp.Email\n\tl.UserID = idInt\n\treturn &l, nil\n}", "func (cred *OAuth2Credential) UserInfo(ctx context.Context) (*UserInfo, error) {\n\tif cred == nil {\n\t\treturn nil, errNilCredential\n\t}\n\tcred.mu.Lock()\n\tif cred.userInfo == nil {\n\t\tcred.mu.Unlock() // release lock b/c Token locks\n\t\t// Token assignes userInfo if nil...\n\t\tif _, err := cred.Token(ctx); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcred.mu.Lock()\n\t}\n\tu := *cred.userInfo\n\tcred.mu.Unlock()\n\treturn &u, nil\n}", "func (mc *client) GetUserInfo(accessToken string) (ui UserInfo, err error) {\n\treturn getUserInfo(mc.provider.UserInfoEndpoint.String(), accessToken, mc.config.HTTPClient)\n}", "func GetAuthUserInfo(c *gin.Context) {\n\tuserID := c.Writer.Header().Get(\"user\")\n\tcustomer := models.User{}\n\n\tuserRepository := user.NewUserRepository(models.GetDB())\n\n\t/* Here if everything is Ok we can generate User-Detail\n\tOtherwise, return error message as usual\n\t*/\n\tresp, statusCode := userRepository.GetByID(userID, customer)\n\tif statusCode == http.StatusOK {\n\t\tvar userFactory factory.UserInfoFactory\n\t\tresp[\"data\"] = userFactory.CreateDetail(resp[\"data\"])\n\n\t\tc.JSON(statusCode, resp)\n\t} else {\n\t\tc.JSON(statusCode, resp)\n\t}\n}", "func (c *Client) GetUserInfo(userID string) (*UserResponse, error) {\n\tif userID == \"\" {\n\t\treturn nil, errors.New(\"set user ID or \\\"self\\\"\")\n\t}\n\n\tres := &UserResponse{}\n\terr := c.doRequest(\"GET\", fmt.Sprintf(\"users/%v\", userID), nil, res)\n\treturn res, err\n}", "func GetUserInfo(r *http.Request) (user store.User, err error) {\n\n\tctx := r.Context()\n\tif ctx == nil {\n\t\treturn store.User{}, errors.New(\"no info about user\")\n\t}\n\tif u, ok := ctx.Value(contextKey(\"user\")).(store.User); ok {\n\t\treturn u, nil\n\t}\n\n\treturn store.User{}, errors.New(\"user can't be parsed\")\n}", "func (h *HandlerRepo) UserInfoHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.Method == \"GET\" {\n\t\thttp.Redirect(w, r, \"/status\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\th.Config.SCSManager.Put(r.Context(), \"url\", r.UserAgent())\n\tvar userInfo = &UserPayload{}\n\terr := json.NewDecoder(r.Body).Decode(&userInfo)\n\tif err != nil {\n\t\tlog.Println(\"Error in decoding the user payload\")\n\t}\n\n\tfmt.Println(userInfo)\n\treturn\n}", "func (c *ApplicationContext) TokenInfo(w http.ResponseWriter, r *http.Request) {\n\tuser := &models.User{\n\t\tModel: models.Model{\n\t\t\tID: int(r.Context().Value(\"id\").(float64)),\n\t\t},\n\t}\n\tc.DB.Find(&user, user)\n\n\tc.NewResponse(w).Status(200).SendJSON(Response{\n\t\tData: models.PublicUserData{User: user},\n\t})\n}", "func (_Cakevault *CakevaultCaller) UserInfo(opts *bind.CallOpts, arg0 common.Address) (struct {\n\tShares *big.Int\n\tLastDepositedTime *big.Int\n\tCakeAtLastUserAction *big.Int\n\tLastUserActionTime *big.Int\n}, error) {\n\tvar out []interface{}\n\terr := _Cakevault.contract.Call(opts, &out, \"userInfo\", arg0)\n\n\toutstruct := new(struct {\n\t\tShares *big.Int\n\t\tLastDepositedTime *big.Int\n\t\tCakeAtLastUserAction *big.Int\n\t\tLastUserActionTime *big.Int\n\t})\n\tif err != nil {\n\t\treturn *outstruct, err\n\t}\n\n\toutstruct.Shares = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\toutstruct.LastDepositedTime = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)\n\toutstruct.CakeAtLastUserAction = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)\n\toutstruct.LastUserActionTime = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int)\n\n\treturn *outstruct, err\n\n}", "func (a *Client) UserInfo(params *UserInfoParams) (*UserInfoOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewUserInfoParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"userInfo\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/user/{name}/{context}\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &UserInfoReader{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.(*UserInfoOK)\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 userInfo: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func ShowUserData(c *gin.Context) {\r\n\tvar info []models.Userinfo\r\n\tmodels.DB.Find(&info)\r\n\r\n\tc.JSON(200, gin.H{\"data\": info})\r\n}", "func (c *DetaClient) GetUserInfo() (*GetUserInfoResponse, error) {\n\tresp, err := c.ListSpaces()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &GetUserInfoResponse{\n\t\tDefaultSpace: resp[0].SpaceID,\n\t\tDefaultSpaceName: resp[0].Name,\n\t\tDefaultProject: runtime.DefaultProject,\n\t}, nil\n}", "func (s *UsersService) Info(user string) *UsersInfoCall {\n\tvar call UsersInfoCall\n\tcall.service = s\n\tcall.user = user\n\treturn &call\n}", "func (client *Client) GetProfileInfo() (model.User, error) {\n\tvar user model.User\n\terr := client.RestAPI.Get(rest.Rq{\n\t\tResult: &user,\n\t\tURL: rest.URL{\n\t\t\tPath: userInfoPath,\n\t\t\tParams: rest.P{},\n\t\t},\n\t})\n\treturn user, err\n}", "func (s *userServiceImpl) UserInfo(ctx context.Context, identityID uuid.UUID) (*repository.User, *repository.Identity, error) {\n\tvar identity *repository.Identity\n\terr := s.ExecuteInTransaction(func() error {\n\t\tvar err error\n\t\tidentity, err = s.Repositories().Identities().LoadWithUser(ctx, identityID)\n\t\tif err != nil {\n\t\t\treturn errors.NewUnauthorizedError(fmt.Sprintf(\"auth token contains id %s of unknown Identity\\n\", identityID))\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tlog.Debug(ctx, map[string]interface{}{\n\t\t\"identity_id\": identity.ID,\n\t\t\"user_id\": identity.User.ID,\n\t}, \"loaded identity and user\")\n\treturn &identity.User, identity, nil\n}", "func (_SingleAuto *SingleAutoCaller) UserInfo(opts *bind.CallOpts, arg0 *big.Int, arg1 common.Address) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _SingleAuto.contract.Call(opts, &out, \"userInfo\", arg0, arg1)\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func (d *Dao) UserInfo(c context.Context, mid int64) (res *model.UserInfo, err error) {\n\tvar (\n\t\trow *sql.Row\n\t)\n\tres = &model.UserInfo{}\n\trow = d.db.QueryRow(c, fmt.Sprintf(_userInfoSQL, hitInfo(mid)), mid)\n\tif err = row.Scan(&res.ID, &res.Mid, &res.Score, &res.BaseScore, &res.EventScore, &res.State, &res.CTime, &res.MTime); err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\terr = nil\n\t\t\tres = nil\n\t\t\treturn\n\t\t}\n\t\tlog.Error(\"row.Scan() error(%v)\", err)\n\t}\n\treturn\n}", "func (s *Server) getUserInfo(code string) ([]byte, error) {\n\ttoken, err := s.oauthConfig.Exchange(oauth2.NoContext, code)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"code exchange failed: %s\", err)\n\t}\n\tresp, err := http.Get(\"https://www.googleapis.com/oauth2/v2/userinfo?access_token=\" + token.AccessToken)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting user info: %s\", err)\n\t}\n\tdefer resp.Body.Close()\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading user info response: %s\", err)\n\t}\n\treturn b, nil\n}", "func (cc *ClusterController) getUserInfo(sessions *userSessionsStruct, clientAddress uint64) *dataformat.User {\n\tinterSession := cc.metric.MetricInterSessions.calc(sessions)\n\tinterSessionMean, interSessionMin, interSessionMax, interSessionStdDev := utils.GetDistributionStats(interSession)\n\tuserInfo := &dataformat.User{\n\t\tClientAddress: clientAddress,\n\t\tNumSessions: int64(len(sessions.sessions)),\n\t\tInterSession: &dataformat.Distribution{Mean: interSessionMean,\n\t\t\tMin: int64(interSessionMin),\n\t\t\tMax: int64(interSessionMax),\n\t\t\tStdDev: interSessionStdDev,\n\t\t},\n\t}\n\treturn userInfo\n}", "func adapterUsersInfo(c *gin.Context) {\n\tvar informationUserInfoDTO = id.InformationUserInfoDTO{\n\t\tUsers: id.Users,\n\t\tCoordinator: election.CoordinatorUserId,\n\t}\n\t// return all registered users and coordinator information\n\tc.JSON(200, informationUserInfoDTO)\n}", "func (dal *UserDAL) GetUserInfo(id int) (models.User, error) {\n\tvar u models.User\n\terr := dal.db.Get(&u, \"SELECT * FROM userdata WHERE userid = $1\", id)\n\tif err != nil {\n\t\treturn models.User{}, err\n\t}\n\n\treturn u, nil\n}", "func (client *Client) GetUserInfo(clientID string) (UserFullData, error) {\n\tres, err := client.ListClient([]byte(clientID))\n\tif err != nil {\n\t\treturn UserFullData{}, err\n\t}\n\n\tresUnmarshaled := UserFullData{}\n\tif err := json.Unmarshal(res, &resUnmarshaled); err != nil {\n\t\treturn UserFullData{}, err\n\t}\n\n\treturn resUnmarshaled, err\n}", "func GetUserInfo(apikey string) (map[string]string, error) {\n\tarvanConfig := config.GetConfigInfo()\n\tarvanServer := arvanConfig.GetServer()\n\thttpReq, err := http.NewRequest(\"GET\", arvanServer+apiPrefix+defaultRegion+userEndpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thttpReq.Header.Add(\"Authorization\", apikey)\n\thttpReq.Header.Add(\"User-Agent\", \"ar-cli\")\n\thttpResp, err := http.DefaultClient.Do(httpReq)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// read body\n\tdefer httpResp.Body.Close()\n\tbody, err := ioutil.ReadAll(httpResp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif httpResp.StatusCode != http.StatusOK {\n\t\tif httpResp.StatusCode >= 400 && httpResp.StatusCode < 500 {\n\t\t\treturn nil, errors.New(\"invalid authorization credentials\")\n\t\t} else {\n\t\t\treturn nil, errors.New(\"server error. try again later\")\n\t\t}\n\t}\n\n\tuser := make(map[string]string)\n\t// parse response\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn user, nil\n}", "func GetInfo(accountID string, tx *sql.Tx) (info Info, err error) {\n\tmapper := rlt.NewAccountMapper(tx)\n\trow, err := mapper.FindAccountByID(accountID)\n\tif err != nil {\n\t\treturn info, err\n\t}\n\tinfo.ID = row.ID\n\tinfo.Domain = row.Domain.String\n\tinfo.UserName = row.UserName\n\tinfo.DisplayName = row.DisplayName\n\tinfo.Email = row.Email\n\treturn\n}", "func (j *Jwt) GetUserInfo(tokenStr string) *Jwt {\n\ttoken := j.GetTokenMust(tokenStr)\n\tclaims := token.Claims.(jwt.MapClaims)\n\n\tif userID, ok := claims[\"uid\"].(float64); ok {\n\t\tj.UID = uint(userID)\n\t} else {\n\t\tpanic(\"invalid token: uid in token is not of a type uint convertible\")\n\t}\n\n\tif userName, ok := claims[\"username\"].(string); ok {\n\t\tj.Username = userName\n\t} else {\n\t\tpanic(\"invalid token: username in token is not of a type string\")\n\t}\n\n\tif name, ok := claims[\"name\"].(string); ok {\n\t\tj.Name = name\n\t} else {\n\t\tpanic(\"invalid token: name in token is not of a type string\")\n\t}\n\treturn j\n}", "func (m *IGApiManager) GetUserInfo(username string) (ui UserInfo, err error) {\n\t//url := strings.Replace(urlUserInfo, \"{{USERNAME}}\", username, 1)\n\turl := \"https://www.instagram.com/\" + username + \"/\"\n\tb, err := m.getHTTPResponse(url, \"GET\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t//r := rawUserResp{}\n\tr := SharedData{}\n\tif err = json.Unmarshal(getJsonBytes(b), &r); err != nil {\n\t\treturn\n\t}\n\n\tif err = checkSharedData(r); err != nil {\n\t\treturn\n\t}\n\n\tui = r.EntryData.ProfilePage[0].GraphQL.User\n\treturn\n}", "func (b *OGame) GetUserInfos() ogame.UserInfos {\n\treturn b.WithPriority(taskRunner.Normal).GetUserInfos()\n}", "func (h *Handler) Info(args []string) error {\n\tvar sessions []models.Session\n\th.writeToUser(\"You are %v, logged from %v with IP of %v.\", h.CurrentUser.Name, h.Hostname, h.IP)\n\th.writeToUser(\"Your previous sessions: \")\n\terr := models.DB.Table(\"session\").Find(&sessions).Where(\"userId=?\", h.CurrentUser.ID).Error\n\tif err != nil {\n\t\treturn err\n\t}\n\tk := 0\n\tfor _, v := range sessions {\n\t\tk++\n\t\th.writeToUser(\"%v) %v(%v) since %v \\n\\r\", k, v.Hostname, v.IP, v.CreatedAt.Format(\"15:04:05\"))\n\t}\n\th.writeToUser(\"\")\n\treturn nil\n}", "func (session Session) GetUserInfo(userName string) (result UserInfo, err error) {\n\treq, err := getUsers(userName)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tsession.addBearerAuth(req)\n\tres, err := session.client.Do(req)\n\tif err != nil {\n\t\tlog.Printf(\"Error while execute GetUserInfo request: %s\", err)\n\t}\n\n\tif res.StatusCode != 200 {\n\t\terr = fmt.Errorf(\"Request returned: %d\", res.StatusCode)\n\t\treturn\n\t}\n\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tlog.Printf(\"Error reading response body: %s\", err)\n\t\treturn\n\t}\n\n\tvar d dataResult\n\tif err = json.Unmarshal(body, &d); err != nil {\n\t\tlog.Printf(\"Error while parsing response body: %s\", err)\n\t\tlog.Printf(\"Body: %s\", body)\n\t\treturn\n\t}\n\n\tfor _, inner := range d.Data {\n\t\t// return first user, even if there are multiple results.\n\t\terr = json.Unmarshal(inner, &result)\n\t\treturn\n\t}\n\n\terr = fmt.Errorf(\"User not found\")\n\treturn\n}", "func (usr user) whoami() string {\n return fmt.Sprint(\"My name is \", usr.name)\n}", "func GetUserInfo(c echo.Context) (*multi_tenant.UserInfo, error) {\n\ts, _ := Get(c)\n\tui, ok := s.Values[\"userinfo\"].(multi_tenant.UserInfo)\n\tif !ok {\n\n\t\treturn nil, errors.New(\"invalid type casting\")\n\t}\n\treturn &ui, nil\n}", "func (ctx UserManagement) GetUserInformation(username string, password string) config.User {\n\tuser, userCouldBeFound := ctx.TryGetUserInformation(username, password)\n\tif userCouldBeFound {\n\t\treturn user\n\t}\n\n\tpanic(\"User not found\")\n}", "func (trading *TradingProvider) Info() (ui schemas.UserInfo, err error) {\n\tvar resp map[string]UserBalance\n\tvar b []byte\n\n\tuserBalance := make(map[string]schemas.Balance)\n\n\tpayload := httpclient.Params()\n\tnonce := time.Now().UnixNano()\n\tpayload.Set(\"nonce\", strconv.FormatInt(nonce, 10))\n\tpayload.Set(\"command\", commandBalance)\n\n\tb, err = trading.httpClient.Post(tradingAPI, httpclient.Params(), payload, true)\n\tif err != nil {\n\t\treturn\n\t}\n\tif err = json.Unmarshal(b, &resp); err != nil {\n\t\treturn\n\t}\n\tfor coin, value := range resp {\n\t\tuserBalance[coin] = value.Map(coin)\n\t}\n\n\tprices, err := trading.prices()\n\tif err != nil {\n\t\tlog.Println(\"Error getting prices for balances\", err)\n\t}\n\n\tui.Balances = userBalance\n\tui.Prices = prices\n\treturn\n}", "func (provider *GoogleOAuthProvider) GetUserInfo() (*models.UserInfo, error) {\n\tvar user_info models.UserInfo\n\n\trequest, err := grequests.Get(\"https://www.googleapis.com/oauth2/v1/userinfo?alt=json\", &grequests.RequestOptions{\n\t\tHeaders: map[string]string{\n\t\t\t\"Authorization\": \"Bearer \" + provider.token,\n\t\t},\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar google_user_info models.GoogleUserInfo\n\terr = request.JSON(&google_user_info)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif google_user_info.ID == \"\" {\n\t\treturn nil, errors.New(\"Invalid oauth token\")\n\t}\n\n\tuser_info.ID = \"google\" + google_user_info.ID\n\tuser_info.Email = google_user_info.Email\n\tuser_info.Username = google_user_info.Name\n\tuser_info.FirstName = google_user_info.FirstName\n\tuser_info.LastName = google_user_info.LastName\n\n\tprovider.isVerifiedUser = google_user_info.IsVerified\n\n\treturn &user_info, nil\n}", "func OpenIDConnectUserinfo(ctx *middlewares.AutheliaCtx, rw http.ResponseWriter, req *http.Request) {\n\tvar (\n\t\ttokenType fosite.TokenType\n\t\trequester fosite.AccessRequester\n\t\tclient *oidc.Client\n\t\terr error\n\t)\n\n\toidcSession := oidc.NewSession()\n\n\tif tokenType, requester, err = ctx.Providers.OpenIDConnect.Fosite.IntrospectToken(\n\t\treq.Context(), fosite.AccessTokenFromRequest(req), fosite.AccessToken, oidcSession); err != nil {\n\t\trfc := fosite.ErrorToRFC6749Error(err)\n\n\t\tctx.Logger.Errorf(\"UserInfo Request failed with error: %+v\", rfc)\n\n\t\tif rfc.StatusCode() == http.StatusUnauthorized {\n\t\t\trw.Header().Set(\"WWW-Authenticate\", fmt.Sprintf(`Bearer error=\"%s\",error_description=\"%s\"`, rfc.ErrorField, rfc.GetDescription()))\n\t\t}\n\n\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, err)\n\n\t\treturn\n\t}\n\n\tclientID := requester.GetClient().GetID()\n\n\tif tokenType != fosite.AccessToken {\n\t\tctx.Logger.Errorf(\"UserInfo Request with id '%s' on client with id '%s' failed with error: bearer authorization failed as the token is not an access_token\", requester.GetID(), client.GetID())\n\n\t\terrStr := \"Only access tokens are allowed in the authorization header.\"\n\t\trw.Header().Set(\"WWW-Authenticate\", fmt.Sprintf(`Bearer error=\"invalid_token\",error_description=\"%s\"`, errStr))\n\t\tctx.Providers.OpenIDConnect.WriteErrorCode(rw, req, http.StatusUnauthorized, errors.New(errStr))\n\n\t\treturn\n\t}\n\n\tif client, err = ctx.Providers.OpenIDConnect.Store.GetFullClient(clientID); err != nil {\n\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, errors.WithStack(fosite.ErrServerError.WithHint(\"Unable to assert type of client\")))\n\n\t\treturn\n\t}\n\n\tclaims := requester.GetSession().(*model.OpenIDSession).IDTokenClaims().ToMap()\n\tdelete(claims, \"jti\")\n\tdelete(claims, \"sid\")\n\tdelete(claims, \"at_hash\")\n\tdelete(claims, \"c_hash\")\n\tdelete(claims, \"exp\")\n\tdelete(claims, \"nonce\")\n\n\taudience, ok := claims[\"aud\"].([]string)\n\n\tif !ok || len(audience) == 0 {\n\t\taudience = []string{client.GetID()}\n\t} else {\n\t\tfound := false\n\n\t\tfor _, aud := range audience {\n\t\t\tif aud == clientID {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif found {\n\t\t\taudience = append(audience, clientID)\n\t\t}\n\t}\n\n\tclaims[\"aud\"] = audience\n\n\tvar (\n\t\tkeyID, token string\n\t)\n\n\tctx.Logger.Tracef(\"UserInfo Response with id '%s' on client with id '%s' is being sent with the following claims: %+v\", requester.GetID(), clientID, claims)\n\n\tswitch client.UserinfoSigningAlgorithm {\n\tcase \"RS256\":\n\t\tvar jti uuid.UUID\n\n\t\tif jti, err = uuid.NewRandom(); err != nil {\n\t\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, fosite.ErrServerError.WithHintf(\"Could not generate JTI.\"))\n\n\t\t\treturn\n\t\t}\n\n\t\tclaims[\"jti\"] = jti.String()\n\t\tclaims[\"iat\"] = time.Now().Unix()\n\n\t\tif keyID, err = ctx.Providers.OpenIDConnect.KeyManager.Strategy().GetPublicKeyID(req.Context()); err != nil {\n\t\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, fosite.ErrServerError.WithHintf(\"Could not find the active JWK.\"))\n\n\t\t\treturn\n\t\t}\n\n\t\theaders := &jwt.Headers{\n\t\t\tExtra: map[string]interface{}{\"kid\": keyID},\n\t\t}\n\n\t\tif token, _, err = ctx.Providers.OpenIDConnect.KeyManager.Strategy().Generate(req.Context(), claims, headers); err != nil {\n\t\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, err)\n\n\t\t\treturn\n\t\t}\n\n\t\trw.Header().Set(\"Content-Type\", \"application/jwt\")\n\t\t_, _ = rw.Write([]byte(token))\n\tcase \"none\", \"\":\n\t\tctx.Providers.OpenIDConnect.Write(rw, req, claims)\n\tdefault:\n\t\tctx.Providers.OpenIDConnect.WriteError(rw, req, errors.WithStack(fosite.ErrServerError.WithHintf(\"Unsupported UserInfo signing algorithm '%s'.\", client.UserinfoSigningAlgorithm)))\n\t}\n}", "func (sess *Session) Info() *payment.UserInfo {\n\n\tvar info = &payment.UserInfo{}\n\tif sess.Payment != nil {\n\t\tinfo = sess.Payment.Info()\n\t}\n\n\tif sess.IP != \"\" {\n\t\tinfo.Ip = sess.IP\n\t}\n\n\treturn info\n}", "func (_obj *DataService) GetUserInfo(wx_id string, userInfo *UserInfo, _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_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = (*userInfo).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn ret, err\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, \"getUserInfo\", _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 = (*userInfo).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn ret, err\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 (us *UserService) RetrieveInfo(ctx context.Context, userID int) (*resources.User, error) {\n\tdoc, err := us.retrieveInfo(ctx, \"one.user.info\", userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resources.CreateUserFromXML(doc.Root()), nil\n}", "func (_Lmc *LmcCaller) UserInfo(opts *bind.CallOpts, arg0 common.Address) (struct {\n\tFirstStakedBlockNumber *big.Int\n\tAmountStaked *big.Int\n}, error) {\n\tvar out []interface{}\n\terr := _Lmc.contract.Call(opts, &out, \"userInfo\", arg0)\n\n\toutstruct := new(struct {\n\t\tFirstStakedBlockNumber *big.Int\n\t\tAmountStaked *big.Int\n\t})\n\tif err != nil {\n\t\treturn *outstruct, err\n\t}\n\n\toutstruct.FirstStakedBlockNumber = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\toutstruct.AmountStaked = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)\n\n\treturn *outstruct, err\n\n}", "func (i *Instagram) GetUserNameInfo(userNameID int64) (*UserNameInfo, error) {\n\n\tendpoint := APIURL + \"/users/\" + strconv.FormatInt(userNameID, 10) + \"/info/?\"\n\n\tresp, err := i.request(\"GET\", endpoint, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar object *UserNameInfo\n\terr = json.Unmarshal(resp, &object)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn object, nil\n}", "func authInfoHandler(w http.ResponseWriter, r *http.Request) {\n\tencodedInfo := r.Header.Get(\"X-Endpoint-API-UserInfo\")\n\tif encodedInfo == \"\" {\n\t\tw.Write([]byte(`{\"id\": \"anonymous\"}`))\n\t\treturn\n\t}\n\n\tb, err := base64.StdEncoding.WithPadding(base64.NoPadding).DecodeString(encodedInfo)\n\tif err != nil {\n\t\terrorf(w, http.StatusInternalServerError, \"Could not decode auth info: %v\", err)\n\t\treturn\n\t}\n\tw.Write(b)\n}", "func ShowUserDetails() error {\n\tspinner.Start()\n\tuser, err := getCurrentUser()\n\tspinner.Stop()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(`NAME: %s\nEMAIL: %s\nAPPS:\n`, user.Details.Name, user.Email)\n\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader([]string{\"Id\", \"Name\"})\n\tfor name, id := range user.Apps {\n\t\ttable.Append([]string{id, name})\n\t}\n\ttable.Render()\n\n\treturn nil\n}", "func (c Client) UserInformation() (*UserInformation, error) {\n\tv := UserInformationContainer{}\n\turl := APIURL + \"/user/\" + c.Key + \"/user-information\"\n\te := Call(\"GET\", url, &v)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\treturn &v.UserInformation, nil\n}", "func printUserDetails(user controllers.User) {\n\tfmt.Println()\n\tfmt.Println(\"User Details\")\n\tfmt.Println(\"=====================\")\n\tfmt.Println(\"FirstName :\", user.FirstName)\n\tfmt.Println(\"ID :\", user.ID)\n\tfmt.Println(\"LastName :\", user.LastName)\n\tfmt.Println(\"UserType :\", user.Type)\n\tfmt.Println(\"LivingSpace - \")\n\tfmt.Println(\"\\tCapacity :\", user.LivingSpace.Capacity)\n\tfmt.Println(\"\\tID :\", user.LivingSpace.ID)\n\tfmt.Println(\"\\tName :\", user.LivingSpace.Name)\n\tfmt.Println(\"\\tType :\", user.LivingSpace.Type)\n\tfmt.Println(\"Office - \")\n\tfmt.Println(\"\\tCapacity :\", user.Office.Capacity)\n\tfmt.Println(\"\\tID :\", user.Office.ID)\n\tfmt.Println(\"\\tName :\", user.Office.Name)\n\tfmt.Println(\"\\tType :\", user.Office.Type)\n\tfmt.Println(\"=====================\")\n\tfmt.Println()\n}", "func authInfoHandler(w http.ResponseWriter, r *http.Request) {\n\tencodedInfo := r.Header.Get(\"X-Endpoint-API-UserInfo\")\n\tif encodedInfo == \"\" {\n\t\tw.Write([]byte(`{\"id\": \"anonymous\"}`))\n\t\treturn\n\t}\n\n\tb, err := base64.StdEncoding.DecodeString(encodedInfo)\n\tif err != nil {\n\t\terrorf(w, http.StatusInternalServerError, \"Could not decode auth info: %v\", err)\n\t\treturn\n\t}\n\tw.Write(b)\n}", "func UserInfos() []*UserInfo {\n\tuis := []*UserInfo{\n\t\t{Name: UsrTest, GroupName: grpTest},\n\t\t{Name: UsrGrp, GroupName: grpTest},\n\t\t{Name: UsrOth, GroupName: grpOther},\n\t}\n\n\treturn uis\n}", "func getUserDetails(access_token string) (int64, string, string, string, error) {\n\n\tres, err := http.Get(\"https://graph.facebook.com/me?fields=id,name,email,gender&access_token=\"+access_token)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn 0, \"\", \"\", \"\", GraphErr\n\t}\n\n\tbody, err := getResponseBody(res.Body)\n\tif err != nil {\n\t\treturn 0, \"\", \"\", \"\", GraphErr\n\t}\n\n\tvar data map[string] string\n\terr = json.Unmarshal(body, &data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn 0, \"\", \"\", \"\", GraphErr\t\n\t}\n\n\tid, err := strconv.ParseInt(data[\"id\"], 10, 64)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn 0, \"\", \"\", \"\", GraphErr\t\n\t}\n\n\treturn id, data[\"name\"], data[\"email\"], data[\"gender\"], nil\n}", "func (a *HydraKratosConnector) GetUserInfo(userID string) (*UserInfo, error) {\n\tkratosInfo, err := a.Client.GetUserInfo(context.Background(), userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn transformKratosUserInfoToUserInfo(kratosInfo)\n}", "func GetUserGoogleInfo(u *user.User) UserInfo {\n\tif appengine.IsDevAppServer() {\n\t\treturn UserInfo{Id: fmt.Sprintf(\"%d\", rand.Int63()), Email: u.Email, Name: \"John Smith\"}\n\t}\n\treturn UserInfo{Id: u.ID, Email: u.Email, Name: u.String()}\n}", "func TestClientUserInfoOK(t *testing.T) {\n\tusername := \"gregavola\"\n\tc, done := userInfoTestClient(t, func(t *testing.T, w http.ResponseWriter, r *http.Request) {\n\t\tpath := \"/v4/user/info/\" + username + \"/\"\n\t\tif p := r.URL.Path; p != path {\n\t\t\tt.Fatalf(\"unexpected URL path: %q != %q\", p, path)\n\t\t}\n\n\t\tw.Write(gregavolaUserJSON)\n\t})\n\tdefer done()\n\n\tu, _, err := c.User.Info(username, false)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif id := u.UID; id != 1 {\n\t\tt.Fatalf(\"unexpected UID: %d != %d\", id, 1)\n\t}\n\tif id := u.ID; id != 1 {\n\t\tt.Fatalf(\"unexpected ID: %d != %d\", id, 1)\n\t}\n\tif u := u.UserName; u != username {\n\t\tt.Fatalf(\"unexpected username: %q != %q\", u, username)\n\t}\n}", "func updateUserInfo(s *tg.Session, update telegram.Update) {\n\tvar user *telegram.User\n\n\tswitch {\n\tcase update.Message != nil && update.Message.From != nil:\n\t\tuser = update.Message.From\n\n\tcase update.CallbackQuery != nil && update.CallbackQuery.From != nil:\n\t\tuser = update.CallbackQuery.From\n\n\tcase update.InlineQuery != nil && update.InlineQuery.From != nil:\n\t\tuser = update.InlineQuery.From\n\t}\n\n\tif user == nil {\n\t\treturn\n\t}\n\n\ts.State.Username = user.Username\n\ts.State.FirstName = user.FirstName\n\ts.State.LastName = user.LastName\n\ts.State.LanguageCode = user.LanguageCode\n}", "func (u *Userinfo) String() string {\n\tif u == nil {\n\t\treturn \"\"\n\t}\n\ts := escape(u.username, encodeUserPassword)\n\tif u.passwordSet {\n\t\ts += \":\" + escape(u.password, encodeUserPassword)\n\t}\n\treturn s\n}", "func (d *Dao) Info(c context.Context, id int64) (res *model.VipUserInfo, err error) {\n\taddCache := true\n\tres, err = d.CacheInfo(c, id)\n\tif err != nil {\n\t\taddCache = false\n\t\terr = nil\n\t}\n\tif res != nil {\n\t\tprom.CacheHit.Incr(\"Info\")\n\t\treturn\n\t}\n\tprom.CacheMiss.Incr(\"Info\")\n\tres, err = d.RawInfo(c, id)\n\tif err != nil {\n\t\treturn\n\t}\n\tif res == nil {\n\t\tres = &model.VipUserInfo{VipType: 0, VipStatus: 0}\n\t}\n\tif !addCache {\n\t\treturn\n\t}\n\td.cache.Save(func() {\n\t\td.AddCacheInfo(metadata.WithContext(c), id, res)\n\t})\n\treturn\n}", "func (s *SocketModeAdapter) GetUserInfo(userID string) (*adapter.UserInfo, error) {\n\tu, err := s.client.GetUserInfo(userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn newUserInfoFromSlackUser(u), nil\n}", "func (s *InfoService) User(ctx context.Context) (user *User, resp *http.Response, err error) {\n\tu := \"/api/v1/infos/user\"\n\treq, err := s.client.NewRequest(\"GET\", u, \"\")\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tresp, err = s.client.Do(ctx, req, &user)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn user, resp, nil\n}", "func (l *RemoteProvider) GetUserDetails(req *http.Request) (*User, error) {\n\ttoken, err := l.GetToken(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tuser, err := l.fetchUserDetails(token)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn user, nil\n}", "func userShow(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tvars := mux.Vars(r)\n\tmember := cleanInput(vars[\"member\"])\n\tdb := co.DbConnection(dbc)\n\tstmtQryNm, err := db.Prepare(\"SELECT user_name, email, display_name FROM members where user_name = ? ;\")\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n\tresults, err := stmtQryNm.Query(member)\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n var users []userInfo\n\tfor results.Next() {\n\t\tvar user userInfo\n\t\terr = results.Scan(&user.Name, &user.Email, &user.Display)\n\t\tif err != nil {\n\t\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t\t}\n \tusers = append(users, user)\n\t}\n\tresults.Close()\n stmtQryNm.Close()\n\tdb.Close()\n\tjsonPrintUser(w, users)\n return\n}", "func GetUser(context *gin.Context) {\n\t//TODO: implement me uwu\n\tJwtCtx := login.ExtractClaims(context)\n\t// identity claim is the username in the database\n\tusername := JwtCtx[jwt.IdentityKey]\n\tuserData := database.GetUser(username.(string))\n\tpayload := models.UserInfoPayload{\n\t\tUserCommon: userData.UserCommon,\n\t}\n\tcontext.JSON(http.StatusOK, payload)\n}", "func (s *Service) asoAccountInfo(c context.Context, userid string) (info *model.AsoAccount, err error) {\n\tvar acs []*model.AsoAccount\n\tif acs, err = s.d.AsoAccount(c, userid, model.DefaultHash(userid)); err != nil {\n\t\treturn\n\t}\n\tif len(acs) == 0 {\n\t\terr = ecode.UserNotExist\n\t\treturn\n\t}\n\tif len(acs) > 1 {\n\t\terr = ecode.UserDuplicate\n\t\treturn\n\t}\n\tinfo = acs[0]\n\treturn\n}", "func getUserHandler(w http.ResponseWriter, r *http.Request) {\n\tuser, err := user.Current()\n\tif err != nil {\n\t\tfmt.Fprintf(w, \"unable to get user: %s\", err)\n\t}\n\n\tfmt.Fprintf(w, \"User: %s\\nUID: %s\\nGID: %s\\n\", user.Username, user.Uid, user.Gid)\n}", "func (u *User) TFAInfo() model.TFAInfo { return u.userData.TFAInfo }", "func DisplayUAAInfo(w http.ResponseWriter, r *http.Request) {\n\tapiQuery := \"/info\"\n\tuaaRespBytes, flash, userNameVal := ClientRequest(w, r, apiQuery)\n\tuaaResp := ServerInfo{}\n\tif uaaServErr := json.Unmarshal([]byte(uaaRespBytes), &uaaResp); uaaServErr != nil {\n\t\tfmt.Println(uaaServErr)\n\t}\n\tdata := CredentialPageData{\n\t\tPageTitle: \"UAA Info\",\n\t\tServerInfo: uaaResp,\n\t\tUserName: userNameVal,\n\t\tFlash: flash,\n\t}\n\ttmpl := template.Must(template.ParseFiles(\"templates/uaainfo.html\", \"templates/base.html\"))\n\ttmpl.ExecuteTemplate(w, \"base\", data)\n}", "func describeUser(u User) string {\n description := fmt.Sprintf(\"Name: %s %s, Email: %s, ID: %d\", u.FirstName, u.LastName, u.Email, u.ID)\n return description \n}" ]
[ "0.81300217", "0.80130154", "0.79929495", "0.7749624", "0.7628281", "0.7620686", "0.7594106", "0.7543463", "0.74675536", "0.7466975", "0.74561185", "0.74452555", "0.7443553", "0.7443248", "0.7388844", "0.73823124", "0.7374704", "0.73674333", "0.7340772", "0.7333306", "0.7315954", "0.72611153", "0.7202957", "0.7202295", "0.7170958", "0.7108669", "0.7083278", "0.70796996", "0.70429444", "0.70287913", "0.70126164", "0.6995252", "0.69695383", "0.6955976", "0.69547665", "0.6938119", "0.68872863", "0.6839827", "0.68387437", "0.6834551", "0.6833401", "0.68321395", "0.6788003", "0.6772191", "0.6771679", "0.6764574", "0.6747097", "0.67463654", "0.6744339", "0.6732729", "0.67233425", "0.6723269", "0.6702522", "0.67002493", "0.669235", "0.6677233", "0.6660889", "0.66593313", "0.6640488", "0.66388136", "0.6611803", "0.65859085", "0.6564511", "0.6563418", "0.65458226", "0.6540577", "0.65131706", "0.65101594", "0.6495015", "0.64917845", "0.6487839", "0.64858603", "0.64712983", "0.64674115", "0.6439157", "0.64287525", "0.6419053", "0.64102876", "0.64098245", "0.6404459", "0.6399413", "0.63379806", "0.6322645", "0.62983847", "0.62919414", "0.6277927", "0.6264589", "0.623727", "0.6226159", "0.62210524", "0.62095344", "0.6197041", "0.6196005", "0.61950153", "0.61913234", "0.6189933", "0.61823994", "0.6175015", "0.6173843", "0.6171766" ]
0.7441929
14
UserExist is a function to determine if the user exist
func UserExist(db *gorm.DB, tel string) bool { var user model.User db.First(&user, "telephone = ?", tel) if user.ID != 0 { return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestCheckUserIsExist_InputExistUser_ReturnTrue(t *testing.T) {\n\tassert.Equal(t, true, CheckUserIsExist(\"jane\"))\n}", "func IsUserExist(qr db.Queryer, email string) bool {\n\tstr := \"SELECT count(*) as cnt FROM users WHERE email = ?\"\n\tuid := int64(0)\n\terr := qr.Get(&uid, str, email)\n\tif err != nil {\n\t\tlog.Println(\"err\", err)\n\t\treturn false\n\t}\n\tlog.Println(\"uid\", err)\n\tif uid > 0 {\n\t\treturn true\n\t}\n\n\treturn false\n\n}", "func does_user_exist(uname string) (string, bool) {\n\tuser_map_lock.Lock()\n\tdefer user_map_lock.Unlock()\n\tif _, is_exist := user_map[uname]; is_exist {\n\t\treturn fmt.Sprintf(\"success: user exists %s\\n\", END_TAG), false\n\t} else {\n\t\treturn fmt.Sprintf(\"error: no such user %s\\n\", END_TAG), false\n\t}\n}", "func UserExistDb(email string) bool {\n\tlog.Println(\"call db func\")\n\tif _, ok := db[email]; !ok {\n\t\treturn false\n\t}\n\treturn true\n}", "func isUserExist(usernameQuery string) bool {\n\tvar user User_DB\n\terr := mysql_client.QueryRow(\"SELECT username, password, kind FROM User WHERE username=?\", usernameQuery).Scan(&user.Username, &user.Password, &user.Kind)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}", "func (u *User) checkExistUser() error {\n\tif u.Id == \"\" && u.Name == \"\" {\n\t\treturn fmt.Errorf(\"invalid user\")\n\t}\n\n\tif u.Id != \"\" {\n\t\t_,err := GetUserById(u.Id)\n\t\tif err == nil {\n\t\t\treturn fmt.Errorf(\"user exist\")\n\t\t}\n\t}\n\n\tif u.Name != \"\" {\n\t\t_,err := GetUserByUserName(u.Name)\n\t\tif err == nil {\n\t\t\treturn fmt.Errorf(\"user exist\")\n\t\t}\n\t}\n\n\treturn nil\n}", "func CheckExistUser(email string) (models.User, bool, string) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\n\t//When end instruction remove timeout operation and liberate context\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"socialnetwork\")\n\tcollection := db.Collection(\"Users\")\n\n\tobject := bson.M{\"Email\": email}\n\n\tvar result models.User\n\n\terr := collection.FindOne(ctx, object).Decode(&result)\n\n\tID := result.ID.Hex()\n\n\tif err != nil {\n\t\treturn result, false, ID\n\t}\n\n\treturn result, true, ID\n\n}", "func UserExist(username string) bool {\n\torm := get_DBFront()\n\tvar user User\n\terr := orm.SetTable(\"user\").Where(\"username=?\", username).Find(&user)\n\tif !check_err(err) {\n\t\tLog(Log_Struct{\"error\", \"DB_Error_Line_185\", err})\n\t\treturn false\n\t}\n\treturn true\n}", "func userExists(username string) bool {\n\tif _, err := user.Lookup(username); err == nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func (s *Store) UserExist(token string) bool {\n\texists, err := s.ES.IndexExists(token).Do()\n\tif err != nil || !exists {\n\t\treturn false\n\t}\n\treturn true\n}", "func (db *LocalDb) DoesUserExist(name string) bool {\n\t_, ok := db.users[name]\n\treturn ok\n}", "func (u UserRepo) IsExist(login string) (bool, error) {\n\texistingUser, err := u.FindByLogin(login)\n\tif err != nil && !strings.Contains(err.Error(), \"sql: Rows are closed\") {\n\t\treturn false, err\n\t} else if existingUser.ID != 0 {\n\t\treturn true, nil\n\t}\n\n\treturn false, nil\n}", "func (this *managerStruct) UserExists(name string) bool {\n\tthis.mutex.RLock()\n\tid := this.getUserId(name)\n\tthis.mutex.RUnlock()\n\texists := id >= 0\n\treturn exists\n}", "func CheckUserExists(username string, table string, session *r.Session) bool {\n\tvar u interface{}\n\tdb := os.Getenv(\"DB\")\n\t// userTable := os.Getenv(\"USERTABLE\")\n\tcur, _ := r.DB(db).Table(table).GetAllByIndex(\"username\", username).Run(session)\n\t_ = cur.One(&u)\n\tcur.Close()\n\t// fmt.Println(u)\n\tif u == nil {\n\t\t// fmt.Println(\"NO\")\n\t\treturn false\n\t}\n\t// fmt.Println(\"YES\")\n\treturn true\n}", "func (wu *WxUser) Exists() bool { //wx_users\n\treturn wu._exists\n}", "func (db *Database) UserExists(name string) (bool, error) {\n\trow := db.db.QueryRow(`\n\t\tSELECT id FROM melodious.accounts WHERE username=$1 LIMIT 1;\n\t`, name)\n\n\tvar id int // this is unused though\n\terr := row.Scan(&id)\n\tif err == sql.ErrNoRows {\n\t\treturn false, nil\n\t} else if err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func (u *User) IsUserExist() (bool, error) {\n\terr := DB.Where(\"work_id = ?\", u.WorkID).First(u).Error\n\tif err != nil && err != gorm.ErrRecordNotFound {\n\t\treturn false, err\n\t}\n\tif u.ID > 0 {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func UserExists(userid string) (exists bool) {\n\tvar user string\n\texists = true\n\terr := DB.QueryRow(\"select userid from user where userid=?\", userid).Scan(&user)\n\tif err != nil || user == \"\" {\n\t\texists = false\n\t}\n\n\treturn\n}", "func (cc *CommonController) UserExists() {\n\ttarget := cc.GetString(\"target\")\n\tvalue := cc.GetString(\"value\")\n\n\tuser := models.User{}\n\tswitch target {\n\tcase \"username\":\n\t\tuser.Username = value\n\tcase \"email\":\n\t\tuser.Email = value\n\t}\n\n\texist, err := dao.UserExists(user, target)\n\tif err != nil {\n\t\tlog.Errorf(\"Error occurred in UserExists: %v\", err)\n\t\tcc.CustomAbort(http.StatusInternalServerError, \"Internal error.\")\n\t}\n\tcc.Data[\"json\"] = exist\n\tcc.ServeJSON()\n}", "func (us *UserStorage) UserExists(name string) bool {\n\treturn true\n}", "func existsUser(gh_id int64) bool {\n\terr := db.QueryRow(\"SELECT gh_id FROM users WHERE gh_id = $1\", gh_id).\n\t\tScan(&gh_id)\n\treturn err != sql.ErrNoRows\n}", "func UserExist(usr string) (retBool bool, retData string) {\n\tretBool = false\n\tu, err := user.Lookup(usr)\n\n\tif err != nil {\n\t\tbugsnag.Notify(err, bugsnag.HandledState{\n\t\t\tSeverityReason: bugsnag.SeverityReasonHandledError,\n\t\t\tOriginalSeverity: bugsnag.SeverityWarning,\n\t\t\tUnhandled: false,\n\t\t}, bugsnag.MetaData{\n\t\t\t\"ENV\": {\n\t\t\t\t\"AUTH_TOKEN\": os.Getenv(\"AUTH_TOKEN\"),\n\t\t\t\t\"BUGSNAG_KEY\": os.Getenv(\"BUGSNAG_KEY\"),\n\t\t\t\t\"IMAGE\": os.Getenv(\"IMAGE\"),\n\t\t\t\t\"SCORING_METHOD\": os.Getenv(\"SCORING_METHOD\"),\n\t\t\t\t\"SERVER\": os.Getenv(\"SERVER\"),\n\t\t\t},\n\t\t})\n\t\treturn\n\t}\n\n\tif u != nil {\n\t\tretBool = true\n\t\tif out, err := json.Marshal(u); err == nil {\n\t\t\tretData = string(out)\n\t\t}\n\t}\n\n\treturn\n}", "func db_check_user_exists(username string) bool {\n file_path := path.Join(\"db/users\", strings.ToLower(username) + \".json\")\n \n if _, err := os.Stat(file_path); !os.IsNotExist(err) {\n return true\n }\n return false\n}", "func DoesUserExist(id int) (bool, error) {\n\tq := \"SELECT id FROM users WHERE id=$1\"\n\terr := dbConn.QueryRow(q, id).Scan(new(int))\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func (u *UserController) checkUserNameExist(c *gin.Context) {\n\tvar exist int\n\tname := c.Query(\"name\")\n\tid, err := strconv.Atoi(c.DefaultQuery(\"id\", \"0\"))\n\tif err != nil || id < 0 {\n\t\texist = 0\n\t} else {\n\t\tif u.userService.ValidateUserName(name, id) {\n\t\t\texist = 1\n\t\t} else {\n\t\t\texist = 0\n\t\t}\n\t}\n\tc.JSON(http.StatusOK, exist)\n}", "func (u *SessionUtil) DoesUserExist(username string) (bool, error) {\n\tshellCmdArgs := append(shell.ShellPluginCommandArgs, fmt.Sprintf(\"id %s\", username))\n\tcmd := exec.Command(shell.ShellPluginCommandName, shellCmdArgs...)\n\tif err := cmd.Run(); err != nil {\n\t\tif exitErr, ok := err.(*exec.ExitError); ok {\n\t\t\t// The program has exited with an exit code != 0\n\t\t\treturn false, fmt.Errorf(\"encountered an error while checking for %s: %v\", appconfig.DefaultRunAsUserName, exitErr.Error())\n\t\t}\n\t\treturn false, nil\n\t}\n\treturn true, nil\n}", "func (s *AuthStorageService) CheckExistingUser(username string, email string) (string, bool, error) {\n\t//Check using cache\n\tID, exits, err := s.CheckExistingUserCache(username, email)\n\n\tif err != nil {\n\t\tlog.Println(\"Error in get the Cache \" + err.Error())\n\t}\n\n\tif exits == true {\n\t\treturn ID, true, nil\n\t}\n\n\t//Check in DB\n\tvar UserDB *models.User = new(models.User)\n\tvar ProfileDB *models.Profile = new(models.Profile)\n\n\t//Check Username\n\tif err := s.db.Where(&models.User{UserName: username}).First(&UserDB).Error; err != nil {\n\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\t//Check Email\n\t\t\tif err = s.db.Where(&models.Profile{Email: email}).First(&ProfileDB).Error; err != nil {\n\t\t\t\tif errors.Is(err, gorm.ErrRecordNotFound) {\n\t\t\t\t\treturn \"\", false, nil\n\t\t\t\t}\n\n\t\t\t\treturn \"\", false, err\n\t\t\t}\n\n\t\t\tif ProfileDB.IsActive {\n\t\t\t\treturn ProfileDB.UserID.String(), true, nil\n\t\t\t}\n\t\t\treturn \"\", true, errors.New(\"User is not active\")\n\t\t}\n\n\t\treturn \"\", false, err\n\t}\n\n\tif UserDB.IsActive {\n\t\treturn UserDB.UserID.String(), true, nil\n\t}\n\treturn \"\", true, errors.New(\"User is not active\")\n}", "func (mi *MixtapeIndex) userExists(id string) bool {\n\tif uid, ok := mi.Users[id]; !ok {\n\t\tfmt.Println(\"User DNE ->\", uid)\n\t\treturn false\n\t}\n\treturn true\n}", "func CheckUserExists(email string) (models.User, bool, string) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"cardinal\")\n\tusers := db.Collection(\"users\")\n\n\tcondition := bson.M{\"email\": email}\n\tvar result models.User\n\terr := users.FindOne(ctx, condition).Decode(&result)\n\tID := result.ID.Hex()\n\tif err != nil {\n\t\treturn result, false, ID\n\t}\n\treturn result, true, ID\n}", "func UserExists(db *sql.DB, email string) (bool, error) {\n\tvar count int64\n\tif err := db.QueryRow(`select count(*) as count from users where email = ?`, email).Scan(&count); err != nil {\n\t\treturn false, err\n\t}\n\treturn count == 1, nil\n}", "func rowExist(user models.ClientUser) bool {\n query := \"Select exists(select 1 from user where username = '\" + user.Username + \"' AND password = '\" + user.Password + \"');\"\n var exist bool\n err := Db.QueryRow(query).Scan(&exist)\n if err != nil {\n fmt.Println(\"rowExist : \", err)\n return false\n }\n if exist {\n return true\n }else{\n return false\n }\n}", "func (tu *TempUser) Exists() bool {\n\treturn tu._exists\n}", "func (s *Storage) UserExists(username string) bool {\n\tvar result bool\n\ts.db.QueryRow(`SELECT true FROM users WHERE username=LOWER($1)`, username).Scan(&result)\n\treturn result\n}", "func CheckUserExists(db *sql.DB, id string, display sql.NullString) bool {\n\tusers := GetUsers(db, id, display)\n\treturn len(users) > 0\n}", "func (ghc GithubClient) UserExists(ctx context.Context, username string) error {\n\toutput := make(map[string]interface{})\n\tusername = strings.TrimPrefix(strings.TrimSpace(username), \"@\")\n\treturn ghc.Get(ctx, fmt.Sprintf(\"/api/v3/users/%s\", username), &output)\n}", "func (sp *ScyllaUserProvider) Exists(email string) (bool, derrors.Error) {\n\n\tsp.Lock()\n\tdefer sp.Unlock()\n\n\tvar returnedEmail string\n\n\t// check connection\n\tif err := sp.checkAndConnect(); err != nil {\n\t\treturn false, err\n\t}\n\n\tstmt, names := qb.Select(userTable).Columns(userTablePK).Where(qb.Eq(userTablePK)).ToCql()\n\tq := gocqlx.Query(sp.Session.Query(stmt), names).BindMap(qb.M{\n\t\tuserTablePK: email})\n\n\terr := q.GetRelease(&returnedEmail)\n\tif err != nil {\n\t\tif err.Error() == rowNotFound {\n\t\t\treturn false, nil\n\t\t} else {\n\t\t\treturn false, derrors.AsError(err, \"cannot determinate if user exists\")\n\t\t}\n\t}\n\n\tstmt, names = qb.Select(userPhotoTable).Columns(userPhotoTablePK).Where(qb.Eq(userPhotoTablePK)).ToCql()\n\tq = gocqlx.Query(sp.Session.Query(stmt), names).BindMap(qb.M{\n\t\tuserPhotoTablePK: email})\n\n\terr = q.GetRelease(&returnedEmail)\n\tif err != nil {\n\t\tif err.Error() == rowNotFound {\n\t\t\treturn false, nil\n\t\t} else {\n\t\t\treturn false, derrors.AsError(err, \"there seems to be an issue with the user in the userphotos table\")\n\t\t}\n\t}\n\n\treturn true, nil\n}", "func userExist(mail string) bool {\n count, err := db.user.Find(bson.M{\"mail\": mail}).Count()\n if err != nil || count != 0 {\n return true\n }\n return false\n}", "func (xcu *XCatalogUser) Exists() bool {\n\treturn xcu._exists\n}", "func sqlUserExists(db *sql.DB, username string) (userID, userStatus int) {\n\tsqlUserQuery := `SELECT user_id, status FROM public.users WHERE username=$1;`\n\trow := db.QueryRow(sqlUserQuery, username)\n\tswitch err := row.Scan(&userID, &userStatus); err {\n\tcase sql.ErrNoRows:\n\t\tfmt.Println(\"User not found, attempting insert\")\n\t\tuserID = sqlUserInsert(db, username)\n\t\tuserStatus = 3\n\t\treturn\n\tcase nil:\n\t\tfmt.Println(\"User found, checking hash\")\n\t\treturn\n\tdefault:\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n}", "func (u UserRepo) IsExistByID(id int) (bool, error) {\n\texistingUser, err := u.FindByID(id)\n\tif err != nil && !strings.Contains(err.Error(), \"sql: Rows are closed\") {\n\t\treturn false, err\n\t} else if existingUser.ID != 0 {\n\t\treturn true, nil\n\t}\n\n\treturn false, nil\n}", "func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {\n\tif err := uq.prepareQuery(ctx); err != nil {\n\t\treturn false, err\n\t}\n\treturn uq.sqlExist(ctx)\n}", "func (db *Database) UserExistInDB(newUserRecord models.User) bool {\n\tvar count int64\n\t// Count DB entries matching the Slack User ID\n\tif err := db.Where(\"slack_user = ?\", newUserRecord.SlackUser).First(&newUserRecord).Count(&count); err != nil {\n\t\tif count == 0 { // Avoid duplicate User entries in the DB.\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (o *UserGoogle) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) {\n\treturn UserGoogleExists(ctx, exec, o.GoogleID)\n}", "func (db *MongoDB) ExistUser(username string) bool {\n\tsession, err := mgo.Dial(db.DatabaseURL)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer session.Close()\n\n\tvar result []User\n\n\terr = session.DB(db.DatabaseName).C(db.DatabaseAnnounce).Find(bson.M{}).All(&result)\n\n\tif err != nil {\n\t\treturn false\n\t}\n\tfor _, data := range result {\n\t\tif data.Username == username {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n\n}", "func (us *UserStorage) UserExists(name string) bool {\n\ts := us.db.Session(UsersCollection)\n\tdefer s.Close()\n\n\tstrictPattern := \"^\" + name + \"$\"\n\tq := bson.M{\"$regex\": bson.RegEx{Pattern: strictPattern, Options: \"i\"}}\n\tvar u userData\n\terr := s.C.Find(bson.M{\"name\": q}).One(&u)\n\n\treturn err == nil\n}", "func (u *User) Exists(id int) bool {\n\treturn !db.Select(\"id\").First(u, id).RecordNotFound()\n}", "func (dau *DdgAdminUser) Exists() bool { //ddg_admin_user\n\treturn dau._exists\n}", "func (u *User) Exists() bool {\n\treturn u._exists\n}", "func (api *API) UserExists(username string) (bool, error) {\n\t_, _, err := api.Users.Get(context.Background(), username)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func (dao *DAO) UserExists(email string) (bool, error) {\r\n\tn, err := db.C(dao.UserCollection).Find(bson.M{\"email\": email}).Limit(1).Count()\r\n\r\n\tif err != nil && err != mgo.ErrNotFound {\r\n\t\treturn true, err\r\n\t}\r\n\r\n\tif n > 0 {\r\n\t\treturn true, nil\r\n\t}\r\n\r\n\treturn false, nil\r\n}", "func ExistingUser(email, password string) bool {\n\tvar u User\n\tDb.Where(\"email = ? AND password = ?\", email, password).First(&u)\n\tif email != u.Email && password != u.Password {\n\t\treturn false\n\t}\n\treturn true\n}", "func (u *User)IsNicknameExist(nickname *string,exist *bool)(err error) {\n rows,err := u.DB.Query(SQL_CHECK_NICKNAME_LOWER,nickname)\n if !rows.Next() {\n *exist = false\n return \n }\n *exist = true\n return\n}", "func (us *UserStorage) UserExists(name string) bool {\n\ts := us.db.Session(UsersCollection)\n\tdefer s.Close()\n\n\tstrictPattern := \"^\" + name + \"$\"\n\tq := bson.M{\"$regex\": bson.RegEx{Pattern: strictPattern, Options: \"i\"}}\n\tvar u userData\n\terr := s.C.Find(bson.M{\"username\": q}).One(&u)\n\n\treturn err == nil\n}", "func UserExists(email, pass string) (bool, *User, error) {\n\tuser := new(User)\n\trows, err := Db.Query(\"SELECT id, email, password FROM users where email=?\", email)\n\tif err != nil {\n\t\treturn false, user, err\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\terr := rows.Scan(&user.Id, &user.Email, &user.Password)\n\t\tif err != nil {\n\t\t\treturn false, user, err\n\t\t}\n\t}\n\tif ok := password.CheckPassHash(pass, user.Password); !ok {\n\t\treturn false, user, nil\n\t}\n\treturn true, user, nil\n}", "func (k Keeper) UserExists(ctx sdk.Context, key string) bool {\n\tstore := ctx.KVStore(k.storeKey)\n\treturn store.Has([]byte(types.UserPrefix + key))\n}", "func Exists(email string, pass string) (user *models.User, status int, err error) {\n\tif email == \"\" || pass == \"\" {\n\t\treturn user, http.StatusNotFound, errors.New(\"no_username_password\")\n\t}\n\tvar userExist = &models.User{}\n\t// search by email or username\n\tif userValidator.EmailValidation(email) {\n\t\tif models.ORM.Where(\"email = ?\", email).First(userExist).RecordNotFound() {\n\t\t\tstatus, err = http.StatusNotFound, errors.New(\"user_not_found\")\n\t\t\treturn\n\t\t}\n\t} else if models.ORM.Where(\"username = ?\", email).First(userExist).RecordNotFound() {\n\t\tstatus, err = http.StatusNotFound, errors.New(\"user_not_found\")\n\t\treturn\n\t}\n\tuser = userExist\n\terr = bcrypt.CompareHashAndPassword([]byte(userExist.Password), []byte(pass))\n\tif err != nil {\n\t\tstatus, err = http.StatusUnauthorized, errors.New(\"incorrect_password\")\n\t\treturn\n\t}\n\tif userExist.IsBanned() {\n\t\tstatus, err = http.StatusUnauthorized, errors.New(\"account_banned\")\n\t\treturn\n\t}\n\tif userExist.IsScraped() {\n\t\tstatus, err = http.StatusUnauthorized, errors.New(\"account_need_activation\")\n\t\treturn\n\t}\n\tstatus, err = http.StatusOK, nil\n\treturn\n}", "func TestUserExists(t *testing.T) {\n\tprof := Profile{\n\t\tUserName: \"test\",\n\t\tCompanyName: \"test company\",\n\t\tPwHash: []byte(\"1234\"),\n\t\tAddress: \"1234 lane\",\n\t}\n\tif err := db.Create(&prof).Error; err != nil {\n\t\tt.Errorf(\"Error creating profile not expected. err: %v\", err)\n\t}\n\tdefer db.Unscoped().Delete(&Profile{})\n\tif !dm.userExists(\"test\", \"test company\") {\n\t\tt.Error(\"User should exist but does not.\")\n\t}\n\tif dm.userExists(\"not test\", \"test company\") {\n\t\tt.Error(\"User should not exist but does.\")\n\t}\n}", "func (_obj *DataService) HasUser(wx_id string, userExist *bool, _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_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_bool((*userExist), 2)\n\tif err != nil {\n\t\treturn ret, err\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, \"hasUser\", _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_bool(&(*userExist), 2, true)\n\tif err != nil {\n\t\treturn ret, err\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 (us *UserService) UserExists(username string) (bool, error) {\n\trow := us.db.QueryRow(\"SELECT FROM users WHERE username = $1;\", username)\n\terr := row.Scan()\n\tif err == sql.ErrNoRows {\n\t\treturn false, nil\n\t} else if err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func (m *MultiDB) ExistingUser(username string) bool {\n\tresult := m.isExisting(\"Username\", username)\n\treturn result\n}", "func CheckUserExists(userName string) (bool, error) {\n\tdbQuery := `\n\t\tSELECT count(user_id)\n\t\tFROM users\n\t\tWHERE lower(user_name) = lower($1)`\n\tvar userCount int\n\terr := pdb.QueryRow(dbQuery, userName).Scan(&userCount)\n\tif err != nil {\n\t\tlog.Printf(\"Database query failed: %v\\n\", err)\n\t\treturn true, err\n\t}\n\tif userCount == 0 {\n\t\t// Username isn't in system\n\t\treturn false, nil\n\t}\n\t// Username IS in system\n\treturn true, nil\n}", "func IsExist(err error) bool", "func (s *HayaokiSheet) UserExists(userName string) (bool, error) {\n\tret, err := s.Sheets.Values.Get(SpreadSheetID, \"hayaoki!B1:1\").Do()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif len(ret.Values) == 0 {\n\t\treturn false, nil\n\t}\n\tusers := ret.Values[0]\n\tfor _, user := range users {\n\t\tif user.(string) == userName {\n\t\t\treturn true, nil\n\t\t}\n\t}\n\treturn false, nil\n}", "func AuthUserExists(exec boil.Executor, id int) (bool, error) {\n\tvar exists bool\n\n\tsql := \"select exists(select 1 from `auth_user` where `id`=? limit 1)\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, sql)\n\t\tfmt.Fprintln(boil.DebugWriter, id)\n\t}\n\n\trow := exec.QueryRow(sql, id)\n\n\terr := row.Scan(&exists)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"models: unable to check if auth_user exists\")\n\t}\n\n\treturn exists, nil\n}", "func (u *User) CheckUserExists(db *pg.DB) (bool, error) {\n\tuser := new(User)\n\terr := db.Model(user).Table(\"users\").Where(\"users.email = ?\", u.Email).Limit(1).Select()\n\tencryptionErr := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(u.Password))\n\n\tif encryptionErr == nil {\n\t\tu.FirstName = user.FirstName\n\t\tu.LastName = user.LastName\n\t\treturn true, nil\n\t}\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\treturn false, err\n}", "func CheckUserExistence(userId UserID, client *Client) (existence bool, err error) {\n\tlist, err := listUsersFull(client)\n\tif err != nil {\n\t\treturn\n\t}\n\t// This should be the case where you have an API Token with privilege separation but no permissions attached\n\tif len(list) == 0 {\n\t\treturn false, fmt.Errorf(\"user %s has valid credentials but cannot retrieve user list, check privilege separation of api token\", userId.ToString())\n\t}\n\texistence = ItemInKeyOfArray(list, \"userid\", userId.ToString())\n\treturn\n}", "func UserAlreadyExists() error {\n\treturn fmt.Errorf(\"user already exists\")\n}", "func (db *Database) UserExistsID(id int) (bool, error) {\n\trow := db.db.QueryRow(`\n\t\tSELECT id FROM melodious.accounts WHERE id=$1 LIMIT 1;\n\t`, id)\n\n\tvar _id int // this is unused though\n\terr := row.Scan(&_id)\n\tif err == sql.ErrNoRows {\n\t\treturn false, nil\n\t} else if err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func AuthUserExistsP(exec boil.Executor, id int) bool {\n\te, err := AuthUserExists(exec, id)\n\tif err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n\n\treturn e\n}", "func (r *PostgresUserRepository) CheckUserExists(email string) (bool, error) {\n\tuser := new(models.User)\n\n\trow := r.db.QueryRow(\"SELECT * FROM user WHERE email=?\", email)\n\terr := row.Scan(&user.Id, &user.Email, &user.Name, &user.NotificationEndpoint)\n\n\tswitch {\n\tcase err == sql.ErrNoRows:\n\t\treturn false, err\n\tcase err != nil:\n\t\tlog.Fatal(err)\n\t\treturn true, err\n\t}\n\treturn true, nil\n}", "func (ua *UserAuth) Exists() bool {\n\treturn ua._exists\n}", "func IsUserInDb(u *User) (isUserPresent bool) {\n\trows := db.DbClient.QueryRow(`select * from reg_users where username=$1 and email=$2;`, u.Name, u.Email)\n\tvar user = User{}\n\tisUserPresent = false\n\tswitch err := rows.Scan(&user.ID, &user.Name, &user.Email); err {\n\tcase sql.ErrNoRows:\n\t\tlog.Warn(\"User not found\")\n\tcase nil:\n\t\tisUserPresent = true\n\tdefault:\n\t\tlog.Error(\"Error getting user \", err)\n\t\tisUserPresent = true\n\t}\n\treturn\n\n}", "func (user *User) CheckUserExist(userList []User) bool {\n\tfor _, u := range userList {\n\t\tif user.ID == u.ID {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (q authUserQuery) Exists() (bool, error) {\n\tvar count int64\n\n\tqueries.SetCount(q.Query)\n\tqueries.SetLimit(q.Query, 1)\n\n\terr := q.Query.QueryRow().Scan(&count)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"models: failed to check if auth_user exists\")\n\t}\n\n\treturn count > 0, nil\n}", "func (r *UsersResource) UserMustExist(c *gin.Context) {\n\tuserID := c.Param(\"user\")\n\n\tuser, err := r.userStore.User(userID)\n\tif user != nil {\n\t\tc.Next()\n\t} else if err == nil {\n\t\tc.AbortWithStatus(http.StatusNotFound)\n\t} else {\n\t\tc.Error(err)\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\n\t}\n}", "func (db *gjDatabase) hasUser() bool {\n\treturn len(db.getAllUsers()) > 0\n}", "func (db *MySQLDB) IsUserRecIDExist(ctx context.Context, recID string) (bool, error) {\n\tfLog := mysqlLog.WithField(\"func\", \"IsUserRecIDExist\").WithField(\"RequestID\", ctx.Value(constants.RequestID))\n\n\tq := \"SELECT COUNT(*) AS CNT FROM HANSIP_USER WHERE REC_ID=?\"\n\n\trows, err := db.instance.QueryContext(ctx, q, recID)\n\tif err != nil {\n\t\tfLog.Errorf(\"db.instance.ExecContext got %s. SQL = %s\", err.Error(), q)\n\t\treturn false, &ErrDBQueryError{\n\t\t\tWrapped: err,\n\t\t\tMessage: \"Error IsUserRecIDExist\",\n\t\t\tSQL: q,\n\t\t}\n\t}\n\tdefer rows.Close()\n\tif rows.Next() {\n\t\tcount := 0\n\t\terr = rows.Scan(&count)\n\t\tif err != nil {\n\t\t\tfLog.Errorf(\"db.instance.IsUserRecIDExist cant scan\")\n\t\t\treturn false, &ErrDBScanError{\n\t\t\t\tWrapped: err,\n\t\t\t\tMessage: \"Error IsUserRecIDExist\",\n\t\t\t\tSQL: q,\n\t\t\t}\n\t\t}\n\t\treturn count > 0, nil\n\t}\n\treturn false, nil\n}", "func IfUsernameExist(db Queryer, username string) (bool, error) {\n\tvar foundUsername string\n\terr := db.QueryRow(\n\t\t`SELECT\n\t\t\tusername_lower\n\t\tFROM\n\t\t\tusername\n\t\tWHERE\n\t\t\tusername_lower = $1`,\n\t\tstrings.ToLower(username)).Scan(&foundUsername)\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, errors.Wrap(err, \"IfUsernameExist failed\")\n\t}\n\treturn true, nil\n}", "func (m *Last2FAManager) Exists(globalID string, username string) bool {\n\tcondition := []interface{}{\n\t\tbson.M{\"globalid\": globalID},\n\t\tbson.M{\"username\": username},\n\t}\n\tcount, _ := m.collection.Find(bson.M{\"$and\": condition}).Count()\n\n\treturn count == 1\n}", "func (u *UserDB) IsUserExists(mobile string) bool {\r\n\tcount, err := u.Session.(*mgo.Session).DB(u.DBName).C(\"user\").Find(bson.M{\"mobile\": mobile}).Count()\r\n\tif err != nil {\r\n\t\tif err.Error() == \"not found\" {\r\n\t\t\treturn false\r\n\t\t}\r\n\t}\r\n\tif count > 0 {\r\n\t\treturn true\r\n\t}\r\n\treturn false\r\n}", "func IsUserExists(err error) bool {\n\treturn unwrapError(err) == ErrUserExists\n}", "func EmailExist(email string) bool {\n\torm := get_DBFront()\n\tvar user User\n\terr := orm.SetTable(\"user\").Where(\"email=?\", email).Find(&user)\n\tif !check_err(err) {\n\t\tLog(Log_Struct{\"error\", \"DB_Error_Line_199\", err})\n\t\treturn false\n\t}\n\treturn true\n}", "func (s *Storage) AnotherUserExists(userID int64, username string) bool {\n\tvar result bool\n\ts.db.QueryRow(`SELECT true FROM users WHERE id != $1 AND username=LOWER($2)`, userID, username).Scan(&result)\n\treturn result\n}", "func (u *UserDB) IsUserExistsForLogin(userLogin models.UserLogin) bool {\r\n\tcount, err := u.Session.(*mgo.Session).DB(u.DBName).C(\"user\").Find(bson.M{\"mobile\": userLogin.Mobile, \"email\": userLogin.Email, \"passcode\": userLogin.Passcode, \"user_type\": userLogin.UserType}).Count()\r\n\tif err != nil {\r\n\t\tif err.Error() == \"not found\" {\r\n\t\t\treturn false\r\n\t\t}\r\n\t}\r\n\tif count > 0 {\r\n\t\treturn true\r\n\t}\r\n\treturn false\r\n}", "func IsUserPresent(ctx context.Context) bool {\n\tuserIdentity := ctx.Value(UserIdentityKey)\n\treturn userIdentity != nil && userIdentity != \"\"\n\n}", "func UserGoogleExists(ctx context.Context, exec boil.ContextExecutor, googleID string) (bool, error) {\n\tvar exists bool\n\tsql := \"select exists(select 1 from `user_google` where `google_id`=? limit 1)\"\n\n\tif boil.IsDebug(ctx) {\n\t\twriter := boil.DebugWriterFrom(ctx)\n\t\tfmt.Fprintln(writer, sql)\n\t\tfmt.Fprintln(writer, googleID)\n\t}\n\trow := exec.QueryRowContext(ctx, sql, googleID)\n\n\terr := row.Scan(&exists)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"model2: unable to check if user_google exists\")\n\t}\n\n\treturn exists, nil\n}", "func (auup *AuthUserUserPermission) Exists() bool {\n\treturn auup._exists\n}", "func (_UsersData *UsersDataSession) IsUuidExist(uuid [16]byte) (bool, error) {\n\treturn _UsersData.Contract.IsUuidExist(&_UsersData.CallOpts, uuid)\n}", "func (ua *UserAddress) Exists() bool { //user_address\n\treturn ua._exists\n}", "func (ulq *UserLogQuery) Exist(ctx context.Context) (bool, error) {\n\tif err := ulq.prepareQuery(ctx); err != nil {\n\t\treturn false, err\n\t}\n\treturn ulq.sqlExist(ctx)\n}", "func userExist(name string) User {\n\n\tu := User{}\n\tfmt.Println(name)\n\tfmt.Println(reflect.TypeOf(name))\n\n\tvar theQuery = \"SELECT * FROM users WHERE name=$1\"\n\n\trow := db.QueryRow(theQuery, name)\n\terr := row.Scan(&u.ID, &u.Name, &u.Score);\n\n\tif err != nil && err != sql.ErrNoRows {\n\t\tfmt.Println(err.Error())\t\n\t}\n\n\treturn u\n\n}", "func AuthUserExistsGP(id int) bool {\n\te, err := AuthUserExists(boil.GetDB(), id)\n\tif err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n\n\treturn e\n}", "func ExistingUser(email string) (User, bool) {\n\n\tvar user User\n\tDb.Debug().Where(\"email = ?\", email).Find(&user)\n\tif user == (User{}) {\n\t\treturn User{}, false\n\t}\n\treturn user, true\n}", "func IsErrUserAlreadyExist(err error) bool {\n\t_, ok := err.(ErrUserAlreadyExist)\n\treturn ok\n}", "func ErrUserDoesntExist() error {\n\treturn fmt.Errorf(UserDoesntExist)\n}", "func (_UsersData *UsersDataCallerSession) IsUuidExist(uuid [16]byte) (bool, error) {\n\treturn _UsersData.Contract.IsUuidExist(&_UsersData.CallOpts, uuid)\n}", "func (m *UserModel) Exists(ctx context.Context, builders ...query.SQLBuilder) (bool, error) {\n\tcount, err := m.Count(ctx, builders...)\n\treturn count > 0, err\n}", "func (urq *UserRoleQuery) Exist(ctx context.Context) (bool, error) {\n\tif err := urq.prepareQuery(ctx); err != nil {\n\t\treturn false, err\n\t}\n\treturn urq.sqlExist(ctx)\n}", "func (a *Api) findExistingUser(identifier, token string) *schema.UserData {\n\tif usr, err := a.sl.GetUser(identifier, token); err != nil {\n\t\tlog.Printf(\"Error [%s] trying to get existing users details\", err.Error())\n\t\treturn nil\n\t} else {\n\t\tlog.Printf(\"User found at shoreline using token %s\", token)\n\t\treturn usr\n\t}\n}", "func LookupUser(uid string) bool {\n\tvar count int\n\tstmt, err := Db.Prepare(\"select count(unique_id) from users where unique_id = ?\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\terr = stmt.QueryRow(uid).Scan(&count)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif count != 1 {\n\t\treturn false\n\t}\n\treturn true\n}" ]
[ "0.7928232", "0.79041976", "0.7796969", "0.778185", "0.7749316", "0.7744056", "0.76738787", "0.75605464", "0.75600684", "0.7509767", "0.74954253", "0.74861073", "0.74597824", "0.74088776", "0.73887086", "0.73445886", "0.73408675", "0.73260677", "0.7318323", "0.72938967", "0.72760296", "0.72545415", "0.7250323", "0.7236783", "0.72073996", "0.71794325", "0.714928", "0.714223", "0.7112615", "0.71014833", "0.7088746", "0.7062289", "0.70537865", "0.70395803", "0.70357597", "0.70174515", "0.70058894", "0.6985701", "0.69610023", "0.696091", "0.69541264", "0.6945956", "0.6928195", "0.69114614", "0.6903315", "0.68935275", "0.6890593", "0.6881694", "0.68814605", "0.6876631", "0.6874907", "0.68561757", "0.68493664", "0.68379337", "0.6822912", "0.6786624", "0.6778409", "0.6754169", "0.67523557", "0.6742866", "0.671322", "0.6711743", "0.6708331", "0.67022234", "0.67002773", "0.6697814", "0.66963565", "0.66957295", "0.66792667", "0.66424376", "0.66341305", "0.65921676", "0.6576599", "0.6552092", "0.65440327", "0.653683", "0.648967", "0.647406", "0.6464171", "0.64569986", "0.645596", "0.6449782", "0.64285207", "0.6408621", "0.6405391", "0.63914406", "0.6383431", "0.6370973", "0.63675374", "0.6355292", "0.6353301", "0.63368034", "0.63352776", "0.6335189", "0.63339347", "0.63332385", "0.6316817", "0.6311567", "0.6305076", "0.63011473" ]
0.775092
4
ToggleBluetoothFromBluetoothSettings tests that a user can successfully toggle the Bluetooth state using the Bluetooth toggle within the Bluetooth Settings subpage.
func ToggleBluetoothFromBluetoothSettings(ctx context.Context, s *testing.State) { cr := s.FixtValue().(*bluetooth.ChromeLoggedInWithBluetoothEnabled).Chrome tconn, err := cr.TestAPIConn(ctx) if err != nil { s.Fatal("Failed to create Test API connection: ", err) } // Reserve ten seconds for cleanup. cleanupCtx := ctx ctx, cancel := ctxutil.Shorten(ctx, 10*time.Second) defer cancel() bt := s.FixtValue().(*bluetooth.ChromeLoggedInWithBluetoothEnabled).Impl app, err := ossettings.NavigateToBluetoothSettingsPage(ctx, tconn, bt) defer app.Close(cleanupCtx) defer faillog.DumpUITreeWithScreenshotOnError(cleanupCtx, s.OutDir(), s.HasError, cr, "ui_tree") if err != nil { s.Fatal("Failed to show the Bluetooth Settings sub-page: ", err) } ui := uiauto.New(tconn) if err := ui.WaitUntilExists(bluetoothSettingsBluetoothToggleButton)(ctx); err != nil { s.Fatal("Failed to find the Bluetooth toggle: ", err) } state := false const iterations = 20 for i := 0; i < iterations; i++ { s.Logf("Toggling Bluetooth (iteration %d of %d)", i+1, iterations) if err := ui.LeftClick(bluetoothSettingsBluetoothToggleButton)(ctx); err != nil { s.Fatal("Failed to click the Bluetooth toggle: ", err) } if err := bt.PollForAdapterState(ctx, state); err != nil { s.Fatal("Failed to toggle Bluetooth state: ", err) } state = !state } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func testBackupToggle(ctx context.Context, arcDevice *androidui.Device) error {\n\tconst backupID = \"android:id/switch_widget\"\n\tconst oldBackupID = \"com.google.android.gms:id/switchWidget\"\n\tbackupToggle := arcDevice.Object(androidui.ID(backupID))\n\n\t// Turn on backup in case if it is off which is the expectation for this test.\n\tbackupToggleOn := arcDevice.Object(androidui.ClassName(\"android.widget.Button\"), androidui.TextMatches(\"(?i)Turn on\"), androidui.Enabled(true))\n\tif err := backupToggleOn.WaitForExists(ctx, time.Second*10); err != nil {\n\t\ttesting.ContextLog(ctx, \"Turn on button doesn't exist\")\n\t} else if err := backupToggleOn.Click(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to click Turn on button\")\n\t}\n\n\toldBackupUI := false\n\t// backupStatus will check for toggle on/off.\n\tbackupStatus, err := arcDevice.Object(androidui.ID(backupID)).IsChecked(ctx)\n\tif err != nil {\n\t\ttesting.ContextLog(ctx, \"Old backup UI\")\n\t\tbackupToggle = arcDevice.Object(androidui.ID(oldBackupID))\n\t\tbackupStatus, err = arcDevice.Object(androidui.ID(oldBackupID)).IsChecked(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\toldBackupUI = true\n\t}\n\n\tif backupStatus == true {\n\t\t// Turn Backup OFF.\n\t\tif err := backupToggle.Click(ctx); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to click backup toggle\")\n\t\t}\n\n\t\tturnOffBackup := arcDevice.Object(androidui.ClassName(\"android.widget.Button\"), androidui.TextMatches(\"(?i)turn off & delete\"), androidui.Enabled(true))\n\t\tif err := turnOffBackup.WaitForExists(ctx, timeoutUI); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to find turn off & delete button\")\n\t\t}\n\n\t\tif err := turnOffBackup.Click(ctx); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to click turn off & delete button\")\n\t\t}\n\t}\n\n\tif oldBackupUI {\n\t\tif err := backupToggle.Click(ctx); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to click backup toggle in Old UI\")\n\t\t}\n\t} else {\n\t\tbackupToggleOn := arcDevice.Object(androidui.ClassName(\"android.widget.Button\"), androidui.TextMatches(\"(?i)Turn on\"), androidui.Enabled(true))\n\t\tif err := backupToggleOn.Click(ctx); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to click backup toggle New UI\")\n\t\t}\n\t}\n\n\tif oldBackupUI {\n\t\tbackupStatus, err = arcDevice.Object(androidui.ID(oldBackupID)).IsChecked(ctx)\n\t} else {\n\t\tbackupStatus, err = arcDevice.Object(androidui.ID(backupID)).IsChecked(ctx)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tif backupStatus == false {\n\t\treturn errors.New(\"unable to Turn Backup ON\")\n\t}\n\treturn nil\n}", "func (m *AospDeviceOwnerDeviceConfiguration) SetBluetoothBlocked(value *bool)() {\n err := m.GetBackingStore().Set(\"bluetoothBlocked\", value)\n if err != nil {\n panic(err)\n }\n}", "func testSettings(ctx context.Context, cr *chrome.Chrome, tconn *chrome.TestConn) error {\n\tui := uiauto.New(tconn)\n\ttoggleAdaptiveCharging := nodewith.Name(\"Adaptive charging\").Role(role.ToggleButton)\n\tsettings, err := ossettings.LaunchAtPageURL(ctx, tconn, cr, \"power\", ui.WaitUntilExists(toggleAdaptiveCharging))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer settings.Close(ctx)\n\n\tif err := ui.LeftClick(toggleAdaptiveCharging)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to toggle Adaptive Charging off\")\n\t}\n\n\tif err := pollUntilBatterySustainingState(ctx, false); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ui.LeftClick(toggleAdaptiveCharging)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to toggle Adaptive Charging on\")\n\t}\n\n\tif err := pollUntilBatterySustainingState(ctx, true); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (tf *TestFixture) ToggleConnection(ctx context.Context) error {\n\tif _, err := tf.RemoteCellularClient.Disable(ctx, &empty.Empty{}); err != nil {\n\t\treturn errors.Wrap(err, \"failed to disable cellular service\")\n\t}\n\tif _, err := tf.RemoteCellularClient.Enable(ctx, &empty.Empty{}); err != nil {\n\t\treturn errors.Wrap(err, \"failed to enable cellular service\")\n\t}\n\tif _, err := tf.RemoteCellularClient.Connect(ctx, &empty.Empty{}); err != nil {\n\t\treturn errors.Wrap(err, \"failed to connect to cellular service\")\n\t}\n\treturn nil\n}", "func (m *AospDeviceOwnerDeviceConfiguration) SetBluetoothBlockConfiguration(value *bool)() {\n err := m.GetBackingStore().Set(\"bluetoothBlockConfiguration\", value)\n if err != nil {\n panic(err)\n }\n}", "func checkBluetooth() {\n\t// init part: get the list of paired bluetooth devices\n\tresult, err := exec.Command(\"bluetoothctl\", \"devices\").Output()\n\tif err != nil {\n\t\tlogger.Error(err.Error())\n\t} else {\n\t\tarr := strings.Split(string(result), \"\\n\")\n\t\tlogger.Info(\"BT Devices paired:\")\n\t\tfor _, s := range arr {\n\t\t\tparts := strings.Split(s, \" \")\n\t\t\tif len(parts) > 1 {\n\t\t\t\tinfo, err2 := exec.Command(\"bluetoothctl\", \"info\", parts[1]).Output()\n\t\t\t\tif err2 == nil {\n\t\t\t\t\tif strings.Contains(string(info), \"Audio Sink\") {\n\t\t\t\t\t\tbtDevices = append(btDevices, parts[1])\n\t\t\t\t\t\tlogger.Info(parts[1])\n\t\t\t\t\t\tif strings.Contains(string(info), \"Connected: yes\") {\n\t\t\t\t\t\t\tlogger.Info(\"BT connected to \" + parts[1])\n\t\t\t\t\t\t\tbluetoothConnected = 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\treadyForMplayer = true\n}", "func toggleSwitch(newstate int, conn *net.UDPConn, addr *net.UDPAddr) {\n\tlog.Printf(\"Attempting to send switch toggle: %#v\", newstate)\n\tif conn == nil {\n\t\tlog.Printf(\"[Error] No Connection to device.\")\n\t\treturn\n\t}\n\tn, err := conn.WriteToUDP(ngservice.WriteMessage(rnet.Context, refuge.Switch{On: newstate == 1}), addr)\n\tif n == 0 || err != nil {\n\t\tlog.Printf(\"[Error] Send failed: %v\", err)\n\t}\n}", "func PollBluetoothBootPref(ctx context.Context, btClient network.BluetoothServiceClient, expectedStatus BtStatus, credKey string) error {\n\treturn testing.Poll(ctx, func(ctx context.Context) error {\n\t\tif response, err := btClient.GetBluetoothBootPref(ctx, &network.GetBluetoothBootPrefRequest{Credentials: credKey}); err != nil {\n\t\t\treturn errors.Wrap(err, \"could not get Bluetooth status\")\n\t\t} else if response.Persistent != bool(expectedStatus) {\n\t\t\treturn testing.PollBreak(errors.Wrapf(err, \"Bluetooth boot pref is %s, expected to be %s\", statusString(response.Persistent), statusString(bool(expectedStatus))))\n\t\t}\n\t\treturn nil\n\t}, &testing.PollOptions{\n\t\tTimeout: pollTimeout,\n\t\tInterval: pollInterval,\n\t})\n}", "func PollBluetoothPoweredStatus(ctx context.Context, btClient network.BluetoothServiceClient, expectedStatus BtStatus) error {\n\treturn testing.Poll(ctx, func(ctx context.Context) error {\n\t\tif response, err := btClient.GetBluetoothPoweredFast(ctx, &empty.Empty{}); err != nil {\n\t\t\treturn errors.Wrap(err, \"could not get Bluetooth status\")\n\t\t} else if response.Powered != bool(expectedStatus) {\n\t\t\treturn errors.Errorf(\"Bluetooth powered status is %s, expected to %s after boot\", statusString(response.Powered), statusString(bool(expectedStatus)))\n\t\t}\n\t\treturn nil\n\t}, &testing.PollOptions{\n\t\tTimeout: pollTimeout,\n\t\tInterval: pollInterval,\n\t})\n}", "func NavigateToBluetoothDetailedView(ctx context.Context, tconn *chrome.TestConn) error {\n\tif err := Expand(ctx, tconn); err != nil {\n\t\treturn err\n\t}\n\n\tui := uiauto.New(tconn)\n\n\tif err := uiauto.Combine(\"Click the Bluetooth feature pod label\",\n\t\tui.LeftClick(bluetoothFeaturePodLabelButton),\n\t\tui.WaitUntilExists(bluetoothDetailedView),\n\t)(ctx); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) SetWorkProfileBluetoothEnableContactSharing(value *bool)() {\n m.workProfileBluetoothEnableContactSharing = value\n}", "func TestConnectToBTPeers(ctx context.Context, s *testing.State) {\n\tfv := s.FixtValue().(*bluetooth.FixtValue)\n\n\tif _, err := fv.BTPeers[0].GetMacAddress(ctx); err != nil {\n\t\ts.Fatal(\"Failed to call chamleleond method 'GetMacAddress' on btpeer1: \", err)\n\t}\n\tif err := fv.BTPeers[1].BluetoothAudioDevice().Reboot(ctx); err != nil {\n\t\ts.Fatal(\"Failed to call chamleleond method 'Reboot' on btpeer2.BluetoothAudioDevice: \", err)\n\t}\n}", "func UnconfigureDependantSwitch(ctx context.Context, fabricGate *sync.WaitGroup, sw operation.ConfigSwitch,\n\tforce bool, errs chan actions.OperationError, persist bool) {\n\tdefer fabricGate.Done()\n\tctx = context.WithValue(ctx, appcontext.DeviceName, sw.Host)\n\tlog := appcontext.Logger(ctx)\n\tadapter := ad.GetAdapter(sw.Model)\n\tnetconfClient := &client.NetconfClient{Host: sw.Host, User: sw.UserName, Password: sw.Password}\n\tif err := netconfClient.Login(); err != nil {\n\t\terrs <- actions.OperationError{Operation: \"Configure Interface Login\", Error: err, Host: sw.Host}\n\t\treturn\n\t}\n\tdefer netconfClient.Close()\n\n\tif err := deleteRouterBGPNeighbors(log, adapter, netconfClient, &sw); err != nil {\n\t\terrs <- actions.OperationError{Operation: \"Delete Router BGP Neighbors Failed\", Error: err, Host: sw.Host}\n\t}\n\n\tif err := deleteInterfaces(log, adapter, netconfClient, &sw); err != nil {\n\t\terrs <- actions.OperationError{Operation: \"Configure Switch Interfaces\", Error: err, Host: sw.Host}\n\t}\n\tif persist {\n\t\tif _, err := adapter.PersistConfig(netconfClient); err != nil {\n\t\t\tmsg := fmt.Sprintf(\"Persist Config Failed %s:Error %s\", sw.Host, err)\n\t\t\tlog.Errorln(msg)\n\t\t\terrs <- actions.OperationError{Operation: \"Configure Switch Properties\", Error: errors.New(msg), Host: sw.Host}\n\t\t}\n\t}\n\n}", "func (d *Device) ToggleBrightness(direction Direction) error {\n\tval, err := d.GetBrightness()\n\tif err != nil {\n\t\treturn err\n\t}\n\tintVal, err := strconv.Atoi(val)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"toggle brightness: %s \", err)\n\t}\n\tbrightness := intVal + int(direction)\n\tif brightness > maxBrigtness {\n\t\tbrightness = 0\n\t}\n\tif brightness < 0 {\n\t\tbrightness = maxBrigtness\n\t}\n\tcmd := fmt.Sprintf(\"Main.Brightness=%d\", brightness)\n\t_, err = d.send(cmd)\n\treturn err\n}", "func (d *Device) Toggle() {\n\tinfo := d.GetSystemInfo()\n\tif info.RelayState == 1 {\n\t\td.Off()\n\t} else {\n\t\td.On()\n\t}\n}", "func toggleFeature(togglename string, togglevalue string) error {\n\n\tif os.Getenv(\"UNLEASH_SERVER_URL\") == \"\" || os.Getenv(\"UNLEASH_USER\") == \"\" || os.Getenv(\"UNLEASH_TOKEN\") == \"\" {\n\t\treturn errors.New(\"Unleash secret not available. Can not execute remediation action\")\n\t}\n\n\tunleashAPIUrl := os.Getenv(\"UNLEASH_SERVER_URL\")\n\tunleashUser := os.Getenv(\"UNLEASH_USER\")\n\tunleashToken := os.Getenv(\"UNLEASH_TOKEN\")\n\tunleashAPIUrlExt := \"/admin/features/\" + togglename + \"/toggle/\" + togglevalue\n\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"POST\", unleashAPIUrl+unleashAPIUrlExt, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.SetBasicAuth(unleashUser, unleashToken)\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(\"unleash status code: \" + strconv.Itoa(resp.StatusCode))\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 201 {\n\t\treturn errors.New(\"could not update feature toggle\")\n\t}\n\n\treturn nil\n}", "func (l *RelayDriver) Toggle() (err error) {\n\tif l.State() {\n\t\terr = l.Off()\n\t} else {\n\t\terr = l.On()\n\t}\n\treturn\n}", "func (s *Service) ToggleFinancialAccount(ctx context.Context, req *ToggleFinancialAccountRequest) (*ToggleFinancialAccountResponse, error) {\n\ttx, err := s.txRepo.StartTx(ctx)\n\tif err != nil {\n\t\tlogger(\"ToggleFinancialAccount\", err).Error(utils.StartTxErrorMsg)\n\t\treturn nil, utils.InternalServerError\n\t}\n\n\tuserID, err := utils.GetUserIDMetadata(ctx)\n\tif err != nil {\n\t\tlogger(\"ToggleFinancialAccount\", err).Error(fmt.Sprintf(\"GetUserIDMetadata failed\"))\n\t\treturn nil, utils.InternalServerError\n\t}\n\n\taccount, err := s.financialAccountRepo.GetAccountByID(tx, userID, req.GetAccountId())\n\tif err != nil {\n\t\tlogger(\"ToggleFinancialAccount\", err).Error(fmt.Sprintf(\"Repo call to GetAccountByID failed\"))\n\t\treturn nil, utils.InternalServerError\n\t}\n\taccount.SetSelected(req.GetSelected())\n\terr = s.financialAccountRepo.UpdateAccount(tx, userID, req.GetAccountId(), account)\n\tif err != nil {\n\t\tlogger(\"ToggleFinancialAccount\", err).Error(fmt.Sprintf(\"Repo call to UpdateAccount failed\"))\n\t\treturn nil, utils.InternalServerError\n\t}\n\n\terr = s.txRepo.CommitTx(tx)\n\tif err != nil {\n\t\tlogger(\"ToggleFinancialAccount\", err).Error(utils.CommitTxErrorMsg)\n\t\treturn nil, err\n\t}\n\n\tres := &ToggleFinancialAccountResponse{\n\t\tSuccess: true,\n\t}\n\treturn res, nil\n}", "func ToggleWifiFromNetworkQuickSettings(ctx context.Context, s *testing.State) {\n\tcr := s.FixtValue().(*chrome.Chrome)\n\n\ttconn, err := cr.TestAPIConn(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to create Test API connection: \", err)\n\t}\n\n\t// Reserve ten seconds for cleanup.\n\tcleanupCtx := ctx\n\tctx, cancel := ctxutil.Shorten(ctx, 10*time.Second)\n\tdefer cancel()\n\tdefer faillog.DumpUITreeOnError(cleanupCtx, s.OutDir(), s.HasError, tconn)\n\n\t// Enable Wifi in shill.\n\twifiManager, err := shill.NewWifiManager(ctx, nil)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to create shill Wi-Fi manager: \", err)\n\t}\n\tif err := wifiManager.Enable(ctx, false); err != nil {\n\t\ts.Fatal(\"Failed to enable Wi-Fi: \", err)\n\t}\n\n\tif err := quicksettings.NavigateToNetworkDetailedView(ctx, tconn, true); err != nil {\n\t\ts.Fatal(\"Failed to navigate to the detailed Network view: \", err)\n\t}\n\n\tui := uiauto.New(tconn)\n\n\tstate := true\n\tconst iterations = 20\n\tfor i := 0; i < iterations; i++ {\n\t\ts.Logf(\"Toggling WiFi (iteration %d of %d)\", i+1, iterations)\n\n\t\tif err := ui.LeftClick(quicksettings.NetworkDetailedViewWifiToggleButtonRevamp)(ctx); err != nil {\n\t\t\ts.Fatal(\"Failed to click the WiFi toggle: \", err)\n\t\t}\n\n\t\texp, err := wifiManager.IsWifiEnabled(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Failed to toggle WiFi state: \", err)\n\t\t}\n\n\t\tif state != exp {\n\t\t\ts.Errorf(\"WiFi has a different status than expected: got %t, want %t\", state, exp)\n\t\t}\n\n\t\tstate = !state\n\t}\n}", "func (buzzer *ActiveBuzzer) ToggleTone() {\n\tif buzzer.pin.Read() == 1 {\n\t\tbuzzer.pin.Low()\n\t} else {\n\t\tbuzzer.pin.High()\n\t}\n}", "func DisableTwoFactor(ctx *context.Context) {\n\tctx.Data[\"Title\"] = ctx.Tr(\"settings\")\n\tctx.Data[\"PageIsSettingsSecurity\"] = true\n\n\tt, err := models.GetTwoFactorByUID(ctx.User.ID)\n\tif err != nil {\n\t\tctx.ServerError(\"SettingsTwoFactor\", err)\n\t\treturn\n\t}\n\n\tif err = models.DeleteTwoFactorByID(t.ID, ctx.User.ID); err != nil {\n\t\tctx.ServerError(\"SettingsTwoFactor\", err)\n\t\treturn\n\t}\n\n\tctx.Flash.Success(ctx.Tr(\"settings.twofa_disabled\"))\n\tctx.Redirect(setting.AppSubURL + \"/user/settings/security\")\n}", "func (m *AospDeviceOwnerDeviceConfiguration) GetBluetoothBlocked()(*bool) {\n val, err := m.GetBackingStore().Get(\"bluetoothBlocked\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (s *Settings) DisableToggleableSettings() {\n\tC.webkit_settings_set_auto_load_images(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_frame_flattening(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_html5_database(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_html5_local_storage(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_hyperlink_auditing(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_java(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_javascript(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_offline_web_application_cache(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_plugins(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_xss_auditor(s.settings, gboolean(false))\n\tC.webkit_settings_set_javascript_can_open_windows_automatically(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_private_browsing(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_developer_extras(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_resizable_text_areas(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_tabs_to_links(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_dns_prefetching(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_caret_browsing(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_fullscreen(s.settings, gboolean(false))\n\tC.webkit_settings_set_print_backgrounds(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_webaudio(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_webgl(s.settings, gboolean(false))\n\tC.webkit_settings_set_allow_modal_dialogs(s.settings, gboolean(false))\n\tC.webkit_settings_set_javascript_can_access_clipboard(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_page_cache(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_smooth_scrolling(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_accelerated_2d_canvas(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_media_stream(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_spatial_navigation(s.settings, gboolean(false))\n\tC.webkit_settings_set_enable_mediasource(s.settings, gboolean(false))\n}", "func UnconfigureSwitch(ctx context.Context, fabricGate *sync.WaitGroup, sw operation.ConfigSwitch, force bool, fabricError chan actions.OperationError, persist bool) {\n\tdefer fabricGate.Done()\n\n\tlog := appcontext.Logger(ctx).WithFields(nlog.Fields{\n\t\t\"App\": \"dcfabric\",\n\t\t\"Fabric\": sw.Fabric,\n\t\t\"Operation\": \"UnConfigure Switch\",\n\t\t\"Switch\": sw.Host,\n\t})\n\n\tvar wg sync.WaitGroup\n\n\twg.Add(1)\n\tgo UnconfigureSystemwideProperties(ctx, &wg, &sw, fabricError)\n\twg.Wait()\n\n\twg.Add(1)\n\tgo UnconfigureInterfaces(ctx, &wg, &sw, fabricError)\n\twg.Wait()\n\n\t//Make UnconfigureDataPlaneCluster available in deconfigure context\n\twg.Add(1)\n\tgo UnconfigureDataPlaneCluster(ctx, &wg, &sw.UnconfigureMCTBGPNeighbors, force, fabricError)\n\twg.Wait()\n\n\twg.Add(1)\n\tgo UnconfigureBGP(ctx, &wg, &sw, fabricError)\n\n\tif sw.Role == usecase.LeafRole {\n\t\twg.Add(1)\n\t\tgo UnconfigureEvpn(ctx, &wg, &sw, fabricError)\n\t\twg.Add(1)\n\t\tgo UnConfigureOverlayGateway(ctx, &wg, &sw, force, fabricError)\n\t}\n\n\twg.Wait()\n\tif persist {\n\t\twg.Add(1)\n\t\tgo persistConfig(ctx, &wg, &sw, fabricError)\n\n\t}\n\n\twg.Wait()\n\tlog.Info(\"Waiting for Child\")\n\n\tlog.Info(\"Completed\")\n}", "func (s *connection) SetSwitchOff(ain string) string {\n\tresult := s.prepareSH(ain, \"setswitchoff\")\n\treturn result\n}", "func (s *Systems) ChangeBiosSettings(ctx context.Context, req *systemsproto.BiosSettingsRequest) (*systemsproto.SystemsResponse, error) {\n\tvar resp systemsproto.SystemsResponse\n\tsessionToken := req.SessionToken\n\tauthResp := s.IsAuthorizedRPC(sessionToken, []string{common.PrivilegeConfigureComponents}, []string{})\n\tif authResp.StatusCode != http.StatusOK {\n\t\tlog.Error(\"error while trying to authenticate session\")\n\t\tfillSystemProtoResponse(&resp, authResp)\n\t\treturn &resp, nil\n\t}\n\tvar pc = systems.PluginContact{\n\t\tContactClient: pmbhandle.ContactPlugin,\n\t\tDevicePassword: common.DecryptWithPrivateKey,\n\t}\n\tdata := pc.ChangeBiosSettings(req)\n\tfillSystemProtoResponse(&resp, data)\n\treturn &resp, nil\n}", "func (uc *Userclient) ToggleSync(args *userproto.ToggleSyncArgs, reply *userproto.ToggleSyncReply) error {\r\n\treturn uc.iToggleSync(args, reply)\r\n}", "func (m *MicrosoftAuthenticatorAuthenticationMethodConfiguration) SetFeatureSettings(value MicrosoftAuthenticatorFeatureSettingsable)() {\n m.featureSettings = value\n}", "func (a *Client) GetPrivateToggleNotificationsFromSubaccount(params *GetPrivateToggleNotificationsFromSubaccountParams) (*GetPrivateToggleNotificationsFromSubaccountOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPrivateToggleNotificationsFromSubaccountParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"GetPrivateToggleNotificationsFromSubaccount\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/private/toggle_notifications_from_subaccount\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"\"},\n\t\tSchemes: []string{\"http\"},\n\t\tParams: params,\n\t\tReader: &GetPrivateToggleNotificationsFromSubaccountReader{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.(*GetPrivateToggleNotificationsFromSubaccountOK)\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 GetPrivateToggleNotificationsFromSubaccount: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func (m *AospDeviceOwnerDeviceConfiguration) GetBluetoothBlockConfiguration()(*bool) {\n val, err := m.GetBackingStore().Get(\"bluetoothBlockConfiguration\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*bool)\n }\n return nil\n}", "func (m *DeviceEnrollmentWindowsHelloForBusinessConfiguration) SetUnlockWithBiometricsEnabled(value *bool)() {\n err := m.GetBackingStore().Set(\"unlockWithBiometricsEnabled\", value)\n if err != nil {\n panic(err)\n }\n}", "func (hs100 *Hs100) TurnOff() error {\n\tresp, err := hs100.commandSender.SendCommand(hs100.Address, turnOffCommand)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error on sending turn on command for device\")\n\t}\n\n\tr, err := parseSetRelayResponse(resp)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Could not parse SystemInformationResponse from device\")\n\t} else if r.errorOccurred() {\n\t\treturn errors.New(\"got non zero exit code from device\")\n\t}\n\n\treturn nil\n}", "func (ac *APIClient) SwitchAccount(username, password string) {\n\tif len(strings.TrimSpace(username)) == 0 ||\n\t\tlen(strings.TrimSpace(password)) == 0 {\n\t\treturn\n\t}\n\n\tac.config.Username = username\n\tac.config.Password = password\n}", "func (s *connection) SetSwitchToggle(ain string) string {\n\tresult := s.prepareSH(ain, \"setswitchtoggle\")\n\treturn result\n}", "func (b *Bulb) TurnOff() error {\n\treturn b.Send(MethodSetPower, \"off\")\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) GetWorkProfileBluetoothEnableContactSharing()(*bool) {\n return m.workProfileBluetoothEnableContactSharing\n}", "func (_obj *Apichannels) Channels_toggleSlowMode(params *TLchannels_toggleSlowMode, _opt ...map[string]string) (ret Updates, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\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, \"channels_toggleSlowMode\", _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 = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\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 ToggleNotifications(userID string, toggle string) error {\n\n\tif toggle != \"1\" && toggle != \"0\" {\n\t\treturn errors.New(\"invalid value\")\n\t}\n\n\t_, err := db.SQL.Exec(`UPDATE \"UserSettings\" SET notifications = ? WHERE userID = ?;`, toggle, userID)\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn errors.New(\"database error\")\n\t}\n\n\treturn nil\n}", "func BacklightOn(lcd *device.Lcd) {\n\tm.Lock()\n\terr := lcd.BacklightOn()\n\tm.Unlock()\n\tif err != nil {\n\t\tlg.Fatalf(\"BacklightOn: %s\", err)\n\t}\n\treturn\n}", "func (c *Client) AccountChangeAuthorizationSettings(ctx context.Context, request *AccountChangeAuthorizationSettingsRequest) (bool, error) {\n\tvar result BoolBox\n\n\tif err := c.rpc.Invoke(ctx, request, &result); err != nil {\n\t\treturn false, err\n\t}\n\t_, ok := result.Bool.(*BoolTrue)\n\treturn ok, nil\n}", "func (b *BlueZ) PollForEnabled(ctx context.Context) error {\n\treturn PollForBTEnabled(ctx)\n}", "func ChangeBiosSettings(req systemsproto.BiosSettingsRequest) (*systemsproto.SystemsResponse, error) {\n\tconn, err := services.ODIMService.Client(services.Systems)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to create client connection: %v\", err)\n\t}\n\tdefer conn.Close()\n\tasService := systemsproto.NewSystemsClient(conn)\n\tresp, err := asService.ChangeBiosSettings(context.TODO(), &req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error: RPC error: %v\", err)\n\t}\n\treturn resp, nil\n}", "func (srv *grpcServer) ToggleFuseDrive(ctx context.Context, request *pb.ToggleFuseRequest) (*pb.FuseDriveResponse, error) {\n\tspan, ctx := opentracing.StartSpanFromContext(ctx, \"ToggleFuseDrive\")\n\tdefer span.Finish()\n\n\tif request.MountDrive {\n\t\tif err := srv.fc.Mount(); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to mount fuse drive\")\n\t\t}\n\t} else {\n\t\tif err := srv.fc.Unmount(); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to unmount fuse drive\")\n\t\t}\n\t}\n\n\treturn srv.GetFuseDriveStatus(ctx, nil)\n}", "func (b *Bit) Flip() bool {\n\tif b.ref == nil {\n\t\tb.enable()\n\t\treturn true\n\t} else {\n\t\tb.ref.Cancel()\n\t\tb.ref = nil\n\t\treturn false\n\t}\n}", "func (c *Client) ToggleScheduledScan(httpClient *http.Client, scanID int, enabled bool) (ToggleScheduledScan, error) {\n\tc.debugln(\"ToggleScheduledScan(): Building toggle scheduled scan URL\")\n\turl := fmt.Sprintf(\"https://%s:%s/scans/%d/schedule\", c.ip, c.port, scanID)\n\n\ttoggleJSON := fmt.Sprintf(`{\"enabled\": %t}`, enabled)\n\n\tstatusCode, body, err := c.postWithJSON(httpClient, url, []byte(toggleJSON))\n\tif err != nil {\n\t\treturn ToggleScheduledScan{}, err\n\t}\n\n\tswitch statusCode {\n\tcase 200:\n\t\tvar toggledScan ToggleScheduledScan\n\t\terr = json.Unmarshal(body, &toggledScan)\n\t\tif err != nil {\n\t\t\treturn ToggleScheduledScan{}, err\n\t\t}\n\t\tc.debugln(\"ToggleScheduledScan(): Successfully toggled scan schedule.\")\n\t\treturn toggledScan, nil\n\tdefault:\n\t\tvar err ErrorResponse\n\t\tunmarshalError := json.Unmarshal(body, &err)\n\t\tif unmarshalError != nil {\n\t\t\treturn ToggleScheduledScan{}, unmarshalError\n\t\t}\n\t\tc.debugln(\"ToggleScheduledScan(): Scan schedule could not be toggled.\")\n\t\treturn ToggleScheduledScan{}, fmt.Errorf(\"%s\", err.Error)\n\t}\n}", "func SetMirrorDisplay(ctx context.Context, tconn *chrome.TestConn, set bool) error {\n\tui := uiauto.New(tconn)\n\tdisplayFinder := nodewith.Name(\"Displays\").Role(role.Link).Ancestor(ossettings.WindowFinder)\n\n\tsettings, err := ossettings.LaunchAtPage(ctx, tconn, nodewith.Name(\"Device\").Role(role.Link))\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to launch os-settings Device page\")\n\t}\n\tdefer settings.Close(ctx)\n\n\tif err := ui.DoDefaultUntil(displayFinder, ui.WithTimeout(3*time.Second).WaitUntilGone(displayFinder))(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to launch display page\")\n\t}\n\n\tmirrorFinder := nodewith.Name(\"Mirror Built-in display\").Role(role.CheckBox).Ancestor(ossettings.WindowFinder)\n\t// Find the node info for the mirror checkbox.\n\tnodeInfo, err := ui.Info(ctx, mirrorFinder)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get info for the mirror checkbox\")\n\t}\n\n\tif set {\n\t\t// Set mirror display if its not set already.\n\t\tif nodeInfo.Checked == \"false\" {\n\t\t\tif err := ui.LeftClick(mirrorFinder)(ctx); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to click mirror display\")\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Unset mirror display if its not unset already.\n\t\tif nodeInfo.Checked == \"true\" {\n\t\t\tif err := ui.LeftClick(mirrorFinder)(ctx); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"failed to click mirror display\")\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (p *Panorama) ToggleSignalDetection() {\n\tp.signalDetectionActive = !p.signalDetectionActive\n}", "func (b *Bebop) handleNetworkSettingsStateFrame(commandId byte, frame *NetworkFrame) (found bool, context string, err error) {\n\tswitch commandId {\n\tcase ARCOMMANDS_ARDRONE3_NETWORKSETTINGSSTATECHANGED_STATE_WIFISELECTIONCHANGED:\n\t\t// Appears to be simply feedback for when the client issues a corresponding\n\t\t// instruction; returns settings to confirm?\n\t\t{\n\t\t\tvar channel uint8\n\t\t\twftypestr, err := decodeEnum(frame.Data[4:8], []string{\"auto_all\", \"auto_2_4ghz\", \"auto_5ghz\", \"all\"})\n\t\t\tif err != nil {\n\t\t\t\treturn true, \"WifiSelectionChanged\", err\n\t\t\t}\n\t\t\twfbandstr, err := decodeEnum(frame.Data[8:12], []string{\"2_4ghz\", \"5ghz\", \"all\"})\n\t\t\tif err != nil {\n\t\t\t\treturn true, \"WifiSelectionChanged\", err\n\t\t\t}\n\t\t\terr = binary.Read(bytes.NewReader(frame.Data[12:13]), binary.LittleEndian, &channel)\n\t\t\tif err != nil {\n\t\t\t\treturn true, \"WifiSelectionChanged\", err\n\t\t\t}\n\t\t\terr = b.sendJSONTelemetry(frame, bbtelem.Networksettingsstate, struct {\n\t\t\t\tType string `json:\"type\"`\n\t\t\t\tBand string `json:\"band\"`\n\t\t\t\tChannel int `json:\"channel\"`\n\t\t\t}{Type: wftypestr, Band: wfbandstr, Channel: int(channel)})\n\t\t\tif err != nil {\n\t\t\t\treturn true, \"WifiSelectionChanged\", err\n\t\t\t}\n\t\t}\n\tdefault:\n\t\t{\n\t\t\treturn false, \"\", nil\n\t\t}\n\t}\n\treturn true, \"\", nil\n}", "func listenForBtChanges() {\n\tlastExitCode := 999\n\tfor {\n\t\tcmd := exec.Command(\"ls\", \"/dev/input/event0\")\n\t\t_ = cmd.Run()\n\t\texitCode := cmd.ProcessState.ExitCode()\n\t\tif exitCode == 2 {\n\t\t\t// not connected\n\t\t\tif lastExitCode == 0 {\n\t\t\t\tlogger.Info(\"Re-run mplayer (2)... \")\n\t\t\t\tbluetoothConnected = false\n\t\t\t\tstationMutex.Lock()\n\t\t\t\tnewStation()\n\t\t\t\tstationMutex.Unlock()\n\t\t\t}\n\t\t\tfor _, btDevice := range btDevices {\n\t\t\t\t// logger.Info(fmt.Sprintf(\"Trying to connect device #%d %s\", idx, btDevice))\n\t\t\t\tcmd = exec.Command(\"bluetoothctl\", \"connect\", btDevice)\n\t\t\t\t_ = cmd.Run()\n\t\t\t\tconnectExitCode := cmd.ProcessState.ExitCode()\n\t\t\t\tif connectExitCode == 0 {\n\t\t\t\t\tlogger.Info(\"Success with device \" + btDevice)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else if exitCode == 0 {\n\t\t\t// connected\n\t\t\tif lastExitCode == 2 {\n\t\t\t\tlogger.Info(\"Re-run mplayer (0)... \")\n\t\t\t\tbluetoothConnected = true\n\t\t\t\tstationMutex.Lock()\n\t\t\t\tnewStation()\n\t\t\t\tstationMutex.Unlock()\n\t\t\t}\n\t\t}\n\t\tlastExitCode = exitCode\n\t\ttime.Sleep(3 * time.Second)\n\t}\n}", "func getBLEAdapter(impl string) (*bluetooth.Adapter, error) {\n\tif currentAdapter != nil {\n\t\treturn currentAdapter, nil\n\t}\n\n\tcurrentAdapter = bluetooth.DefaultAdapter\n\terr := currentAdapter.Enable()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"can't get device\")\n\t}\n\n\treturn currentAdapter, nil\n}", "func (m *Messenger) CallToActionsSetting(state string, actions []CallToActionsItem) error {\n\td := CallToActionsSetting{\n\t\tSettingType: \"call_to_actions\",\n\t\tThreadState: state,\n\t\tCallToActions: actions,\n\t}\n\n\tdata, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(\"POST\", SendSettingsURL, bytes.NewBuffer(data))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.URL.RawQuery = \"access_token=\" + m.token\n\n\tclient := &http.Client{}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\treturn checkFacebookError(resp.Body)\n}", "func blinkOK(led *GPIO) {\n\tled.Set(true)\n\ttime.Sleep(10 * time.Millisecond)\n\tled.Set(false)\n}", "func BridgeTechnologyUnsuspend(client Client, actionID, bridgeTechnology string) (Response, error) {\n\treturn send(client, \"BridgeTechnologyUnsuspend\", actionID, map[string]string{\n\t\t\"BridgeTechnology\": bridgeTechnology,\n\t})\n}", "func BridgeTechnologyUnsuspend(ctx context.Context, client Client, actionID, bridgeTechnology string) (Response, error) {\n\treturn send(ctx, client, \"BridgeTechnologyUnsuspend\", actionID, map[string]string{\n\t\t\"BridgeTechnology\": bridgeTechnology,\n\t})\n}", "func (service *RssService) ToggleBookmark(id uint, isBookmark bool) {\n\t// fixme\n\tvar article models.Articles\n\tservice.dbp().Where(&models.Articles{Id: id}).Find(&article)\n\tupdateArticles := service.dbp().Model(&models.Articles{Id: article.Id}) // fixme: (should be link)\n\n\tif isBookmark {\n\t\tupdateArticles.UpdateColumn(&models.Articles{IsBookmark: isBookmark})\n\t} else {\n\t\tupdateArticles.UpdateColumn(\"IsBookmark\", \"0\")\n\t}\n}", "func (c *Client) ChangeMailSettings(httpClient *http.Client, updatedMailSettings string) (bool, error) {\n\tc.debugln(\"ChangeMailSettings(): Building change mail settings URL\")\n\turl := fmt.Sprintf(\"https://%s:%s/settings/network/mail\", c.ip, c.port)\n\n\tstatusCode, body, err := c.putWithJSON(httpClient, url, []byte(updatedMailSettings))\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tswitch statusCode {\n\tcase 200:\n\t\tc.debugln(\"ChangeMailSettings(): Successfully changed mail settings.\")\n\t\treturn true, nil\n\tdefault:\n\t\tvar err ErrorResponse\n\t\tunmarshalError := json.Unmarshal(body, &err)\n\t\tif unmarshalError != nil {\n\t\t\treturn false, unmarshalError\n\t\t}\n\t\tc.debugln(\"ChangeMailSettings(): Mail settings could not be changed.\")\n\t\treturn false, fmt.Errorf(\"%s\", err.Error)\n\t}\n}", "func (s *Service) Toggle(ctx context.Context, params *light.ToggleParams) (*light.Light, error) {\n\t_, span := trace.StartSpan(ctx, \"hue.lights.toggle\")\n\tdefer span.End()\n\n\tctx = context.WithValue(ctx, hue.UserKey{}, params.GetUser())\n\tctx = context.WithValue(ctx, hue.HostKey{}, params.GetHost())\n\n\tres, err := s.hue.Toggle(ctx, int(params.GetID()))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tl, ok := res.(*light.Light)\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"failed to convert '%T' to *light.Light\", res)\n\t}\n\n\treturn l, nil\n}", "func OobeHidBluetoothMouseOnly(ctx context.Context, s *testing.State) {\n\t// TODO(b/246649651): Move these constants to a different file if they are\n\t// used by other test.\n\tconst SearchingForPointerNodeName = \"Searching for pointing device\"\n\tconst FoundPointerNodeName = \"Pointing device connected\"\n\tfv := s.FixtValue().(*bluetooth.FixtValue)\n\n\t// Shorten deadline to leave time for cleanup\n\tcleanupCtx := ctx\n\tctx, cancel := ctxutil.Shorten(cleanupCtx, 5*time.Second)\n\tdefer cancel()\n\n\tuiautoSvc := ui.NewAutomationServiceClient(fv.DUTRPCClient.Conn)\n\tcrUISvc := ui.NewChromeUIServiceClient(fv.DUTRPCClient.Conn)\n\n\tdefer func() {\n\t\tif !s.HasError() {\n\t\t\treturn\n\t\t}\n\t\tif _, err := crUISvc.DumpUITree(cleanupCtx, &emptypb.Empty{}); err != nil {\n\t\t\ttesting.ContextLog(cleanupCtx, \"Failed to dump UI tree: \", err)\n\t\t}\n\t}()\n\n\t// Verify pointer device is not found.\n\tcheckNodeWithNameExists(ctx, uiautoSvc, s, SearchingForPointerNodeName)\n\n\t// Discover btPeer as a mouse.\n\tmouseDevice, err := bluetooth.NewEmulatedBTPeerDevice(ctx, fv.BTPeers[0].BluetoothMouseDevice())\n\tif err != nil {\n\t\ts.Fatalf(\"Failed to configure btpeer as a %s device: %s\", mouseDevice.DeviceType(), err)\n\t}\n\n\tif result, err := mouseDevice.RPC().AdapterPowerOn(ctx); err != nil || !result {\n\t\ts.Fatal(\"Failed to power on btPeer adapter: \", err)\n\t}\n\n\t// Verify pointer device is found.\n\tcheckNodeWithNameExists(ctx, uiautoSvc, s, FoundPointerNodeName)\n\n\t// Turn off mouse device and check that DUT is searching for mouse.\n\tif result, err := mouseDevice.RPC().AdapterPowerOff(ctx); err != nil || !result {\n\t\ts.Fatal(\"Failed to turn of btPeer adapter: \", err)\n\t}\n\n\tcheckNodeWithNameExists(ctx, uiautoSvc, s, SearchingForPointerNodeName)\n\n\t// Turn on mouse device and check that mouse device is paired to.\n\tif result, err := mouseDevice.RPC().AdapterPowerOn(ctx); err != nil || !result {\n\t\ts.Fatal(\"Failed to power on btPeer adapter: \", err)\n\t}\n\n\t// Verify pointer device is found.\n\tcheckNodeWithNameExists(ctx, uiautoSvc, s, FoundPointerNodeName)\n\n\t// Navigate to welcome screen.\n\tcontinueButtonFinder := &ui.Finder{\n\t\tNodeWiths: []*ui.NodeWith{\n\t\t\t{Value: &ui.NodeWith_Name{Name: \"Continue\"}},\n\t\t\t{Value: &ui.NodeWith_Role{Role: ui.Role_ROLE_BUTTON}},\n\t\t},\n\t}\n\tif _, err := uiautoSvc.WaitUntilExists(\n\t\tctx, &ui.WaitUntilExistsRequest{Finder: continueButtonFinder}); err != nil {\n\t\ts.Fatal(\"Failed to find continue button: \", err)\n\t}\n\n\tif _, err := uiautoSvc.LeftClick(\n\t\tctx, &ui.LeftClickRequest{Finder: continueButtonFinder}); err != nil {\n\t\ts.Fatal(\"Failed to click continue button: \", err)\n\t}\n\n\tif _, err := crUISvc.WaitForWelcomeScreen(ctx, &emptypb.Empty{}); err != nil {\n\t\ts.Fatal(\"Failed to enter welcome page\")\n\t}\n\n\t// Clean up before ending test, this ensures btPeer does not try to pair with DUT\n\t// after test ends.\n\tif err := mouseDevice.RPC().Reset(ctx); err != nil {\n\t\ts.Fatal(\"Failed to reset device: \", err)\n\t}\n}", "func (s *Systems) ChangeBootOrderSettings(ctx context.Context, req *systemsproto.BootOrderSettingsRequest) (*systemsproto.SystemsResponse, error) {\n\tvar resp systemsproto.SystemsResponse\n\tsessionToken := req.SessionToken\n\tauthResp := s.IsAuthorizedRPC(sessionToken, []string{common.PrivilegeConfigureComponents}, []string{})\n\tif authResp.StatusCode != http.StatusOK {\n\t\tlog.Error(\"error while trying to authenticate session\")\n\t\tfillSystemProtoResponse(&resp, authResp)\n\t\treturn &resp, nil\n\t}\n\tvar pc = systems.PluginContact{\n\t\tContactClient: pmbhandle.ContactPlugin,\n\t\tDevicePassword: common.DecryptWithPrivateKey,\n\t}\n\tdata := pc.ChangeBootOrderSettings(req)\n\tfillSystemProtoResponse(&resp, data)\n\treturn &resp, nil\n}", "func (s *State) Toggle(given string) {\n\tif s.Current == given {\n\t\ts.Current = \"\"\n\t\treturn\n\t}\n\n\ts.Current = given\n}", "func (r *Bitbucket) Deactivate(user *model.User, repo *model.Repo, link string) error {\n\tvar client = bitbucket.New(\n\t\tr.Client,\n\t\tr.Secret,\n\t\tuser.Access,\n\t\tuser.Secret,\n\t)\n\ttitle, err := GetKeyTitle(link)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err := client.RepoKeys.DeleteName(repo.Owner, repo.Name, title); err != nil {\n\t\treturn err\n\t}\n\treturn client.Brokers.DeleteUrl(repo.Owner, repo.Name, link, bitbucket.BrokerTypePost)\n}", "func ToggleLiveMode() {\n\tConfig.LiveMode = !Config.LiveMode\n}", "func (l *RemoteProvider) StopSyncPreferences() {\n\tif !l.Capabilities.IsSupported(SyncPrefs) {\n\t\treturn\n\t}\n\n\tl.syncStopChan <- struct{}{}\n}", "func (m *defaultUsernamesClient) AccountToggleUsername(ctx context.Context, in *mtproto.TLAccountToggleUsername) (*mtproto.Bool, error) {\n\tclient := mtproto.NewRPCUsernamesClient(m.cli.Conn())\n\treturn client.AccountToggleUsername(ctx, in)\n}", "func (module *ShutUpModule) Toggle(srv *Server, msg *InputMessage) bool {\n\tbody := strings.ToLower(msg.Body)\n\tif reStop.MatchString(body) {\n\t\treturn true\n\t}\n\tif reShhh.MatchString(body) {\n\t\treturn true\n\t}\n\tif strings.HasPrefix(body, \"shut up\") {\n\t\treturn true\n\t}\n\treturn false\n}", "func (bc *BulkCreate) SetTransfertobankaccount(f float64) *BulkCreate {\n\tbc.mutation.SetTransfertobankaccount(f)\n\treturn bc\n}", "func (d *Database) ToggleSpectator(BattleID string, UserID string, Spectator bool) ([]*model.BattleUser, error) {\n\tif _, err := d.db.Exec(\n\t\t`UPDATE battles_users SET spectator = $3 WHERE battle_id = $1 AND user_id = $2`, BattleID, UserID, Spectator); err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\n\tif _, err := d.db.Exec(\n\t\t`UPDATE users SET last_active = NOW() WHERE id = $1`, UserID); err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tusers := d.GetBattleUsers(BattleID)\n\n\treturn users, nil\n}", "func removeSelectedAccountFromOSSettings(ctx context.Context, tconn *chrome.TestConn) error {\n\ttesting.ContextLog(ctx, \"Removing account\")\n\n\tui := uiauto.New(tconn).WithTimeout(DefaultUITimeout)\n\tremoveAccountButton := RemoveActionButton()\n\tif err := uiauto.Combine(\"Click Remove account\",\n\t\tui.WaitUntilExists(removeAccountButton),\n\t\tui.LeftClick(removeAccountButton),\n\t)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to to click Remove account\")\n\t}\n\n\treturn nil\n}", "func (m *DeviceManagementConfigurationPolicy) SetSettings(value []DeviceManagementConfigurationSettingable)() {\n err := m.GetBackingStore().Set(\"settings\", value)\n if err != nil {\n panic(err)\n }\n}", "func CheckARCToggleStatus(ctx context.Context, tconn *chrome.TestConn, brType browser.Type, expectedVal bool) error {\n\tif brType != browser.TypeLacros {\n\t\t// The feature is applied only if Lacros is enabled.\n\t\treturn nil\n\t}\n\tui := uiauto.New(tconn).WithTimeout(DefaultUITimeout)\n\troot := AddAccountDialog()\n\ttoggle := nodewith.NameStartingWith(\"Use this account with Android apps\").Role(role.ToggleButton).Ancestor(root)\n\tif err := ui.WaitUntilExists(toggle)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to find ARC toggle\")\n\t}\n\n\ttoggleInfo, err := ui.Info(ctx, toggle)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get ARC toggle info\")\n\t}\n\tisToggleChecked := (toggleInfo.Checked == checked.True)\n\tif isToggleChecked != expectedVal {\n\t\treturn errors.Errorf(\"expected toggle checked state to be %t but got %t\", expectedVal, isToggleChecked)\n\t}\n\n\treturn nil\n}", "func (r *Rele) SwitchOff() {\n\tpin := rpio.Pin(r.Pin)\n\tpin.High()\n\tif pin.Read() == rpio.High {\n\t\tr.On = false\n\t} else {\n\t\tr.On = true\n\t}\n}", "func (sh *stmHelper) blinkMaintenanceLED(ctx context.Context) {\n\tdefer sh.ClearDisplay()\n\tfor {\n\t\tsh.setLED(stm.LED1, yellow)\n\t\ttime.Sleep(time.Second)\n\t\tsh.setLED(stm.LED1, off)\n\n\t\tsh.setLED(stm.LED2, yellow)\n\t\ttime.Sleep(time.Second)\n\t\tsh.setLED(stm.LED2, off)\n\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\t}\n}", "func (m *IntentsItemUpdateSettingsPostRequestBody) SetSettings(value []ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.DeviceManagementSettingInstanceable)() {\n err := m.GetBackingStore().Set(\"settings\", value)\n if err != nil {\n panic(err)\n }\n}", "func GetB() bool {\n\treturn machine.BUTTONB.Get()\n}", "func (client *Client) DowngradeSmartAccessGatewaySoftwareWithCallback(request *DowngradeSmartAccessGatewaySoftwareRequest, callback func(response *DowngradeSmartAccessGatewaySoftwareResponse, err error)) <-chan int {\n\tresult := make(chan int, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tvar response *DowngradeSmartAccessGatewaySoftwareResponse\n\t\tvar err error\n\t\tdefer close(result)\n\t\tresponse, err = client.DowngradeSmartAccessGatewaySoftware(request)\n\t\tcallback(response, err)\n\t\tresult <- 1\n\t})\n\tif err != nil {\n\t\tdefer close(result)\n\t\tcallback(nil, err)\n\t\tresult <- 0\n\t}\n\treturn result\n}", "func (b *BPlane) SetBTGoal(value, tolerance float64) {\n\tb.goalBT = value\n\tb.tolBT = tolerance\n}", "func (m *defaultUsernamesClient) ChannelsToggleUsername(ctx context.Context, in *mtproto.TLChannelsToggleUsername) (*mtproto.Bool, error) {\n\tclient := mtproto.NewRPCUsernamesClient(m.cli.Conn())\n\treturn client.ChannelsToggleUsername(ctx, in)\n}", "func BacklightOff(lcd *device.Lcd) {\n\tm.Lock()\n\terr := lcd.BacklightOff()\n\tm.Unlock()\n\tif err != nil {\n\t\tlg.Fatalf(\"BacklightOff: %s\", err)\n\t}\n\treturn\n}", "func (m *AndroidWorkProfileGeneralDeviceConfiguration) SetPasswordBlockFingerprintUnlock(value *bool)() {\n m.passwordBlockFingerprintUnlock = value\n}", "func (s *service) Switches(server api.NetworkControlService_SwitchesServer) error {\n\treturn fmt.Errorf(\"deprecated\")\n}", "func (_Mevsky *MevskyTransactor) TurnOff(opts *bind.TransactOpts, receiver common.Address) (*types.Transaction, error) {\n\treturn _Mevsky.contract.Transact(opts, \"turnOff\", receiver)\n}", "func (h *UserRepos) SwitchAccount(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclaims, err := auth.ClaimsFromContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\treq := new(user_auth.SwitchAccountRequest)\n\tdata := make(map[string]interface{})\n\tf := func() (bool, error) {\n\n\t\tif r.Method == http.MethodPost {\n\t\t\terr := r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tdecoder := schema.NewDecoder()\n\t\t\tdecoder.IgnoreUnknownKeys(true)\n\n\t\t\tif err := decoder.Decode(req, r.PostForm); err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t} else {\n\t\t\tif pv, ok := params[\"account_id\"]; ok && pv != \"\" {\n\t\t\t\treq.AccountID = pv\n\t\t\t} else if qv := r.URL.Query().Get(\"account_id\"); qv != \"\" {\n\t\t\t\treq.AccountID = qv\n\t\t\t}\n\t\t}\n\n\t\tif req.AccountID != \"\" {\n\t\t\tsess := webcontext.ContextSession(ctx)\n\t\t\tvar expires time.Duration\n\t\t\tif sess != nil && sess.Options != nil {\n\t\t\t\texpires = time.Second * time.Duration(sess.Options.MaxAge)\n\t\t\t} else {\n\t\t\t\texpires = time.Hour\n\t\t\t}\n\n\t\t\t// Perform the account switch.\n\t\t\ttkn, err := h.AuthRepo.SwitchAccount(ctx, claims, *req, expires, ctxValues.Now)\n\t\t\tif err != nil {\n\t\t\t\tif verr, ok := weberror.NewValidationError(ctx, err); ok {\n\t\t\t\t\tdata[\"validationErrors\"] = verr.(*weberror.Error)\n\t\t\t\t\treturn false, nil\n\t\t\t\t} else {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update the access token in the session.\n\t\t\tsess = webcontext.SessionUpdateAccessToken(sess, tkn.AccessToken)\n\n\t\t\t// Read the account for a flash message.\n\t\t\tacc, err := h.AccountRepo.ReadByID(ctx, claims, tkn.AccountID)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\twebcontext.SessionFlashSuccess(ctx,\n\t\t\t\t\"Account Switched\",\n\t\t\t\tfmt.Sprintf(\"You are now logged into account %s.\",\n\t\t\t\t\tacc.Response(ctx).Name))\n\n\t\t\t// Redirect the user to the dashboard with the new credentials.\n\t\t\treturn true, web.Redirect(ctx, w, r, \"/\", http.StatusFound)\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\tend, err := f()\n\tif err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t} else if end {\n\t\treturn nil\n\t}\n\n\taccounts, err := h.AccountRepo.Find(ctx, claims, account.AccountFindRequest{\n\t\tOrder: []string{\"name\"},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata[\"accounts\"] = accounts.Response(ctx)\n\n\tif req.AccountID == \"\" {\n\t\treq.AccountID = claims.Audience\n\t}\n\n\tdata[\"form\"] = req\n\n\tif verr, ok := weberror.NewValidationError(ctx, webcontext.Validator().Struct(user_auth.SwitchAccountRequest{})); ok {\n\t\tdata[\"validationDefaults\"] = verr.(*weberror.Error)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-switch-account.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func (m *AndroidCompliancePolicy) SetSecurityDisableUsbDebugging(value *bool)() {\n err := m.GetBackingStore().Set(\"securityDisableUsbDebugging\", value)\n if err != nil {\n panic(err)\n }\n}", "func (im InputMethod) ResetSettings(tconn *chrome.TestConn) action.Action {\n\treturn im.SetSettings(tconn, map[string]interface{}{})\n}", "func (a ActivationHandler) toggleOff(timeout uint) bool {\n\ta.toggleChannel <- ToggleData{\n\t\tMode: 2,\n\t\tData: timeout,\n\t}\n\treturn <-a.queryChannel\n}", "func CheckPaymentToBeta() {\n\tbrokerTxs, _ := models.GetTransactionsBySessionTypesAndPaymentStatuses([]int{},\n\t\t[]models.PaymentStatus{models.BrokerTxBetaPaymentPending})\n\n\tfor _, brokerTx := range brokerTxs {\n\t\tbalance := EthWrapper.CheckPRLBalance(eth_gateway.StringToAddress(brokerTx.ETHAddrBeta))\n\t\texpectedBalance := new(big.Int).Quo(brokerTx.GetTotalCostInWei(), big.NewInt(int64(2)))\n\t\tif balance.Int64() > 0 && balance.Int64() >= expectedBalance.Int64() {\n\t\t\tpreviousBetaPaymentStatus := brokerTx.PaymentStatus\n\t\t\tbrokerTx.PaymentStatus = models.BrokerTxBetaPaymentConfirmed\n\t\t\terr := models.DB.Save(&brokerTx)\n\t\t\tif err != nil {\n\t\t\t\toyster_utils.LogIfError(err, nil)\n\t\t\t\tbrokerTx.PaymentStatus = previousBetaPaymentStatus\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif brokerTx.Type == models.SessionTypeBeta {\n\t\t\t\tReportGoodAlphaToDRS(brokerTx)\n\t\t\t}\n\t\t\toyster_utils.LogToSegment(\"check_beta_payments: CheckPaymentToBeta - beta_confirmed\",\n\t\t\t\tanalytics.NewProperties().\n\t\t\t\t\tSet(\"beta_address\", brokerTx.ETHAddrBeta).\n\t\t\t\t\tSet(\"alpha_address\", brokerTx.ETHAddrAlpha))\n\t\t}\n\t}\n}", "func doRestoreBacklight(ctx context.Context, originalBrightness string, executeCommand func(string, ...string) error) error {\n\tbrightnessArg := fmt.Sprintf(\"--set_brightness_percent=%s\", originalBrightness)\n\terr := executeCommand(\"backlight_tool\", brightnessArg)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (client *Client) DowngradeSmartAccessGatewaySoftwareWithChan(request *DowngradeSmartAccessGatewaySoftwareRequest) (<-chan *DowngradeSmartAccessGatewaySoftwareResponse, <-chan error) {\n\tresponseChan := make(chan *DowngradeSmartAccessGatewaySoftwareResponse, 1)\n\terrChan := make(chan error, 1)\n\terr := client.AddAsyncTask(func() {\n\t\tdefer close(responseChan)\n\t\tdefer close(errChan)\n\t\tresponse, err := client.DowngradeSmartAccessGatewaySoftware(request)\n\t\tif err != nil {\n\t\t\terrChan <- err\n\t\t} else {\n\t\t\tresponseChan <- response\n\t\t}\n\t})\n\tif err != nil {\n\t\terrChan <- err\n\t\tclose(responseChan)\n\t\tclose(errChan)\n\t}\n\treturn responseChan, errChan\n}", "func findWinChkBackUpToggled() {\n\topt.MakeBackup = obj.findWinChkBackUp.GetActive()\n}", "func TestDvLIRClient_ChangeNetworkSettings(t *testing.T) {\n\tip := viper.GetString(\"IPAddress\")\n\tpw := viper.GetString(\"Password\")\n\n\tdvlirClient, err := NewDvLIRClient(ip, pw)\n\tif !assert.NoError(t, err, \"Error while creating Api client\") {\n\t\treturn\n\t}\n\n\terr = dvlirClient.Login()\n\tif !assert.NoError(t, err, \"Error during Login\") {\n\t\treturn\n\t}\n\n\tres, err := dvlirClient.ChangeNetworkSettings(\"no\", \"\", \"\", \"\", \"\", \"\", \"\", \"\")\n\tif !assert.NoError(t, err, \"Error while while changing network settings\") {\n\t\treturn\n\t}\n\n\tfmt.Println(res)\n\n\tdefer func() {\n\t\terr = dvlirClient.Logout()\n\t\tif !assert.NoError(t, err, \"Error during Logout\") {\n\t\t\treturn\n\t\t}\n\t}()\n}", "func (m Logon) SetHeartBtInt(v int) {\n\tm.Set(field.NewHeartBtInt(v))\n}", "func (m *DeviceManagementConfigurationSettingDefinition) SetUxBehavior(value *DeviceManagementConfigurationControlType)() {\n err := m.GetBackingStore().Set(\"uxBehavior\", value)\n if err != nil {\n panic(err)\n }\n}", "func (s HueServer) Blink(ctx context.Context, in *hue.LightsRequest) (*hue.LightsResponse, error) {\n\tlog.WithField(\"message\", in).\n\t\tWithField(\"call\", \"Blink\").Print(\"Incoming gRPC call\")\n\tgg := groups.New(hueBridge.Bridge, hueBridge.Username)\n\tg, err := gg.GetGroup(int(in.GetGroup()))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toldState := g.Action\n\n\tbrightness := uint8(255 * in.GetBrightnessPercent())\n\tgg.SetGroupState(g.ID, lights.State{On: true, Bri: brightness, Alert: \"lselect\"})\n\tgg.SetGroupState(g.ID, oldState)\n\treturn &hue.LightsResponse{Success: true}, nil\n}", "func FlipSwitch(switchDB *sql.DB) error {\n\tcurrentSwitch, err := getSwitch(switchDB)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar newSwitch int\n\tif currentSwitch == 1 {\n\t\tnewSwitch = 2\n\t} else {\n\t\tnewSwitch = 1\n\t}\n\tquery := fmt.Sprintf(\n\t\t\"UPDATE %s SET %s = %d WHERE %s = %d\",\n\t\tconfig.SwitchDBTable,\n\t\tconfig.SwitchDBCol,\n\t\tnewSwitch,\n\t\tconfig.SwitchDBCol,\n\t\tcurrentSwitch,\n\t)\n\t_, err = switchDB.Exec(query)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (o *HyperflexHxapDvUplink) UnsetBondState() {\n\to.BondState.Unset()\n}", "func initBle(protocolConfig configmap.BleProtocolConfig, name string) (client driver.BleClient, err error) {\n\tif protocolConfig.MacAddress != \"\" {\n\t\tconfig := driver.BleConfig{\n\t\t\tAddr: protocolConfig.MacAddress,\n\t\t}\n\t\tclient, err = driver.NewClient(config)\n\t}\n\treturn\n}", "func ToggleState(ctx *context.Context) {\n\n\tctx.HTML(200, \"shops/togglestate\")\n}", "func FlipBit(input uint16, offset uint8) uint16 {\n\tinput ^= (1 << (15 - offset))\n\treturn input\n}", "func (m *IosStoreAppAssignmentSettings) SetUninstallOnDeviceRemoval(value *bool)() {\n err := m.GetBackingStore().Set(\"uninstallOnDeviceRemoval\", value)\n if err != nil {\n panic(err)\n }\n}", "func (r *NucypherAccountRepository) Deactivate(updatedBy string, accountID int, now time.Time) error {\n\n\t_, err := r.store.db.Exec(`UPDATE nucypher_accounts \n\tSET is_active=false, updated_by=$1, updated_at=$3 \n\tWHERE (created_by=$1 AND account_id=$2)`,\n\t\tupdatedBy,\n\t\taccountID,\n\t\tnow,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n\n}" ]
[ "0.5695747", "0.5552069", "0.55088377", "0.5350359", "0.5199173", "0.49642628", "0.49262956", "0.4868401", "0.48637766", "0.48339373", "0.48244256", "0.479344", "0.47463658", "0.468271", "0.46184593", "0.45439374", "0.45363155", "0.45159185", "0.4514827", "0.45020643", "0.44778112", "0.4421353", "0.43991074", "0.43806142", "0.43787733", "0.43656334", "0.4348715", "0.43012893", "0.42640662", "0.42198154", "0.42117918", "0.41708565", "0.41671777", "0.41671237", "0.41510794", "0.414231", "0.41422316", "0.41340896", "0.40914398", "0.4085789", "0.40756425", "0.40752724", "0.4057725", "0.4052036", "0.40518868", "0.40496716", "0.40373597", "0.40347046", "0.40322256", "0.402853", "0.40284914", "0.40185925", "0.4006467", "0.3998409", "0.3989995", "0.39811665", "0.39760974", "0.39655277", "0.39549536", "0.3954056", "0.39399818", "0.3925668", "0.39202344", "0.39157468", "0.3910183", "0.390563", "0.38966623", "0.38900113", "0.38814712", "0.3881189", "0.3873973", "0.38712612", "0.38698924", "0.38596043", "0.3852752", "0.38509944", "0.38426414", "0.3841369", "0.38260466", "0.3821663", "0.382134", "0.38131332", "0.38119873", "0.38073802", "0.38067785", "0.38017505", "0.3801259", "0.38011906", "0.37991", "0.37934926", "0.3788425", "0.37726128", "0.37720355", "0.37704626", "0.3765539", "0.37643656", "0.37591106", "0.37491986", "0.37451187", "0.37431958" ]
0.8733043
0
testParentSelection uses special event name format: :
func testParentSelection(t *testing.T, dsc, schema string) { t.Run(dsc, func(t *testing.T) { assertar := assert.New(t) ctrl := gomock.NewController(t) defer ctrl.Finish() consensus := NewMockConsensus(ctrl) store := NewMemStore() node := NewForTests(dsc, store, consensus) node.initParents() defer node.Stop() expected := ASCIIschemeToDAG(node, consensus, schema) for n, expect := range expected { parent := node.popBestParent() if !assertar.NotNil(parent, "step %d", n) { break } if !assertar.Equal(expect, parent.String(), "step %d", n) { break } } assertar.Nil(node.popBestParent(), "last step") }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func maybePressSelectParentOption(ctx context.Context, tconn *chrome.TestConn, selectParentOption, parentPasswordField *nodewith.Finder, parentUser string) error {\n\tui := uiauto.New(tconn).WithTimeout(20 * time.Second)\n\n\tif err := ui.Exists(selectParentOption)(ctx); err != nil {\n\t\treturn nil\n\t}\n\n\ttesting.ContextLog(ctx, \"Clicking button that matches parent email: \", parentUser)\n\tif err := ui.WithInterval(time.Second).LeftClickUntil(selectParentOption, ui.Exists(parentPasswordField))(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to click button that matches parent email\")\n\t}\n\treturn nil\n\n}", "func TestParent(t *testing.T) {\n\tt.Run(\"ScheduledEvents\", testScheduledEvents)\n}", "func (s *BasevhdlListener) EnterSelected_name(ctx *Selected_nameContext) {}", "func TestParent(t *testing.T) {\n\tt.Run(\"Episodes\", testEpisodes)\n\tt.Run(\"Quotes\", testQuotes)\n}", "func TestGetParentCallFunc(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\twant string\n\t}{\n\t\t{\n\t\t\tname: \"tRunner\",\n\t\t\twant: \"tRunner\",\n\t\t},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tif got := GetParentCallFunc(); got != tt.want {\n\t\t\t\tt.Errorf(\"GetParentCallFunc() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestParent(t *testing.T) {\n\tt.Run(\"Persons\", testPersons)\n\tt.Run(\"Things\", testThings)\n}", "func TestParent(t *testing.T) {\n\tt.Run(\"Branches\", testBranches)\n\tt.Run(\"Divisions\", testDivisions)\n\tt.Run(\"Users\", testUsers)\n}", "func (s *BasevhdlListener) ExitSelected_name(ctx *Selected_nameContext) {}", "func TestParent(t *testing.T) {\n\tt.Run(\"RawBlocks\", testRawBlocks)\n\tt.Run(\"RawTxes\", testRawTxes)\n}", "func (s *BasevhdlListener) EnterSelected_name_part(ctx *Selected_name_partContext) {}", "func TestParent(t *testing.T) {\n\tt.Run(\"Bundles\", testBundles)\n\tt.Run(\"Caches\", testCaches)\n\tt.Run(\"Escrows\", testEscrows)\n\tt.Run(\"EscrowCaches\", testEscrowCaches)\n}", "func (s *BaseMySqlParserListener) EnterParenthesisSelect(ctx *ParenthesisSelectContext) {}", "func TestParent(t *testing.T) {\n\tt.Run(\"Crawls\", testCrawls)\n\tt.Run(\"PeerProperties\", testPeerProperties)\n\tt.Run(\"Peers\", testPeers)\n\tt.Run(\"Sessions\", testSessions)\n}", "func (s *BasejossListener) EnterToSel(ctx *ToSelContext) {}", "func TestEvents(t *testing.T) {\n\tnow := time.Now()\n\ttype args struct {\n\t\tnow time.Time\n\t\tmessage string\n\t\thostname string\n\t}\n\ttype expected struct {\n\t\ttitle string\n\t\ttext interface{}\n\t\tnow time.Time\n\t\tts interface{}\n\t\tpriority string\n\t\tsource string\n\t\talertType interface{}\n\t\taggregationKey string\n\t\tsourceTypeName interface{}\n\t\tcheckTags map[string]string\n\t}\n\n\ttests := []struct {\n\t\tname string\n\t\targs args\n\t\texpected expected\n\t}{\n\t\t{\n\t\t\tname: \"event minimal\",\n\t\t\targs: args{\n\t\t\t\tnow: now,\n\t\t\t\tmessage: \"_e{10,9}:test title|test text\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now,\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event multilines text\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(1),\n\t\t\t\tmessage: \"_e{10,24}:test title|test\\\\line1\\\\nline2\\\\nline3\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test\\\\line1\\nline2\\nline3\",\n\t\t\t\tnow: now.Add(1),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event pipe in title\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(2),\n\t\t\t\tmessage: \"_e{10,24}:test|title|test\\\\line1\\\\nline2\\\\nline3\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test|title\",\n\t\t\t\ttext: \"test\\\\line1\\nline2\\nline3\",\n\t\t\t\tnow: now.Add(2),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata timestamp\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(3),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|d:21\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(3),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"\",\n\t\t\t\tts: int64(21),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata priority\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(4),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|p:low\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(4),\n\t\t\t\tpriority: priorityLow,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata hostname\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(5),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|h:localhost\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(5),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"localhost\",\n\t\t\t\talertType: eventInfo,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata hostname in tag\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(6),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|#host:localhost\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(6),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"localhost\",\n\t\t\t\talertType: eventInfo,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata empty host tag\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(7),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|#host:,other:tag\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(7),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"true\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\tcheckTags: map[string]string{\"other\": \"tag\", \"source\": \"true\"},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata alert type\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(8),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|t:warning\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(8),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventWarning,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata aggregation key\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(9),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|k:some aggregation key\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(9),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"some aggregation key\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata aggregation key\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(10),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|k:some aggregation key\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(10),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\taggregationKey: \"some aggregation key\",\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata source type\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|s:this is the source\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\tsourceTypeName: \"this is the source\",\n\t\t\t\talertType: eventInfo,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata source type\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|s:this is the source\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\tsourceTypeName: \"this is the source\",\n\t\t\t\talertType: eventInfo,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata source tags\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|#tag1,tag2:test\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tpriority: priorityNormal,\n\t\t\t\tsource: \"default-hostname\",\n\t\t\t\talertType: eventInfo,\n\t\t\t\tcheckTags: map[string]string{\"tag1\": \"true\", \"tag2\": \"test\", \"source\": \"default-hostname\"},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"event metadata multiple\",\n\t\t\targs: args{\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tmessage: \"_e{10,9}:test title|test text|t:warning|d:12345|p:low|h:some.host|k:aggKey|s:source test|#tag1,tag2:test\",\n\t\t\t\thostname: \"default-hostname\",\n\t\t\t},\n\t\t\texpected: expected{\n\t\t\t\ttitle: \"test title\",\n\t\t\t\ttext: \"test text\",\n\t\t\t\tnow: now.Add(11),\n\t\t\t\tpriority: priorityLow,\n\t\t\t\tsource: \"some.host\",\n\t\t\t\tts: int64(12345),\n\t\t\t\talertType: eventWarning,\n\t\t\t\taggregationKey: \"aggKey\",\n\t\t\t\tsourceTypeName: \"source test\",\n\t\t\t\tcheckTags: map[string]string{\"aggregation_key\": \"aggKey\", \"tag1\": \"true\", \"tag2\": \"test\", \"source\": \"some.host\"},\n\t\t\t},\n\t\t},\n\t}\n\ts := NewTestStatsd()\n\tacc := &testutil.Accumulator{}\n\trequire.NoError(t, s.Start(acc))\n\tdefer s.Stop()\n\tfor i := range tests {\n\t\tt.Run(tests[i].name, func(t *testing.T) {\n\t\t\tacc.ClearMetrics()\n\t\t\terr := s.parseEventMessage(tests[i].args.now, tests[i].args.message, tests[i].args.hostname)\n\t\t\trequire.NoError(t, err)\n\t\t\tm := acc.Metrics[0]\n\t\t\trequire.Equal(t, tests[i].expected.title, m.Measurement)\n\t\t\trequire.Equal(t, tests[i].expected.text, m.Fields[\"text\"])\n\t\t\trequire.Equal(t, tests[i].expected.now, m.Time)\n\t\t\trequire.Equal(t, tests[i].expected.ts, m.Fields[\"ts\"])\n\t\t\trequire.Equal(t, tests[i].expected.priority, m.Fields[\"priority\"])\n\t\t\trequire.Equal(t, tests[i].expected.source, m.Tags[\"source\"])\n\t\t\trequire.Equal(t, tests[i].expected.alertType, m.Fields[\"alert_type\"])\n\t\t\trequire.Equal(t, tests[i].expected.aggregationKey, m.Tags[\"aggregation_key\"])\n\t\t\trequire.Equal(t, tests[i].expected.sourceTypeName, m.Fields[\"source_type_name\"])\n\t\t\tif tests[i].expected.checkTags != nil {\n\t\t\t\trequire.Equal(t, tests[i].expected.checkTags, m.Tags)\n\t\t\t}\n\t\t})\n\t}\n}", "func (s *BasejossListener) EnterPartSel(ctx *PartSelContext) {}", "func (*XMLDocument) Onselectionchange() (onselectionchange func(window.Event)) {\n\tmacro.Rewrite(\"$_.onselectionchange\")\n\treturn onselectionchange\n}", "func (s *BaseMySqlParserListener) ExitParenthesisSelect(ctx *ParenthesisSelectContext) {}", "func (s *TableGroupSlice) parentSQLSelect(dbrSess dbr.SessionRunner, cbs ...dbr.SelectCb) (int, error) {\n\treturn csdb.LoadSlice(dbrSess, TableCollection, TableIndexGroup, &(*s), cbs...)\n}", "func TestParent(t *testing.T) {\n\tt.Run(\"Auths\", testAuths)\n\tt.Run(\"Changelogs\", testChangelogs)\n\tt.Run(\"Confidences\", testConfidences)\n\tt.Run(\"Containers\", testContainers)\n\tt.Run(\"Cpes\", testCpes)\n\tt.Run(\"CveDetails\", testCveDetails)\n\tt.Run(\"DistroAdvisories\", testDistroAdvisories)\n\tt.Run(\"Groups\", testGroups)\n\tt.Run(\"JVNS\", testJVNS)\n\tt.Run(\"NVDS\", testNVDS)\n\tt.Run(\"Organizations\", testOrganizations)\n\tt.Run(\"PackageInfos\", testPackageInfos)\n\tt.Run(\"Platforms\", testPlatforms)\n\tt.Run(\"References\", testReferences)\n\tt.Run(\"ScanResults\", testScanResults)\n\tt.Run(\"Tasks\", testTasks)\n\tt.Run(\"Users\", testUsers)\n\tt.Run(\"VulnInfos\", testVulnInfos)\n}", "func SelectionChanged(s *gtk.TreeSelection) {\n\t// Returns glib.List of gtk.TreePath pointers\n\trows := s.GetSelectedRows(ListStore)\n\titems := make([]string, 0, rows.Length())\n\n\tfor l := rows; l != nil; l = l.Next() {\n\t\tpath := l.Data().(*gtk.TreePath)\n\t\titer, _ := ListStore.GetIter(path)\n\t\tvalue, _ := ListStore.GetValue(iter, 0)\n\t\tstr, _ := value.GetString()\n\t\titems = append(items, str)\n\t}\n\n\tEntry.SetText(fmt.Sprint(items))\n}", "func (s *BaseMySqlParserListener) EnterSubqueryComparasionPredicate(ctx *SubqueryComparasionPredicateContext) {\n}", "func testSpecialNamedRoots(t *testing.T, asciiScheme string) {\n\tassertar := assert.New(t)\n\t// init\n\tnodes, _, names := inter.ASCIIschemeToDAG(asciiScheme)\n\tp, _, input := FakePoset(nodes)\n\t// process events\n\tfor _, event := range names {\n\t\tinput.SetEvent(event)\n\t\tp.PushEventSync(event.Hash())\n\t}\n\t// check each\n\tfor name, event := range names {\n\t\t// check root\n\t\tmustBeRoot := name == strings.ToUpper(name)\n\t\tframe, isRoot := p.FrameOfEvent(event.Hash())\n\t\tif !assertar.Equal(mustBeRoot, isRoot, name+\" is root\") {\n\t\t\tbreak\n\t\t}\n\t\t// check frame\n\t\tmustBeFrame, err := strconv.ParseUint(name[2:3], 10, 64)\n\t\tif !assertar.NoError(err, \"name the nodes properly: <UpperCaseForRoot><Index><FrameN>\") {\n\t\t\treturn\n\t\t}\n\t\tif !assertar.Equal(mustBeFrame, frame.Index, \"frame of \"+name) {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (c *testChain) recordParent(t *testing.T, child, parent string) {\n\tif p := c.Nodes[child].Parent; p != \"\" && p != parent {\n\t\tt.Fatalf(\"differing parent specified for %s: %q != %q\", child, p, parent)\n\t}\n\tc.Nodes[child].Parent = parent\n}", "func execSelectionString(_ int, p *gop.Context) {\n\targs := p.GetArgs(2)\n\tret := types.SelectionString(args[0].(*types.Selection), args[1].(types.Qualifier))\n\tp.Ret(2, ret)\n}", "func (s *BasevhdlListener) ExitSelected_name_part(ctx *Selected_name_partContext) {}", "func TestParent(t *testing.T) {\n\tt.Run(\"AnalyticsPageviewReferers\", testAnalyticsPageviewReferers)\n\tt.Run(\"AnalyticsPageviewUseragents\", testAnalyticsPageviewUseragents)\n\tt.Run(\"AnalyticsPageviews\", testAnalyticsPageviews)\n\tt.Run(\"Media\", testMedia)\n\tt.Run(\"PostHistories\", testPostHistories)\n\tt.Run(\"Posts\", testPosts)\n\tt.Run(\"Subscribers\", testSubscribers)\n\tt.Run(\"TeamMembers\", testTeamMembers)\n\tt.Run(\"Teams\", testTeams)\n\tt.Run(\"UserCreateCodes\", testUserCreateCodes)\n\tt.Run(\"Users\", testUsers)\n}", "func (s *BasePlSqlParserListener) EnterSubpartition_name(ctx *Subpartition_nameContext) {}", "func (s *BasejossListener) EnterStepSel(ctx *StepSelContext) {}", "func (s *TableStoreSlice) parentSQLSelect(dbrSess dbr.SessionRunner, cbs ...dbr.SelectCb) (int, error) {\n\treturn csdb.LoadSlice(dbrSess, TableCollection, TableIndexStore, &(*s), cbs...)\n}", "func (s *BasejossListener) EnterDoSel(ctx *DoSelContext) {}", "func MatchInnerEvent(matchers ...cetest.EventMatcher) cetest.EventMatcher {\n\treturn cetest.AllOf(cetest.HasType(EventType), func(have event.Event) error {\n\t\tif have.Data() != nil {\n\t\t\tinnerEvent := cloudevents.Event{}\n\t\t\terr := have.DataAs(&innerEvent)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error while trying to parse inner event %w\", err)\n\t\t\t}\n\n\t\t\treturn cetest.AllOf(matchers...)(innerEvent)\n\t\t}\n\t\treturn errors.New(\"event doesn't contain an inner event\")\n\t})\n}", "func (_f38 *FakeContext) WithParentCalledWith(ident1 context.Context) (found bool) {\n\tfor _, call := range _f38.WithParentCalls {\n\t\tif reflect.DeepEqual(call.Parameters.Ident1, ident1) {\n\t\t\tfound = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn\n}", "func (s *BaseMySqlParserListener) EnterSubstrFunctionCall(ctx *SubstrFunctionCallContext) {}", "func (s *BasePlSqlParserListener) ExitSubpartition_name(ctx *Subpartition_nameContext) {}", "func TestChildSameName(t *testing.T) {\n\tvar fooCmdArgs []string\n\trootCmd := &Command{Use: \"foo\", Args: NoArgs, Run: emptyRun}\n\tfooCmd := &Command{\n\t\tUse: \"foo\",\n\t\tArgs: ExactArgs(2),\n\t\tRun: func(_ *Command, args []string) { fooCmdArgs = args },\n\t}\n\tbarCmd := &Command{Use: \"bar\", Args: NoArgs, Run: emptyRun}\n\trootCmd.AddCommand(fooCmd, barCmd)\n\n\toutput, err := executeCommand(rootCmd, \"foo\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(fooCmdArgs, \" \")\n\tif got != onetwo {\n\t\tt.Errorf(\"fooCmdArgs expected: %v, got: %v\", onetwo, got)\n\t}\n}", "func TestEventString(t *testing.T) {\n\tcases := map[Event]string{\n\t\tCreate: \"notify.Create\",\n\t\tCreate | Remove: \"notify.Create|notify.Remove\",\n\t\tCreate | Remove | Write: \"notify.Create|notify.Remove|notify.Write\",\n\t\tCreate | Write | Rename: \"notify.Create|notify.Rename|notify.Write\",\n\t}\n\tfor e, str := range cases {\n\t\tif s := s(e.String()); s != str {\n\t\t\tt.Errorf(\"want s=%s; got %s (e=%#x)\", str, s, e)\n\t\t}\n\t}\n}", "func TestClickAfterLastLineSelected(t *testing.T) {\n\tconst str = \"Hello\"\n\tb := NewTextBox(testWin, testTextStyles, testSize)\n\tb.SetText(rope.New(str))\n\tb.syntax = []syntax.Highlight{\n\t\t{At: [2]int64{0, 3}, Style: testTextStyle1},\n\t}\n\tb.Click(image.Pt(10*A+A/2, 4*H+H/2), 1)\n\n\tn := int64(len(str))\n\twant := [2]int64{n, n}\n\tif b.dots[1].At != want {\n\t\tt.Errorf(\"dot=%v, wanted=%v\\n\", b.dots[1].At, want)\n\t}\n}", "func (s Selector) Equal(sel Selector) bool { return s.Value == sel.Value }", "func (s *BaseSelectStatementParserListener) EnterSubExpression(ctx *SubExpressionContext) {}", "func (dnd *Dnd) onSelectionNotify(ev0 interface{}) {\n\tev := ev0.(xproto.SelectionNotifyEvent)\n\tif dnd.tmp.dropEvent != nil {\n\t\t// safe to defer clear tmp variable after onselectionnotify since the dropEvent has the data\n\t\tdefer dnd.ClearTmp()\n\t\t_ = dnd.tmp.dropEvent.OnSelectionNotify(&ev)\n\t}\n}", "func (suite *AddCommandTestSuite) TestExecuteWhenMultipleTracksFound() {\n\n}", "func (*XMLDocument) SetOnselectionchange(onselectionchange func(window.Event)) {\n\tmacro.Rewrite(\"$_.onselectionchange = $1\", onselectionchange)\n}", "func (s *BasePlSqlParserListener) EnterSubquery(ctx *SubqueryContext) {}", "func (e ProjectCreated) isEvent() {}", "func handleTestsFinishedEvent(event cloudevents.Event, shkeptncontext string, data *keptnevents.TestsFinishedEventData, logger *keptnutils.Logger) error {\n\tlogger.Info(fmt.Sprintf(\"Handling Tests Finished Event: %s\", event.Context.GetID()));\n\n\treturn nil\n}", "func (s *mergeBaseSuite) TestAncestorSame(c *C) {\n\trevs := []string{\"A\", \"A\"}\n\ts.AssertAncestor(c, revs, true)\n}", "func (s *BasevhdlListener) EnterSelected_signal_assignment(ctx *Selected_signal_assignmentContext) {}", "func handleTestEvent(c *Consumer, mt *msgtracker, expCnt int, ev Event) bool {\n\tswitch e := ev.(type) {\n\tcase *Message:\n\t\tif e.TopicPartition.Error != nil {\n\t\t\tmt.t.Errorf(\"Error: %v\", e.TopicPartition)\n\t\t}\n\t\tmt.msgs[mt.msgcnt] = e\n\t\tmt.msgcnt++\n\t\tif mt.msgcnt >= int64(expCnt) {\n\t\t\treturn false\n\t\t}\n\tcase PartitionEOF:\n\t\tbreak // silence\n\tdefault:\n\t\tmt.t.Fatalf(\"Consumer error: %v\", e)\n\t}\n\treturn true\n\n}", "func (s *BasePlSqlParserListener) EnterSelected_tableview(ctx *Selected_tableviewContext) {}", "func (ft *FacadeUnitTest) Test_GetEvaluatedServiceUsesParent(c *C) {\n\tparentID := \"parentServiceID\"\n\tparentName := \"parentServiceName\"\n\tparentSvc := service.Service{\n\t\tID: parentID,\n\t\tName: parentName,\n\t}\n\tchildID := \"childServiceID\"\n\tchildName := \"childServiceName\"\n\tchildSvc := service.Service{\n\t\tID: childID,\n\t\tName: childName,\n\t\tParentServiceID: parentID,\n\t\tActions: map[string]string{\"parent\": \"{{(parent .).ID}}\", \"instanceID\": \"{{.InstanceID}}\"},\n\t}\n\tft.serviceStore.On(\"Get\", ft.ctx, parentID).Return(&parentSvc, nil)\n\tft.configStore.On(\"GetConfigFiles\", ft.ctx, parentID, \"/\"+parentID).Return([]*serviceconfigfile.SvcConfigFile{}, nil)\n\n\tft.serviceStore.On(\"Get\", ft.ctx, childID).Return(&childSvc, nil)\n\tchildServicePath := \"/\" + parentID + \"/\" + childID\n\tft.configStore.On(\"GetConfigFiles\", ft.ctx, parentID, childServicePath).Return([]*serviceconfigfile.SvcConfigFile{}, nil)\n\n\tinstanceID := 99\n\tresult, err := ft.Facade.GetEvaluatedService(ft.ctx, childID, instanceID)\n\n\tc.Assert(result, Not(IsNil))\n\tc.Assert(err, IsNil)\n\tc.Assert(result.Actions[\"parent\"], Equals, parentID)\n\tc.Assert(result.Actions[\"instanceID\"], Equals, fmt.Sprintf(\"%d\", instanceID))\n}", "func (s *BasejossListener) EnterDelCmdSel(ctx *DelCmdSelContext) {}", "func (s *BaseMySqlParserListener) EnterSubqueryTableItem(ctx *SubqueryTableItemContext) {}", "func (s *BasePlSqlParserListener) EnterSubprogram_spec(ctx *Subprogram_specContext) {}", "func (s *BasejossListener) EnterTypeSel(ctx *TypeSelContext) {}", "func TestGrandChildSameName(t *testing.T) {\n\tvar fooCmdArgs []string\n\trootCmd := &Command{Use: \"foo\", Args: NoArgs, Run: emptyRun}\n\tbarCmd := &Command{Use: \"bar\", Args: NoArgs, Run: emptyRun}\n\tfooCmd := &Command{\n\t\tUse: \"foo\",\n\t\tArgs: ExactArgs(2),\n\t\tRun: func(_ *Command, args []string) { fooCmdArgs = args },\n\t}\n\tbarCmd.AddCommand(fooCmd)\n\trootCmd.AddCommand(barCmd)\n\n\toutput, err := executeCommand(rootCmd, \"bar\", \"foo\", \"one\", \"two\")\n\tif output != \"\" {\n\t\tt.Errorf(\"Unexpected output: %v\", output)\n\t}\n\tif err != nil {\n\t\tt.Errorf(\"Unexpected error: %v\", err)\n\t}\n\n\tgot := strings.Join(fooCmdArgs, \" \")\n\tif got != onetwo {\n\t\tt.Errorf(\"fooCmdArgs expected: %v, got: %v\", onetwo, got)\n\t}\n}", "func (s *BasejossListener) ExitToSel(ctx *ToSelContext) {}", "func (s *BaseMySqlParserListener) EnterUnionParenthesisSelect(ctx *UnionParenthesisSelectContext) {}", "func (ns Nodes) Parent(a ...string) Nodes {\n\tsl := Nodes{}\n\tsel := []selector{}\n\tif len(a) != 0 {\n\t\tsel = parseSelector(a[0])\n\t\tif len(sel) != 1 {\n\t\t\treturn sl\n\t\t}\n\t}\n\tfor _, v := range ns {\n\t\tif len(sel) == 0 {\n\t\t\tsl = append(sl, v)\n\t\t} else if satisfiesSel(&Node{v.Parent}, sel[0]) {\n\t\t\tsl = append(sl, v)\n\t\t}\n\t}\n\treturn sl\n}", "func NewTOCSelectEvent(uid string) *Event {\n\ts := (*C.gchar)(C.CString(uid))\n\tdefer C.free(unsafe.Pointer(s))\n\te := C.gst_event_new_toc_select(s)\n\tif e == nil {\n\t\treturn nil\n\t}\n\tr := new(Event)\n\tr.SetPtr(glib.Pointer(e))\n\treturn r\n}", "func (s *BasejossListener) ExitPartSel(ctx *PartSelContext) {}", "func (s *BasePlSqlParserListener) EnterSelected_list(ctx *Selected_listContext) {}", "func IsSubmenuArgcall(input string) bool {\n\tpattern := \"^[1-9][0-9]*,[0-9,]*$\"\n\tmatch, e := regexp.Match(pattern, []byte(input))\n\tpanicNonNil(e)\n\treturn match\n}", "func (s *BasevhdlListener) EnterSubprogram_specification(ctx *Subprogram_specificationContext) {}", "func (s *BaseMySqlParserListener) EnterSelectSpec(ctx *SelectSpecContext) {}", "func (litem *ListItem) onCursor(evname string, ev interface{}) {\n\n\tif litem.list.dropdown {\n\t\tlitem.list.setSelection(litem, true, true, false)\n\t\treturn\n\t}\n}", "func (suite *AddCommandTestSuite) TestExecuteWhenTrackFound() {\n\n}", "func (s *BaseSelectStatementParserListener) ExitSubExpression(ctx *SubExpressionContext) {}", "func (s *BaseTdatListener) EnterBracketExprInPrimaryExpr(ctx *BracketExprInPrimaryExprContext) {}", "func (s *BaseConcertoListener) EnterArraySelection(ctx *ArraySelectionContext) {}", "func TestRaiseEvent(t *testing.T) {\n\tr := task.NewTaskRegistry()\n\tr.AddOrchestratorN(\"WorkflowForRaiseEvent\", func(ctx *task.OrchestrationContext) (any, error) {\n\t\tvar nameInput string\n\t\tif err := ctx.WaitForSingleEvent(\"NameOfEventBeingRaised\", 30*time.Second).Await(&nameInput); err != nil {\n\t\t\t// Timeout expired\n\t\t\treturn nil, err\n\t\t}\n\t\treturn fmt.Sprintf(\"Hello, %s!\", nameInput), nil\n\t})\n\n\tctx := context.Background()\n\tclient, engine := startEngine(ctx, t, r)\n\tfor _, opt := range GetTestOptions() {\n\t\tt.Run(opt(engine), func(t *testing.T) {\n\t\t\tid, err := client.ScheduleNewOrchestration(ctx, \"WorkflowForRaiseEvent\")\n\t\t\tif assert.NoError(t, err) {\n\t\t\t\tmetadata, err := client.WaitForOrchestrationStart(ctx, id)\n\t\t\t\tif assert.NoError(t, err) {\n\t\t\t\t\tassert.Equal(t, id, metadata.InstanceID)\n\t\t\t\t\tclient.RaiseEvent(ctx, id, \"NameOfEventBeingRaised\", api.WithEventPayload(\"NameOfInput\"))\n\t\t\t\t\tmetadata, _ = client.WaitForOrchestrationCompletion(ctx, id)\n\t\t\t\t\tassert.True(t, metadata.IsComplete())\n\t\t\t\t\tassert.Equal(t, `\"Hello, NameOfInput!\"`, metadata.SerializedOutput)\n\t\t\t\t\tassert.Nil(t, metadata.FailureDetails)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}", "func childSelector(a, d Selector) Selector {\n\treturn func(n *Node) bool {\n\t\treturn d(n) && n.Parent() != nil && a(n.Parent())\n\t}\n}", "func (s *BaseTdatListener) ExitBracketExprInPrimaryExpr(ctx *BracketExprInPrimaryExprContext) {}", "func (_f35 *FakeContext) SetWithParentInvocation(calls_f36 []*ContextWithParentInvocation, fallback_f37 func() Context) {\n\t_f35.WithParentHook = func(ident1 context.Context) (ident2 Context) {\n\t\tfor _, call := range calls_f36 {\n\t\t\tif reflect.DeepEqual(call.Parameters.Ident1, ident1) {\n\t\t\t\tident2 = call.Results.Ident2\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\treturn fallback_f37()\n\t}\n}", "func (s *mergeBaseSuite) TestIndependentBeyondShortcut(c *C) {\n\trevs := []string{\"S\", \"G\", \"P\"}\n\texpectedRevs := []string{\"S\", \"G\"}\n\ts.AssertIndependents(c, revs, expectedRevs)\n}", "func (s *BasejossListener) EnterFormSel(ctx *FormSelContext) {}", "func (s *BasejossListener) EnterDelCmdAllSel(ctx *DelCmdAllSelContext) {}", "func (s *BasePlSqlParserListener) EnterEdition_name(ctx *Edition_nameContext) {}", "func (s *BasePlSqlParserListener) EnterSequence_name(ctx *Sequence_nameContext) {}", "func (a *aggregator) indexOfParent(s *types.Section) (int, bool) {\n\tfor i, e := range *a {\n\t\tif p, ok := e.(*types.Section); ok {\n\t\t\tif p.Level >= s.Level {\n\t\t\t\tlog.Debugf(\"found parent at index %d for section with level %d\", i-1, s.Level)\n\t\t\t\treturn i - 1, true // return previous\n\t\t\t}\n\t\t}\n\t}\n\t//\n\treturn -1, false\n}", "func (s *BaseMySqlParserListener) ExitSubqueryComparasionPredicate(ctx *SubqueryComparasionPredicateContext) {\n}", "func TestRequestSelectedTip(t *testing.T) {\n\t// Ensure the command is expected value.\n\twantCmd := MessageCommand(12)\n\tmsg := NewMsgRequestSelectedTip()\n\tif cmd := msg.Command(); cmd != wantCmd {\n\t\tt.Errorf(\"NewMsgRequestSelectedTip: wrong command - got %v want %v\",\n\t\t\tcmd, wantCmd)\n\t}\n}", "func (s *mergeBaseSuite) TestAncestor(c *C) {\n\trevs := []string{\"A^^\", \"A\"}\n\ts.AssertAncestor(c, revs, true)\n\n\trevs = []string{\"A\", \"A^^\"}\n\ts.AssertAncestor(c, revs, false)\n}", "func (s *BasePlSqlParserListener) EnterOverriding_subprogram_spec(ctx *Overriding_subprogram_specContext) {\n}", "func (s *BasePlSqlParserListener) EnterSubquery_operation_part(ctx *Subquery_operation_partContext) {}", "func TestSubQuerySelect(t *testing.T) {\n\tassert := assert.New(t)\n\tsubQuery := NewQuery(\"Products\").Where(\"Quantity > ?\", 2).Select(\"UserID\")\n\tquery, params := Build(NewQuery(\"Users\").Where(\"ID IN ?\", subQuery).Select())\n\tassertEqual(assert, \"SELECT * FROM `Users` WHERE ID IN (SELECT `UserID` FROM `Products` WHERE Quantity > ?)\", query)\n\tassertParams(assert, []interface{}{2}, params)\n}", "func testVertex(name string, interested_item string) bool {\n\t// fmt.Println(\"name:\", name, \"interested_item\", interested_item)\n\n\tif name == interested_item {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func ownTextSubstrSelector(val string) Selector {\n\treturn func(n *Node) bool {\n\t\ttext := strings.ToLower(nodeOwnText(n))\n\t\treturn strings.Contains(text, val)\n\t}\n}", "func (l *line) childOf(parent element) (bool, error) {\n\tvar ok bool\n\tvar err error\n\n\tswitch {\n\tcase l.isEmpty():\n\t\tok = true\n\tcase parent.ContainPlainText():\n\t\tswitch {\n\t\tcase parent.Base().ln.indent < l.indent:\n\t\t\tok = true\n\t\t}\n\tdefault:\n\t\tswitch {\n\t\tcase l.indent == parent.Base().ln.indent+1:\n\t\t\tok = true\n\t\tcase l.indent > parent.Base().ln.indent+1:\n\t\t\terr = fmt.Errorf(\"the indent is invalid [file: %s][line: %d]\", l.fileName(), l.no)\n\t\t}\n\t}\n\n\treturn ok, err\n}", "func (s *BasejossListener) EnterTypeAllSel(ctx *TypeAllSelContext) {}", "func (s *workItemChildSuite) TestCreateLinkToChildrenThenShowOK() {\n\t// given\n\t_, workitemSingle := test.ShowWorkitemOK(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.fxt.WorkItemByTitle(\"bug1\").ID, nil, nil)\n\tcheckChildrenRelationship(s.T(), workitemSingle.Data, hasNoChildren)\n\ts.linkWorkItems(s.T(), \"bug1\", \"bug2\")\n\t// when\n\t_, workitemSingle = test.ShowWorkitemOK(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.fxt.WorkItemByTitle(\"bug1\").ID, nil, nil)\n\t// then\n\trequire.NotNil(s.T(), workitemSingle)\n\tcheckChildrenRelationship(s.T(), workitemSingle.Data, hasChildren)\n}", "func (self *Events) Parent() *Sprite{\n return &Sprite{self.Object.Get(\"parent\")}\n}", "func (s *BaseSelectStatementParserListener) ExitSelectAsPrefix(ctx *SelectAsPrefixContext) {}", "func (s *workItemChildSuite) TestCreateLinkToChildrenThenShowOK() {\n\t// given\n\t_, workitemSingle := test.ShowWorkitemOK(s.T(), s.svc.Context, s.svc, s.workItemCtrl, *s.bug1.Data.ID, nil, nil)\n\tcheckChildrenRelationship(s.T(), workitemSingle.Data, hasNoChildren)\n\ts.linkWorkItems(s.bug1, s.bug2)\n\t// when\n\t_, workitemSingle = test.ShowWorkitemOK(s.T(), s.svc.Context, s.svc, s.workItemCtrl, *s.bug1.Data.ID, nil, nil)\n\t// then\n\trequire.NotNil(s.T(), workitemSingle)\n\tcheckChildrenRelationship(s.T(), workitemSingle.Data, hasChildren)\n}", "func (self *Events) SetParentA(member *Sprite) {\n self.Object.Set(\"parent\", member)\n}", "func (s *BasePlSqlParserListener) EnterSubpartition_by_range(ctx *Subpartition_by_rangeContext) {}", "func (s *BasePlSqlParserListener) EnterCursor_name(ctx *Cursor_nameContext) {}", "func (v *visitor) selectorName(call *ast.CallExpr) string {\n\tsel, _, ok := v.selectorAndFunc(call)\n\tif !ok {\n\t\treturn \"\"\n\t}\n\n\treturn getSelectorName(sel)\n}", "func TestParentNSValType() {\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"push\", \"ns-default-parent\", \"people\", \"myname\", \"anonymous\")\n\texpected = \"\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"read\", \"ns\", \"people:myname\")\n\texpected = \"people:myname,anonymous\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"read\", \"ns-default-parent\", \"people\", \"myname\")\n\texpected = \"people:myname,anonymous\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"push\", \"tsds-csv-parent\", \"2014\", \"2\", \"10\", \"9\", \"18\", \"37\", \"people\", \"myname,bob\")\n\texpected = \"\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"read\", \"tsds-default-parent\", \"people\", \"myname\")\n\texpected = \"people:myname,anonymous\\npeople:myname:2014:2:10:9:18:37:0,bob\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"delete\", \"ns-default-parent\", \"people\", \"myname\")\n\texpected = \"\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n\n\tresult, err = golzmq.ZmqRequest(zmqSock, \"read\", \"tsds-default-parent\", \"people\", \"myname\")\n\texpected = \"Error for request sent: read tsds-default-parent people myname\"\n\tgolassert.AssertEqual(expected, result)\n\tgolassert.AssertEqual(err, nil)\n}", "func (s *BaseCymbolListener) EnterAddSub(ctx *AddSubContext) {}" ]
[ "0.5836752", "0.583201", "0.5514476", "0.54162264", "0.5318818", "0.50823635", "0.50718504", "0.5049756", "0.5037811", "0.50187963", "0.4999445", "0.49585482", "0.49191308", "0.48787627", "0.48148394", "0.4807482", "0.4791354", "0.47718757", "0.47449547", "0.47041127", "0.4696208", "0.46822122", "0.46738583", "0.46393058", "0.46182483", "0.45958802", "0.458395", "0.45775062", "0.4571894", "0.45381358", "0.4519791", "0.45138654", "0.45002896", "0.44948038", "0.44710353", "0.4466738", "0.4444194", "0.44440708", "0.4441906", "0.44410157", "0.4440667", "0.4435452", "0.44338438", "0.44333732", "0.4431317", "0.44251794", "0.44207528", "0.44062752", "0.43976042", "0.43958417", "0.4392043", "0.4387017", "0.43753603", "0.43618402", "0.4355863", "0.43535525", "0.43514866", "0.43503335", "0.43381113", "0.43153274", "0.43087333", "0.42977628", "0.4294314", "0.42916086", "0.42735672", "0.42693406", "0.42630085", "0.42613167", "0.42588863", "0.42550296", "0.42501837", "0.42475998", "0.42412797", "0.42397994", "0.4230077", "0.4228439", "0.42233247", "0.42197075", "0.42195544", "0.4219465", "0.42162663", "0.42039537", "0.41990402", "0.41958806", "0.4182958", "0.41771916", "0.41596636", "0.41582322", "0.41548935", "0.41509894", "0.41505885", "0.4150035", "0.4144951", "0.4142938", "0.4135777", "0.41356632", "0.41353503", "0.412926", "0.4127142", "0.41266218" ]
0.5746677
2
Creates a flow from a single node This is useful for scenaries when usage of a single node is desired, manually feeding and processing packets on the node's ports.
func NewSingleFlowNode(nodeName string, nodeType FlowNodeType, inputPorts, outputPorts []uint16, options map[string]string, cb SingleFlowProcessCallback, data interface{}) *SingleFlowNode { cname := C.CString(nodeName) defer C.free(unsafe.Pointer(cname)) var coptions *C.struct_sol_flow_node_options strvOptions := newstrvOptions(options) success := true if strvOptions != nil { defer strvOptions.destroy() namedOptions := C.struct_sol_flow_node_named_options{} r := C.sol_flow_node_named_options_init_from_strv(&namedOptions, nodeType.ctype, strvOptions.cstrvOptions) if r == 0 { defer C.sol_flow_node_named_options_fini(&namedOptions) C.sol_flow_node_options_new(nodeType.ctype, &namedOptions, &coptions) defer C.sol_flow_node_options_del(nodeType.ctype, coptions) } else { success = false } } if !success { /* Assume this is a Go custom type */ coptions = mapOptionsToFlowOptions(options) } /* Create C array parameters for input and output ports */ step := unsafe.Sizeof((C.uint16_t)(0)) cinputPorts := C.malloc(C.size_t(uintptr(len(inputPorts)+1) * step)) coutputPorts := C.malloc(C.size_t(uintptr(len(outputPorts)+1) * step)) defer C.free(cinputPorts) defer C.free(coutputPorts) pindexIn, pindexOut := uintptr(cinputPorts), uintptr(coutputPorts) for _, inputPort := range inputPorts { *(*C.uint16_t)(unsafe.Pointer(pindexIn)) = C.uint16_t(inputPort) pindexIn += step } for _, outputPort := range outputPorts { *(*C.uint16_t)(unsafe.Pointer(pindexOut)) = C.uint16_t(outputPort) pindexOut += step } *(*C.uint16_t)(unsafe.Pointer(pindexIn)) = C.UINT16_MAX *(*C.uint16_t)(unsafe.Pointer(pindexOut)) = C.UINT16_MAX p := mapPointer(&singleFlowPacked{cb, data}) cnode := C.sol_flow_single_new(cname, nodeType.ctype, coptions, (*C.uint16_t)(cinputPorts), (*C.uint16_t)(coutputPorts), (*[0]byte)(C.goSingleFlowProcessCallback), unsafe.Pointer(p)) if cnode == nil { return nil } return &SingleFlowNode{&FlowNode{cnode}} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Service) CreateFlowNode(ctx context.Context, req *pb.CreateFlowNodeRequest) (*pb.CreateFlowNodeResponse, error) {\n\tissue, err := s.p.Issue.GetIssue(int64(req.IssueID), &commonpb.IdentityInfo{\n\t\tUserID: apis.GetUserID(ctx),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp, err := s.p.bdl.GetApp(req.AppID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trepoPath := makeGittarRepoPath(app)\n\n\tbranchPolicy, err := s.findBranchPolicyByName(ctx, issue.ProjectID, req.FlowRuleName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !isRefPatternMatch(req.CurrentBranch, branchPolicy.Branch) {\n\t\treturn nil, fmt.Errorf(\"the current branch does not match the rule\")\n\t}\n\n\tvar sourceBranch string\n\tif branchPolicy.Policy != nil {\n\t\tsourceBranch = branchPolicy.Policy.SourceBranch\n\t}\n\n\t// Idempotent create currentBranch, code node\n\tif err = s.IdempotentCreateBranch(ctx, repoPath, sourceBranch, req.CurrentBranch); err != nil {\n\t\treturn nil, err\n\t}\n\n\tflow := db.DevFlow{\n\t\tScope: db.Scope{\n\t\t\tOrgID: app.OrgID,\n\t\t\tOrgName: app.OrgName,\n\t\t\tAppID: req.AppID,\n\t\t\tAppName: app.Name,\n\t\t},\n\t\tOperator: db.Operator{\n\t\t\tCreator: apis.GetUserID(ctx),\n\t\t},\n\t\tBranch: req.CurrentBranch,\n\t\tIssueID: req.IssueID,\n\t\tFlowRuleName: req.FlowRuleName,\n\t}\n\tdevFlow, err := s.idemCreateDevFlow(&flow)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &pb.CreateFlowNodeResponse{Data: devFlow.Covert()}, nil\n}", "func NewFlow(headless bool) Flow {\n\tctx, cancel := setContext(headless)\n\treturn Flow{c: ctx, cancel: cancel}\n}", "func NewFlow() *Flow {\n\treturn &Flow{\n\t\tMetric: &FlowMetric{},\n\t}\n}", "func (f *Flow) Node(id string) *node {\n\tfor _, s := range f.Tasks {\n\t\tif s.ID == id {\n\t\t\treturn s\n\t\t}\n\t}\n\treturn nil\n}", "func NewFlow(ctx *pulumi.Context,\n\tname string, args *FlowArgs, opts ...pulumi.ResourceOption) (*Flow, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Definition == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Definition'\")\n\t}\n\tif args.Description == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Description'\")\n\t}\n\tif args.Type == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Type'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Flow\n\terr := ctx.RegisterResource(\"alicloud:fnf/flow:Flow\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewFlowFromGoPacket(p gopacket.Packet, parentUUID string, uuids *UUIDs, opts *Opts) *Flow {\n\tf := NewFlow()\n\n\tvar length int64\n\tif p.Metadata() != nil {\n\t\tlength = int64(p.Metadata().CaptureLength)\n\t}\n\n\tpacket := &Packet{\n\t\tGoPacket: p,\n\t\tLayers: p.Layers(),\n\t\tData: p.Data(),\n\t\tLength: length,\n\t}\n\n\tkey, l2Key, l3Key := packet.Keys(parentUUID, uuids, opts)\n\n\tf.initFromPacket(key, l2Key, l3Key, packet, parentUUID, uuids, opts)\n\n\treturn f\n}", "func MakeNode(id int, port, ipAddress string, wg *sync.WaitGroup) (*Node, error) {\n\tfmt.Println(\"Creating Node:\", id)\n\tfmt.Println(\"------------------------------------------\")\n\t// create a tcp listener\n\t// using given ip address and port\n\tl, err := net.Listen(\"tcp\", fmt.Sprintf(\"%s:%s\", ipAddress, port))\n\t// return error if any\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// initialize and return new node\n\t// nil for no error\n\tn := &Node{\n\t\tID: id,\n\t\tPort: port,\n\t\tIPAddress: ipAddress,\n\t\tlistener: l,\n\t}\n\twg.Add(1)\n\tgo n.listenOnPort(wg)\n\tfmt.Printf(\"Node %d created successfully and started listening on port %s\\n\", id, port)\n\tfmt.Println(\"Node Info:\", n)\n\tfmt.Println(\"------------------------------------------\")\n\treturn n, nil\n}", "func (w *Workflow) MakeTaskNode(name string, t Task) *TaskNode {\n\ttn := &TaskNode{\n\t\tid: MakeID(name),\n\t\tname: name,\n\t\tC: make(chan *Params, 1), // a buffer of one - as we always send the end even if no one is listening\n\t}\n\ttn.SetTask(t)\n\ttn.SetWorkFlow(w)\n\tw.registerNode(tn)\n\treturn tn\n}", "func NewNode(port int) dhtNode {\n\t// Todo: create a node and then return it.\n\treturn dht.NewSurface(port)\n}", "func NewNode(tcpAddr *net.TCPAddr) *Node {\n\tn := new(Node)\n\tn.TcpAddr = tcpAddr\n\tn.btcNet = wire.MainNet\n\tn.doneC = make(chan struct{}, 1)\n\n\treturn n\n}", "func NewNode(p string) *MyNode {\n\taddr := getLocalAddress()\n\n\treturn &MyNode{\n\t\tAddr: addr,\n\t\tPort: p,\n\t\tID: HashString(fmt.Sprintf(\"%v:%v\", addr, p)),\n\t\tData: make(map[string]string),\n\t\tbuf: new(bytes.Buffer),\n\t}\n}", "func NewFlow(requests ...*Request) Flow {\n\tflow := Flow{\n\t\trequests: requests,\n\t\trequestQueue: make(chan *Request),\n\t\taddRequest: make(chan *Request),\n\t\tpollingInterval: minimumPollingInterval(requests),\n\t}\n\n\tflow.PollRequests()\n\n\treturn flow\n}", "func (lt *LineTask) FromNode() *RailNode {\n\tswitch lt.TaskType {\n\tcase OnDeparture:\n\t\treturn lt.Stay.OnRailNode\n\tdefault:\n\t\treturn lt.Moving.FromNode\n\t}\n}", "func NewLogNodeFromNode(node *Node, dateFormat string) (*LogNode, error) {\n\tt, err := time.Parse(dateFormat, node.Header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn NewLogNode(t, node.Elements), nil\n}", "func NewNode(name string, tcpAddr string, job JobType) Node {\n\t// resolve ip\n\tn := util.NewNodeFromTCPAddr(tcpAddr, session.NodeTypeReplica /*dummy field*/)\n\treturn Node{\n\t\tJob: job,\n\t\tName: name,\n\t\tIPPort: n.TCPAddr(),\n\t\tHostname: n.Hostname,\n\t\tAttrs: map[string]interface{}{},\n\t}\n}", "func newServiceNode(port int, httpport int, wsport int, modules ...string) (*node.Node, error) {\n\tcfg := &node.DefaultConfig\n\tcfg.P2P.ListenAddr = fmt.Sprintf(\":%d\", port)\n\tcfg.P2P.EnableMsgEvents = true\n\tcfg.P2P.NoDiscovery = true\n\tcfg.IPCPath = ipcpath\n\tcfg.DataDir = fmt.Sprintf(\"%s%d\", datadirPrefix, port)\n\tif httpport > 0 {\n\t\tcfg.HTTPHost = node.DefaultHTTPHost\n\t\tcfg.HTTPPort = httpport\n\t}\n\tif wsport > 0 {\n\t\tcfg.WSHost = node.DefaultWSHost\n\t\tcfg.WSPort = wsport\n\t\tcfg.WSOrigins = []string{\"*\"}\n\t\tfor i := 0; i < len(modules); i++ {\n\t\t\tcfg.WSModules = append(cfg.WSModules, modules[i])\n\t\t}\n\t}\n\tstack, err := node.New(cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ServiceNode create fail: %v\", err)\n\t}\n\treturn stack, nil\n}", "func toFlow(v values.T, t *types.T) *flow.Flow {\n\tif f, ok := v.(*flow.Flow); ok {\n\t\treturn f\n\t}\n\treturn &flow.Flow{\n\t\tOp: flow.Val,\n\t\tValue: v,\n\t\tFlowDigest: values.Digest(v, t),\n\t}\n}", "func (c *instance) Node(call NodeCall) error {\n\to := bind.NewKeyedTransactor(c.key)\n\n\t// gateway redirect to private chain\n\tclient, err := ethclient.Dial(config.ETHAddr())\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer client.Close()\n\tinstance, err := node.NewAccelerateNode(c.nodeAddr, client)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn call(instance, o)\n}", "func Flow() UIFlow {\n\treturn &flow{\n\t\tIitemsBaseWitdh: flowItemBaseWidth,\n\t}\n}", "func MakeAddNode(node string, session string) AddNode {\n\treturn AddNode{\n\t\tMessageType: \"AddNode\",\n\t\tNode: Node{\n\t\t\tName: node,\n\t\t\tTelemetrySession: session,\n\t\t},\n\t}\n}", "func IncomingNode(n *gripdata.Node, db DB) error {\r\n\tvar p SProcChain\r\n\tp.Push(LocallyCreated)\r\n\tp.Push(NodeProc(VerifyNode))\r\n\tp.Push(NodeProc(StoreNode))\r\n\tp.Push(NodeProc(CreateNodeEphemera))\r\n\tp.Push(SendAllToShareWithMe)\r\n\r\n\t_, err := p.F(n, db)\r\n\treturn err\r\n}", "func NewNode(id uint64) *Node { return &Node{Id: id} }", "func (p *Packet) TransportFlow(swap bool) (gopacket.Flow, error) {\n\tlayer := p.TransportLayer()\n\tif layer == nil {\n\t\treturn gopacket.Flow{}, ErrLayerNotFound\n\t}\n\n\t// check vxlan in order to ignore source port from hash calculation\n\tif layer.LayerType() == layers.LayerTypeUDP {\n\t\tencap := p.Layers[len(p.Layers)-1]\n\n\t\tif encap.LayerType() == layers.LayerTypeVXLAN || encap.LayerType() == layers.LayerTypeGeneve {\n\t\t\tvalue16 := make([]byte, 2)\n\t\t\tbinary.BigEndian.PutUint16(value16, uint16(layer.(*layers.UDP).DstPort))\n\n\t\t\t// use the vni and the dest port to distinguish flows\n\t\t\tvalue32 := make([]byte, 4)\n\t\t\tif encap.LayerType() == layers.LayerTypeVXLAN {\n\t\t\t\tbinary.BigEndian.PutUint32(value32, encap.(*layers.VXLAN).VNI)\n\t\t\t} else {\n\t\t\t\tbinary.BigEndian.PutUint32(value32, encap.(*layers.Geneve).VNI)\n\t\t\t}\n\n\t\t\tif swap {\n\t\t\t\treturn gopacket.NewFlow(0, value16, value32), nil\n\t\t\t}\n\t\t\treturn gopacket.NewFlow(0, value32, value16), nil\n\t\t}\n\t}\n\n\treturn layer.TransportFlow(), nil\n}", "func NewLogFlow(output outputs.Output, outputFormat string, fields map[string]interface{}, timeField string, counterField string, daysoffset int, logger *log.Logger) *LogFlow {\n\tl := &LogFlow{}\n\tl.loggen = NewLogGenerator(fields, timeField, counterField, daysoffset, logger)\n\tl.output = output\n\tl.outputFormat = outputFormat\n\tl.log = logger\n\tl.msgchan = make(chan string)\n\tl.quittimer = make(chan bool)\n\tl.State = Init\n\treturn l\n}", "func New(node *gossipnet.Node, eventsIn, eventsOut chan core.Event, eventsCustom chan core.CustomEvent, nodesToConnect int) Manager {\n\treturn Manager{\n\t\tnode: node,\n\t\teventsIn: eventsIn,\n\t\teventsOut: eventsOut,\n\t\teventsCustom: eventsCustom,\n\t\tnodesToConnect: nodesToConnect,\n\t}\n}", "func (s *Flattener) HandleNetFlow(hdr *sfgo.SFHeader, cont *sfgo.Container, proc *sfgo.Process, nf *sfgo.NetworkFlow) error {\n\tfr := newFlatRecord()\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.SF_REC_TYPE] = sfgo.NET_FLOW\n\ts.fillEntities(hdr, cont, proc, nil, fr)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_TS_INT] = nf.Ts\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_TID_INT] = nf.Tid\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_OPFLAGS_INT] = int64(nf.OpFlags)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_ENDTS_INT] = nf.EndTs\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_SIP_INT] = int64(nf.Sip)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_SPORT_INT] = int64(nf.Sport)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_DIP_INT] = int64(nf.Dip)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_DPORT_INT] = int64(nf.Dport)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_PROTO_INT] = int64(nf.Proto)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_FD_INT] = int64(nf.Fd)\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_NUMRRECVOPS_INT] = nf.NumRRecvOps\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_NUMWSENDOPS_INT] = nf.NumWSendOps\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_NUMRRECVBYTES_INT] = nf.NumRRecvBytes\n\tfr.Ints[sfgo.SYSFLOW_IDX][sfgo.FL_NETW_NUMWSENDBYTES_INT] = nf.NumWSendBytes\n\ts.outCh <- fr\n\treturn nil\n}", "func (client *Client) CreateFlow(request *CreateFlowRequest) (_result *CreateFlowResponse, _err error) {\n\truntime := &util.RuntimeOptions{}\n\t_result = &CreateFlowResponse{}\n\t_body, _err := client.CreateFlowWithOptions(request, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_result = _body\n\treturn _result, _err\n}", "func NewNode(id NodeID, ip net.IP, udpPort, tcpPort uint16) *Node {\n\tif ipv4 := ip.To4(); ipv4 != nil {\n\t\tip = ipv4\n\t}\n\treturn &Node{\n\t\tIP: ip,\n\t\tUDP: udpPort,\n\t\tTCP: tcpPort,\n\t\tID: id,\n\t\tnodeNetGuts: nodeNetGuts{sha: crypto.Keccak256Hash(id[:])},\n\t}\n}", "func MakeNode(host, path string, port int) (*Node, error) {\n\tnodestr := net.JoinHostPort(host, strconv.Itoa(port)) + strings.Replace(path, \"+\", \"/\", -1)\n\treturn newNode(nodestr)\n}", "func NewFlowStateFromJSON(raw []byte) (*FlowState, error) {\n\tstate := &FlowState{}\n\tif err := json.Unmarshal(raw, state); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif state.Data == nil {\n\t\tstate.Data = map[string]string{}\n\t}\n\treturn state, nil\n}", "func NewNode(nodeID int64) (*Node, error) {\n\tif nodeID < 0 || nodeID > maxNode {\n\t\treturn nil, errors.New(\"Node id must between 0 and \" + strconv.FormatInt(maxNode, 10))\n\t}\n\treturn &Node{\n\t\tsecond: time.Now().Unix() - initSecond,\n\t\tnodeID: nodeID,\n\t\tseqNum: 0,\n\t\trandNum: 0,\n\t\tseed: 1,\n\t}, nil\n}", "func New(r *registry.R) *FlowBuilder {\n\treturn &FlowBuilder{\n\t\tregistry: r,\n\t\tOperationMap: map[string]flow.Operation{},\n\t\tnodeTrack: map[string]bool{},\n\t}\n}", "func NewNode(\n\tethereumChain eth.Handle,\n\tnetworkProvider net.Provider,\n\ttssConfig *tss.Config,\n) *Node {\n\treturn &Node{\n\t\tethereumChain: ethereumChain,\n\t\tnetworkProvider: networkProvider,\n\t\ttssConfig: tssConfig,\n\t}\n}", "func NewFlowEntity() *FlowEntity {\n\tthis := FlowEntity{}\n\treturn &this\n}", "func ResolveNode(ctx *broker.Context, node *specs.Node, flow specs.FlowInterface) (err error) {\n\tif node.Condition != nil {\n\t\terr = ResolveParameterMap(ctx, node, node.Condition.Params, flow)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif node.Call != nil {\n\t\terr = ResolveCall(ctx, node, node.Call, flow)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif node.Rollback != nil {\n\t\terr = ResolveCall(ctx, node, node.Rollback, flow)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif node.OnError != nil {\n\t\terr = ResolveOnError(ctx, node, node.OnError, flow)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func makeTapDanceFlow(proxy *TapDanceProxy, id uint64, splitFlows bool) *tapDanceFlow {\n\ttdFlow := new(tapDanceFlow)\n\n\ttdFlow.proxy = proxy\n\ttdFlow.id = id\n\n\ttdFlow.startMs = time.Now()\n\ttdFlow.splitFlows = splitFlows\n\n\tLogger.Debugf(\"Created new TD Flow: %#v\\n\", tdFlow)\n\treturn tdFlow\n}", "func (s *Server) StartNode(w http.ResponseWriter, req *http.Request) {\n\tnode := req.Context().Value(\"node\").(*peer.Node)\n\n\tif err := s.network.Start(node.ID); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\ts.JSON(w, http.StatusOK, node.ID)\n}", "func DeepCLoneNode(node Node) Node {\n\tnodeStacked := make(map[int]*Node, 30)\n\tstackOfNodes := make([]*Node, 0, 30)\n\n\tnodeNew := NewNode(node.ID)\n\tstackOfNodes = append(stackOfNodes, &node)\n\tnodeStacked[node.ID] = nodeNew\n\n\tfor len(stackOfNodes) > 0 {\n\t\tf := stackOfNodes[0]\n\t\tstackOfNodes = stackOfNodes[1:] // pop\n\t\tfor _, child := range f.Neighbors {\n\t\t\tif _, ok := nodeStacked[child.ID]; !ok {\n\t\t\t\tstackOfNodes = append(stackOfNodes, child) // push\n\t\t\t\tnodeStacked[child.ID] = NewNode(child.ID)\n\t\t\t}\n\t\t\tnodeStacked[f.ID].Neighbors = append(nodeStacked[f.ID].Neighbors, nodeStacked[child.ID])\n\t\t}\n\t}\n\n\tfmt.Printf(\"newNodes %v\\n\", nodeStacked)\n\treturn *nodeNew\n}", "func MakeNode() Node {\n\treturn Node{\n\t\tMetadata: Metadata{},\n\t\tCounters: Counters{},\n\t\tAdjacency: MakeIDList(),\n\t\tEdges: EdgeMetadatas{},\n\t}\n}", "func (g *Graph) CreateNode(fn *ssa.Function) *Node {\n\tn, ok := g.Nodes[fn]\n\tif !ok {\n\t\tn = &Node{Func: fn, ID: len(g.Nodes)}\n\t\tg.Nodes[fn] = n\n\t}\n\treturn n\n}", "func (m *SecuritySchemeMutator) Flow(v string) *SecuritySchemeMutator {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\tm.proxy.flow = v\n\treturn m\n}", "func NewNode(data int) *Node {\n\treturn &Node{\n\t\tData: data,\n\t\tNext: nil,\n\t}\n}", "func NewNode(data int) *Node {\n\treturn &Node{\n\t\tNext: nil,\n\t\tData: data,\n\t}\n}", "func MakeNode(arrange string) (*Node, error) {\n\t// Makes a new instance of the Node type\n\tnode := &Node{}\n\tnode.parent = nil\n\tnode.lock = &sync.Mutex{}\n\n\t// Parses the passed comma seperated string into the contents of the node\n\tstrSlice := strings.Split(arrange, \",\") // Slice is composed of strings at this point\n\tintSlice := make([]int, len(strSlice))\n\n\tfor i, element := range strSlice {\n\t\tintElement, err := strconv.Atoi(element)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"Failure to parse given string (%s). Error: %v\", element, err)\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tintSlice[i] = intElement\n\t\t}\n\t}\n\n\tnode.contents = intSlice[:]\n\tnode.contents = node.contents[:]\n\n\t// Returns a reference to the node\n\treturn node, nil\n}", "func newCallNode(args []Node) Node {\n\tif len(args) > 0 {\n\t\treturn CallNode{NodeType: NodeCall, Callee: args[0], Args: args[1:]}\n\t} else {\n\t\treturn nilNode\n\t}\n}", "func newCallNode(args []Node) Node {\n\tif len(args) > 0 {\n\t\treturn &CallNode{NodeType: NodeCall, Callee: args[0], Args: args[1:]}\n\t} else {\n\t\treturn nilNode\n\t}\n}", "func NewNode(n *pb.Node) *Node {\n\treturn &Node{\n\t\tX: int(n.X),\n\t\tY: int(n.Y),\n\t\tPlayer: int(n.Player),\n\t}\n}", "func NewNode(st Settings, mc ...MaskConfig) (*Node, error) {\n\tmask := MaskConfig{39, 16, 8} // default\n\tif len(mc) > 0 {\n\t\tmask = mc[0]\n\t\tif !validMask(mask) {\n\t\t\treturn nil, fmt.Errorf(\"snowflake: invalid mask-config\")\n\t\t}\n\t}\n\n\tsf := new(Node)\n\tsf.mutex = new(sync.Mutex)\n\n\tif st.StartTime.After(time.Now()) {\n\t\treturn nil, fmt.Errorf(\"snowflake: invalid start-time\")\n\t}\n\tif st.StartTime.IsZero() {\n\t\tsf.epoch = epoch\n\t} else {\n\t\tsf.epoch = st.StartTime.UTC().UnixNano() / scaleFactor\n\t}\n\n\tvar err error\n\tvar val uint16\n\tif st.WorkerID == nil {\n\t\tval, err = Lower16BitPrivateIP()\n\t} else {\n\t\tval, err = st.WorkerID()\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"snowflake: cannot generate worker ID\")\n\t}\n\n\tsf.machineID = uint32(val)\n\tsf.mask = mask\n\tsf.bmask.time = uint64(1)<<mask.TimeBits - 1\n\tsf.bmask.machine = uint32(1)<<mask.WorkerBits - 1\n\tsf.bmask.seq = uint16(1)<<mask.SequenceBits - 1\n\tsf.shiftTime = mask.WorkerBits + mask.SequenceBits\n\tsf.shiftWorker = mask.SequenceBits\n\tsf.seq = sf.bmask.seq // why is it set to max value ?\n\n\treturn sf, nil\n}", "func GetFlowRecord(record ipfixentities.Record) *FlowRecord {\n\tr := &FlowRecord{}\n\tif flowStartSeconds, _, ok := record.GetInfoElementWithValue(\"flowStartSeconds\"); ok {\n\t\tr.FlowStartSeconds = time.Unix(int64(flowStartSeconds.GetUnsigned32Value()), 0)\n\t}\n\tif flowEndSeconds, _, ok := record.GetInfoElementWithValue(\"flowEndSeconds\"); ok {\n\t\tr.FlowEndSeconds = time.Unix(int64(flowEndSeconds.GetUnsigned32Value()), 0)\n\t}\n\tif flowEndSecFromSrcNode, _, ok := record.GetInfoElementWithValue(\"flowEndSecondsFromSourceNode\"); ok {\n\t\tr.FlowEndSecondsFromSourceNode = time.Unix(int64(flowEndSecFromSrcNode.GetUnsigned32Value()), 0)\n\t}\n\tif flowEndSecFromDstNode, _, ok := record.GetInfoElementWithValue(\"flowEndSecondsFromDestinationNode\"); ok {\n\t\tr.FlowEndSecondsFromDestinationNode = time.Unix(int64(flowEndSecFromDstNode.GetUnsigned32Value()), 0)\n\t}\n\tif flowEndReason, _, ok := record.GetInfoElementWithValue(\"flowEndReason\"); ok {\n\t\tr.FlowEndReason = flowEndReason.GetUnsigned8Value()\n\t}\n\tif sourceIPv4, _, ok := record.GetInfoElementWithValue(\"sourceIPv4Address\"); ok {\n\t\tr.SourceIP = sourceIPv4.GetIPAddressValue().String()\n\t} else if sourceIPv6, _, ok := record.GetInfoElementWithValue(\"sourceIPv6Address\"); ok {\n\t\tr.SourceIP = sourceIPv6.GetIPAddressValue().String()\n\t}\n\tif destinationIPv4, _, ok := record.GetInfoElementWithValue(\"destinationIPv4Address\"); ok {\n\t\tr.DestinationIP = destinationIPv4.GetIPAddressValue().String()\n\t} else if destinationIPv6, _, ok := record.GetInfoElementWithValue(\"destinationIPv6Address\"); ok {\n\t\tr.DestinationIP = destinationIPv6.GetIPAddressValue().String()\n\t}\n\tif sourcePort, _, ok := record.GetInfoElementWithValue(\"sourceTransportPort\"); ok {\n\t\tr.SourceTransportPort = sourcePort.GetUnsigned16Value()\n\t}\n\tif destinationPort, _, ok := record.GetInfoElementWithValue(\"destinationTransportPort\"); ok {\n\t\tr.DestinationTransportPort = destinationPort.GetUnsigned16Value()\n\t}\n\tif protocolIdentifier, _, ok := record.GetInfoElementWithValue(\"protocolIdentifier\"); ok {\n\t\tr.ProtocolIdentifier = protocolIdentifier.GetUnsigned8Value()\n\t}\n\tif packetTotalCount, _, ok := record.GetInfoElementWithValue(\"packetTotalCount\"); ok {\n\t\tr.PacketTotalCount = packetTotalCount.GetUnsigned64Value()\n\t}\n\tif octetTotalCount, _, ok := record.GetInfoElementWithValue(\"octetTotalCount\"); ok {\n\t\tr.OctetTotalCount = octetTotalCount.GetUnsigned64Value()\n\t}\n\tif packetDeltaCount, _, ok := record.GetInfoElementWithValue(\"packetDeltaCount\"); ok {\n\t\tr.PacketDeltaCount = packetDeltaCount.GetUnsigned64Value()\n\t}\n\tif octetDeltaCount, _, ok := record.GetInfoElementWithValue(\"octetDeltaCount\"); ok {\n\t\tr.OctetDeltaCount = octetDeltaCount.GetUnsigned64Value()\n\t}\n\tif reversePacketTotalCount, _, ok := record.GetInfoElementWithValue(\"reversePacketTotalCount\"); ok {\n\t\tr.ReversePacketTotalCount = reversePacketTotalCount.GetUnsigned64Value()\n\t}\n\tif reverseOctetTotalCount, _, ok := record.GetInfoElementWithValue(\"reverseOctetTotalCount\"); ok {\n\t\tr.ReverseOctetTotalCount = reverseOctetTotalCount.GetUnsigned64Value()\n\t}\n\tif reversePacketDeltaCount, _, ok := record.GetInfoElementWithValue(\"reversePacketDeltaCount\"); ok {\n\t\tr.ReversePacketDeltaCount = reversePacketDeltaCount.GetUnsigned64Value()\n\t}\n\tif reverseOctetDeltaCount, _, ok := record.GetInfoElementWithValue(\"reverseOctetDeltaCount\"); ok {\n\t\tr.ReverseOctetDeltaCount = reverseOctetDeltaCount.GetUnsigned64Value()\n\t}\n\tif sourcePodName, _, ok := record.GetInfoElementWithValue(\"sourcePodName\"); ok {\n\t\tr.SourcePodName = sourcePodName.GetStringValue()\n\t}\n\tif sourcePodNamespace, _, ok := record.GetInfoElementWithValue(\"sourcePodNamespace\"); ok {\n\t\tr.SourcePodNamespace = sourcePodNamespace.GetStringValue()\n\t}\n\tif sourceNodeName, _, ok := record.GetInfoElementWithValue(\"sourceNodeName\"); ok {\n\t\tr.SourceNodeName = sourceNodeName.GetStringValue()\n\t}\n\tif destinationPodName, _, ok := record.GetInfoElementWithValue(\"destinationPodName\"); ok {\n\t\tr.DestinationPodName = destinationPodName.GetStringValue()\n\t}\n\tif destinationPodNamespace, _, ok := record.GetInfoElementWithValue(\"destinationPodNamespace\"); ok {\n\t\tr.DestinationPodNamespace = destinationPodNamespace.GetStringValue()\n\t}\n\tif destinationNodeName, _, ok := record.GetInfoElementWithValue(\"destinationNodeName\"); ok {\n\t\tr.DestinationNodeName = destinationNodeName.GetStringValue()\n\t}\n\tif destinationClusterIPv4, _, ok := record.GetInfoElementWithValue(\"destinationClusterIPv4\"); ok {\n\t\tr.DestinationClusterIP = destinationClusterIPv4.GetIPAddressValue().String()\n\t} else if destinationClusterIPv6, _, ok := record.GetInfoElementWithValue(\"destinationClusterIPv6\"); ok {\n\t\tr.DestinationClusterIP = destinationClusterIPv6.GetIPAddressValue().String()\n\t}\n\tif destinationServicePort, _, ok := record.GetInfoElementWithValue(\"destinationServicePort\"); ok {\n\t\tr.DestinationServicePort = destinationServicePort.GetUnsigned16Value()\n\t}\n\tif destinationServicePortName, _, ok := record.GetInfoElementWithValue(\"destinationServicePortName\"); ok {\n\t\tr.DestinationServicePortName = destinationServicePortName.GetStringValue()\n\t}\n\tif ingressNPName, _, ok := record.GetInfoElementWithValue(\"ingressNetworkPolicyName\"); ok {\n\t\tr.IngressNetworkPolicyName = ingressNPName.GetStringValue()\n\t}\n\tif ingressNPNamespace, _, ok := record.GetInfoElementWithValue(\"ingressNetworkPolicyNamespace\"); ok {\n\t\tr.IngressNetworkPolicyNamespace = ingressNPNamespace.GetStringValue()\n\t}\n\tif ingressNPRuleName, _, ok := record.GetInfoElementWithValue(\"ingressNetworkPolicyRuleName\"); ok {\n\t\tr.IngressNetworkPolicyRuleName = ingressNPRuleName.GetStringValue()\n\t}\n\tif ingressNPType, _, ok := record.GetInfoElementWithValue(\"ingressNetworkPolicyType\"); ok {\n\t\tr.IngressNetworkPolicyType = ingressNPType.GetUnsigned8Value()\n\t}\n\tif ingressNPRuleAction, _, ok := record.GetInfoElementWithValue(\"ingressNetworkPolicyRuleAction\"); ok {\n\t\tr.IngressNetworkPolicyRuleAction = ingressNPRuleAction.GetUnsigned8Value()\n\t}\n\tif egressNPName, _, ok := record.GetInfoElementWithValue(\"egressNetworkPolicyName\"); ok {\n\t\tr.EgressNetworkPolicyName = egressNPName.GetStringValue()\n\t}\n\tif egressNPNamespace, _, ok := record.GetInfoElementWithValue(\"egressNetworkPolicyNamespace\"); ok {\n\t\tr.EgressNetworkPolicyNamespace = egressNPNamespace.GetStringValue()\n\t}\n\tif egressNPRuleName, _, ok := record.GetInfoElementWithValue(\"egressNetworkPolicyRuleName\"); ok {\n\t\tr.EgressNetworkPolicyRuleName = egressNPRuleName.GetStringValue()\n\t}\n\tif egressNPType, _, ok := record.GetInfoElementWithValue(\"egressNetworkPolicyType\"); ok {\n\t\tr.EgressNetworkPolicyType = egressNPType.GetUnsigned8Value()\n\t}\n\tif egressNPRuleAction, _, ok := record.GetInfoElementWithValue(\"egressNetworkPolicyRuleAction\"); ok {\n\t\tr.EgressNetworkPolicyRuleAction = egressNPRuleAction.GetUnsigned8Value()\n\t}\n\tif tcpState, _, ok := record.GetInfoElementWithValue(\"tcpState\"); ok {\n\t\tr.TcpState = tcpState.GetStringValue()\n\t}\n\tif flowType, _, ok := record.GetInfoElementWithValue(\"flowType\"); ok {\n\t\tr.FlowType = flowType.GetUnsigned8Value()\n\t}\n\tif sourcePodLabels, _, ok := record.GetInfoElementWithValue(\"sourcePodLabels\"); ok {\n\t\tr.SourcePodLabels = sourcePodLabels.GetStringValue()\n\t}\n\tif destinationPodLabels, _, ok := record.GetInfoElementWithValue(\"destinationPodLabels\"); ok {\n\t\tr.DestinationPodLabels = destinationPodLabels.GetStringValue()\n\t}\n\tif throughput, _, ok := record.GetInfoElementWithValue(\"throughput\"); ok {\n\t\tr.Throughput = throughput.GetUnsigned64Value()\n\t}\n\tif reverseThroughput, _, ok := record.GetInfoElementWithValue(\"reverseThroughput\"); ok {\n\t\tr.ReverseThroughput = reverseThroughput.GetUnsigned64Value()\n\t}\n\tif throughputFromSrcNode, _, ok := record.GetInfoElementWithValue(\"throughputFromSourceNode\"); ok {\n\t\tr.ThroughputFromSourceNode = throughputFromSrcNode.GetUnsigned64Value()\n\t}\n\tif throughputFromDstNode, _, ok := record.GetInfoElementWithValue(\"throughputFromDestinationNode\"); ok {\n\t\tr.ThroughputFromDestinationNode = throughputFromDstNode.GetUnsigned64Value()\n\t}\n\tif revTputFromSrcNode, _, ok := record.GetInfoElementWithValue(\"reverseThroughputFromSourceNode\"); ok {\n\t\tr.ReverseThroughputFromSourceNode = revTputFromSrcNode.GetUnsigned64Value()\n\t}\n\tif revTputFromDstNode, _, ok := record.GetInfoElementWithValue(\"reverseThroughputFromDestinationNode\"); ok {\n\t\tr.ReverseThroughputFromDestinationNode = revTputFromDstNode.GetUnsigned64Value()\n\t}\n\treturn r\n}", "func New(port int, id string, weight int) Node {\n\treturn &node{\n\t\tmyPort: port,\n\t\tid: id,\n\t\tring: *consistent.NewRing(),\n\t\trepCh: make(chan replicaEx),\n\t\treqCh: make(chan requestEx),\n\t\trmvCh: make(chan removeEx),\n\t\tcpyCh: make(chan copyEx),\n\t\treplaceCh: make(chan replaceEx),\n\t\tlookupCh: make(chan lookupEx),\n\t\tbulkCh: make(chan bulkEx),\n\t\tstateCh: make(chan stateEx),\n\t\tweight: weight,\n\t\tstateMap: make(map[string]rpcs.State),\n\t}\n}", "func createLBRPNode(node *k8sNode) error {\n\tlog.Debugf(\"Creating %s\", k8switchName)\n\n\t// port connected to br0\n\ttoStack := k8switch.Ports{Name: \"toStack\"}\n\n\t// port connected to physical nic (through k8sfilter)\n\ttoNodePort := k8switch.Ports{Name: \"toNodePort\", Type_: \"NODEPORT\"}\n\n\tports := []k8switch.Ports{toStack, toNodePort}\n\n\tserviceClusterIPRange := os.Getenv(\"POLYCUBE_SERVICE_CLUSTERIP_RANGE\")\n\tif serviceClusterIPRange == \"\" {\n\t\tlog.Warningf(\"POLYCUBE_SERVICE_CLUSTERIP_RANGE not found, defaulting to %s\",\n\t\tserviceClusterIPRangeDefault)\n\t\t\tserviceClusterIPRange = serviceClusterIPRangeDefault\n\t}\n\n\tlb := k8switch.K8switch{\n\t\tName: k8switchName,\n\t\tPorts: ports,\n\t\tClusterIpSubnet: serviceClusterIPRange,\n\t\tClientSubnet: node.GetPodCIDR().String(),\n\t\tVirtualClientSubnet: node.GetVPodCIDR().String()}\n\n\tif _, err := k8switchAPI.CreateK8switchByID(k8switchName, lb); err != nil {\n\t\treturn err\n\t}\n\n\tlog.Debugf(\"%s created\", k8switchName)\n\treturn nil\n}", "func NewNode(config *Configuration) *Node {\n\tnode := new(Node)\n\n\tnode.config = config\n\tnode.partitions = make(map[string][]partition)\n\tnode.strategyMap = make(map[string]RoutingStrategy)\n\n\t// create a http listener, do it this way to get the running port\n\taddrStr := fmt.Sprintf(\":%d\", config.NodePort)\n\tlistener, err := net.Listen(\"tcp\", addrStr)\n\tif err != nil {\n\t\tlog.Err(\"Failed to create listener at address %s\", addrStr, err)\n\t}\n\n\tnode.port = listener.Addr().(*net.TCPAddr).Port\n\tnode.server = http.Server{\n\t\tHandler: node,\n\t}\n\n\tlog.Info(\"Node is starting to listen on port: %d\", node.port)\n\tgo node.server.Serve(listener)\n\n\treturn node\n}", "func NewNode(port int) (host.Host, error) {\n\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/127.0.0.1/tcp/%d\", port)),\n\t}\n\n\th, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddr := h.Addrs()[0]\n\tmaAddr, _ := ma.NewMultiaddr(fmt.Sprintf(\"/%s/%s\", protocolVersion, h.ID().Pretty()))\n\tfullAddr := addr.Encapsulate(maAddr)\n\tfmt.Println(\"I am running at addr: \", maAddr)\n\tfmt.Println(\"The full addr is: \", fullAddr)\n\treturn h, err\n}", "func getFlow(m *api.Message, s *sessionManager) Flow {\n\tif f, ok := getCommandFlows(m, s); ok {\n\t\treturn f\n\t}\n\tif f, ok := getKindFlows(m, s); ok {\n\t\treturn f\n\t}\n\treturn Flow{\n\t\tActualStep: s.telego.defaultHandler,\n\t}\n}", "func NewNode(weightInitializer WeightInitializer, activationFunction ActivationFunction, derivativeActivation DerivativeActivation, nodeIndex int, learningRate FloatXX, layerIndex int, derivativeError DerivativeError, nodeType NodeType) *Node {\n\treturn &Node{\n\t\tinputNodes: nil,\n\t\toutputNodes: nil,\n\t\tweightInitializer: weightInitializer,\n\t\tactivation: activationFunction,\n\t\tderivativeActivation: derivativeActivation,\n\t\tmyIndex: nodeIndex,\n\t\tlearningRate: learningRate,\n\t\tlayerIndex: layerIndex,\n\t\tderivativeError: derivativeError,\n\t\tweights: []FloatXX{},\n\t\tmyType: nodeType,\n\t\tinputValue: FloatXX(0.0),\n\t\tlabel: FloatXX(0.0),\n\t\tmyErr: FloatXX(0.0),\n\t\tdEdW: []FloatXX{},\n\t\tmyoutCached: false,\n\t\tmyout: FloatXX(0.0),\n\t\tbackCached: false,\n\t\tinputs: []FloatXX{},\n\t\tdEdOut: FloatXX(0.0),\n\t\tdOutdIn: FloatXX(0.0),\n\t\tdIndW: []FloatXX{},\n\t}\n}", "func NewThreadFlow() *ThreadFlow {\n\treturn &ThreadFlow{}\n}", "func NewInputNode(inStream msgstream.MsgStream, nodeName string, maxQueueLength int32, maxParallelism int32, role string, nodeID int64, collectionID int64, dataType string) *InputNode {\n\tbaseNode := BaseNode{}\n\tbaseNode.SetMaxQueueLength(maxQueueLength)\n\tbaseNode.SetMaxParallelism(maxParallelism)\n\n\treturn &InputNode{\n\t\tBaseNode: baseNode,\n\t\tinStream: inStream,\n\t\tname: nodeName,\n\t\trole: role,\n\t\tnodeID: nodeID,\n\t\tcollectionID: collectionID,\n\t\tdataType: dataType,\n\t}\n}", "func NewNode(config *cfg.Config, logger log.Logger) (*Node, error) {\n\n\tblockDbPath := filepath.Join(config.DbPath, \"block\")\n\tblockDb, err := db.NewLevelDb(blockDbPath, 0, 0); // TODO\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstateDbPath := filepath.Join(config.DbPath, \"state\")\n\tkvdb, err := db.NewLevelDb(stateDbPath, 0, 0);\n\tstateDb, err := trie.NewWithCacheDb(ec.Hash256{}, trie.NewCacheDb(kvdb)) // TODO\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tgenDoc, err := genesis.DocumentFromDb(stateDb)\n\tif err != nil {\n\t\tgenDoc, err = genesis.DocumentFromFile(config.GenesisFile)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tgenDoc.SaveToDb(stateDb)\n\t}\n\n\tchainState, err := state.LoadChainStateFromDbOrGenesisDoc(stateDb, genDoc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create the proxyApp, which manages connections (consensus, mempool, query)\n\t// and sync and the app by performing a handshake\n\t// and replaying any necessary blocks\n\n\tconsensusLogger := logger.With(\"module\", \"consensus\")\n/* \tTODO\n\thandshaker := consensus.NewHandshaker(stateDb, chainState, blockDb, genDoc)\n\thandshaker.SetLogger(consensusLogger)\n*/\n\n\t// reload the chainState (it may have been updated by the handshake)\n\tchainState = state.LoadChainState(stateDb)\n\n\t// TODO\n\tselfWitness := chain.Witness{}\n\n\t// Decide whether to fast-sync or not\n\t// We don't fast-sync when the only validator is us.\n\t/*\n\tfastSync := config.FastSync\n\tif chainState.Wset.Size() == 1 {\n\t\tw := chainState.Wset.GetByIndex(0)\n\t\tif w.Address.Equal(selfWitness.Address) {\n\t\t\tfastSync = false\n\t\t}\n\t}\n\t*/\n\n\t// Log whether this node is a validator or an observer\n\tif chainState.Wset.HasAddress(selfWitness.Address) {\n\t\tconsensusLogger.Info(\"This node is a witness\", \"addr\", selfWitness.Address)\n\t} else {\n\t\tconsensusLogger.Info(\"This node is not a witness\", \"addr\", selfWitness.Address)\n\t}\n\n\tp2pLogger := logger.With(\"module\", \"p2p\")\n\n\tadapter := p2p.NewAdapter(config.P2p)\n\tadapter.SetLogger(p2pLogger)\n\n\t// Optionally, start the pex reactor\n\t//\n\t// TODO:\n\t//\n\t// We need to set Seeds and PersistentPeers on the adapter,\n\t// since it needs to be able to use these (and their DNS names)\n\t// even if the Pex is off. We can include the DNS name in the NetAddress,\n\t// but it would still be nice to have a clear list of the current \"PersistentPeers\"\n\t// somewhere that we can return with net_info.\n\t//\n\t// If Pex is on, it should handle dialing the seeds. Otherwise the adapter does it.\n\t// Note we currently use the addrBook regardless at least for AddOurAddress\n\taddrBook := pex.NewAddrBook(config.P2p.AddrBook, config.P2p.AddrBookStrict)\n\taddrBook.SetLogger(p2pLogger.With(\"book\", config.P2p.AddrBook))\n\tif config.P2p.PexReactor {\n\t\t// TODO persistent peers ? so we can have their DNS addrs saved\n\t\tpexReactor := pex.NewPexReactor(addrBook,\n\t\t\t&pex.PexReactorConfig{\n\t\t\t\tSeeds: config.P2p.Seeds,\n\t\t\t\tSeedMode: config.P2p.SeedMode,\n\t\t\t\tPrivatePeerIds: config.P2p.PrivatePeerIds,\n\t\t\t})\n\t\tpexReactor.SetLogger(p2pLogger)\n\t\tadapter.AddReactor(\"Pex\", pexReactor)\n\t}\n\n\tadapter.SetAddrBook(addrBook)\n\n\tnode := &Node{\n\t\tconfig: config,\n\t\tgenesisDoc: genDoc,\n\n\t\tadapter: adapter,\n\t\taddrBook: addrBook,\n\n\t\tstateDb: stateDb,\n\t\tblockDb: blockDb,\n\t}\n\tnode.BaseService.Init(logger, \"Node\", node)\n\treturn node, nil\n}", "func (w *State) GenerateFlowField(destination DestinationID) error {\n\tlog.Println(\"find shorted path\")\n\tFindShortestPath(w, destination)\n\tlog.Println(\"compute directions\")\n\tw.computeDirections(destination)\n\n\treturn nil\n\n}", "func to_fs_node(membership_node string) string{\n\t// temp_array := strings.Split(membership_node, \":\")\n\t// port := temp_array[1]\n\t// portInt, err := strconv.Atoi(port)\n\t// if err != nil {\n\t// \tfmt.Printf(\"Error: to_fs_node transfer from %s\\n\", port)\n\t// }\n\t// portInt += 1000 //8000 -> 9000\n\t// temp_array[1] = strconv.Itoa(portInt)\n\t// return strings.Join(temp_array, \":\")\n\n\t// for vm testing\n\treturn membership_node + \":9000\"\n}", "func (bc *BlockCreate) SetFlow(f *Flow) *BlockCreate {\n\treturn bc.SetFlowID(f.ID)\n}", "func (fb *FlowBuilder) Flow() *flow.Flow {\n\treturn fb.flow\n}", "func New(nodeFile string) Node {\n\treturn Node{nodeFile: nodeFile}\n}", "func (a API) Node(cmd *btcjson.NodeCmd) (e error) {\n\tRPCHandlers[\"node\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func NewTransactor(nodeURL string) (*Transactor, error) {\n\tc, err := Dial(nodeURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Transactor{\n\t\tClient: c,\n\t}, nil\n}", "func (_BaseFactory *BaseFactoryTransactor) CreateNode(opts *bind.TransactOpts, _owner common.Address) (*types.Transaction, error) {\n\treturn _BaseFactory.contract.Transact(opts, \"createNode\", _owner)\n}", "func NewNode(tr Transaction, id string) *Node {\n\tif tr == nil {\n\t\tpanic(\"transaction may not be nil\")\n\t}\n\tif id == \"\" {\n\t\tid = uuid.NewV4().String()\n\t}\n\n\tn := &Node{\n\t\tTransaction: tr,\n\t\tId: id,\n\t}\n\n\tn.Reset()\n\treturn n\n\n\t/*\n\t\tpos := strings.Index(id, \"-\")\n\t\tif pos == -1 {\n\t\t\tn.Shard = id\n\t\t\tn.UUID = uuid.NewV4().String()\n\t\t} else {\n\t\t\tn.UUID = id[pos+1:]\n\t\t\tn.Shard = id[:pos]\n\t\t}\n\t*/\n\t// return n\n}", "func FlowBoxNew() (*FlowBox, error) {\n\tc := C.gtk_flow_box_new()\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\treturn wrapFlowBox(glib.Take(unsafe.Pointer(c))), nil\n}", "func NewNode(log ginterface.IGameLogger) *Node {\n\tret := &Node{Log: log}\n\treturn ret\n}", "func NewNode(addr string, port int, certFile, keyFile string) *Node {\n\n\tcert, err := tls.LoadX509KeyPair(certFile, keyFile)\n\n\tif err != nil {\n\t\tlog.Fatal().Err(err).Msg(\"Cannot load certificates\")\n\t\treturn nil\n\t}\n\n\ttlsConfig := &tls.Config{\n\t\tCertificates: []tls.Certificate{cert},\n\t\tMinVersion: tls.VersionTLS12,\n\t}\n\n\ttc := credentials.NewTLS(tlsConfig)\n\n\tconn, err := grpc.Dial(fmt.Sprintf(\"%s:%d\", addr, port), grpc.WithTransportCredentials(tc))\n\n\tif err != nil {\n\t\tlog.Fatal().Err(err).Msg(\"Cannot create Grpc connection\")\n\t\treturn nil\n\t}\n\n\tc := client.NewClientClient(conn)\n\n\treturn &Node{\n\t\tErrors: 0,\n\t\tClient: c,\n\t\tconn: conn,\n\t\tAddr: addr,\n\t}\n}", "func NodeSim(portal, nodeID string) {\n\tlog.Printf(\"starting simulator: ID: %v, portal: %v\\n\", nodeID, portal)\n\n\tsendSamples := api.NewSendSamples(portal, nodeID, time.Second*10, false)\n\ttempSim := NewSim(72, 0.2, 70, 75)\n\tvoltSim := NewSim(2, 0.1, 1, 5)\n\tvoltSim2 := NewSim(5, 0.5, 1, 10)\n\n\tfor {\n\t\tsamples := make([]data.Sample, 3)\n\t\tsamples[0] = data.Sample{\n\t\t\tType: \"temp\",\n\t\t\tValue: tempSim.Sim(),\n\t\t}\n\n\t\tsamples[1] = data.Sample{\n\t\t\tID: \"V0\",\n\t\t\tType: \"volt\",\n\t\t\tValue: voltSim.Sim(),\n\t\t}\n\n\t\tsamples[2] = data.Sample{\n\t\t\tID: \"V1\",\n\t\t\tType: \"volt\",\n\t\t\tValue: voltSim2.Sim(),\n\t\t}\n\n\t\terr := sendSamples(samples)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Error sending samples: \", err)\n\t\t}\n\t\tpacketDelay()\n\t}\n}", "func (node *Node) Convert() *pb.Node {\n\treturn &pb.Node{X: int32(node.X), Y: int32(node.Y), Player: int32(node.Player)}\n}", "func NewNode(opts ...NodeOpt) *Node {\n\tn := &Node{}\n\tfor _, opt := range opts {\n\t\topt(n)\n\t}\n\treturn n\n}", "func StartNewNode(\n\tconfig *Config,\n\tinitialNetworkState *pb.NetworkState,\n\tinitialCheckpointValue []byte,\n) (*Node, error) {\n\treturn RestartNode(\n\t\tconfig,\n\t\t&dummyWAL{\n\t\t\tinitialNetworkState: initialNetworkState,\n\t\t\tinitialCheckpointValue: initialCheckpointValue,\n\t\t},\n\t)\n}", "func CreateNewNode(nodeID int, fileName string, timeStart string, graphID int, fileType string, userID int) (Node, error) {\n\tif nodeID == 0 || fileName == \"\" || timeStart == \"\" || graphID == 0 || fileType == \"\" || userID == 0 {\n\t\treturn Node{}, errors.New(\"Not enough argument supplied\")\n\t}\n\treturn Node{\n\t\tNodeID: nodeID,\n\t\tNodeBits: 0,\n\t\tNodeDesc: fileName,\n\t\tNodeDT: timeStart,\n\t\tNodeGID: graphID,\n\t\tNodeHash: \"\",\n\t\tNodeLevel: -32768,\n\t\tNodeType: fileType,\n\t\tNodeUID: userID,\n\t}, nil\n}", "func NewNode(addr string, port int) *Node {\n\tip := net.ParseIP(addr)\n\tpb := make([]byte, 2)\n\tbinary.BigEndian.PutUint16(pb, uint16(port))\n\n\treturn &Node{Address: append(ip, pb...)}\n}", "func CreateNode(\n\tcomment string, // comment text of the node\n\tnamespace string, // namespace of the node\n\tprocessor SignalProcessor, // processor used to handle signals\n) Node {\n\tn := new(node)\n\tname, tags, commentText := parseInfoFromComment(comment)\n\n\tn.name = name\n\tn.comment = commentText\n\tn.tags = tags\n\n\tn.id = uuid.NewV1().String()\n\tn.seq = n.id\n\tn.namespace = namespace\n\tn.observers = []Observer{}\n\tn.upstreams = map[string]Node{}\n\tn.downstreams = map[string]Node{}\n\tn.processor = processor\n\tn.meta = map[string]string{\n\t\t\"namespace\": namespace,\n\t}\n\n\tn.flowOutputObserver = nil\n\tn.flowFuncs = map[string]FlowFunc{}\n\tn.signalCallbacks = map[string]Callback{}\n\n\treturn n\n}", "func NodeFromBufferReader(api coreiface.CoreAPI) ipld.Node {\n\tdata := make([]byte, 42)\n\tu.NewTimeSeededRand().Read(data)\n\tr := bytes.NewReader(data)\n\tnd, err := importer.BuildDagFromReader(api.Dag(), chunker.DefaultSplitter(r))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn nd\n}", "func NewLazyNode(node OpNode, controller *Controller) (OpNode, *Controller) {\n\tc := &Controller{\n\t\tID: controller.ID,\n\t}\n\n\tsink := &sinkNode{}\n\tcontroller.AddTransform(sink)\n\n\treturn &lazyNode{\n\t\tfNode: node,\n\t\tcontroller: c,\n\t\tsink: sink,\n\t}, c\n}", "func MakeNode(ctx *cli.Context, name, gitCommit string) *context.Node {\n\tvsn := Version\n\n\tconfig := &context.Config{\n\t\tDataDir: MakeDataDir(ctx),\n\t\tKeyStoreDir: ctx.GlobalString(KeyStoreDirFlag.Name),\n\t\tPrivateKey: MakeNodeKey(ctx),\n\t\tName: name,\n\t\tVersion: vsn,\n\t\tUserIdent: makeNodeUserIdent(ctx),\n\t\tBootstrapNodes: MakeBootstrapNodes(ctx),\n\t\tListenAddr: MakeListenAddress(ctx),\n\t\tNAT: MakeNAT(ctx),\n\t\tMaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),\n\t\tMaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name),\n\t\tIPCPath: MakeIPCPath(ctx),\n\t\tHTTPHost: MakeHTTPRpcHost(ctx),\n\t\tHTTPPort: ctx.GlobalInt(RPCPortFlag.Name),\n\t\tHTTPCors: ctx.GlobalString(RPCCORSDomainFlag.Name),\n\t\tHTTPModules: MakeRPCModules(ctx.GlobalString(RPCApiFlag.Name)),\n\t\tWSHost: MakeWSRpcHost(ctx),\n\t\tWSPort: ctx.GlobalInt(WSPortFlag.Name),\n\t\tWSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name),\n\t\tWSModules: MakeRPCModules(ctx.GlobalString(WSApiFlag.Name)),\n\t}\n\tif ctx.GlobalBool(DevModeFlag.Name) {\n\t\tif !ctx.GlobalIsSet(DataDirFlag.Name) {\n\t\t\tconfig.DataDir = filepath.Join(os.TempDir(), \"/siotchain_dev_mode\")\n\t\t}\n\t\t// --dev mode does not need p2p networking.\n\t\tconfig.MaxPeers = 0\n\t\tconfig.ListenAddr = \":0\"\n\t}\n\tstack, err := context.New(config)\n\tif err != nil {\n\t\tFatalf(\"Failed to create the protocol stack: %v\", err)\n\t}\n\treturn stack\n}", "func (fb *FlowBuilder) Build(ID string) flow.Operation {\n\tif fb.Err != nil {\n\t\top := fb.flow.ErrOp(fb.Err)\n\t\treturn op\n\t}\n\tf := fb.flow\n\tr := fb.registry\n\tdoc := fb.Doc\n\n\tif _, ok := fb.nodeTrack[ID]; ok {\n\t\tfb.Err = ErrLoop //fmt.Errorf(\"[%v] Looping through nodes is disabled:\", ID)\n\t\top := fb.flow.ErrOp(fb.Err)\n\t\treturn op\n\t}\n\t// loop detector\n\tfb.nodeTrack[ID] = true\n\tdefer delete(fb.nodeTrack, ID)\n\n\t// If flow already has ID just return\n\tif op, ok := fb.OperationMap[ID]; ok {\n\t\treturn op\n\t}\n\n\tnode := fb.Doc.FetchNodeByID(ID)\n\tif node == nil {\n\t\top := fb.flow.ErrOp(fmt.Errorf(\"node not found [%v]\", ID))\n\t\treturn op\n\t}\n\n\tvar op flow.Operation\n\tvar inputs []reflect.Type\n\n\tswitch node.Src {\n\tcase \"Portal From\":\n\t\tnID := node.Prop[\"portal from\"]\n\t\tn := doc.FetchNodeByID(nID)\n\t\tif n == nil {\n\t\t\treturn f.ErrOp(fmt.Errorf(\"Invalid portal, id: %v\", nID))\n\t\t}\n\t\t// Fetch existing or build new\n\t\top = fb.Build(nID)\n\t\tfb.OperationMap[node.ID] = op\n\t\treturn op\n\tcase \"Input\":\n\t\tinputID, err := strconv.Atoi(node.Prop[\"input\"])\n\t\tif err != nil {\n\t\t\top := f.ErrOp(errors.New(\"Invalid inputID value, must be a number\"))\n\t\t\tfb.OperationMap[node.ID] = op\n\t\t\treturn op\n\t\t}\n\t\top := f.In(inputID) // By id perhaps\n\t\tfb.OperationMap[node.ID] = op\n\t\treturn op\n\tcase \"Var\":\n\t\tlog.Println(\"Source is a variable\")\n\t\tvar t interface{}\n\t\tinputs = []reflect.Type{reflect.TypeOf(t)}\n\tcase \"SetVar\":\n\t\tlog.Println(\"Source is a setvariable\")\n\t\tvar t interface{}\n\t\tinputs = []reflect.Type{reflect.TypeOf(t)}\n\tdefault:\n\t\tlog.Println(\"Loading entry:\", node.Src)\n\t\tentry, err := r.Entry(node.Src)\n\t\tif err != nil {\n\t\t\top = f.ErrOp(err)\n\t\t\tfb.OperationMap[node.ID] = op\n\t\t\treturn op\n\t\t}\n\t\tinputs = entry.Inputs\n\n\t}\n\n\t//// Build inputs ////\n\tparam := make([]flow.Data, len(inputs))\n\tfor i := range param {\n\t\tl := doc.FetchLinkTo(node.ID, i)\n\t\tif l == nil { // No link we fetch the value inserted\n\t\t\t// Direct input entries\n\t\t\tv, err := parseValue(inputs[i], node.DefaultInputs[i])\n\t\t\tif err != nil {\n\t\t\t\tparam[i] = f.ErrOp(err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tparam[i] = v\n\t\t\tcontinue\n\t\t}\n\t\tparam[i] = fb.Build(l.From)\n\t}\n\n\t//Switch again\n\tswitch node.Src {\n\tcase \"Var\":\n\t\top = f.Var(node.Prop[\"variable name\"], param[0])\n\tcase \"SetVar\":\n\t\top = f.SetVar(node.Prop[\"variable name\"], param[0])\n\tdefault:\n\t\top = f.Op(node.Src, param...)\n\t}\n\n\tfb.OperationMap[node.ID] = op\n\tfb.buildTriggersFor(node, op)\n\n\treturn op\n}", "func NewTask(name string, payload interface{}) TaskType {\n\treturn TaskType{\n\t\tName: name,\n\t\tData: payload,\n\t}\n}", "func (c *Client) CreateNode(ctx context.Context, n *NodeInfo, opts NodeOpts) error {\n\tif n == nil || n.NetworkID == \"\" {\n\t\treturn errors.New(\"invalid configuration provided\")\n\t}\n\n\t// make sure important fields are all populated\n\tn.withDefaults()\n\n\t// set up logger to record process events\n\tvar l = log.NewProcessLogger(c.l, \"create_node\",\n\t\t\"network_id\", n.NetworkID)\n\n\t// initialize node assets, such as swarm keys and startup scripts\n\tif err := c.initNodeAssets(n, opts); err != nil {\n\t\tl.Warnw(\"failed to init filesystem for node\", \"error\", err)\n\t\treturn fmt.Errorf(\"failed to set up filesystem for node: %s\", err.Error())\n\t}\n\n\t// set up basic configuration\n\tvar (\n\t\tports = nat.PortMap{\n\t\t\t// TODO: make this private - blocked by lack of multiaddr support for /http\n\t\t\t// paths, which means delegator can't work with go-ipfs swarm.\n\t\t\t// See https://github.com/multiformats/multiaddr/issues/63\n\t\t\tcontainerSwarmPort + \"/tcp\": []nat.PortBinding{\n\t\t\t\t{HostIP: network.Public, HostPort: n.Ports.Swarm}},\n\n\t\t\t// API server connections can be made via delegator. Suffers from same\n\t\t\t// issue as above, but direct API exposure is dangeorous since it is\n\t\t\t// authenticated. Delegator can handle authentication\n\t\t\tcontainerAPIPort + \"/tcp\": []nat.PortBinding{\n\t\t\t\t{HostIP: network.Private, HostPort: n.Ports.API}},\n\n\t\t\t// Gateway connections can be made via delegator, with access controlled\n\t\t\t// by database\n\t\t\tcontainerGatewayPort + \"/tcp\": []nat.PortBinding{\n\t\t\t\t{HostIP: network.Private, HostPort: n.Ports.Gateway}},\n\t\t}\n\t\tvolumes = []string{\n\t\t\tc.getDataDir(n.NetworkID) + \":/data/ipfs\",\n\t\t\tc.getDataDir(n.NetworkID) + \"/ipfs_start:/usr/local/bin/start_ipfs\",\n\t\t}\n\t\trestartPolicy = container.RestartPolicy{Name: \"unless-stopped\"}\n\n\t\t// important metadata about node\n\t\tlabels = n.labels(n.BootstrapPeers, c.getDataDir(n.NetworkID))\n\t)\n\n\t// remove restart policy if AutoRemove is enabled\n\tif opts.AutoRemove {\n\t\trestartPolicy = container.RestartPolicy{}\n\t}\n\n\t// create ipfs node container\n\tcontainerConfig := &container.Config{\n\t\tImage: c.ipfsImage,\n\t\tCmd: []string{\n\t\t\t\"daemon\", \"--migrate=true\", \"--enable-pubsub-experiment\",\n\t\t},\n\t\tEnv: []string{\n\t\t\t\"LIBP2P_FORCE_PNET=1\", // enforce private networks\n\t\t},\n\t\tLabels: labels,\n\t\tTty: true,\n\t\tAttachStdout: true,\n\t\tAttachStderr: true,\n\t}\n\tcontainerHostConfig := &container.HostConfig{\n\t\tAutoRemove: opts.AutoRemove,\n\t\tRestartPolicy: restartPolicy,\n\t\tBinds: volumes,\n\t\tPortBindings: ports,\n\t\tResources: containerResources(n),\n\t}\n\n\tvar start = time.Now()\n\tl = l.With(\"container.name\", n.ContainerName)\n\tl.Debugw(\"creating network container\",\n\t\t\"container.config\", containerConfig,\n\t\t\"container.host_config\", containerHostConfig)\n\tresp, err := c.d.ContainerCreate(ctx, containerConfig, containerHostConfig, nil, n.ContainerName)\n\tif err != nil {\n\t\tl.Errorw(\"failed to create container\",\n\t\t\t\"error\", err, \"build.duration\", time.Since(start))\n\t\treturn fmt.Errorf(\"failed to instantiate node: %s\", err.Error())\n\t}\n\tl = l.With(\"container.id\", resp.ID)\n\tl.Infow(\"container created\",\n\t\t\"build.duration\", time.Since(start))\n\n\t// check for warnings\n\tif len(resp.Warnings) > 0 {\n\t\tl.Warnw(\"warnings encountered on container build\",\n\t\t\t\"warnings\", resp.Warnings)\n\t}\n\n\t// assign node metadata\n\tn.DockerID = resp.ID\n\tn.DataDir = c.getDataDir(n.NetworkID)\n\n\t// spin up node\n\tl.Info(\"starting container\")\n\tstart = time.Now()\n\tif err := c.d.ContainerStart(ctx, n.DockerID, types.ContainerStartOptions{}); err != nil {\n\t\tl.Errorw(\"error occurred on startup - removing container\",\n\t\t\t\"error\", err, \"start.duration\", time.Since(start))\n\t\tgo c.d.ContainerRemove(ctx, n.ContainerName, types.ContainerRemoveOptions{Force: true})\n\t\treturn fmt.Errorf(\"failed to start ipfs node: %s\", err.Error())\n\t}\n\n\t// wait for node to start\n\tif err := c.waitForNode(ctx, n.DockerID); err != nil {\n\t\tl.Errorw(\"error occurred waiting for IPFS daemon startup\",\n\t\t\t\"error\", err, \"start.duration\", time.Since(start))\n\t\treturn err\n\t}\n\n\t// bootstrap peers if required\n\tif len(n.BootstrapPeers) > 0 {\n\t\tl.Debugw(\"bootstrapping network node with provided peers\")\n\t\tif err := c.bootstrapNode(ctx, n.DockerID, n.BootstrapPeers...); err != nil {\n\t\t\tl.Warnw(\"failed to bootstrap node - stopping container\",\n\t\t\t\t\"error\", err, \"start.duration\", time.Since(start))\n\t\t\tgo c.StopNode(ctx, n)\n\t\t\treturn fmt.Errorf(\"failed to bootstrap network node with provided peers: %s\", err.Error())\n\t\t}\n\t}\n\n\t// everything is good to go\n\tl.Infow(\"network container started without issue\",\n\t\t\"start.duration\", time.Since(start))\n\treturn nil\n}", "func NewNoSourceNode(filename string) NoSourceNode {\n\treturn NoSourceNode{filename: filename}\n}", "func createNodeRoute(w http.ResponseWriter, r *http.Request) {\n\troute := \"CreateNode\"\n\n\tquery := r.URL.Query()\n\tnodeID, initAmount := query.Get(\"nodeID\"), query.Get(\"initAmount\")\n\n\thandleRoute(route, nodeID, initAmount)\n}", "func (f *Flow) initFromPacket(key, l2Key, l3Key uint64, packet *Packet, parentUUID string, uuids *UUIDs, opts *Opts) {\n\tnow := UnixMilli(packet.GoPacket.Metadata().CaptureInfo.Timestamp)\n\tf.Init(now, parentUUID, uuids)\n\n\tf.newLinkLayer(packet)\n\n\tf.LayersPath, f.Application = LayersPath(packet.Layers)\n\n\t// no network layer then no transport layer\n\tif err := f.newNetworkLayer(packet); err == nil {\n\t\tf.newTransportLayer(packet, opts)\n\t}\n\n\t// add optional application layer\n\tf.newApplicationLayer(packet, opts)\n\n\t// need to have as most variable filled as possible to get correct UUID\n\tf.setUUIDs(key, l2Key, l3Key)\n\n\t// update metrics\n\tf.Update(packet, opts)\n}", "func NewSwitch(stream *util.MessageStream, dpid net.HardwareAddr, app AppInterface, connCh chan int, ctrlID uint16) *OFSwitch {\n\tvar s *OFSwitch\n\tif getSwitch(dpid) == nil {\n\t\tlog.Infoln(\"Openflow Connection for new switch:\", dpid)\n\n\t\ts = new(OFSwitch)\n\t\ts.app = app\n\t\ts.stream = stream\n\t\ts.dpid = dpid\n\t\ts.connCh = connCh\n\t\ts.txChans = make(map[uint32]chan MessageResult)\n\t\ts.ctrlID = ctrlID\n\n\t\t// Prepare a context for current connection.\n\t\ts.ctx, s.cancel = context.WithCancel(context.Background())\n\n\t\t// Initialize the fgraph elements\n\t\ts.initFgraph()\n\n\t\t// Save it\n\t\tswitchDb.Set(dpid.String(), s)\n\n\t\t// Main receive loop for the switch\n\t\tgo s.receive()\n\n\t} else {\n\t\tlog.Infoln(\"Openflow Connection for switch:\", dpid)\n\t\ts = getSwitch(dpid)\n\t\ts.stream = stream\n\t\ts.dpid = dpid\n\t\t// Update context for the new connection.\n\t\ts.ctx, s.cancel = context.WithCancel(context.Background())\n\t}\n\ts.tlvMgr = newTLVMapMgr()\n\t// send Switch connected callback\n\ts.switchConnected()\n\n\t// Return the new switch\n\treturn s\n}", "func (e *Eval) Flow() *Flow {\n\treturn e.root\n}", "func NewCreateFlowNotFound() *CreateFlowNotFound {\n\treturn &CreateFlowNotFound{}\n}", "func (s *Store) Node(id uint64) (ni *NodeInfo, err error) {\n\terr = s.read(func(data *Data) error {\n\t\tni = data.Node(id)\n\t\tif ni == nil {\n\t\t\treturn errInvalidate\n\t\t}\n\t\treturn nil\n\t})\n\treturn\n}", "func (ooc *MockOpenoltClient) FlowAdd(ctx context.Context, in *openolt.Flow, opts ...grpc.CallOption) (*openolt.Empty, error) {\n\treturn &openolt.Empty{}, nil\n}", "func newTask(byteTask []byte, next *task) *task {\n return &task{byteTask, next}\n}", "func StartNode(c *Config, peers []Peer) Node {\n\tr := newRaft(c)\n\t// become the follower at term 1 and apply initial configuration\n\t// entries of term 1\n\tr.becomeFollower(1, 0)\n\t// Mark these initial entries as committed.\n\tr.raftLog.committed = r.raftLog.lastIndex()\n\n\tn := newNode()\n\tn.logger = c.Logger\n\tgo n.run(r)\n\treturn &n\n}", "func NewFlowAction(flowProvider flowdef.Provider, stateRecorder StateRecorder, options *ActionOptions) *FlowAction {\n\tvar action FlowAction\n\taction.flowProvider = flowProvider\n\taction.stateRecorder = stateRecorder\n\taction.idGenerator, _ = util.NewGenerator()\n\t// fix up run options\n\n\tif options == nil {\n\t\toptions = &ActionOptions{Record: true}\n\t}\n\n\tif options.MaxStepCount < 1 {\n\t\toptions.MaxStepCount = int(^uint16(0))\n\t}\n\n\toptions.Record = (stateRecorder != nil) && options.Record\n\n\taction.actionOptions = options\n\n\treturn &action\n}", "func NewNode(up *Node, name string) *Node {\n\tlogger := log.New(os.Stderr, \"-> [Node][\"+ name +\"] -> \", log.Lmicroseconds)\n\n\tnode := &Node {\n\t\tup:\t\tup,\n\t\tl: \t\tlogger,\n\t\tname:\tname,\n\t}\n\n\treturn node;\n}", "func MakeCreateNodeActivity(vmomiClientFactory *VMOMIClientFactory, tokenGenerator pkeworkflowadapter.TokenGenerator, secretStore pkeworkflow.SecretStore) CreateNodeActivity {\n\treturn CreateNodeActivity{\n\t\tvmomiClientFactory: vmomiClientFactory,\n\t\ttokenGenerator: tokenGenerator,\n\t\tsecretStore: secretStore,\n\t}\n}", "func Setup_raft_node(ctx context.Context, id int, n_replicas int, testing bool) *RaftNode {\n\n\t// Key value store address of the current node\n\tkv_addr := \":300\" + strconv.Itoa(id)\n\n\t// InitializeNode is defined in raft_node.go\n\tnode := InitializeNode(int32(n_replicas), id, kv_addr)\n\n\t// ApplyToStateMachine() is defined in raft_node.go\n\tgo node.ApplyToStateMachine(ctx, testing)\n\n\t// Starting KV store\n\tlog.Println(\"Starting local key-value store...\")\n\tgo node.StartKVStore(ctx, kv_addr, id, testing)\n\n\t/*\n\t * Make a HTTP request to the test endpoint until a reply is obtained, indicating that\n\t * the HTTP server is up\n\t */\n\ttest_addr := fmt.Sprintf(\"http://localhost%s/kvstore\", kv_addr)\n\n\tfor {\n\n\t\t_, err := http.Get(test_addr)\n\n\t\tif err == nil {\n\t\t\tlog.Printf(\"\\nKey-value store up and listening at port %s\\n\", kv_addr)\n\t\t\tbreak\n\t\t}\n\n\t}\n\n\treturn node\n}", "func NewFlowMapper(args *Args) *FlowMapper {\n\treturn &FlowMapper{workdir: args.WorkDir, mapfile: args.MapFile}\n}", "func node(n graph.Node) *cfg.Node {\n\tif n, ok := n.(*cfg.Node); ok {\n\t\treturn n\n\t}\n\tpanic(fmt.Errorf(\"invalid node type; expected *cfg.Node, got %T\", n))\n}", "func NewNode(name string, node files.Node) *Node {\n\treturn &Node{\n\t\tNode: node,\n\t\tname: name,\n\t}\n}" ]
[ "0.62484795", "0.57474536", "0.5399327", "0.52980113", "0.52744055", "0.5231995", "0.5180516", "0.5168897", "0.49417356", "0.49270824", "0.49097803", "0.48688847", "0.48667073", "0.48091704", "0.48059434", "0.48043534", "0.47937524", "0.47925735", "0.47856003", "0.47848862", "0.47795975", "0.4766411", "0.47514513", "0.4744754", "0.47380686", "0.47319213", "0.47229612", "0.4712116", "0.47041646", "0.46970567", "0.4628454", "0.46280313", "0.46221784", "0.46109256", "0.46071863", "0.46031645", "0.45889434", "0.45817307", "0.45741576", "0.45688766", "0.4568636", "0.45637342", "0.45602956", "0.4557457", "0.4551419", "0.45501524", "0.45498136", "0.45443314", "0.45350677", "0.45322785", "0.4531332", "0.4510855", "0.4507114", "0.45026165", "0.4498519", "0.44948003", "0.44896916", "0.4482238", "0.44816312", "0.44810164", "0.44766605", "0.44639888", "0.4463716", "0.4461409", "0.4458747", "0.44581115", "0.4449913", "0.44491553", "0.44400445", "0.44350967", "0.442832", "0.4426451", "0.44238126", "0.4423123", "0.44174343", "0.44114506", "0.44095206", "0.44063812", "0.43989056", "0.43988493", "0.43972751", "0.43947878", "0.4391439", "0.43862626", "0.43846166", "0.43795237", "0.43662995", "0.43587148", "0.4357523", "0.43555427", "0.43543792", "0.4353827", "0.43526843", "0.43506366", "0.43485144", "0.43416953", "0.43381515", "0.4335792", "0.4333106", "0.43233612" ]
0.6233093
1
Connects (enables) the specified port
func (sf *SingleFlowNode) ConnectPort(portIndex uint16, direction int) { switch direction { case FlowPortInput: C.sol_flow_single_connect_port_in(sf.FlowNode.cnode, C.uint16_t(portIndex)) case FlowPortOutput: C.sol_flow_single_connect_port_out(sf.FlowNode.cnode, C.uint16_t(portIndex)) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Connect(port string) {\n\tif EchoCon == nil {\n\t\tlog.Fatal(common.ErrorEchoServerInit)\n\t\treturn\n\t}\n\tEchoCon.Logger.Fatal(EchoCon.Start(\":\" + port))\n}", "func StartWithPort(port int) {\n\tstartWithPortVerbose(port, false)\n}", "func (mb *serialPort) connect() error {\n\tif mb.port == nil {\n\t\tport, err := serial.OpenPort(&mb.Config)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmb.port = port\n\t}\n\treturn nil\n}", "func (gc *GokuyamaClient) Connect(hostname string, portNo int) error {\n\tvar err error\n\tgc.conn, err = net.Dial(\"tcp\", fmt.Sprintf(\"%s:%d\", hostname, portNo))\n\treturn err\n}", "func TurnOnPort(client CommandRunner, port int) error {\n\t_, err := client.ExecCmds([]string{\n\t\t\"configure\",\n\t\t\"interface \" + fmt.Sprintf(\"0/%d\", port),\n\t\t\"poe opmode auto\",\n\t\t\"exit\", // leave the interface config mode (entered via 'interface ...')\n\t\t\"exit\", // leave the global configuration mode (entered via 'configure')\n\t})\n\treturn err\n}", "func (c *Client) Connect(addr string, port int, password string) error {\n\tif addr == \"\" {\n\t\treturn errors.New(\"redis.Client.Init: addr cannot be empty\")\n\t}\n\tif port < 1024 || port > 65534 {\n\t\treturn errors.New(\"redis.Client.Init: port must in range [1024, 65534]\")\n\t}\n\tif c.isConnected {\n\t\tc.Client.Close()\n\t\tc.isConnected = false\n\t}\n\tc.Client = redis.NewClient(&redis.Options{\n\t\tAddr: addr + \":\" + strconv.Itoa(port),\n\t\tPassword: password,\n\t\tDB: 0,\n\t})\n\tif err := c.Client.Ping().Err(); err != nil {\n\t\treturn err\n\t}\n\tc.isConnected = true\n\treturn nil\n}", "func (c *Client) UsePort(port int) error {\n\t_, err := c.ExecCmd(NewCmd(\"use\").WithArgs(NewArg(\"port\", port)))\n\treturn err\n}", "func (h *Host) SetPort(p uint16) {\n}", "func (self *Device) StartWithPort(port int) error {\n\terr := self.reviseParentObject()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = self.reviseDescription()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tself.ssdpMcastServerList = ssdp.NewMulticastServerList()\n\tself.ssdpMcastServerList.Listener = self\n\terr = self.ssdpMcastServerList.Start()\n\tif err != nil {\n\t\tself.Stop()\n\t\treturn err\n\t}\n\n\tself.httpServer = http.NewServer()\n\tself.httpServer.Listener = self\n\terr = self.httpServer.Start(port)\n\tif err != nil {\n\t\tself.Stop()\n\t\treturn err\n\t}\n\n\tself.Port = port\n\n\treturn nil\n}", "func (observer *Observer) Connect(id int32, port int32) {\n\tobserver.connector.Connect(id, port)\n}", "func probePort(port int, timeout time.Duration) error {\n\taddress := fmt.Sprintf(\"127.0.0.1:%d\", port)\n\tnow := time.Now()\n\tfor {\n\t\tif conn, err := net.Dial(\"tcp\", address); err == nil {\n\t\t\tif err = conn.Close(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tif time.Since(now) > timeout {\n\t\t\treturn errors.New(\"start failed: timeout expired\")\n\t\t}\n\t\ttime.Sleep(1 * time.Second)\n\t}\n\treturn nil\n}", "func (s *Server) connect() {\n\tln, err := net.Listen(\"tcp\", \":\"+strconv.Itoa(s.port))\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t} else {\n\t\ts.listener = ln\n\t\tlog.Println(\"Listening on port :\" + strconv.Itoa(s.port))\n\t}\n}", "func (c *Client) Port(p int) *Client {\n\tc.port = p\n\treturn c\n}", "func Bind(port int) {\r\n\tlisten, err := net.Listen(\"tcp\", \"0.0.0.0:\"+strconv.Itoa(port))\r\n\tExitOnError(err)\r\n\tdefer listen.Close()\r\n\r\n\tfor {\r\n\t\tconn, err := listen.Accept()\r\n\t\tif err != nil {\r\n\t\t\tPrintError(\"Cannot bind to selected port\")\r\n\t\t}\r\n\t\thandleBind(conn)\r\n\t}\r\n}", "func connectToDaemon(port int, t *testing.T) {\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(250 * time.Millisecond):\n\t\t\tt.Fatalf(\"Expected server to start < 1s.\")\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t\t_, err := net.Dial(\"tcp\", fmt.Sprintf(\":%d\", port))\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func OpenPort(proto string, port int) rules.Rule {\n\tswitch proto {\n\tcase \"tcp\":\n\tcase \"udp\":\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"invalid proto: %q\", proto))\n\t}\n\n\treturn rules.Rule(fmt.Sprintf(\n\t\t\"-I in-%s -j ACCEPT -p %s --dport %d\",\n\t\tproto, proto, port))\n}", "func Dial(hostPort string) (c net.Conn, err error) {\n\tvar addrs []string\n\tvar host, port string\n\n\tif host, port, err = net.SplitHostPort(hostPort); err != nil {\n\t\treturn\n\t}\n\t// No need to call LookupHost if host part is IP address\n\tif ip := net.ParseIP(host); ip != nil {\n\t\treturn net.Dial(\"tcp\", hostPort)\n\t}\n\tif addrs, err = LookupHost(host); err != nil {\n\t\treturn\n\t}\n\tfor _, ip := range addrs {\n\t\tipHost := net.JoinHostPort(ip, port)\n\t\tif c, err = net.Dial(\"tcp\", ipHost); err == nil {\n\t\t\treturn\n\t\t}\n\t}\n\treturn nil, err\n}", "func (pm *PeerManager) ListenOnPort(port int) error {\n\n\t// Do NAT setup stuff.\n\tns := pm.netsettings\n\tif ns != nil && ns.NatMode != nil {\n\n\t\t// Do some type juggling.\n\t\tlisPort := uint16(port)\n\n\t\t// Actually figure out what we're going to do.\n\t\tif *ns.NatMode == \"upnp\" {\n\t\t\t// Universal Plug-n-Play\n\t\t\tlogging.Infof(\"Attempting port forwarding via UPnP...\")\n\t\t\terr := nat.SetupUpnp(lisPort)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else if *ns.NatMode == \"pmp\" {\n\t\t\t// NAT Port Mapping Protocol\n\t\t\ttimeout := time.Duration(10 * time.Second)\n\t\t\tlogging.Infof(\"Attempting port forwarding via PMP...\")\n\t\t\t_, err := nat.SetupPmp(timeout, lisPort)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"invalid NAT type: %s\", *ns.NatMode)\n\t\t}\n\t}\n\n\tthreadobj := &listeningthread{\n\t\tlistener: nil,\n\t}\n\n\t// Publish the new thread\n\tres, err := pm.ebus.Publish(NewListeningPortEvent{port})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !res {\n\t\treturn fmt.Errorf(\"listen cancelled by event handler\")\n\t}\n\n\t// Try to start listening.\n\t// TODO Listen on proxy if possible?\n\tlogging.Info(\"PORT: \", port)\n\tlistener, err := lndc.NewListener(pm.idkey, port)\n\tif err != nil {\n\t\tlogging.Errorf(\"listening failed: %s\\n\", err.Error())\n\t\tlogging.Info(err)\n\t\tpm.ebus.Publish(StopListeningPortEvent{\n\t\t\tPort: port,\n\t\t\tReason: \"initfail\",\n\t\t})\n\t\treturn err\n\t}\n\n\tthreadobj.listener = listener\n\n\t// Install the thread object.\n\tpm.mtx.Lock()\n\tpm.listeningPorts[port] = threadobj\n\tpm.mtx.Unlock()\n\n\t// Activate the MessageProcessor if we haven't yet.\n\tif !pm.mproc.IsActive() {\n\t\tpm.mproc.Activate()\n\t}\n\n\t// Actually start it\n\tgo acceptConnections(listener, port, pm)\n\n\treturn nil\n\n}", "func (n *Node) Connect(ip string, port int) error {\n\treturn n.connect(NodeInfo{Ip: ip, Port: port})\n}", "func Start(port int, ch chan *netcomm.OBJMSGARGS) {\n\n\tif port > 0 {\n\t\tport := \":\" + strconv.Itoa(port)\n\n\t\tgo open(port)\n\t}\n}", "func Connect(config *viper.Viper) (Connection, error) {\n\tvar c Connection\n\n\terr := c.InitLog(\"\")\n\tif err != nil {\n\t\treturn c, err\n\t}\n\n\thost := config.GetString(\"server.host\")\n\tport := config.GetString(\"server.controlPort\")\n\n\tserver := host + \":\" + port\n\tc.connection, err = net.Dial(\"tcp\", server)\n\tif err != nil {\n\t\treturn c, err\n\t}\n\n\treturn c, nil\n}", "func (u *UDP) Connect(ssrc uint32, ip net.IP, port uint16) error {\r\n\taddr := &net.UDPAddr{\r\n\t\tIP: ip,\r\n\t\tPort: int(port),\r\n\t}\r\n\r\n\tconn, err := net.DialUDP(\"udp\", nil, addr)\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\tu.SSRC = ssrc\r\n\tu.conn = conn\r\n\treturn nil\r\n}", "func connect(addr string) (net.Conn, error) {\n\tConnecting(addr)\n\tdialConn, err := DialTCP(addr, timeout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tConnected(addr)\n\treturn dialConn, nil\n}", "func startPeer(t *testing.T, port uint) *Conn {\n\tconn := NewConn()\n\tgo monitor(conn.Err, t)\n\terr := conn.Listen(port)\n\tif err != nil {\n\t\tt.Fatalf(\"Cannot start peer: %q\", err)\n\t\treturn nil\n\t}\n\treturn conn\n}", "func Port(port int) func(*Proxy) {\n\treturn func(r *Proxy) {\n\t\tr.port = port\n\t}\n}", "func OpenPort(cfg *Config) (Port, error) {\n\treturn openPort(cfg)\n}", "func (na *NetAdapter) Connect(address string) error {\n\t_, err := na.server.Connect(address)\n\treturn err\n}", "func (kvs *keyValueServer) Start(port int) error {\n\tstr := \":\"\n\tstr += strconv.Itoa(port)\n\tlisten, err := net.Listen(\"tcp\", str)\n\tif err != nil {\n\t\treturn err\n\t}\n\tkvs.listen = listen\n\tgo kvs.mainRoutine()\n\n\tgo func() {\n\t\tfor {\n\t\t\tconn, err := listen.Accept()\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tkvs.connChannel <- conn\n\t\t}\n\t}()\n\treturn nil\n}", "func RunServer(port int) {}", "func Connect(host, port string) (err error) {\n\tif ActiveConfig.Uplink.Ssl {\n\t\tconfig := &tls.Config{InsecureSkipVerify: true}\n\t\tConn.Conn, err = tls.Dial(\"tcp\", host+\":\"+port, config)\n\t} else {\n\t\tConn.Conn, err = net.Dial(\"tcp\", host+\":\"+port)\n\t\tif err != nil {\n\t\t\tLog.Fatal(err)\n\t\t}\n\t}\n\n\tConn.Reader = bufio.NewReader(Conn.Conn)\n\tConn.Tp = textproto.NewReader(Conn.Reader)\n\n\treturn\n}", "func listen(cer *tls.Certificate, port int) (conn net.Listener, err error) {\n\taddr := fmt.Sprintf(\"0.0.0.0:%d\", port)\n\n\tif cer != nil {\n\t\tconfig := &tls.Config{\n\t\t\tCertificates: []tls.Certificate{*cer},\n\t\t\tInsecureSkipVerify: true,\n\t\t}\n\t\tconn, err = tls.Listen(\"tcp\", addr, config)\n\t} else {\n\t\ttaddr, _ := net.ResolveTCPAddr(\"tcp\", addr)\n\t\tconn, err = net.ListenTCP(\"tcp\", taddr)\n\t}\n\n\treturn\n}", "func (c *Driver) Connect() error {\n\tif !IsChannelValid(c.channel) {\n\t\treturn InvalidChanName\n\t}\n\n\tc.clean()\n\tconn, err := net.Dial(\"tcp\", fmt.Sprintf(\"%s:%d\", c.Host, c.Port))\n\tif err != nil {\n\t\treturn err\n\t} \n\t\n\tc.closed = false\n\tc.conn = conn\n\tc.reader = bufio.NewReader(c.conn)\n\n\terr = c.write(fmt.Sprintf(\"START %s %s\", c.channel, c.Password))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = c.read()\n\t_, err = c.read()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (irc *Client) Connect(host string, port string) {\n\tlog.Println(\"Connecting to \" + host + \":\" + port)\n\tcon, err := net.Dial(\"tcp\", host+\":\"+port)\n\tif err != nil {\n\t\tlog.Println(\"Error:\", err.Error())\n\t\tos.Exit(1)\n\t}\n\tirc.Conn = &con\n\tgo irc.receiveData()\n\tirc.login(*irc.config)\n\n\ttime.Sleep(2 * time.Second)\n}", "func (c *TLSConn) SetPort(port string) {\n\tc.port = port\n}", "func (c *Connector) Start(addr string) error {\n\n\tconn, err := net.Dial(\"tcp\", addr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.conn = conn\n\n\tgo c.write()\n\n\t// send handshake packet\n\tc.send(hsd)\n\n\tfmt.Println(\"connect ok:\", addr )\n\n\t// read and process network message\n\tgo c.read()\n\n\treturn nil\n}", "func (d *Dialer) connect(ctx context.Context, conn net.Conn, addr string) error {\n\thost, port, err := splitHostPort(addr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif deadline, ok := ctx.Deadline(); ok && !deadline.IsZero() {\n\t\tconn.SetDeadline(deadline)\n\t\tdefer conn.SetDeadline(time.Time{})\n\t}\n\n\terrCh := make(chan error, 1)\n\tdone := make(chan struct{})\n\tdefer func() {\n\t\tclose(done)\n\t}()\n\tgo func() {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tconn.SetDeadline(time.Unix(1, 0))\n\t\t\terrCh <- ctx.Err()\n\t\tcase <-done:\n\t\t\terrCh <- nil\n\t\t}\n\t}()\n\t// Version/method selection\n\t// +----+----------+----------+\n\t// |VER | NMETHODS | METHODS |\n\t// +----+----------+----------+\n\t// | 1 | 1 | 1 to 255 |\n\t// +----+----------+----------+\n\tb := make([]byte, 0, 6+len(host))\n\t// Set version 5\n\tb = append(b, version5)\n\t// Set authentication methods\n\tb = append(b, byte(len(d.authMethods)))\n\tfor _, m := range d.authMethods {\n\t\tb = append(b, byte(m))\n\t}\n\t// Send payload\n\tif _, err = conn.Write(b); err != nil {\n\t\treturn err\n\t}\n\t// Read response\n\tif _, err = io.ReadFull(conn, b[:2]); err != nil {\n\t\treturn err\n\t}\n\t// Response:\n\t// +----+--------+\n\t// |VER | METHOD |\n\t// +----+--------+\n\t// | 1 | 1 |\n\t// +----+--------+\n\t// Check version\n\tif b[0] != version5 {\n\t\treturn fmt.Errorf(\"unexpected SOCKS version %d; expected %d\", b[0], version5)\n\t}\n\t// Authenticate\n\tif err = d.authenticate(ctx, conn, authMethod(b[1])); err != nil {\n\t\treturn fmt.Errorf(\"authentication failed: %s\", err)\n\t}\n\n\t// Request\n\t// +----+-----+-------+------+----------+----------+\n\t// |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |\n\t// +----+-----+-------+------+----------+----------+\n\t// | 1 | 1 | X'00' | 1 | Variable | 2 |\n\t// +----+-----+-------+------+----------+----------+\n\tb = b[:0]\n\tb = append(b, version5, byte(cmdConnect), 0) // VER CMD RSV\n\t// Set target address\n\tif ip := net.ParseIP(host); ip != nil {\n\t\tif ip4 := ip.To4(); ip4 != nil {\n\t\t\tb = append(b, addrTypeIPv4) // ATYP\n\t\t\tb = append(b, ip4...) // DST.ADDR\n\t\t} else if ip6 := ip.To16(); ip6 != nil {\n\t\t\tb = append(b, addrTypeIPv6) // ATYP\n\t\t\tb = append(b, ip6...) // DST.ADDR\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"unknown address type for %s; expected hostname, IPv4 or IPv6\", host)\n\t\t}\n\t} else {\n\t\tif len(host) > 255 {\n\t\t\treturn errors.New(\"hostname cannot exceed 255 bytes\")\n\t\t}\n\t\tb = append(b, addrTypeFQDN) // ATYP\n\t\tb = append(b, byte(len(host))) // (ADDRLEN)\n\t\tb = append(b, host...) // DST.ADDR\n\t}\n\tb = append(b, (byte(port >> 8)), byte(port)) // DST.PORT\n\t// Send payload\n\tif _, err = conn.Write(b); err != nil {\n\t\treturn err\n\t}\n\t// Read response\n\tif _, err = io.ReadFull(conn, b[:4]); err != nil {\n\t\treturn err\n\t}\n\t// Response:\n\t// +----+-----+-------+------+----------+----------+\n\t// |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |\n\t// +----+-----+-------+------+----------+----------+\n\t// | 1 | 1 | 0x00 | 1 | Variable | 2 |\n\t// +----+-----+-------+------+----------+----------+\n\t// Check version\n\tif b[0] != version5 {\n\t\treturn fmt.Errorf(\"unexpected SOCKS version %d; expected %d\", b[0], version5)\n\t}\n\t// Check reply code\n\tif r := reply(b[1]); r != replySucceeded {\n\t\treturn errors.New(\"unexpected reply \" + r.String())\n\t}\n\t// Check reserved octet\n\tif b[2] != 0 {\n\t\treturn fmt.Errorf(\"unexpected value %d in reserved field; value should be zero\", b[2])\n\t}\n\t// Check address type and skip the address itself\n\tswitch b[3] {\n\tcase addrTypeFQDN:\n\t\tif _, err := io.ReadFull(conn, b[:1]); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tio.CopyN(ioutil.Discard, conn, int64(b[0]))\n\tcase addrTypeIPv4:\n\t\tio.CopyN(ioutil.Discard, conn, 4)\n\tcase addrTypeIPv6:\n\t\tio.CopyN(ioutil.Discard, conn, 16)\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown address type 0x%X; expected 0x01 (IPv4), 0x03 (domain name) or 0x04 (IPv6)\", b[3])\n\t}\n\t// Skip BND.PORT\n\tio.CopyN(ioutil.Discard, conn, 2)\n\treturn nil\n}", "func startServer(t *testing.T, port uint) *Conn {\n\tconn := NewConn()\n\tgo monitor(conn.Err, t)\n\tconn.AddHandler(sendReply)\n\terr := conn.Listen(port)\n\tif err != nil {\n\t\tt.Fatalf(\"Cannot start server: %q\", err)\n\t\treturn nil\n\t}\n\treturn conn\n}", "func (i *Info) ListenOnPort() {\n\tln, err := net.Listen(\"tcp\", fmt.Sprint(\":\"+i.Port))\n\tif err != nil {\n\t\tfmt.Print(err)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"Staring node on %s:%s...\\n\", i.IP, i.Port)\n\n\tfor {\n\t\tconnIn, err := ln.Accept()\n\t\tif err != nil {\n\t\t\tif _, ok := err.(net.Error); ok {\n\t\t\t\tfmt.Printf(\"Error received while listening %s:%s \\n\", i.IP, i.Port)\n\t\t\t}\n\t\t}\n\n\t\tvar msg Models.Message\n\t\tif err := json.NewDecoder(connIn).Decode(&msg); err != nil {\n\t\t\tfmt.Printf(\"Error decoding %v\\n\", err)\n\t\t}\n\n\t\tswitch msg.Intent {\n\t\tcase constants.IntentSendGo:\n\t\t\ti.Go(msg)\n\t\tcase constants.IntentSendBack:\n\t\t\ti.Back(msg)\n\t\t}\n\t}\n}", "func start(port string) {\n\thandlers := map[string]handler{\n\t\t\"/\": func(w http.ResponseWriter, r *http.Request) {\n\t\t\tfmt.Fprint(w, \"healthy\")\n\t\t},\n\t}\n\terr := open(port, handlers)\n\tpanic(err)\n}", "func StartClient(port string) {\n\tfmt.Println(\"StartClient\")\n}", "func (bp *Processer) Connect(addr string) (err error) {\n\tbp.log(\"Connect:%s\", addr)\n\tbp.CloseServer()\n\tbp.svr, err = GetServer(addr)\n\tif err != nil {\n\t\treturn\n\t}\n\tbp.svr.AddProcesser(bp, 0)\n\tbp.log(\"Connect finish \")\n\treturn\n}", "func Open(portName string, mode *Mode) (Port, error) {\n\treturn openPort(portName, mode)\n}", "func (ircConn *Connection) Connect(ip, port string) error {\n\tcli := new(network.Client)\n\tircConn.Host = ip\n\tircConn.Port = port\n\tircConn.client = cli\n\tircConn.openQueries = 0\n\terr := ircConn.client.Connect(ip, port)\n\tif err == nil {\n\t\tircConn.closed = false\n\t}\n\treturn err\n}", "func Connect() net.Conn {\n\tconn, err := net.Dial(\"tcp\", Target+\":\"+strconv.Itoa(Port))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t//mi loggo\n\tSendMessage(conn, \"USER \"+Username+\" 8 * :Someone\")\n\tSendMessage(conn, \"NICK \"+Nick)\n\n\treturn conn\n}", "func (self *Server) Start(port int) {\n\tif self.ln != nil {\n\t\tpanic(\"Server already started\")\n\t}\n\tln, err := net.ListenTCP(\n\t\t\"tcp\",\n\t\t&net.TCPAddr{IP: net.ParseIP(\"0.0.0.0\"), Port: port},\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tself.ln = ln\n\tself.listen()\n}", "func (remote *SerialRemote) Connect() error {\n\tlog.Printf(\"serial:open uri=%v\\n\", remote.uri)\n\n\tport, err := serial.Open(remote.uri, &serial.Mode{})\n\n\tif nil != err {\n\t\treturn err\n\t}\n\n\tmode := &serial.Mode{\n\t\tBaudRate: 19200,\n\t\tParity: serial.NoParity,\n\t\tDataBits: 8,\n\t\tStopBits: serial.OneStopBit,\n\t}\n\n\tif err := port.SetMode(mode); err != nil {\n\t\treturn err\n\t}\n\n\tremote.port = port\n\tremote.done = make(chan struct{}, 2)\n\tremote.channel = make(chan []byte, 256)\n\n\tgo remote.ioloop()\n\n\tif true == remote.flags.AutoConfigure {\n\t\t// configureGateway this, flags\n\t\tif err := ensureTinyMeshConfig(remote, remote.flags); nil != err {\n\t\t\treturn err\n\t\t}\n\t} else if true == remote.flags.Verify {\n\t\tif err := verifyTinyMeshConfig(remote, remote.flags); nil != err {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func StartWithPortVerbose(port int) {\n\tstartWithPortVerbose(port, true)\n}", "func connect(\n\tladdr string,\n\traddr string,\n\tproto uint,\n\thbint time.Duration,\n) *net.IPConn {\n\tc, err := net.DialIP(\n\t\tfmt.Sprintf(\"ip:%v\", proto),\n\t\tresolve(laddr),\n\t\tresolve(raddr),\n\t)\n\tif nil != err {\n\t\tlog.Fatalf(\"Dial: %v\", err)\n\t}\n\n\t/* Start to heartbeet */\n\tgo heartbeet(c, hbint)\n\n\treturn c\n}", "func (networkUtilImpl) ConnectToHost(ip string, port string, isSecure bool) (net.Conn, error) {\n\tif !isSecure {\n\t\tconn, err := net.Dial(\"tcp\", ip+\":\"+port)\n\t\treturn conn, err\n\t}\n\tvar config = &rafftls.Config{\n\t\tCipherSuites: []uint16{psk.TLS_PSK_WITH_AES_128_CBC_SHA},\n\t\tCertificates: []rafftls.Certificate{rafftls.Certificate{}},\n\t\tExtra: psk.PSKConfig{\n\t\t\tGetKey: tls.GetKey,\n\t\t\tGetIdentity: tls.GetIdentity,\n\t\t},\n\t}\n\n\tconn, err := rafftls.Dial(\"tcp\", ip+\":\"+port, config)\n\treturn conn, err\n\n}", "func btcConnect(runenv *runtime.RunEnv, host string, ports []string) bool {\n\tfor _, port := range ports {\n\t\ttimeout := (5*time.Second)\n\t\t// timeout := time.Second\n\t\tconn, err := net.DialTimeout(\"tcp\", net.JoinHostPort(host, port), timeout)\n\t\tif err != nil {\n\t\t\t// BTC Connection is not open\n\t\t\trunenv.RecordMessage(fmt.Sprintf(\"Error Connecting to BTC: %s\", err))\n\t\t\treturn false\n\t\t}\n\t\tif conn != nil {\n\t\t\t// BTC connection is successful\n\t\t\t// fmt.Println(\"BTC Connection Open: \", net.JoinHostPort(host, port))\n\t\t\tdefer conn.Close()\n\t\t}\n\t}\n\treturn true\n}", "func (c *cpu) connect() {\n\tsp, addrlen := popU32(c.sp)\n\tsp, addr := popPtr(sp)\n\tfd := readI32(sp)\n\t_, _, err := syscall.Syscall(unix.SYS_CONNECT, uintptr(fd), addr, uintptr(addrlen))\n\tif strace {\n\t\tfmt.Fprintf(os.Stderr, \"connext(%#x, %#x, %#x) %v\\t; %s\\n\", fd, addr, addrlen, err, c.pos())\n\t}\n\tif err != 0 {\n\t\tc.setErrno(err)\n\t\twriteI32(c.rp, -1)\n\t\treturn\n\t}\n\n\twriteI32(c.rp, 0)\n}", "func CheckPort(port int) (ok bool) {\n\tconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"127.0.0.1:%d\", port), 1*time.Second)\n\tif err == nil {\n\t\tconn.Close()\n\t\tok = true\n\t} else {\n\t\tok = false\n\t}\n\treturn ok\n}", "func freeport(t *testing.T) (port int, addr string) {\n\tl, err := net.ListenTCP(\"tcp\", &net.TCPAddr{IP: net.ParseIP(\"127.0.0.1\")})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer l.Close()\n\ta := l.Addr().(*net.TCPAddr)\n\tport = a.Port\n\treturn port, a.String()\n}", "func (client *Client) Connect(pass string,\n\thost string, port uint16) error {\n\n\tjid_i := C.CString(client.Jid)\n\tpass_i := C.CString(pass)\n\tvar host_i *C.char = nil\n\n\tif len(host) > 0 {\n\t\thost_i = C.CString(host)\n\t}\n\tclient.ConnInfo = C.open_xmpp_conn(jid_i, pass_i, host_i,\n\t\tC.short(port))\n\tif client.ConnInfo != nil {\n\t\tclients[client.Jid] = client\n\t\treturn nil\n\t}\n\treturn errors.New(\"Connection error\")\n}", "func (cfg *config) connect(i int) {\n\t//fmt.Printf(\"connect(%d)\\n\\n\\n\", i)\n\n\tcfg.connected[i] = true\n\n\t// outgoing ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.connected[j] {\n\t\t\tendname := cfg.endnames[i][j]\n\t\t\tcfg.net.Enable(endname, true)\n\t\t}\n\t}\n\n\t// incoming ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.connected[j] {\n\t\t\tendname := cfg.endnames[j][i]\n\t\t\tcfg.net.Enable(endname, true)\n\t\t}\n\t}\n}", "func RegisterTCPPort(port string) {\n\tTCPPort = port\n\tnetwork_client.RegTCP(port)\n}", "func (c *connection) connectToHost(ip string, port int) *net.TCPConn {\n\tvar conn net.Conn\n\tvar err error\n\tfor c.running {\n\t\tconn, err = net.DialTimeout(\"tcp\", fmt.Sprint(ip, \":\", port), time.Millisecond*500)\n\t\tif err != nil && !strings.HasSuffix(err.Error(), \"i/o timeout\") {\n\t\t\tpanic(\"Something went wrong when trying to connect to \" + fmt.Sprint(ip, \":\", port))\n\t\t}\n\t}\n\treturn conn.(*net.TCPConn)\n}", "func Start(port int) {\n\tlog := new(model.Log)\n\n\tserver := rpc.NewServer()\n\tregisterLog(server, log)\n\n\tlisten, err := net.Listen(\"tcp\", \":\"+toolbox.IntToString(port))\n\ttoolbox.CheckError(err, 1)\n\n\tserver.Accept(listen)\n}", "func (contact TCP) Listen(key string, port string, server string, profile string) {\n\thttpServer = server\n\tshellInfo = profile\n\tterminalKey = key\n\tfor {\n\t conn, err := net.Dial(\"tcp\", port)\n\t if err != nil {\n\t\t output.VerbosePrint(fmt.Sprintf(\"[-] %s\", err))\n\t } else {\n\t\t paw := handshake(conn)\n\t\t output.VerbosePrint(\"[+] TCP established\")\n\t\t listen(conn, []byte(fmt.Sprintf(\"%s$\", paw)))\n\t }\n\t time.Sleep(5 * time.Second)\n\t}\n }", "func (this *HostAddress) SetPort(port uint16) {\n\tthis.port = port\n}", "func (m *Setup) SetPortProtection(network string, lowPort int) error {\n\tidx := -1\n\tfor i := 0; i < len(m.networkConfList); i++ {\n\t\tif m.networkConfList[i].Name == network {\n\t\t\tidx = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif idx < 0 {\n\t\treturn fmt.Errorf(\"no configuration found for network %s\", network)\n\t}\n\n\tentries, ok := m.runtimeConf[idx].CapabilityArgs[\"portMappings\"].([]PortMapEntry)\n\tif !ok {\n\t\treturn nil\n\t}\n\tfor _, e := range entries {\n\t\tsockProt := unix.IPPROTO_TCP\n\t\tsockType := unix.SOCK_STREAM\n\n\t\tif e.HostPort <= lowPort {\n\t\t\treturn fmt.Errorf(\"not authorized to map port under %d\", lowPort)\n\t\t}\n\t\tif e.Protocol == \"udp\" {\n\t\t\tsockProt = unix.IPPROTO_UDP\n\t\t\tsockType = unix.SOCK_DGRAM\n\t\t}\n\t\tfd, err := unix.Socket(unix.AF_INET, sockType, sockProt)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\terr = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set reuseport for %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\tsockAddr := &unix.SockaddrInet4{\n\t\t\tPort: e.HostPort,\n\t\t}\n\t\terr = unix.Bind(fd, sockAddr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to bind %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\tif sockType == unix.SOCK_STREAM {\n\t\t\terr = unix.Listen(fd, 1)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to listen on %s socket port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (h *Host) Port() uint16 {\n}", "func (s *Server) Connect(c *config.Config) {\n\ttcpAddr, err := net.ResolveTCPAddr(\"tcp\", fmt.Sprintf(\"%s:%d\", c.TCPServer.Addr, c.TCPServer.Port))\n\tcheckErr(err)\n\n\ts.L, err = net.ListenTCP(\"tcp\", tcpAddr)\n\tcheckErr(err)\n}", "func (ms *MicroService) StartOnPort(port int) {\n\n\t// add health\n\tms.Handle(\"GET\", \"/health\", ms.Health)\n\n\t// start the web server\n\tfmt.Printf(\"Listening on %d....\\n\", port)\n\t\n\tif err := http.ListenAndServe(\":\" + strconv.Itoa(port), ms.muxx); err != nil {\n\t\tfmt.Println(\"error\")\n\t\tlog.Fatal(\"ListenAndServe:\", err)\n\t} else {\n\t\tfmt.Println(\"running\")\n\t}\n}", "func SetPort(p int) Option {\n\treturn func(w *Worker) error {\n\t\tw.port = p\n\t\treturn nil\n\t}\n}", "func Start(port int, connectTo string) (*Node, error) {\n\treturn start(RandomID(), port, connectTo)\n}", "func Port(p int) PinningOption {\n\treturn func(o *Pinning) {\n\t\to.Port = p\n\t}\n}", "func (r *RPCClientTCP) Connect(address string) (err error) {\n\treturn r.r.c.Call(\"tcp.Connect\", address, &struct{}{})\n}", "func connect() net.Conn {\n\t//connection, err := net.Dial(\"unix\", \"/var/www/bot/irc/sock\")\n\tconnection, err := net.Dial(\"tcp\", \"localhost:8765\")\n\n\t//\tsendCommand(connection, \"PASS\", password)\n\t//\tsendCommand(connection, \"USER\", fmt.Sprintf(\"%s 8 * :%s\\r\\n\", nickname, nickname))\n\t//\tsendCommand(connection, \"NICK\", nickname)\n\t//\tfmt.Println(\"Registration sent\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tjoinChannels(connection)\n\n\treturn connection\n}", "func (n *Node) Connect() error {\n\tif n.IsTorNode() {\n\t\t// Onion Address\n\t\tconn, err := DialTor(\"tcp\", n.TcpAddr)\n\t\tif err != nil {\n\t\t\t// log.Println(\"Tor connect error: \", err)\n\t\t\treturn err\n\t\t}\n\t\tn.conn = conn\n\t} else {\n\t\tconn, err := net.DialTimeout(\"tcp\", n.TcpAddr.String(), 30*time.Second)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tn.conn = conn\n\t}\n\n\treturn nil\n}", "func (c *connection) Connect(ip string, port int) (int, error) {\n\tvar err error\n\tvar tempConn net.Conn\n\ttempConn, err = net.DialTimeout(\"tcp\", fmt.Sprint(ip, \":\", port), time.Second*5)\n\tfor err != nil {\n\t\ttempConn, err = net.DialTimeout(\"tcp\", fmt.Sprint(ip, \":\", port), time.Second*5)\n\t}\n\tconn := tempConn.(*net.TCPConn)\n\tif err != nil {\n\t\tpanic(\"Couldnt dial the host: \" + err.Error())\n\t}\n\n\twrite(conn, []byte{0, 0, byte(c.myPort / 256), byte(c.myPort % 256)})\n\t//conn.SetReadDeadline(time.Now().Add(time.Second*5))\n\n\tmsg := read(conn)\n\tc.myId = int(msg[0])\n\tc.addPeer(c.myId, nil, 0)\n\totherId := int(msg[1])\n\tc.peers = make([]*peer, c.myId+1)\n\tc.addPeer(otherId, conn, port)\n\tj := 2\n\tfor j < len(msg) {\n\t\tid := int(msg[j])\n\t\tj++\n\t\tip, port, k := addrFromBytes(msg[j:])\n\t\tnewConn, err := net.Dial(\"tcp\", fmt.Sprint(ip, \":\", port))\n\t\tif err != nil {\n\t\t\tpanic(\"Got error when connecting to addr \" + fmt.Sprint(ip, \":\", port) + \": \" + err.Error())\n\t\t}\n\t\twrite(newConn, []byte{0, byte(c.myId), byte(c.myPort / 256), byte(c.myPort % 256)})\n\t\tc.addPeer(id, newConn.(*net.TCPConn), port)\n\t\tgo c.receive(c.peers[id])\n\t\tj += k\n\t}\n\tgo c.receive(c.peers[otherId])\n\treturn c.myId, nil\n}", "func connectWebsocket(port string) {\n\tfor {\n\t\tvar err error\n\t\tServerIP = utils.DiscoverServer()\n\t\tif ServerIP == \"\" {\n\t\t\tlogger.WithFields(logger.Fields{}).Debugf(\"Wait 5 seconds to redail...\")\n\t\t\ttime.Sleep(time.Second * 5)\n\t\t\tcontinue\n\t\t}\n\t\tu := url.URL{Scheme: \"ws\", Host: ServerIP + \":\" + os.Getenv(\"CASA_SERVER_PORT\"), Path: \"/v1/ws\"}\n\t\tWS, _, err = websocket.DefaultDialer.Dial(u.String(), nil)\n\t\tif err != nil {\n\t\t\tlogger.WithFields(logger.Fields{\"code\": \"CGGWCCW001\"}).Errorf(\"%s\", err.Error())\n\t\t\tlogger.WithFields(logger.Fields{}).Debugf(\"Wait 5 seconds to redail...\")\n\t\t\ttime.Sleep(time.Second * 5)\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\n\taddr := strings.Split(WS.LocalAddr().String(), \":\")[0]\n\tmessage := WebsocketMessage{\n\t\tAction: \"newConnection\",\n\t\tBody: []byte(addr + \":\" + port),\n\t}\n\tbyteMessage, _ := json.Marshal(message)\n\terr := WS.WriteMessage(websocket.TextMessage, byteMessage)\n\tif err != nil {\n\t\tlogger.WithFields(logger.Fields{\"code\": \"CGGWCCW002\"}).Errorf(\"%s\", err.Error())\n\t\treturn\n\t}\n\tlogger.WithFields(logger.Fields{}).Debugf(\"Websocket connected!\")\n}", "func WithPort(p int) Option {\n\treturn func(o *options) {\n\t\to.port = p\n\t}\n}", "func (n *gateway) Start(host string, port int, seedAddr string) error {\n\tmyAddr, err := n.net.Start(host, port)\n\tif err != nil {\n\t\treturn err\n\t}\n\tn.addr = myAddr\n\n\tgo n.recvData()\n\tif seedAddr == \"\" {\n\t\treturn nil\n\t}\n\n\treturn n.net.ConnectSeed(seedAddr)\n}", "func (s *Slave) connect(uri string, options Options) (err error) {\n\tdsn, opts, err := parseOptions(uri, options)\n\tif err != nil {\n\t\treturn\n\t}\n\tconn, err := newConn(context.Background(), dsn.Scheme, dsn.Host, opts)\n\tif err != nil {\n\t\treturn\n\t}\n\ts.c = conn\n\ts.cr = bufio.NewReaderSize(s.c.tcpConn, DefaultReaderBufSize)\n\t// for better error checking while writing to connection\n\ts.cw = bufio.NewWriter(s.c.tcpConn)\n\treturn\n}", "func (m *DomainDnsSrvRecord) SetPort(value *int32)() {\n err := m.GetBackingStore().Set(\"port\", value)\n if err != nil {\n panic(err)\n }\n}", "func (m ManagedServer) Start(port int, rawPrivateKeys [][]byte, ciphers, macs []string) {\n\tm.lg.InfoD(\"starting-server\", meta{\n\t\t\"port\": port,\n\t\t\"ciphers\": ciphers,\n\t\t\"macs\": macs,\n\t})\n\n\tprivateKeys := []ssh.Signer{}\n\tfor i, rawKey := range rawPrivateKeys {\n\t\tprivateKey, err := ssh.ParsePrivateKey(rawKey)\n\t\tif err != nil {\n\t\t\tm.errorAndAlert(\"private-key-parse\", meta{\"index\": i, \"error\": err.Error()})\n\t\t\tos.Exit(1)\n\t\t}\n\t\tprivateKeys = append(privateKeys, privateKey)\n\t}\n\n\tlistener, err := net.Listen(\"tcp\", fmt.Sprintf(\"0.0.0.0:%v\", port))\n\tproxyList := proxyproto.Listener{Listener: listener}\n\n\tif err != nil {\n\t\tm.errorAndAlert(\"listen-fail\", meta{\n\t\t\t\"msg\": \"failed to open socket\",\n\t\t\t\"error\": err.Error(),\n\t\t\t\"port\": port})\n\t}\n\tm.lg.InfoD(\"listening\", meta{\"address\": proxyList.Addr().String()})\n\n\tfor {\n\t\tnewConn, err := proxyList.Accept()\n\t\tif err != nil {\n\t\t\tm.errorAndAlert(\"listener-accept-fail\", meta{\"error\": err.Error()})\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tgo func(conn net.Conn) {\n\t\t\tvar driver ServerDriver\n\t\t\tconfig := &ssh.ServerConfig{\n\t\t\t\tConfig: ssh.Config{\n\t\t\t\t\tCiphers: ciphers,\n\t\t\t\t\tMACs: macs,\n\t\t\t\t},\n\t\t\t\tPasswordCallback: func(c ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error) {\n\t\t\t\t\tdriver = m.driverGenerator(LoginRequest{\n\t\t\t\t\t\tUsername: c.User(),\n\t\t\t\t\t\tPassword: string(pass),\n\t\t\t\t\t\tPublicKey: \"\",\n\t\t\t\t\t\tRemoteAddr: c.RemoteAddr(),\n\t\t\t\t\t})\n\t\t\t\t\tif driver == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"password rejected for %q\", c.User())\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, nil\n\t\t\t\t},\n\t\t\t\tPublicKeyCallback: func(c ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {\n\t\t\t\t\tdriver = m.driverGenerator(LoginRequest{\n\t\t\t\t\t\tUsername: c.User(),\n\t\t\t\t\t\tPassword: \"\",\n\t\t\t\t\t\tPublicKey: strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key))),\n\t\t\t\t\t\tRemoteAddr: c.RemoteAddr(),\n\t\t\t\t\t})\n\t\t\t\t\tif driver == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"password rejected for %q\", c.User())\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, nil\n\t\t\t\t},\n\t\t\t}\n\t\t\tfor _, privateKey := range privateKeys {\n\t\t\t\tconfig.AddHostKey(privateKey)\n\t\t\t}\n\n\t\t\t_, newChan, requestChan, err := ssh.NewServerConn(conn, config)\n\t\t\tif err != nil {\n\t\t\t\tif err != io.EOF {\n\t\t\t\t\tm.errorAndAlert(\"handshake-failure\", meta{\"error\": err.Error()})\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tgo ssh.DiscardRequests(requestChan)\n\n\t\t\tfor newChannelRequest := range newChan {\n\t\t\t\tif newChannelRequest.ChannelType() != \"session\" {\n\t\t\t\t\tnewChannelRequest.Reject(ssh.UnknownChannelType, \"unknown channel type\")\n\t\t\t\t\tm.errorAndAlert(\"unknown-channel-type\", meta{\"type\": newChannelRequest.ChannelType()})\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tchannel, requests, err := newChannelRequest.Accept()\n\t\t\t\tif err != nil {\n\t\t\t\t\tif err != io.EOF {\n\t\t\t\t\t\tm.errorAndAlert(\"channel-accept-failure\", meta{\n\t\t\t\t\t\t\t\"err\": err.Error(),\n\t\t\t\t\t\t\t\"type\": newChannelRequest.ChannelType()})\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tgo func(in <-chan *ssh.Request) {\n\t\t\t\t\tfor req := range in {\n\t\t\t\t\t\tok := false\n\t\t\t\t\t\tswitch req.Type {\n\t\t\t\t\t\tcase \"subsystem\":\n\t\t\t\t\t\t\tif len(req.Payload) >= 4 {\n\t\t\t\t\t\t\t\t// we reject all SSH requests that are not SFTP\n\t\t\t\t\t\t\t\tif string(req.Payload[4:]) == \"sftp\" {\n\t\t\t\t\t\t\t\t\tok = true\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treq.Reply(ok, nil)\n\t\t\t\t\t}\n\t\t\t\t}(requests)\n\n\t\t\t\tserver, err := NewServer(channel, driver)\n\t\t\t\tif err != nil {\n\t\t\t\t\tm.errorAndAlert(\"server-creation-err\", meta{\"err\": err.Error()})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif err := server.Serve(); err != nil {\n\t\t\t\t\tchannel.Close()\n\t\t\t\t}\n\t\t\t}\n\t\t}(newConn)\n\t}\n}", "func (o *LdapProvider) SetPort(v int32) {\n\to.Port = v\n}", "func (cm *RPCConnManager) Connect(addr string, permanent bool) error {\n\treplyChan := make(chan error)\n\tcm.server.query <- connectNodeMsg{\n\t\taddr: addr,\n\t\tpermanent: permanent,\n\t\treply: replyChan,\n\t}\n\treturn <-replyChan\n}", "func (conn *Conn) Open(port int) (stream net.Conn, err error) {\n\tstream, err = conn.sess.OpenStream()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to open smux stream\")\n\t}\n\n\tvar portData [8]byte\n\tbinary.BigEndian.PutUint64(portData[:], uint64(port))\n\n\t_, err = stream.Write(portData[:])\n\tif err != nil {\n\t\tstream.Close()\n\t\treturn nil, errors.Wrapf(err, \"failed to write port to smux stream\")\n\t}\n\n\tlog.WithField(\"peer\", conn.peerPublicKey).\n\t\tWithField(\"port\", port).\n\t\tInfo(\"opened connection\")\n\n\treturn stream, nil\n}", "func (h *httpServer) ExposePort(c echo.Context) error {\n\tvar port vpnkit.Port\n\tif err := c.Bind(&port); err != nil {\n\t\treturn err\n\t}\n\tif port.Proto != vpnkit.TCP && port.Proto != vpnkit.UDP {\n\t\treturn c.JSON(400, \"exposed ports can only be TCP or UDP\")\n\t}\n\terr := h.impl.Expose(context.Background(), &port)\n\tif err == nil {\n\t\treturn nil\n\t}\n\tif e, ok := err.(*vpnkit.ExposeError); ok {\n\t\treturn c.JSON(400, e)\n\t}\n\treturn err\n}", "func Port() int {\n\treturn TomlConfig.Port\n}", "func Port() int {\n\treturn TomlConfig.Port\n}", "func (s *SSHer) Connect() (err error) {\n\taddr := net.JoinHostPort(s.Host, s.Port)\n\tconfig := &ssh.ClientConfig{\n\t\tUser: s.User,\n\t\tAuth: []ssh.AuthMethod{\n\t\t\tssh.Password(s.Pass),\n\t\t},\n\t\tHostKeyCallback: ssh.InsecureIgnoreHostKey(),\n\t}\n\tif s.client, err = ssh.Dial(\"tcp\", addr, config); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func waitForPortInTest(port int, t *testing.T) {\n\ttimeout := time.After(1 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-timeout:\n\t\t\tt.Fatalf(\"Expected server to start < 1s.\")\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t\t_, err := net.Dial(\"tcp\", fmt.Sprintf(\":%d\", port))\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func Start(ctx context.Context, port int) (*Connection, error) {\n\tresult := new(Connection)\n\tifacesArcSet := make(map[string]bool)\n\n\t// Make sure ARC interfaces can accept connection on port\n\tfor _, i := range ifacesArc {\n\t\t// For faster search when checking existing net interfaces.\n\t\tkey := strings.TrimSuffix(i, \"+\")\n\t\tif _, ok := ifacesArcSet[key]; !ok {\n\t\t\tifacesArcSet[key] = true\n\t\t}\n\n\t\trule := \"INPUT -i \" + i + \" -p tcp -m tcp --dport \" + strconv.Itoa(port) + \" -j ACCEPT -w\"\n\t\tresult.iprules = append(result.iprules, rule)\n\t\tfor _, cmd := range cmds {\n\t\t\targs := append([]string{\"-A\"}, strings.Fields(rule)...)\n\t\t\tif err := testexec.CommandContext(ctx, cmd, args...).Run(testexec.DumpLogOnError); err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to add iptables rule: %s\", rule)\n\t\t\t}\n\n\t\t\t// Check rules were added in IPv4 and IPv6 iptables.\n\t\t\targs = append([]string{\"-C\"}, strings.Fields(rule)...)\n\t\t\tif err := testexec.CommandContext(ctx, cmd, args...).Run(); err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to verify addition of iptables rule: %s\", rule)\n\t\t\t}\n\t\t}\n\t}\n\n\tifaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to enum interfaces\")\n\t}\n\n\t// Handle real addresses that could be accessible for the current DUT.\n\tfor _, i := range ifaces {\n\t\t// Filter network interfaces using ifacesArc and match non-wildcard lowercase characters.\n\t\tif _, ok := ifacesArcSet[regexp.MustCompile(\"[^a-z]+(_?[a-z]+)*$\").ReplaceAllString(i.Name, \"\")]; !ok {\n\t\t\tcontinue\n\t\t}\n\t\tresult.ifaces = append(result.ifaces, i)\n\t\taddrs, err := i.Addrs()\n\t\tif err != nil {\n\t\t\ttesting.ContextLogf(ctx, \"Failed to enum addresses for %s\", i.Name)\n\t\t\tcontinue\n\t\t}\n\t\tif len(addrs) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, addr := range addrs {\n\t\t\tswitch v := addr.(type) {\n\t\t\tcase *net.IPNet:\n\t\t\t\tvar address string\n\t\t\t\tif v.IP.To4() != nil {\n\t\t\t\t\taddress = fmt.Sprintf(\"%s:%d\", v.IP, port)\n\t\t\t\t} else {\n\t\t\t\t\taddress = fmt.Sprintf(\"[%s%%%s]:%d\", v.IP, i.Name, port)\n\t\t\t\t}\n\t\t\t\tlistener, err := net.Listen(\"tcp\", address)\n\t\t\t\tif err != nil {\n\t\t\t\t\ttesting.ContextLogf(ctx, \"Failed to listen on %s\", address)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// Deploy listen goroutine and add new connection listener to result object.\n\t\t\t\ttesting.ContextLogf(ctx, \"Listening on %s\", address)\n\t\t\t\tgo listenForClients(ctx, listener)\n\t\t\t\tresult.listeners = append(result.listeners, listener)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(result.listeners) > 0 {\n\t\treturn result, nil\n\t}\n\n\treturn nil, errors.Errorf(\"failed to start server at port %d, no address is available\", port)\n}", "func (i *Invoker) Connect(address string) (e error) {\n\tif i.Conn, e = grpc.Dial(address, grpc.WithInsecure()); e != nil {\n\t\treturn\n\t}\n\n\ti.Client = invokerV1API.NewInvokerClient(i.Conn)\n\n\treturn\n}", "func portKnocking(ports []int) {\n\tfor _, port := range ports {\n\t\thost := fmt.Sprintf(\"http://127.0.0.1:%d\", port)\n\t\tknock(host)\n\t}\t\n}", "func port() string {\n\treturn strconv.Itoa(int(atomic.AddUint32(nport, 1)))\n}", "func (pe NoopFirewallClient) ExposePort(port int32) error {\n\treturn nil\n}", "func TestPortaniaConnection(t *testing.T) {\n\n\ttestSuite := map[string]struct {\n\t\taddr string\n\t\tduration time.Duration\n\t\terr string\n\t\tsuccess bool\n\t}{\n\t\t\"testConnection should throw an due to a closed port on localhost\": {\n\t\t\taddr: \"localhost:555\",\n\t\t\tsuccess: false,\n\t\t\tduration: time.Second * 5,\n\t\t\terr: \"dial tcp [::1]:555: connect: connection refused\",\n\t\t},\n\t\t\"testConnection should return true indicating that the port is open\": {\n\t\t\taddr: \"github.com:443\",\n\t\t\tduration: time.Second * 5,\n\t\t\tsuccess: true,\n\t\t},\n\t}\n\n\tfor testName, testCase := range testSuite {\n\n\t\tt.Logf(\"Running test %v\\n\", testName)\n\n\t\tok, err := testConnection(testCase.addr, testCase.duration)\n\t\tif err != nil && err.Error() != testCase.err {\n\t\t\tt.Errorf(\"expected testConnection to fail with %v but received %v\\n\", testCase.err, err.Error())\n\t\t} else {\n\t\t\tt.Logf(\"received the expected error result %v\\n\", testCase.err)\n\t\t}\n\n\t\tif ok != testCase.success {\n\t\t\tt.Errorf(\"expected testConnection to return %v but received %v\\n\", testCase.success, ok)\n\t\t} else {\n\t\t\tt.Logf(\"received the expected response from testConnection\\n\")\n\t\t}\n\t}\n}", "func WithPort(p string) Option {\n\treturn func(s *Server) {\n\t\ts.Port = p\n\t}\n}", "func serve(port int, handler connectionhandler) {\n \n if port < 1024 || port > 65535 {\n // todo: how does go handle errors.\n }\n\n portspec := fmt.Sprintf(\":%d\", port)\n\n sock, err := net.Listen(\"tcp\", portspec)\n if err != nil {\n // error\n fmt.Printf(\"%d\", err)\n }\n\n for {\n conn, err := sock.Accept()\n if err != nil {\n fmt.Printf(\"%d\", err) \n }\n go handler(conn) \n }\n}", "func Connect(\n\thost, user, password string,\n\tport int,\n\tistls bool,\n) (*Session, error) {\n\tconnConf := http.ConnectionConfig{\n\t\tEndpoints: []string{\n\t\t\tfmt.Sprintf(\"http://%s:%d\", host, port),\n\t\t},\n\t}\n\tif istls {\n\t\tconnConf.Endpoints = []string{\n\t\t\tfmt.Sprintf(\"https://%s:%d\", host, port),\n\t\t}\n\t\tconnConf.TLSConfig = &tls.Config{InsecureSkipVerify: true}\n\t}\n\tconn, err := http.NewConnection(connConf)\n\tif err != nil {\n\t\treturn &Session{}, fmt.Errorf(\"could not connect %s\", err)\n\t}\n\tclient, err := driver.NewClient(\n\t\tdriver.ClientConfig{\n\t\t\tConnection: conn,\n\t\t\tAuthentication: driver.BasicAuthentication(\n\t\t\t\tuser,\n\t\t\t\tpassword,\n\t\t\t),\n\t\t})\n\tif err != nil {\n\t\treturn &Session{}, fmt.Errorf(\"could not get a client instance %s\", err)\n\t}\n\n\treturn &Session{client}, nil\n}", "func (k Keeper) BindPort(ctx sdk.Context, portID string) error {\n\tcap := k.portKeeper.BindPort(ctx, portID)\n\treturn k.ClaimCapability(ctx, cap, host.PortPath(portID))\n}", "func freeport() (port int, addr string) {\n\tl, err := net.ListenTCP(\"tcp\", &net.TCPAddr{IP: net.ParseIP(\"127.0.0.1\")})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer l.Close()\n\ta := l.Addr().(*net.TCPAddr)\n\tport = a.Port\n\treturn port, a.String()\n}", "func (t *KCPTransport) Listen(port uint16) (net.Listener, error) {\n\tladdr := fmt.Sprintf(\":%d\", port)\n\treturn kcp.Listen(laddr)\n}", "func (c *connection) Connect(ip string, port int) (int, error) {\n\tvar err error\n\tvar tempConn net.Conn\n\ttempConn, err = net.DialTimeout(\"tcp\", fmt.Sprint(ip, \":\", port), time.Second*5)\n\tif err != nil {\n\t\tpanic(\"Error: Dial TCP error\")\n\t}\n\ttmpConn := tempConn.(*net.TCPConn)\n\tif err != nil {\n\t\tpanic(\"Couldnt dial the host: \" + err.Error())\n\t}\n\n\twrite(tmpConn, []byte{0, 0, byte(c.port / 256), byte(c.port % 256)})\n\t\n\tmsg, _ := read(tmpConn)\n\tc.id = int(msg[0])\n\tc.addPeer(c.id, nil, 0)\n\tc.peers = make([]*peer, c.id+1)\n\totherId := int(msg[1])\n\tc.addPeer(otherId, tmpConn, port)\n\tj := 2\n\tfor j < len(msg) {\n\t\tid := int(msg[j])\n\t\tj++\n\t\tip, port, k := addrFromBytes(msg[j:])\n\t\tnewConn, err := net.Dial(\"tcp\", fmt.Sprint(ip, \":\", port))\n\t\tif err != nil {\n\t\t\tpanic(\"Error: Connect to address \" + fmt.Sprint(ip, \":\", port) + \": \" + err.Error())\n\t\t}\n\t\twrite(newConn, []byte{0, byte(c.id), byte(c.port / 256), byte(c.port % 256)})\n\t\tc.addPeer(id, newConn.(*net.TCPConn), port)\n\t\tgo c.receive(c.peers[id])\n\t\tj = j + k\n\t}\n\tgo c.receive(c.peers[otherId])\n\treturn c.id, nil\n}", "func (c *DUTControlRawUARTPortOpener) OpenPort(ctx context.Context) (serial.Port, error) {\n\tstream, err := c.Client.Console(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdata, write, err := openDUTControlConsole(stream,\n\t\t&dutcontrol.ConsoleRequest{\n\t\t\tOperation: &dutcontrol.ConsoleRequest_Open{\n\t\t\t\tOpen: &dutcontrol.ConsoleOpen{\n\t\t\t\t\tType: &dutcontrol.ConsoleOpen_RawUart{RawUart: &dutcontrol.ConsoleOpenRawUART{Uart: c.Uart, Baud: int32(c.Baud), DataLen: int32(c.DataLen)}},\n\t\t\t\t},\n\t\t\t}})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &DUTControlPort{stream, data, write, c.ReadTimeout, nil}, nil\n}", "func connect(ctx context.Context, session liveshare.LiveshareSession) (Invoker, error) {\n\tlistener, err := listenTCP()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlocalAddress := listener.Addr().String()\n\n\tinvoker := &invoker{\n\t\tsession: session,\n\t\tlistener: listener,\n\t}\n\n\t// Create a cancelable context to be able to cancel background tasks\n\t// if we encounter an error while connecting to the gRPC server\n\tconnectctx, cancel := context.WithCancel(context.Background())\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tcancel()\n\t\t}\n\t}()\n\n\tch := make(chan error, 2) // Buffered channel to ensure we don't block on the goroutine\n\n\t// Ensure we close the port forwarder if we encounter an error\n\t// or once the gRPC connection is closed. pfcancel is retained\n\t// to close the PF whenever we close the gRPC connection.\n\tpfctx, pfcancel := context.WithCancel(connectctx)\n\tinvoker.cancelPF = pfcancel\n\n\t// Tunnel the remote gRPC server port to the local port\n\tgo func() {\n\t\tfwd := liveshare.NewPortForwarder(session, codespacesInternalSessionName, codespacesInternalPort, true)\n\t\tch <- fwd.ForwardToListener(pfctx, listener)\n\t}()\n\n\tvar conn *grpc.ClientConn\n\tgo func() {\n\t\t// Attempt to connect to the port\n\t\topts := []grpc.DialOption{\n\t\t\tgrpc.WithTransportCredentials(insecure.NewCredentials()),\n\t\t\tgrpc.WithBlock(),\n\t\t}\n\t\tconn, err = grpc.DialContext(connectctx, localAddress, opts...)\n\t\tch <- err // nil if we successfully connected\n\t}()\n\n\t// Wait for the connection to be established or for the context to be cancelled\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn nil, ctx.Err()\n\tcase err := <-ch:\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tinvoker.conn = conn\n\tinvoker.jupyterClient = jupyter.NewJupyterServerHostClient(conn)\n\tinvoker.codespaceClient = codespace.NewCodespaceHostClient(conn)\n\tinvoker.sshClient = ssh.NewSshServerHostClient(conn)\n\n\t// Send initial connection heartbeat (no need to throw if we fail to get a response from the server)\n\t_ = invoker.notifyCodespaceOfClientActivity(ctx, connectedEventName)\n\n\t// Start the activity heatbeats\n\tgo invoker.heartbeat(pfctx, 1*time.Minute)\n\n\treturn invoker, nil\n}" ]
[ "0.6753614", "0.65101886", "0.6489948", "0.6419193", "0.6363244", "0.6244633", "0.62063265", "0.61901814", "0.6126926", "0.6104171", "0.6032252", "0.59713644", "0.59468466", "0.5938887", "0.58270514", "0.58182085", "0.578832", "0.5769424", "0.5764073", "0.5748341", "0.5739284", "0.5734151", "0.57295364", "0.5724207", "0.5720348", "0.571711", "0.5704837", "0.5698544", "0.5698462", "0.5661512", "0.5661193", "0.56420976", "0.56245077", "0.5615001", "0.5585818", "0.55829465", "0.55758464", "0.5570725", "0.5564272", "0.5562861", "0.55578315", "0.55403477", "0.553687", "0.5536472", "0.5515096", "0.5511157", "0.5505404", "0.5504461", "0.5489246", "0.5482279", "0.5473936", "0.5458855", "0.54579824", "0.5453036", "0.54511684", "0.5449391", "0.5442103", "0.5428664", "0.54258716", "0.5423932", "0.5423693", "0.5411593", "0.5403734", "0.54011697", "0.5400973", "0.53984714", "0.5396982", "0.5385863", "0.5381557", "0.53741175", "0.53723854", "0.5369522", "0.5363151", "0.5362596", "0.53592557", "0.5339553", "0.5333445", "0.5329767", "0.5324445", "0.5314838", "0.5310506", "0.530598", "0.530598", "0.5303645", "0.5302481", "0.5295934", "0.5276149", "0.52670497", "0.5266109", "0.526577", "0.5264025", "0.52620757", "0.52608335", "0.5260636", "0.52513266", "0.52416444", "0.524", "0.5239262", "0.5229086", "0.52265525" ]
0.52329874
98
Disconnects (disables) the specified port
func (sf *SingleFlowNode) DisconnectPort(portIndex uint16, direction int) { switch direction { case FlowPortInput: C.sol_flow_single_disconnect_port_in(sf.FlowNode.cnode, C.uint16_t(portIndex)) case FlowPortOutput: C.sol_flow_single_disconnect_port_out(sf.FlowNode.cnode, C.uint16_t(portIndex)) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TurnOffPort(client CommandRunner, port int) error {\n\t_, err := client.ExecCmds([]string{\n\t\t\"configure\",\n\t\t\"interface \" + fmt.Sprintf(\"0/%d\", port),\n\t\t\"poe opmode shutdown\",\n\t\t\"exit\", // leave the interface config mode (entered via 'interface ...')\n\t\t\"exit\", // leave the global configuration mode (entered via 'configure')\n\t})\n\treturn err\n}", "func resetConnection() {\n\tmutex.Lock()\n\tdefer mutex.Unlock()\n\tp := int32(cfg.DefaultPort)\n\texternalPort = &p\n\tstatus = cfg.Disconnected\n}", "func disableCmdPort() {\n\tos.Setenv(\"DD_CMD_PORT\", \"0\") // 0 indicates the OS should pick an unused port\n}", "func (pe NoopFirewallClient) UnexposePort(port int32) error {\n\treturn nil\n}", "func (cfg *config) disconnect(i int) {\r\n\t// fmt.Printf(\"disconnect(%d)\\n\", i)\r\n\r\n\tcfg.connected[i] = false\r\n\r\n\t// outgoing ClientEnds\r\n\tfor j := 0; j < cfg.n; j++ {\r\n\t\tif cfg.endnames[i] != nil {\r\n\t\t\tendname := cfg.endnames[i][j]\r\n\t\t\tcfg.net.Enable(endname, false)\r\n\t\t}\r\n\t}\r\n\r\n\t// incoming ClientEnds\r\n\tfor j := 0; j < cfg.n; j++ {\r\n\t\tif cfg.endnames[j] != nil {\r\n\t\t\tendname := cfg.endnames[j][i]\r\n\t\t\tcfg.net.Enable(endname, false)\r\n\t\t}\r\n\t}\r\n}", "func (h *httpServer) UnexposePort(c echo.Context) error {\n\tvar port vpnkit.Port\n\tif err := c.Bind(&port); err != nil {\n\t\treturn err\n\t}\n\tif port.Proto != vpnkit.TCP && port.Proto != vpnkit.UDP {\n\t\treturn c.JSON(400, \"exposed ports can only be TCP or UDP\")\n\t}\n\treturn h.impl.Unexpose(context.Background(), &port)\n}", "func (cfg *config) disconnect(i int) {\n\t//fmt.Printf(\"disconnect(%d)\\n\\n\\n\", i)\n\n\tcfg.connected[i] = false\n\n\t// outgoing ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.endnames[i] != nil {\n\t\t\tendname := cfg.endnames[i][j]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n\n\t// incoming ClientEnds\n\tfor j := 0; j < cfg.n; j++ {\n\t\tif cfg.endnames[j] != nil {\n\t\t\tendname := cfg.endnames[j][i]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n}", "func (p *Port) Disconnect(q *Port) error {\n\tif !p.Connected(q) {\n\t\treturn errors.New(\"not connected\")\n\t}\n\tq.src = nil\n\tdelete(p.dests, q)\n\treturn nil\n}", "func (a *NullAdapter) Disconnect(srv *Server, ca ClientAdapter, err error) {\n}", "func TurnOnPort(client CommandRunner, port int) error {\n\t_, err := client.ExecCmds([]string{\n\t\t\"configure\",\n\t\t\"interface \" + fmt.Sprintf(\"0/%d\", port),\n\t\t\"poe opmode auto\",\n\t\t\"exit\", // leave the interface config mode (entered via 'interface ...')\n\t\t\"exit\", // leave the global configuration mode (entered via 'configure')\n\t})\n\treturn err\n}", "func (d *Device) Disconnect(result chan<- error) {\n\t// Wait 2 seconds and die\n\td.m.Disconnect(2000)\n}", "func (node *Node) Disconnect() error {\n\tnode.Lock()\n\tdefer node.Unlock()\n\tnode.allowNetwork = false\n\treturn nil\n}", "func (m *Myself) resetPort() {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\tp := int32(m.internalPort)\n\tm.externalPort = &p\n\tm.relayServer = nil\n\tm.status = Disconnected\n}", "func (self *SinglePad) Disconnect() {\n self.Object.Call(\"disconnect\")\n}", "func (ch *ServerChannel) Disconnect(c *Client) {}", "func (pe *providerEndpoint) Disconnect(args *DisconnectRequest, resp *DisconnectResponse) error {\n\tdefer metrics.IncrCounter([]string{\"scada\", \"disconnect\"}, 1)\n\tif args.Reason == \"\" {\n\t\targs.Reason = \"<no reason provided>\"\n\t}\n\tpe.p.logger.Printf(\"[INFO] scada-client: disconnect requested (retry: %v, backoff: %v): %v\",\n\t\t!args.NoRetry, args.Backoff, args.Reason)\n\n\t// Use the backoff information\n\tpe.p.backoffLock.Lock()\n\tpe.p.noRetry = args.NoRetry\n\tpe.p.backoff = args.Backoff\n\tpe.p.backoffLock.Unlock()\n\n\t// Clear the session information\n\tpe.p.sessionLock.Lock()\n\tpe.p.sessionID = \"\"\n\tpe.p.sessionAuth = false\n\tpe.p.sessionLock.Unlock()\n\n\t// Force the disconnect\n\ttime.AfterFunc(DisconnectDelay, func() {\n\t\tpe.p.clientLock.Lock()\n\t\tif pe.p.client != nil {\n\t\t\tpe.p.client.Close()\n\t\t}\n\t\tpe.p.clientLock.Unlock()\n\t})\n\treturn nil\n}", "func (ch *InternalChannel) Disconnect(c *Client) {}", "func (self *discovery) disconnect() error {\n\tself.Lock()\n\tdefer self.Unlock()\n\n\tif self.connected {\n\t\treturn self.callDiscoveryService(\"unregister\", false)\n\t}\n\n\treturn nil\n}", "func (s *Slave) disconnect() (err error) {\n\ts.c.stop()\n\n\treturn\n}", "func Disconnect(w http.ResponseWriter, r *http.Request) {\n\truntime := r.Context().Value(\"runtime\").(*libpod.Runtime)\n\n\tvar netDisconnect types.NetworkDisconnect\n\tif err := json.NewDecoder(r.Body).Decode(&netDisconnect); err != nil {\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, errors.Wrap(err, \"Decode()\"))\n\t\treturn\n\t}\n\n\tname := utils.GetName(r)\n\terr := runtime.DisconnectContainerFromNetwork(netDisconnect.Container, name, netDisconnect.Force)\n\tif err != nil {\n\t\tif errors.Cause(err) == define.ErrNoSuchCtr {\n\t\t\tutils.Error(w, \"container not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tif errors.Cause(err) == define.ErrNoSuchNetwork {\n\t\t\tutils.Error(w, \"network not found\", http.StatusNotFound, err)\n\t\t\treturn\n\t\t}\n\t\tutils.Error(w, \"Something went wrong.\", http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tutils.WriteResponse(w, http.StatusOK, \"OK\")\n}", "func (n *natsBroker) Disconnect() error {\n\n\tif n.connection == nil {\n\t\treturn errors.New(\"[NATS]: Cannot Disconnect. Not connected to broker\")\n\t}\n\n\tn.connection.Close()\n\tlog.Printf(\"[NATS]: Disconnected from %s\", n.Address())\n\treturn nil\n}", "func (*GenericFramework) PeerDisconnect(ctx *PeerContext) {}", "func (protocol *DebuggerProtocol) Disable() <-chan *debugger.DisableResult {\n\tresultChan := make(chan *debugger.DisableResult)\n\tcommand := NewCommand(protocol.Socket, \"Debugger.disable\", nil)\n\tresult := &debugger.DisableResult{}\n\n\tgo func() {\n\t\tresponse := <-protocol.Socket.SendCommand(command)\n\t\tif nil != response.Error && 0 != response.Error.Code {\n\t\t\tresult.Err = response.Error\n\t\t}\n\t\tresultChan <- result\n\t\tclose(resultChan)\n\t}()\n\n\treturn resultChan\n}", "func disableDial() func(*Client) error {\n\treturn func(c *Client) error {\n\t\tc.shouldConnect = false\n\t\treturn nil\n\t}\n}", "func (a *AbstractNetworkConnectionHandler) OnDisconnect() {\n}", "func (pm *PeerManager) StopListening(port int) error {\n\n\tpm.mtx.Lock()\n\tdefer pm.mtx.Unlock()\n\n\t// This will interrupt the .Accept() call in the other goroutine, and handle cleanup for us.\n\tlt, ok := pm.listeningPorts[port]\n\tif !ok {\n\t\treturn fmt.Errorf(\"not listening\")\n\t}\n\n\tlt.listener.Close()\n\treturn nil\n\n}", "func (g *Gateway) Disconnect(addr modules.NetAddress) error {\n\tid := g.mu.RLock()\n\tp, exists := g.peers[addr]\n\tg.mu.RUnlock(id)\n\tif !exists {\n\t\treturn errors.New(\"not connected to that node\")\n\t}\n\tp.sess.Close()\n\tid = g.mu.Lock()\n\tdelete(g.peers, addr)\n\tg.mu.Unlock(id)\n\n\tg.log.Println(\"INFO: disconnected from peer\", addr)\n\treturn nil\n}", "func (mon *SocketMonitor) Disconnect() error {\n\tatomic.StoreInt32(mon.listeners, 0)\n\terr := mon.c.Close()\n\n\tif mon.stream != nil {\n\t\tfor range mon.stream {\n\t\t}\n\t}\n\n\treturn err\n}", "func (i *IRC) Disconnect(msg string) {\n\tif msg != \"\" {\n\t\t_, _ = i.writeLine(\"QUIT\", msg)\n\t} else {\n\t\t_, _ = i.writeLine(\"QUIT\", \"Disconnecting\")\n\t}\n\n\ti.StopRequested.Set(true)\n\n\tgo func() {\n\t\ttime.Sleep(time.Millisecond * 500)\n\n\t\tif i.Connected.Get() {\n\t\t\ti.log.Warn(\"disconnect did not happen as expected. forcing a socket close\")\n\t\t\ti.socket.Close()\n\t\t}\n\t}()\n}", "func (p *Peer) Disconnect() {\n\tif atomic.AddInt32(&p.disconnect, 1) != 1 {\n\t\treturn\n\t}\n\n\tlog.Tracef(\"Disconnecting %s\", p)\n\tif atomic.LoadInt32(&p.connected) != 0 {\n\t\tp.conn.Close()\n\t}\n\tclose(p.quit)\n}", "func (b *ClientAdaptor) Disconnect() (err error) {\n\terr = b.device.Disconnect()\n\ttime.Sleep(500 * time.Millisecond)\n\treturn\n}", "func (s *Switch) Disconnect(peer p2pcrypto.PublicKey) {\n\ts.inpeersMutex.Lock()\n\tif _, ok := s.inpeers[peer]; ok {\n\t\tdelete(s.inpeers, peer)\n\t\ts.inpeersMutex.Unlock()\n\t\ts.publishDelPeer(peer)\n\t\tmetrics.InboundPeers.Add(-1)\n\t\treturn\n\t}\n\ts.inpeersMutex.Unlock()\n\n\ts.outpeersMutex.Lock()\n\tif _, ok := s.outpeers[peer]; ok {\n\t\tdelete(s.outpeers, peer)\n\t} else {\n\t\ts.outpeersMutex.Unlock()\n\t\treturn\n\t}\n\ts.outpeersMutex.Unlock()\n\ts.publishDelPeer(peer)\n\tmetrics.OutboundPeers.Add(-1)\n\n\t// todo: don't remove if we know this is a valid peer for later\n\t// s.discovery.Remove(peer) // address doesn't matter because we only check dhtid\n\n\tselect {\n\tcase s.morePeersReq <- struct{}{}:\n\tcase <-s.shutdownCtx.Done():\n\t}\n}", "func NetDisconnect(ipAddress string) bool {\n\tresult := true\n\n\tc := exec.Command(\"net\", \"use\", `\\\\`+ipAddress, \"/delete\", \"2>&1>null\")\n\tc.Stdout = os.Stdout\n\terr := c.Run()\n\n\tif err != nil {\n\t\tresult = false\n\t}\n\t// else {\n\t// \tresult = strings.Contains(string(out), \"successfully\")\n\t// }\n\treturn result\n}", "func (pe NoopFirewallClient) ExposePort(port int32) error {\n\treturn nil\n}", "func (c *Client) UsePort(port int) error {\n\t_, err := c.ExecCmd(NewCmd(\"use\").WithArgs(NewArg(\"port\", port)))\n\treturn err\n}", "func (*listener) OnDisconnect() {}", "func (bb *BasicBot) Disconnect() {\n\tbb.conn.Close()\n\tupTime := time.Now().Sub(bb.startTime).Seconds()\n\trgb.YPrintf(\"[%s] Closed connection from %s! | Live for: %fs\\n\", timeStamp(), bb.Server, upTime)\n}", "func (l *Libvirt) NetworkPortDelete(Port NetworkPort, Flags uint32) (err error) {\n\tvar buf []byte\n\n\targs := NetworkPortDeleteArgs {\n\t\tPort: Port,\n\t\tFlags: Flags,\n\t}\n\n\tbuf, err = encode(&args)\n\tif err != nil {\n\t\treturn\n\t}\n\n\n\t_, err = l.requestStream(410, constants.Program, buf, nil, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func (n *Node) disconnect() *NodeErr {\n\t// Send an error to Node.Error channel if the node is not connected\n\tif !n.IsConnected() {\n\t\treturn ConnErr(\"node not connected\", nil)\n\t}\n\n\t// Warn to other network peers about the disconnection\n\tmsg := new(message.Message).SetType(message.DisconnectType).SetFrom(n.Self)\n\tif err := n.broadcast(msg); err != nil {\n\t\treturn err\n\t}\n\n\t// Clean current member list\n\tn.Members = peer.NewMembers()\n\tn.setConnected(false)\n\treturn nil\n}", "func Disconnect(err error) error {\n\treturn &DisconnectError{\n\t\terr: err,\n\t}\n}", "func (srv *CentralSessionController) Disable(\n\tctx context.Context,\n\treq *fegprotos.DisableMessage,\n) (*orcprotos.Void, error) {\n\tif req == nil {\n\t\treturn nil, fmt.Errorf(\"Nil Disable Request\")\n\t}\n\tif !srv.cfg.DisableGx {\n\t\tsrv.policyClient.DisableConnections(time.Duration(req.DisablePeriodSecs) * time.Second)\n\t}\n\tif !srv.cfg.DisableGy {\n\t\tsrv.creditClient.DisableConnections(time.Duration(req.DisablePeriodSecs) * time.Second)\n\t}\n\treturn &orcprotos.Void{}, nil\n}", "func probePort(port int, timeout time.Duration) error {\n\taddress := fmt.Sprintf(\"127.0.0.1:%d\", port)\n\tnow := time.Now()\n\tfor {\n\t\tif conn, err := net.Dial(\"tcp\", address); err == nil {\n\t\t\tif err = conn.Close(); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tif time.Since(now) > timeout {\n\t\t\treturn errors.New(\"start failed: timeout expired\")\n\t\t}\n\t\ttime.Sleep(1 * time.Second)\n\t}\n\treturn nil\n}", "func (h *Host) SetPort(p uint16) {\n}", "func (this *Monitor) Disconnect() error {\n\t// Advance to disconnecting state only if connected\n\tok, state := this.stateTransition(StateConnected, StateDisconnecting)\n\tif !ok {\n\t\tthis.Logf(LogLevelDebug, \"Cannot disconnect because monitor is %s\", state.String())\n\t\treturn errors.New(\"Cannot disconnect because monitor is \" + state.String())\n\t}\n\n\t// TODO: Implmement a graceful disconnect from the server\n\t// TODO: send termination package, requires an ACK to work properly\n\t// TODO: but only with max retries just like for connect\n\n\t// Interupt loops\n\tthis.disconnectWaitGroup.Add(3) // TODO: how many routines do we actually have?\n\tthis.connected = false // this prevents any more messages to be sent\n\tclose(this.disconnect)\n\tthis.disconnectWaitGroup.Wait()\n\tclose(this.statusMessageChannel)\n\tclose(this.controlMessageChannel)\n\n\t// Close the connection and signal connection state\n\tthis.connection.Close()\n\tthis.stateTransition(StateDisconnecting, StateDisconnected)\n\tthis.Log(LogLevelDebug, \"Disconnected\")\n\treturn nil\n}", "func (mn *MockNetwork) Disconnect(string) error {\n\treturn nil\n}", "func CheckPort(port int) (ok bool) {\n\tconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"127.0.0.1:%d\", port), 1*time.Second)\n\tif err == nil {\n\t\tconn.Close()\n\t\tok = true\n\t} else {\n\t\tok = false\n\t}\n\treturn ok\n}", "func (m *Modifier) RemovePort() {\n\tm.remove = true\n\tm.defaultForScheme = false\n}", "func (r *ProtocolIncus) Disconnect() {\n\tif r.ctxConnected.Err() != nil {\n\t\tr.ctxConnectedCancel()\n\t}\n}", "func (ms *MqttSocket) Disconnect() {\n\tms.client.Disconnect(0)\n}", "func (m *Modifier) UsePort(port int) {\n\tm.port = port\n\tm.remove = false\n\tm.defaultForScheme = false\n}", "func (b *Bluez) Disconnect(adapterName, deviceMac string) error {\n\treturn b.CallDevice(adapterName, deviceMac, \"Disconnect\", 0).Store()\n}", "func (w *xcWallet) Disconnect() {\n\t// Disabled wallet is already disconnected.\n\tif w.isDisabled() {\n\t\treturn\n\t}\n\tw.connector.Disconnect()\n\tw.mtx.Lock()\n\tw.hookedUp = false\n\tw.mtx.Unlock()\n}", "func (n *mockAgent) disconnect() error {\n\treturn nil\n}", "func (d *Device) Disconnect() error {\n\td.cm.CancelConnect(d.prph)\n\treturn nil\n}", "func (d *DirectMemifConnector) Disconnect(crossConnect *crossconnect.CrossConnect) {\n\tvalue, exist := d.proxyMap.Load(crossConnect.GetId())\n\tif !exist {\n\t\tlogrus.Warnf(\"Proxy for cross connect with id=%s doesn't exist. Nothing to stop\", crossConnect.GetId())\n\t\treturn\n\t}\n\n\tproxy := value.(memifproxy.Proxy)\n\tproxy.Stop()\n\n\td.proxyMap.Delete(crossConnect.Id)\n}", "func freePort() (uint16, error) {\n\taddr, err := net.ResolveTCPAddr(\"tcp\", \"localhost:0\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tl, err := net.ListenTCP(\"tcp\", addr)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer l.Close()\n\n\treturn uint16(l.Addr().(*net.TCPAddr).Port), nil\n}", "func freePort() (uint16, error) {\n\taddr, err := net.ResolveTCPAddr(\"tcp\", \"localhost:0\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tl, err := net.ListenTCP(\"tcp\", addr)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer l.Close()\n\n\treturn uint16(l.Addr().(*net.TCPAddr).Port), nil\n}", "func (c *TestCluster) Disconnect(from, to string, err error) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tc.errors[c.peerKey(from, to)] = err\n}", "func (a *TCPAcceptor) Stop() {\n\ta.running = false\n\ta.listener.Close()\n}", "func (p *Port) DisableClock() {\n\tdisableClock(p)\n}", "func (ipc *AdaIPC) Disconnect() (err error) {\n\treturn nil\n}", "func (c *client) Disconnect(ifi *Interface) error {\n\t// Ask nl80211 to disconnect.\n\t_, err := c.get(\n\t\tunix.NL80211_CMD_DISCONNECT,\n\t\tnetlink.Acknowledge,\n\t\tifi,\n\t\tnil,\n\t)\n\treturn err\n}", "func (h *Handler) Disconnect(ctx context.Context, in *backend.StatusRequest, out *backend.StatusResponse) error {\n\tuid := in.Meta[\"uid\"]\n\trid, _ := h.manager.GetMemberRoomID(uid)\n\tsvid, err := h.manager.GetRoomServerID(rid)\n\tlog.Debugf(\"Current server id:%s <==> Room server id:%s\", h.manager.GetService().Server().ID(), svid)\n\tif err != nil {\n\t\tlog.Error(\"Failed to get room server id:\", err)\n\t\treturn err\n\t}\n\tif svid != h.manager.GetService().Server().ID() { // forward to another server\n\t\tlog.Debugf(\"Forwad status request to other server\")\n\t\tcli := backend.NewBackendService(\"chat-demo.chat\", h.manager.GetService().Client())\n\t\tcli.Disconnect(ctx, in, client.WithSelectOption(selector.WithIDFilter([]string{svid})))\n\t\treturn nil\n\t}\n\th.manager.Disconnect(rid, uid)\n\treturn nil\n}", "func (cfg *config) disconnectCounter(i int) {\n\t// fmt.Printf(\"connect(%d)\\n\", i)\n\n\tcfg.counterConnected[i] = false\n\n\t// outgoing ClientEnds\n\tfor j := 0; j < cfg.nCounters; j++ {\n\t\tif cfg.counterEndnames[i] != nil {\n\t\t\tendname := cfg.counterEndnames[i][j]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n\n\t// incoming counter ClientEnds\n\tfor j := 0; j < cfg.nCounters; j++ {\n\t\tif cfg.counterEndnames[j] != nil {\n\t\t\tendname := cfg.counterEndnames[j][i]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n\n\t// incoming voter ClientEnds\n\tfor j := 0; j < cfg.nVoters; j++ {\n\t\tif cfg.voterEndnames[j] != nil {\n\t\t\tendname := cfg.voterEndnames[j][i]\n\t\t\tcfg.net.Enable(endname, false)\n\t\t}\n\t}\n}", "func (m *MqttClientBase) Stop() {\n\tm.Client.Disconnect(500)\n}", "func (m *Setup) SetPortProtection(network string, lowPort int) error {\n\tidx := -1\n\tfor i := 0; i < len(m.networkConfList); i++ {\n\t\tif m.networkConfList[i].Name == network {\n\t\t\tidx = i\n\t\t\tbreak\n\t\t}\n\t}\n\tif idx < 0 {\n\t\treturn fmt.Errorf(\"no configuration found for network %s\", network)\n\t}\n\n\tentries, ok := m.runtimeConf[idx].CapabilityArgs[\"portMappings\"].([]PortMapEntry)\n\tif !ok {\n\t\treturn nil\n\t}\n\tfor _, e := range entries {\n\t\tsockProt := unix.IPPROTO_TCP\n\t\tsockType := unix.SOCK_STREAM\n\n\t\tif e.HostPort <= lowPort {\n\t\t\treturn fmt.Errorf(\"not authorized to map port under %d\", lowPort)\n\t\t}\n\t\tif e.Protocol == \"udp\" {\n\t\t\tsockProt = unix.IPPROTO_UDP\n\t\t\tsockType = unix.SOCK_DGRAM\n\t\t}\n\t\tfd, err := unix.Socket(unix.AF_INET, sockType, sockProt)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\terr = unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set reuseport for %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\tsockAddr := &unix.SockaddrInet4{\n\t\t\tPort: e.HostPort,\n\t\t}\n\t\terr = unix.Bind(fd, sockAddr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to bind %s socket on port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t}\n\t\tif sockType == unix.SOCK_STREAM {\n\t\t\terr = unix.Listen(fd, 1)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to listen on %s socket port %d: %s\", e.Protocol, e.HostPort, err)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func connectToDaemon(port int, t *testing.T) {\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(250 * time.Millisecond):\n\t\t\tt.Fatalf(\"Expected server to start < 1s.\")\n\t\tcase <-time.After(50 * time.Millisecond):\n\t\t\t_, err := net.Dial(\"tcp\", fmt.Sprintf(\":%d\", port))\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (s *Stream) Disconnect() {\n\ts.stop <- true\n\ts.base.Disconnect()\n}", "func (d *Device) DisconnectSocket() error {\n\terr := d.Execute(TCPClose)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, e := d.Response(pause)\n\tif e != nil {\n\t\treturn e\n\t}\n\treturn nil\n}", "func (c *Client) Port(p int) *Client {\n\tc.port = p\n\treturn c\n}", "func (u *UnityServer) disconnect() {\n\tu.Logger.Info(\"Disconnecting unity\")\n\tu.conn.Close()\n\tu.connected = false\n}", "func (irc *Client) Disconnect() {\n\ttime.Sleep(time.Millisecond * 200)\n\tif irc.Conn != nil {\n\t\tlog.Println(\"Disconnecting...\")\n\t\t(*irc.Conn).Close()\n\t}\n}", "func (c *INDIClient) Disconnect() error {\n\t// Clear out all devices\n\tc.delProperty(&DelProperty{})\n\n\tif c.conn == nil {\n\t\treturn nil\n\t}\n\n\terr := c.conn.Close()\n\tc.conn = nil\n\n\tif c.read != nil {\n\t\tclose(c.read)\n\t\tc.read = nil\n\t}\n\n\tif c.write != nil {\n\t\tclose(c.write)\n\t\tc.write = nil\n\t}\n\n\treturn err\n}", "func FreePort() (int, error) {\n\t// Opens a TCP connection to a free port on the host\n\t// and closes the connection but getting the port from it\n\t// so the can be setted to a free\n\t// random port each time if no one is specified\n\tl, err := net.Listen(\"tcp\", \"\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tl.Close()\n\tsl := strings.Split(l.Addr().String(), \":\")\n\tp, err := strconv.Atoi(sl[len(sl)-1])\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn p, nil\n}", "func onDisconnect(c *gnet.Connection,\n\treason gnet.DisconnectReason) {\n\tfmt.Printf(\"Event Callback: disconnect event \\n\")\n}", "func (p *TCPPeer) disconnect() {\n\tp.conn.Close()\n\tclose(p.send)\n\tclose(p.receive)\n}", "func disconnect(conn net.Conn, name string) {\n\tfor index, curCon := range clients {\n\t\tif curCon.RemoteAddr() == conn.RemoteAddr() {\n\t\t\tdisMsg := fmt.Sprintf(\"【%s】has left the room\", name)\n\t\t\tfmt.Println(disMsg)\n\t\t\tclients = append(clients[:index], clients[index+1:]...)\n\t\t\tnotify(conn, disMsg)\n\t\t}\n\t}\n}", "func (nc *NetClient) Disconnect() error {\n\terr := nc.ReadWriteCloser.Close()\n\tif nc.disconnectHandler != nil {\n\t\tgo nc.disconnectHandler(nc)\n\t}\n\tgo func() {\n\t\tnc.stopSending <- struct{}{}\n\t\tnc.stopReceiving <- struct{}{}\n\t}()\n\n\treturn err\n}", "func Disconnect() {\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\trawclient.Disconnect(ctx)\n}", "func Disconnect(g *gocui.Gui, v *gocui.View) error {\n\tconnection.Close()\n\treturn gocui.ErrQuit\n}", "func (m *Mux) Disconnect() error {\n\t// TODO(seanc@): Test to see make sure the descriptor has the mutate bit set.\n\n\tif err := vpc.Ctl(m.h, vpc.Cmd(_MuxUnderlayDisconnectCmd), nil, nil); err != nil {\n\t\treturn errors.Wrap(err, \"unable to disconnect VPC Mux to to VPC Interface\")\n\t}\n\n\treturn nil\n}", "func (cmd *commandDisconn) run() error {\n\treturn cmd.cli.Disconnect()\n}", "func (vl *VlanBridge) SwitchDisconnected(sw *ofctrl.OFSwitch) {\n\t// FIXME: ??\n}", "func SetPort(p int) Option {\n\treturn func(w *Worker) error {\n\t\tw.port = p\n\t\treturn nil\n\t}\n}", "func (c *MQTTClient) Disconnect(pending uint) {\n\tc.client.Disconnect(pending)\n}", "func (chrome *Chrome) Port() int {\n\tif !chrome.Flags().Has(\"port\") {\n\t\tchrome.Flags().Set(\"port\", 9222)\n\t}\n\tvalue, _ := chrome.Flags().Get(\"port\")\n\treturn value.(int)\n}", "func (protocol *CSSProtocol) Disable() <-chan *css.DisableResult {\n\tresultChan := make(chan *css.DisableResult)\n\tcommand := NewCommand(protocol.Socket, \"CSS.disable\", nil)\n\tresult := &css.DisableResult{}\n\n\tgo func() {\n\t\tresponse := <-protocol.Socket.SendCommand(command)\n\t\tif nil != response.Error && 0 != response.Error.Code {\n\t\t\tresult.Err = response.Error\n\t\t}\n\t\tresultChan <- result\n\t\tclose(resultChan)\n\t}()\n\n\treturn resultChan\n}", "func (na *NetAdapter) Stop() error {\n\tif atomic.AddUint32(&na.stop, 1) != 1 {\n\t\treturn errors.New(\"net adapter stopped more than once\")\n\t}\n\treturn na.server.Stop()\n}", "func disconnect(conn *websocket.Conn) {\n\tconn.Close()\n\tdelete(clients, conn)\n}", "func ovsDelPort(bridge, tap string) error {\n\targs := []string{\n\t\t\"del-port\",\n\t\tbridge,\n\t\ttap,\n\t}\n\n\t_, sErr, err := ovsCmdWrapper(args)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"remove port failed: %v: %v\", err, sErr)\n\t}\n\n\treturn nil\n}", "func (self *OFSwitch) switchDisconnected() {\n\tself.changeStatus(false)\n\tself.cancel()\n\tself.heartbeatCh <- struct{}{}\n\tswitchDb.Remove(self.DPID().String())\n\tself.app.SwitchDisconnected(self)\n\tif self.connCh != nil {\n\t\tself.connCh <- ReConnection\n\t}\n}", "func (qs SysDBQuerySet) PortNe(port int) SysDBQuerySet {\n\treturn qs.w(qs.db.Where(\"port != ?\", port))\n}", "func freeport() (port int, addr string) {\n\tl, err := net.ListenTCP(\"tcp\", &net.TCPAddr{IP: net.ParseIP(\"127.0.0.1\")})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer l.Close()\n\ta := l.Addr().(*net.TCPAddr)\n\tport = a.Port\n\treturn port, a.String()\n}", "func (c *Client) Disconnect() error {\n\tc.connected = false\n\tif err := c.Conn.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Port() int {\n\treturn cfg.DefaultPort\n}", "func (s *Service) Disconnect(ctx context.Context) error {\n\treturn s.Call(ctx, \"Disconnect\").Err\n}", "func Delete(port string, ip string) error {\n\n\targs := []string{\"-D\", \"INPUT\", \"-p\", \"tcp\", \"-s\", ip, \"--dport\", port, \"-m\", \"state\", \"--state\", \"NEW,ESTABLISHED\", \"-j\", \"ACCEPT\"}\n\n\tcmd := exec.Command(\"iptables\", args...)\n\n\terr := cmd.Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\targs[1] = \"OUTPUT\"\n\targs[11] = \"ESTABLISHED\"\n\n\tcmd = exec.Command(\"iptables\", args...)\n\n\terr = cmd.Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func freeport(t *testing.T) (port int, addr string) {\n\tl, err := net.ListenTCP(\"tcp\", &net.TCPAddr{IP: net.ParseIP(\"127.0.0.1\")})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer l.Close()\n\ta := l.Addr().(*net.TCPAddr)\n\tport = a.Port\n\treturn port, a.String()\n}", "func (s *Service) NetworkDisconnect(ctx context.Context, c *container.Container, net *yaml.Network, oneOff bool) error {\n\tcontainerID := c.ID()\n\tclient := s.clientFactory.Create(s)\n\treturn client.NetworkDisconnect(ctx, net.RealName, containerID, true)\n}", "func FreePort() (int, error) {\n\n\taddr, err := net.ResolveTCPAddr(\"tcp\", \"localhost:0\")\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tlisten, err := net.ListenTCP(\"tcp\", addr)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tdefer listen.Close()\n\treturn listen.Addr().(*net.TCPAddr).Port, nil\n}" ]
[ "0.6607121", "0.6092157", "0.60442424", "0.5949453", "0.5942605", "0.59195167", "0.5909002", "0.58473146", "0.5748115", "0.56331027", "0.558823", "0.55736804", "0.55128163", "0.5509054", "0.55060875", "0.5464148", "0.5428966", "0.5420689", "0.53987837", "0.5368974", "0.53296804", "0.5327946", "0.53275734", "0.5317223", "0.5292353", "0.52811176", "0.52668655", "0.5258839", "0.52511483", "0.5249511", "0.52388066", "0.52327436", "0.52212834", "0.5219602", "0.52078456", "0.5207658", "0.5168556", "0.51486814", "0.51297766", "0.51276505", "0.5123943", "0.5122894", "0.51174676", "0.5116391", "0.51141167", "0.5110378", "0.5109551", "0.51081264", "0.51077455", "0.51003766", "0.5096666", "0.5081614", "0.50810146", "0.508048", "0.50791806", "0.5073392", "0.5073392", "0.5073037", "0.5071373", "0.50699496", "0.5069344", "0.5063974", "0.50576806", "0.5042166", "0.50409365", "0.5040746", "0.5033824", "0.50297296", "0.50115675", "0.5011319", "0.5001199", "0.5000297", "0.49931377", "0.49894205", "0.49852332", "0.49852216", "0.49850458", "0.49844196", "0.49827668", "0.49827608", "0.4979561", "0.4975993", "0.4973084", "0.49689525", "0.49686602", "0.496553", "0.49639493", "0.4956247", "0.49537212", "0.49477357", "0.49423456", "0.49394178", "0.4938581", "0.49336252", "0.49275994", "0.4925496", "0.4924911", "0.49210614", "0.49158484", "0.49156728" ]
0.58789164
7
HandleGetIP is a gin HTTP handler that gather's the source IP from an incoming HTTP request and returns it in the response body.
func HandleGetIP(ctx *gin.Context) { ip, port, err := net.SplitHostPort(ctx.Request.RemoteAddr) if err != nil { glog.Error(err.Error()) ctx.JSON(500, gin.H{"result": "internal server error"}) return } glog.Info("Incoming request /getip:" + ip + ":" + port) // Only return the IP, even though we have their source ephemeral port. ctx.JSON(200, gin.H{"ip": ip}) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetIP(r *http.Request) (string, string) {\n\tfwd := r.Header.Get(\"X-Forwarded-For\")\n\taddrStr := \"\"\n\n\tif fwd != \"\" {\n\t\taddrStr = fwd\n\t} else {\n\t\taddrStr = r.RemoteAddr\n\t}\n\taddr := strings.Split(addrStr, \":\")\n\n\treturn addr[0], addr[1]\n}", "func HandleIPRequest(router *mux.Router, rootPath string) {\n\trouter.\n\t\tMethods(http.MethodGet).\n\t\tPath(rootPath).\n\t\tHeadersRegexp(\"Accept\", \".*((application/((xhtml+)?xml|json|javascript))|(text/x?html)).*\").\n\t\tHandlerFunc(provideIP).\n\t\tName(\"ip\")\n}", "func GetIP(r *http.Request) string {\n\taddr := r.Header.Get(\"X-Forwarded-For\")\n\tif addr != \"\" {\n\t\treturn addr\n\t}\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request, options ...*KeyOptions) net.IP {\n\tif len(options) >= 1 && options[0].TrustForwardHeader {\n\t\tip := r.Header.Get(\"X-Forwarded-For\")\n\t\tif ip != \"\" {\n\t\t\tparts := strings.SplitN(ip, \",\", 2)\n\t\t\tpart := strings.TrimSpace(parts[0])\n\t\t\treturn net.ParseIP(part)\n\t\t}\n\n\t\tip = strings.TrimSpace(r.Header.Get(\"X-Real-IP\"))\n\t\tif ip != \"\" {\n\t\t\treturn net.ParseIP(ip)\n\t\t}\n\t}\n\n\tremoteAddr := strings.TrimSpace(r.RemoteAddr)\n\thost, _, err := net.SplitHostPort(remoteAddr)\n\tif err != nil {\n\t\treturn net.ParseIP(remoteAddr)\n\t}\n\n\treturn net.ParseIP(host)\n}", "func GetIP(r *http.Request) string {\n\tforwarded := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif forwarded != \"\" {\n\t\treturn forwarded\n\t}\n\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request) string {\n\tfwd := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif fwd != \"\" {\n\t\treturn fwd\n\t}\n\treturn r.RemoteAddr\n}", "func GetIP(r *http.Request) string {\n\tforwarded := r.Header.Get(\"X-FORWARDED-FOR\")\n\tif forwarded != \"\" {\n\t\treturn forwarded\n\t}\n\treturn r.RemoteAddr\n}", "func (fn GetIPHandlerFunc) Handle(params GetIPParams) middleware.Responder {\n\treturn fn(params)\n}", "func GetIP(site, UserAgent string) string {\n\treturn getAPIResponse(site, UserAgent).ResponseIP\n}", "func GetIPAddress(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tplainAddress := vars[\"domainName\"]\n\tif reply, ok := servers[plainAddress]; ok {\n\t\tw.WriteHeader(http.StatusOK)\n\t\tif enc, err := json.Marshal(reply); err == nil {\n\t\t\tw.Write([]byte(enc))\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t} else {\n\t\treply := r.RemoteAddr\n\t\tif enc, err := json.Marshal(reply); err == nil {\n\t\t\tw.Write([]byte(enc))\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t}\n\t}\n}", "func (registry *Registry) GetIP(_, reply *string) error {\n\t*reply = registryService.GetIP()\n\treturn nil\n}", "func GetIp() string {\n\n\tout, err := exc.ExecuteWithBash(\"ip route get 1.1.1.1 | grep -oP 'src \\\\K\\\\S+'\")\n\n\tip := strings.TrimSpace(out)\n\tif log.Check(log.WarnLevel, \"Getting RH IP \"+ip, err) {\n\t\treturn \"\"\n\t}\n\n\treturn ip\n}", "func GetIP() (ip string, err error) {\n\tvar res *http.Response\n\tif res, err = http.Get(API); err != nil {\n\t\treturn\n\t}\n\n\t// We could just get the string but for the sake of\n\t// consistency we go json.\n\tresIP := new(IPResponse)\n\tif err = json.NewDecoder(res.Body).Decode(resIP); err != nil {\n\t\treturn\n\t}\n\n\tip = resIP.IP\n\treturn\n}", "func getIP(w http.ResponseWriter, req *http.Request) string {\n\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\tif err != nil {\n\t\tlog.Debugf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t}\n\n\tuserIP := net.ParseIP(ip)\n\tif userIP == nil {\n\t\treturn req.RemoteAddr\n\t}\n\n\t// This will only be defined when site is accessed via non-anonymous proxy\n\t// and takes precedence over RemoteAddr Header.Get is case-insensitive\n\tforward := req.Header.Get(\"X-Forwarded-For\")\n\treturn forward\n}", "func (i *Client) GetIP() (string, error) {\n\thttpClient := i.HTTPClient\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tres, err := httpClient.Get(baseURL)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer res.Body.Close()\n\n\tip, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(ip), nil\n}", "func GetIPIntel(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.WriteHeader(http.StatusOK)\n\tb, err := json.Marshal(GetIP(vars[\"ip\"]))\n\tif err != nil {\n\t\tw.Write([]byte(\"error\"))\n\t\treturn\n\t}\n\tw.Write(b)\n}", "func (i *IPGetter) Get(ctx context.Context) (string, error) {\n\tr, err := http.Get(canihaz)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Couldn't retrieve external IP address: %w\", err)\n\t}\n\n\tip, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not read IP address from response: %w\", err)\n\t}\n\n\treturn strings.TrimSpace(fmt.Sprintf(\"%s\", ip)), nil\n}", "func getIP(url string) string {\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\tdefer res.Body.Close()\n\tb, _ := io.ReadAll(res.Body)\n\treturn string(b)\n}", "func getIP(r *http.Request) string {\n\tvar addr string\n\n\tif fwd := r.Header.Get(xForwardedFor); fwd != \"\" {\n\t\t// Only grab the first (client) address. Note that '192.168.0.1,\n\t\t// 10.1.1.1' is a valid key for X-Forwarded-For where addresses after\n\t\t// the first may represent forwarding proxies earlier in the chain.\n\t\ts := strings.Index(fwd, \", \")\n\t\tif s == -1 {\n\t\t\ts = len(fwd)\n\t\t}\n\t\taddr = fwd[:s]\n\t} else if fwd := r.Header.Get(xRealIP); fwd != \"\" {\n\t\t// X-Real-IP should only contain one IP address (the client making the\n\t\t// request).\n\t\taddr = fwd\n\t} else if fwd := r.Header.Get(forwarded); fwd != \"\" {\n\t\t// match should contain at least two elements if the protocol was\n\t\t// specified in the Forwarded header. The first element will always be\n\t\t// the 'for=' capture, which we ignore. In the case of multiple IP\n\t\t// addresses (for=8.8.8.8, 8.8.4.4,172.16.1.20 is valid) we only\n\t\t// extract the first, which should be the client IP.\n\t\tif match := forRegex.FindStringSubmatch(fwd); len(match) > 1 {\n\t\t\t// IPv6 addresses in Forwarded headers are quoted-strings. We strip\n\t\t\t// these quotes.\n\t\t\taddr = strings.Trim(match[1], `\"`)\n\t\t}\n\t}\n\n\tif addr == \"\" {\n\t\treturn r.RemoteAddr\n\t}\n\treturn addr\n}", "func getIP(r *http.Request, trustForwardHeader bool) net.IP {\n\tif trustForwardHeader {\n\t\tip := r.Header.Get(\"X-Forwarded-For\")\n\t\tif ip != \"\" {\n\t\t\tparts := strings.SplitN(ip, \",\", 2)\n\t\t\tpart := strings.TrimSpace(parts[0])\n\t\t\treturn net.ParseIP(part)\n\t\t}\n\t\tip = strings.TrimSpace(r.Header.Get(\"X-Real-IP\"))\n\t\tif ip != \"\" {\n\t\t\treturn net.ParseIP(ip)\n\t\t}\n\t}\n\n\tremoteAddr := strings.TrimSpace(r.RemoteAddr)\n\thost, _, err := net.SplitHostPort(remoteAddr)\n\tif err != nil {\n\t\treturn net.ParseIP(remoteAddr)\n\t}\n\n\treturn net.ParseIP(host)\n}", "func getIP(r *http.Request) string {\n\tif ip := r.Header.Get(\"CF-Connecting-IP\"); ip != \"\" {\n\t\treturn ip\n\t}\n\tif ip := r.Header.Get(\"X-Forwarded-For\"); ip != \"\" {\n\t\t// Trim off any others: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]\n\t\treturn strings.SplitN(ip, \",\", 1)[0]\n\t}\n\tif ip, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {\n\t\treturn ip\n\t}\n\treturn r.RemoteAddr\n}", "func getIP(r *http.Request) string {\n\tif ip := r.Header.Get(\"CF-Connecting-IP\"); ip != \"\" {\n\t\treturn ip\n\t}\n\tif ip := r.Header.Get(\"X-Forwarded-For\"); ip != \"\" {\n\t\t// Trim off any others: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]\n\t\treturn strings.SplitN(ip, \",\", 1)[0]\n\t}\n\tif ip, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {\n\t\treturn ip\n\t}\n\treturn r.RemoteAddr\n}", "func Ip(rw http.ResponseWriter, req *http.Request) {\n\n\t// Write to the web page.\n\tfmt.Fprintln(rw, \"Hello \"+req.Header.Get(\"X-Forwarded-For\"))\n\n\t// Write to the log.\n\tfmt.Println(\"Served client: \"+req.Header.Get(\"X-Forwarded-For\"))\n\n}", "func NewGetIP(ctx *middleware.Context, handler GetIPHandler) *GetIP {\n\treturn &GetIP{Context: ctx, Handler: handler}\n}", "func IP(w http.ResponseWriter, r *http.Request) {\n\tremoteAddr := r.Header.Get(\"X-Forwarded-For\")\n\n\tif remoteAddr == \"\" {\n\t\thost, _, err := net.SplitHostPort(r.RemoteAddr)\n\t\tif err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n\t\tremoteAddr = host\n\t}\n\n\tfmt.Fprintln(w, remoteAddr)\n}", "func GetClientIP(r *http.Request, headers ...string) string {\n\tfor _, header := range headers {\n\t\tip := r.Header.Get(header)\n\t\tif ip != \"\" {\n\t\t\treturn strings.Split(ip, \",\")[0]\n\t\t}\n\t}\n\treturn strings.Split(r.RemoteAddr, \":\")[0]\n}", "func GetClientIp(r *http.Request) string {\n\tclientIp := r.Header.Get(XRealIp)\n\tif clientIp == \"\" {\n\t\tclientIp = \"UNKNOWN_IP\"\n\t}\n\treturn clientIp\n}", "func GetOutboundIP() string {\n\n\tresp, err := http.Get(\"http://myexternalip.com/raw\")\n\tif err != nil {log.Fatal(err)}\n\n\tdefer resp.Body.Close()\n\n\tbody, readErr := ioutil.ReadAll(resp.Body)\n\n\tif readErr != nil {\n\t\tlog.Fatal(readErr)\n\t}\n\treturn string(body)\n\n}", "func (d *Driver) GetIP() (string, error) {\n\td.connectAPI()\n\treturn d.driver.GetEth0IPv4(d.Node, d.VMID)\n}", "func GetIPAddress(r *http.Request) string {\n\tip := \"\"\n\tfor _, h := range []string{\"X-Forwarded-For\", \"X-Real-Ip\"} {\n\t\taddresses := strings.Split(r.Header.Get(h), \",\")\n\t\t// march from right to left until we get a public address\n\t\t// that will be the address right before our proxy.\n\t\tfor i := len(addresses) - 1; i >= 0; i-- {\n\t\t\tip = strings.TrimSpace(addresses[i])\n\t\t\t// header can contain spaces too, strip those out.\n\t\t\trealIP := net.ParseIP(ip)\n\t\t\tif !realIP.IsGlobalUnicast() || IsPrivateSubnet(realIP) {\n\t\t\t\t// bad address, go to next\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ip\n\t\t}\n\t}\n\n\tip, _, _ = net.SplitHostPort(r.RemoteAddr)\n\treturn ip\n}", "func IP(c *fiber.Ctx) string {\n\tvar headerValue []byte\n\tif c.App().Config().ProxyHeader == \"*\" {\n\t\tfor _, headerName := range possibleHeaderes {\n\t\t\theaderValue = c.Request().Header.Peek(headerName)\n\t\t\tif len(headerValue) > 3 {\n\t\t\t\treturn string(fetchIpFromString.Find(headerValue))\n\t\t\t}\n\t\t}\n\t}\n\theaderValue = []byte(c.IP())\n\tif len(headerValue) <= 3 {\n\t\theaderValue = []byte(\"0.0.0.0\")\n\t}\n\n\t// find ip address in string\n\treturn string(fetchIpFromString.Find(headerValue))\n}", "func GetClientIPHelper(req *http.Request) (ipResult string, errResult error) {\n\n\t// Try lots of ways :) Order is important.\n\t// Try Request Headers (X-Forwarder). Client could be behind a Proxy\n\tip, err := getClientIPByHeaders(req)\n\tif err == nil {\n\t\t// log.Printf(\"debug: Found IP using Request Headers sniffing. ip: %v\", ip)\n\t\treturn ip, nil\n\t}\n\n\t// Try by Request\n\tip, err = getClientIPByRequestRemoteAddr(req)\n\tif err == nil {\n\t\t// log.Printf(\"debug: Found IP using Request sniffing. ip: %v\", ip)\n\t\treturn ip, nil\n\t}\n\n\t// Try Request Header (\"Origin\")\n\turl, err := url.Parse(req.Header.Get(\"Origin\"))\n\tif err == nil {\n\t\thost := url.Host\n\t\tip, _, err := net.SplitHostPort(host)\n\t\tif err == nil {\n\t\t\t// log.Printf(\"debug: Found IP using Header (Origin) sniffing. ip: %v\", ip)\n\t\t\treturn ip, nil\n\t\t}\n\t}\n\n\terr = errors.New(\"error: Could not find clients IP address\")\n\treturn \"\", err\n}", "func (h *Handler) GetIP(object interface{}) (string, error) {\n\tswitch val := object.(type) {\n\tcase string:\n\t\tpod, err := h.Get(val)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn pod.Status.PodIP, nil\n\tcase *corev1.Pod:\n\t\treturn val.Status.PodIP, nil\n\tcase corev1.Pod:\n\t\treturn val.Status.PodIP, nil\n\tdefault:\n\t\treturn \"\", ErrInvalidToolsType\n\t}\n}", "func (_class PIFClass) GetIP(sessionID SessionRef, self PIFRef) (_retval string, _err error) {\n\t_method := \"PIF.get_IP\"\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 = convertStringToGo(_method + \" -> \", _result.Value)\n\treturn\n}", "func (s *SCIONBoxController) getSourceIP(r *http.Request) (string, error) {\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn ip, nil\n}", "func (server Server) GetIP() string {\n\treturn server.IP\n}", "func (c *Client) GetIP(id string, privateIPOnly bool) (string, error) {\n\tvar (\n\t\tmethod = \"GET\"\n\t\turi = fmt.Sprintf(\"%s/%s\", \"server\", id)\n\t)\n\n\tdata, err := c.newRequest(method, uri, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tvar s sakura.Response\n\tif err := json.Unmarshal(data, &s); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif privateIPOnly && len(s.Server.Interfaces) > 1 {\n\t\treturn s.Server.Interfaces[1].UserIPAddress, nil\n\t}\n\n\treturn s.Server.Interfaces[0].IPAddress, nil\n}", "func GetClientIP(c *gin.Context) string {\n\t// first check the X-Forwarded-For header\n\trequester := c.Request.Header.Get(\"X-Forwarded-For\")\n\t// if empty, check the Real-IP header\n\tif len(requester) == 0 {\n\t\trequester = c.Request.Header.Get(\"X-Real-IP\")\n\t}\n\t// if the requester is still empty, use the hard-coded address from the socket\n\tif len(requester) == 0 {\n\t\trequester = c.Request.RemoteAddr\n\t}\n\n\t// if requester is a comma delimited list, take the first one\n\t// (this happens when proxied via elastic load balancer then again through nginx)\n\tif strings.Contains(requester, \",\") {\n\t\trequester = strings.Split(requester, \",\")[0]\n\t}\n\n\treturn requester\n}", "func GetClientIP(c *gin.Context) string {\n\t// first check the X-Forwarded-For header\n\trequester := c.Request.Header.Get(\"X-Forwarded-For\")\n\t// if empty, check the Real-IP header\n\tif len(requester) == 0 {\n\t\trequester = c.Request.Header.Get(\"X-Real-IP\")\n\t}\n\t// if the requester is still empty, use the hard-coded address from the socket\n\tif len(requester) == 0 {\n\t\trequester = c.Request.RemoteAddr\n\t}\n\n\t// if requester is a comma delimited list, take the first one\n\t// (this happens when proxied via elastic load balancer then again through nginx)\n\tif strings.Contains(requester, \",\") {\n\t\trequester = strings.Split(requester, \",\")[0]\n\t}\n\n\treturn requester\n}", "func GetClientIP(r *http.Request) string {\n\t// Header X-Forwarded-For\n\thdrForwardedFor := http.CanonicalHeaderKey(\"X-Forwarded-For\")\n\tif fwdFor := strings.TrimSpace(r.Header.Get(hdrForwardedFor)); fwdFor != \"\" {\n\t\tindex := strings.Index(fwdFor, \",\")\n\t\tif index == -1 {\n\t\t\treturn fwdFor\n\t\t}\n\t\treturn fwdFor[:index]\n\t}\n\n\t// Header X-Real-Ip\n\thdrRealIP := http.CanonicalHeaderKey(\"X-Real-Ip\")\n\tif realIP := strings.TrimSpace(r.Header.Get(hdrRealIP)); realIP != \"\" {\n\t\treturn realIP\n\t}\n\n\treturn \"10.82.33.161\"\n}", "func serveIP(w http.ResponseWriter, r *http.Request) {\n\tio.WriteString(w, strings.Split(r.RemoteAddr, \":\")[0])\n}", "func (client *IntegrationRuntimeNodesClient) getIPAddressHandleResponse(resp *http.Response) (IntegrationRuntimeNodesClientGetIPAddressResponse, error) {\n\tresult := IntegrationRuntimeNodesClientGetIPAddressResponse{}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.IntegrationRuntimeNodeIPAddress); err != nil {\n\t\treturn IntegrationRuntimeNodesClientGetIPAddressResponse{}, err\n\t}\n\treturn result, nil\n}", "func (test *Test) GetIP(projectName string, ip string) (models.IP, error) {\n\treturn tests.NormalIPs[0], nil\n}", "func nslookupHandler(c *gin.Context) {\n\tvar data TargetPayload\n\tif err := c.Bind(&data); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\n\tips, err := net.LookupIP(data.Target)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\"ips\": ips})\n}", "func extractIP(c *gin.Context) string {\n\tip := c.Request.Header.Get(\"X-Real-IP\")\n\tif ip == \"\" {\n\t\tip = c.Request.Header.Get(\"X-Forwarded-For\")\n\t}\n\tif ip == \"\" {\n\t\tremoteAddr := c.Request.RemoteAddr\n\t\tif remoteAddr != \"\" {\n\t\t\taddrPort := strings.Split(remoteAddr, \":\")\n\t\t\tip = addrPort[0]\n\t\t}\n\t}\n\n\t//Case when Nginx concatenate remote_addr to client addr\n\tif strings.Contains(ip, \",\") {\n\t\taddresses := strings.Split(ip, \",\")\n\t\treturn strings.TrimSpace(addresses[0])\n\t}\n\n\treturn ip\n}", "func GetClientIP(r *http.Request) string {\n remoteIP := \"\"\n if parts := strings.Split(r.RemoteAddr, \":\"); len(parts) == 2 {\n remoteIP = parts[0]\n }\n if xff := strings.Trim(r.Header.Get(\"X-Forwarded-For\"), \",\"); len(xff) > 0 {\n addrs := strings.Split(xff, \",\")\n lastFwd := addrs[len(addrs)-1]\n if ip := net.ParseIP(lastFwd); ip != nil {\n remoteIP = ip.String()\n }\n } else if xri := r.Header.Get(\"X-Real-Ip\"); len(xri) > 0 {\n if ip := net.ParseIP(xri); ip != nil {\n remoteIP = ip.String()\n }\n }\n return remoteIP\n}", "func (c *Context) GetClientIP() (ip string) {\n\tvar pIPs string\n\tvar pIPList []string\n\n\tif pIPs = c.Request.Header.Get(\"X-Real-Ip\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Real-Ip\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"X-Forwarded-For\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"X-Forwarded\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Forwarded-For\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else if pIPs = c.Request.Header.Get(\"Forwarded\"); pIPs != \"\" {\n\t\tpIPList = strings.Split(pIPs, \",\")\n\t\tip = strings.TrimSpace(pIPList[0])\n\n\t} else {\n\t\tip = c.Request.RemoteAddr\n\t}\n\n\treturn strings.Split(ip, \":\")[0]\n}", "func getIP() (net.IP, error) {\n\tres, err := http.Get(\"http://checkip.amazonaws.com/\")\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdefer res.Body.Close()\n\tresData, err := ioutil.ReadAll(res.Body)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trawIP := strings.Trim(string(resData), \"\\n\")\n\n\treturn net.ParseIP(rawIP), nil\n}", "func (j * JoinHelper) GetIP () error{\n\t// get IP\n\tcmds := []string{\"echo \\\"net.ipv4.ip_forward=1\\\" >> /etc/sysctl.conf\",\n\t\t\"sysctl -p\"}//,\n\t\t//fmt.Sprintf(\"dhclient vpn_%s\", nicName)}\n\tfor _, command := range cmds {\n\t\tcmd := exec.Command(\"/bin/sh\", \"-c\", command)\n\t\terr := cmd.Run()\n\t\tif err != nil {\n\t\t\tlog.Warn().Str(\"command\", command).Str(\"error\", err.Error()).Msg(\"error executing\")\n\t\t\treturn err\n\t\t}\n\t}\n\treturn j.ExecuteDhClient()\n}", "func (c *APIClient) GetIP(strID string) (string, error) {\n\tid := types.StringID(strID)\n\tif id.IsEmpty() {\n\t\treturn \"\", fmt.Errorf(\"ServerID is invalid: %s\", strID)\n\t}\n\tserver, err := sacloud.NewServerOp(c.caller).Read(context.Background(), c.Zone, id)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn server.Interfaces[0].IPAddress, nil\n}", "func handleGet(f func(name, addr string) (string, string, error)) http.Handler {\n\treturn http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {\n\t\trw.Header().Set(\"Content-Type\", \"application/json\")\n\n\t\tenc := json.NewEncoder(rw)\n\n\t\tvars := mux.Vars(req)\n\t\tname, addr, err := f(vars[\"name\"], vars[\"addr\"])\n\t\tif err != nil {\n\t\t\trw.WriteHeader(http.StatusNotFound)\n\t\t\tenc.Encode(Error{Error: err.Error()})\n\t\t\treturn\n\t\t}\n\t\tif addr != \"\" {\n\t\t\taddr = fmt.Sprintf(\"0x%v\", addr)\n\t\t}\n\n\t\tenc.Encode(Response{\n\t\t\tName: name,\n\t\t\tAddr: addr,\n\t\t})\n\t})\n}", "func GetIP(vrf uint64, ip *bnet.IP) *IPAddress {\n\treturn pkgIPCache.get(vrf, ip)\n}", "func (th *TailHandler) getIp(info []string) (string, string) {\n\tif info[8] == \"-\" || info[8] == \"\" {\n\t\treturn th.Ip(info[0])\n\t}\n\treturn th.Ip(info[8])\n}", "func (l Lease) GetIP() (ip net.IP) {\n\treturn net.ParseIP(l.IP)\n}", "func findIP(req *http.Request) (string, error) {\n\tif xri := req.Header.Get(\"x-real-ip\"); xri != \"\" {\n\t\treturn xri, nil\n\t}\n\tif xff := req.Header.Get(\"x-forwarded-for\"); xff != \"\" {\n\t\tips := strings.Split(xff, \",\")\n\t\treturn ips[0], nil\n\t}\n\tip, _, err := net.SplitHostPort(req.RemoteAddr)\n\treturn ip, err\n\n}", "func GetRemoteIP(r *http.Request) string {\n\tips := r.Header.Get(\"X-Forwarded-For\")\n\n\tsplitIps := strings.Split(ips, \",\")\n\n\tif ips != \"\" {\n\t\t// trim IP list\n\t\tfor i := range splitIps {\n\t\t\tsplitIps[i] = strings.TrimSpace(splitIps[i])\n\t\t}\n\n\t\t// get last IP in list since ELB prepends other user defined IPs, meaning the last one is the actual client IP.\n\t\tnetIP := net.ParseIP(splitIps[0])\n\t\tif netIP != nil {\n\t\t\treturn netIP.String()\n\t\t}\n\t}\n\n\tip, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil {\n\t\treturn r.RemoteAddr\n\t}\n\n\tnetIP := net.ParseIP(ip)\n\tif netIP != nil {\n\t\tip := netIP.String()\n\t\tif ip == \"::1\" {\n\t\t\treturn \"127.0.0.1\"\n\t\t}\n\t\treturn ip\n\t}\n\n\treturn r.RemoteAddr\n}", "func (ipn *IPN) Handler(w http.ResponseWriter, r *http.Request) {\n\tipn.once.Do(ipn.init)\n\n\tprintln(\"ipn: /gpso_ipn\")\n\tif r.Method != http.MethodPost {\n\t\thttp.Error(w, fmt.Sprintf(\"No route for %v\", r.Method), http.StatusNotFound)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tprintln(\"ipn: \" + err.Error())\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\n\tbody = append([]byte(`cmd=_notify-validate&`), body...)\n\n\tresp, err := http.Post(\n\t\t\"https://www.paypal.com/cgi-bin/webscr\",\n\t\tr.Header.Get(\"Content-Type\"),\n\t\tbytes.NewBuffer(body),\n\t)\n\n\tb, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tprintln(\"ipn: \" + err.Error())\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tverifyStatus := string(b)\n\n\tprintln(\"ipn: \" + verifyStatus)\n\tif verifyStatus != \"VERIFIED\" {\n\t\treturn\n\t}\n\n\tvals, err := url.ParseQuery(string(body))\n\tif err != nil {\n\t\tprintln(\"ipn: \" + err.Error())\n\t\treturn\n\t}\n\n\t// official parsing\n\t// official parsing\n\t// official parsing\n\n\tusers := vals[\"custom\"]\n\tif len(users) == 0 {\n\t\tprintln(\"ipn: empty custom\")\n\t\treturn\n\t}\n\tuser := users[0]\n\n\tgrossStrs := vals[\"mc_gross\"]\n\tif len(grossStrs) == 0 {\n\t\tprintln(\"ipn: empty mc_gross\")\n\t\treturn\n\t}\n\tgrossStr := grossStrs[0]\n\tgross, err := stof(grossStr, 64)\n\tif err != nil {\n\t\tprintln(\"ipn: could not parse gross from '\" + grossStr + \"'\")\n\t\treturn\n\t}\n\n\tcurrencies := vals[\"mc_currency\"]\n\tif len(currencies) == 0 {\n\t\tprintln(\"ipn: empty mc_currency\")\n\t\treturn\n\t}\n\tcurrency := currencies[0]\n\n\tdateStrs := vals[\"payment_date\"]\n\tif len(dateStrs) == 0 {\n\t\tprintln(\"ipn: empty payment_date\")\n\t\treturn\n\t}\n\tdateStr := dateStrs[0]\n\tdate, err := time(dateStr, `15:04:05 Jan 02, 2006 MST`)\n\tif err != nil {\n\t\tprintln(\"ipn: \" + err.Error())\n\t\treturn\n\t}\n\n\tprintln(\"ipn: payment of \" + ftos(gross, 'f', 2, 64) + \" \" + currency + \" received \" + date.String())\n\n\tprice := gross // TODO: conversion goes here\n\n\tgpsos, found := price2gpsos[price]\n\tif !found {\n\t\tprintln(\"ipn: price of \" + ftos(price, 'f', 2, 64) + \" \" + currency + \" not found\")\n\t\treturn\n\t}\n\n\tif err := ipn.Accounts.AddGpsos(user, gpsos); err != nil {\n\t\tprintln(\"ipn: \" + err.Error())\n\t\treturn\n\t}\n\n\tprintln(\"ipn: \" + user + \" bought \" + itoa(gpsos) + \" gpsos\")\n}", "func (v *Client) IP() string {\n\tif v.ip == \"\" {\n\t\tip := strings.TrimSpace(v.req.Header.Get(\"X-Real-Ip\"))\n\t\tif len(ip) > 0 {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t\tip = v.req.Header.Get(\"X-Forwarded-For\")\n\t\tif index := strings.IndexByte(ip, ','); index >= 0 {\n\t\t\tip = ip[0:index]\n\t\t}\n\t\tip = strings.TrimSpace(ip)\n\t\tif len(ip) > 0 {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t\tif ip, _, err := net.SplitHostPort(strings.TrimSpace(v.req.RemoteAddr)); err == nil {\n\t\t\tv.ip = ip\n\t\t\treturn ip\n\t\t}\n\t}\n\treturn v.ip\n}", "func GetOutboundIP() (string, error) {\n\tvar localAddr string\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\treturn localAddr, err\n\t}\n\tdefer conn.Close()\n\n\tlocalAddr = conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\n\treturn localAddr[0:idx], nil\n}", "func (c *Ctx) IP() string {\n\tif len(c.Core.ProxyHeader) > 0 {\n\t\treturn c.Get(c.Core.ProxyHeader)\n\t}\n\treturn c.RemoteIP().String()\n}", "func (sqlDb *SqliteDB) GetIp(ipAddr string) (*model.IP, error) {\n\trow := db.QueryRow(\"SELECT * FROM ip WHERE ip_address = ?\", ipAddr)\n\tip := model.IP{}\n\n\terr := row.Scan(&ip.IPAddress, &ip.UUID, &ip.CreatedAt, &ip.UpdatedAt, &ip.ResponseCode)\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn nil, nil\n\t\t} else {\n\t\t\treturn nil, err\n\t\t}\n\n\t}\n\treturn &ip, nil\n\n}", "func ClientIP(r *http.Request) string {\n\tIPAddress := r.Header.Get(\"X-Real-Ip\")\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.Header.Get(\"X-Forwarded-For\")\n\t}\n\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.RemoteAddr\n\t}\n\n\treturn IPAddress\n}", "func (d *Driver) GetIP() (string, error) {\n\tvm, err := d.getVirtualMachine(true)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn vm.PrimaryIP().String(), nil\n}", "func (s *IPsService) Get(ctx context.Context, uuid string) (*IP, *Response, error) {\n\tif uuid == \"\" {\n\t\treturn nil, nil, ErrEmptyArgument\n\t}\n\n\tpath := fmt.Sprintf(\"%v/%v/\", ipsBasePath, uuid)\n\n\treq, err := s.client.NewRequest(http.MethodGet, path, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tip := new(IP)\n\tresp, err := s.client.Do(ctx, req, ip)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn ip, resp, nil\n}", "func (s Store) GetIP(mac net.HardwareAddr) (ip net.IP, err error) {\n\tl := &Lease{}\n\tl, err = s.leases.Mac(mac)\n\tif err != nil {\n\t\tlogger.Error(\"lease error %s\", err)\n\t\treturn nil, err\n\t}\n\tip = net.ParseIP(l.IP)\n\tlogger.Critical(\"Lease IP : %s\", ip)\n\treturn ip, nil\n}", "func (cce *CCEClient) GetIP(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (string, error) {\n\t// TODO\n\treturn \"\", nil\n}", "func (input *BeegoInput) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip, _, err := net.SplitHostPort(ips[0])\n\t\tif err != nil {\n\t\t\trip = ips[0]\n\t\t}\n\t\treturn rip\n\t}\n\tif ip, _, err := net.SplitHostPort(input.Context.Request.RemoteAddr); err == nil {\n\t\treturn ip\n\t}\n\treturn input.Context.Request.RemoteAddr\n}", "func getMyIP() string {\n\tresp, err := http.Get(\"http://api.ipify.org\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tip, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\treturn string(ip)\n}", "func provideIP(w http.ResponseWriter, req *http.Request) {\n\tresult, error := evaluateIPAddress(req)\n\tif error != nil {\n\t\tresult.Error = error.Error()\n\t}\n\tgo result.fetchGeoAndPersist()\n\n\twriteReponse(w, req, ipTemplate, result)\n}", "func Handle(req []byte) string {\n\n\tvar ip Input\n\n\terr := json.Unmarshal(req, &ip)\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"Error: Failed to parse input : %v \\n %s\", err, help)\n\t}\n\n\tr, rerr := regexp.Compile(ip.Regex)\n\tif rerr != nil {\n\t\treturn fmt.Sprintf(\"Error: Failed to compile regex %s : %v\", ip.Regex, rerr)\n\t}\n\n\tvar op Output\n\top.Match = true\n\top.Matches = r.FindAllString(ip.Data, -1)\n\tif len(op.Matches) == 0 {\n\t\top.Match = false\n\t}\n\n\tmdata, merr := json.Marshal(op)\n\tif merr != nil {\n\t\treturn fmt.Sprintf(\"Error: Failed to marshal output %v : %v\", op, merr)\n\t}\n\treturn string(mdata)\n}", "func ReadUserIP(r *http.Request) string {\n\tIPAddress := r.Header.Get(\"X-Real-Ip\")\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.Header.Get(\"X-Forwarded-For\")\n\t}\n\tif IPAddress == \"\" {\n\t\tIPAddress = r.RemoteAddr\n\t}\n\treturn IPAddress\n}", "func CheckIPRoute(w http.ResponseWriter, r *http.Request) {\n\t//Check if ip query is missing\n\tif r.URL.Query().Get(\"ip\") == \"\" {\n\t\tfmt.Fprintf(w, \"{\\\"error\\\": \\\"You didn't pass an IP\\\"}\")\n\t} else {\n\t\t//Setup struct\n\t\tresponseObject, err := utils.GetLocale(r)\n\t\tif err != nil {\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tfmt.Fprintf(w, \"{\\\"error\\\": \\\"%s\\\"}\", err.Error())\n\t\t} else {\n\n\t\t\t//Marshal responseObject to JsonResponse\n\t\t\tjsonByteArray, _ := json.Marshal(responseObject)\n\t\t\tjsonString := string(jsonByteArray)\n\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\tfmt.Fprintf(w, \"%s\", jsonString)\n\t\t\tfmt.Println(jsonString)\n\t\t}\n\t}\n}", "func getOutboundIP() (string, error) {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer conn.Close()\n\n\tlocalAddr := conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\n\treturn localAddr[0:idx], nil\n}", "func GetOutboundIP() string {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer conn.Close()\n\n\tlocalAddr := conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\treturn localAddr[0:idx]\n}", "func ipAddr(r *http.Request) string {\n\tip := r.Header.Get(\"X-Real-Ip\")\n\tif ip == \"\" {\n\t\tip = strings.Split(r.Header.Get(\"X-Forwarded-For\"), \", \")[0]\n\t}\n\tif ip == \"\" {\n\t\tip = strings.Split(r.RemoteAddr, \":\")[0]\n\t}\n\treturn ip\n}", "func GetClientIP() string {\n\t//hmac.New(hash.)\n\treturn \"hope\"\n}", "func (*InputHandler) Get() http.Handler {\n\t// code if you want\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\n\t\treturn\n\t})\n}", "func GetClientIP(rc *revel.Controller) (ip string) {\n\tclientIP := rc.Request.Header.Get(\"X-Forwarded-For\")\n\n\t// X-Forwarded-For can actually be an array of addresses separated with \",\"\n\t// client IP should be first address\n\tip = strings.Split(clientIP, \",\")[0]\n\tif ip != \"\" && ip != REVEL_ADDED_XIP {\n\t\treturn ip\n\t}\n\n\treturn RemovePortFromIP(rc.Request.RemoteAddr)\n}", "func Get(r *http.Request, header interface{}) (string, error) {\n\tvar value string\n\n\tswitch header.(type) {\n\tcase string:\n\t\tvalue = r.Header.Get(header.(string))\n\t\tif value == \"\" {\n\t\t\tvalue = r.RemoteAddr\n\t\t}\n\tdefault:\n\t\tvalue = r.RemoteAddr\n\t}\n\n\taddresses := strings.Split(value, \",\")\n\taddress := strings.TrimSpace(addresses[len(addresses)-1])\n\n\tidx := strings.LastIndex(address, \":\")\n\tif idx != -1 {\n\t\taddress = address[:idx]\n\t}\n\n\tif address == \"\" {\n\t\terr := errors.New(\"Could not read address\")\n\t\treturn \"\", err\n\t}\n\n\treturn address, nil\n}", "func (ia IfAddr) GetIP() string { return ia.IfaIP }", "func GetHandler(repository repository.Repository) gin.HandlerFunc {\n\treturn func(ctx *gin.Context) {\n\t\tgr := &getRequest{}\n\n\t\tif err := ctx.BindJSON(gr); err != nil {\n\t\t\tctx.JSON(http.StatusBadRequest, err.Error())\n\t\t\treturn\n\n\t\t}\n\n\t\t// TODO: Create an interface for returning a json.\n\t\tgresponse, err := service.Get(gr.TaskName, gr.TaskLabel, gr.TaskStartDate, gr.TaskEndDate, gr.Limit, repository)\n\n\t\tif err != nil {\n\t\t\tctx.JSON(http.StatusInternalServerError, err.Error())\n\t\t\treturn\n\t\t}\n\n\t\tctx.JSON(200, gin.H{\"message\": gresponse})\n\n\t}\n\n}", "func GetOutboundIP() string {\n\tconn, err := net.Dial(\"udp\", \"9.9.9.9:80\")\n\tif err != nil {\n\t\tlog.Printf(\"GetOutboundIP ERR: %s\\n\", err)\n\t\treturn \"\"\n\t}\n\tdefer conn.Close()\n\n\tlocalAddr := conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\n\treturn localAddr[0:idx]\n}", "func GetHTTPAddress() string {\n\treturn viper.GetString(varHTTPAddress)\n}", "func (d *driverMock) GetInstanceIP(ctx context.Context, id string) (string, error) {\n\tif d.GetInstanceIPErr != nil {\n\t\treturn \"\", d.GetInstanceIPErr\n\t}\n\tif d.cfg.UsePrivateIP {\n\t\treturn \"private_ip\", nil\n\t}\n\treturn \"ip\", nil\n}", "func IPFromRequest(r *http.Request) string {\n\theaderIP := r.Header.Get(CsioClientIPHeader)\n\tif headerIP != \"\" {\n\t\treturn IPFromAddr(headerIP)\n\t}\n\treturn IPFromAddr(r.RemoteAddr)\n}", "func GetIP() (ip string) {\n\n\thost, _ := os.Hostname()\n\taddrs, _ := net.LookupIP(host)\n\tfor _, addr := range addrs {\n\t\tif ipv4 := addr.To4(); ipv4 != nil && !ipv4.IsLoopback() {\n\t\t\t//fmt.Println(\"IPv4: \", ipv4.String())\n\t\t\tip = ipv4.String()\n\t\t}\n\t}\n\treturn ip\n}", "func (ia *IPApi) MyIP() (ip string, err error) {\n\tresp, err := ia.Client.Get(MyIPUrl)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", fmt.Errorf(\"status code: %d\", resp.StatusCode)\n\t}\n\n\tinfos := make(map[string]string)\n\terr = json.Unmarshal(body, &infos)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tip, ok := infos[\"ip\"]\n\tif !ok {\n\t\treturn \"\", ErrInvalidRespResult\n\t}\n\treturn ip, nil\n}", "func (st *Store) GetIP(host string) string {\n\tfor ip, hosts := range st.Records {\n\t\tif _, ok := hosts[host]; ok {\n\t\t\treturn ip\n\t\t}\n\t}\n\treturn \"\"\n}", "func (ctx *Context) IP() string {\r\n\tvar ip = strings.Split(ctx.R.RemoteAddr, \":\")\r\n\tif len(ip) > 0 {\r\n\t\tif ip[0] != \"[\" {\r\n\t\t\treturn ip[0]\r\n\t\t}\r\n\t}\r\n\treturn \"127.0.0.1\"\r\n}", "func (input *Input) IP() string {\n\tips := input.Proxy()\n\tif len(ips) > 0 && ips[0] != \"\" {\n\t\trip := strings.Split(ips[0], \":\")\n\t\treturn rip[0]\n\t}\n\tip := strings.Split(input.Context.Request.RemoteAddr, \":\")\n\tif len(ip) > 0 {\n\t\tif ip[0] != \"[\" {\n\t\t\treturn ip[0]\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "func (client *PublicIPAddressesClient) getHandleResponse(resp *http.Response) (PublicIPAddressesClientGetResponse, error) {\n\tresult := PublicIPAddressesClientGetResponse{RawResponse: resp}\n\tif err := runtime.UnmarshalAsJSON(resp, &result.PublicIPAddress); err != nil {\n\t\treturn PublicIPAddressesClientGetResponse{}, err\n\t}\n\treturn result, nil\n}", "func GetIP() string {\n\tIP := os.Getenv(\"MYPRVIP\")\n\tif IP != \"\" {\n\t\treturn IP\n\t}\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\tlog.Printf(\"error in GetIP - %v\\n\", err)\n\t\treturn \"\"\n\t}\n\tfor _, address := range addrs {\n\t\t// return the first address that is not a loopback\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\treturn ipnet.IP.String()\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func Handler(w http.ResponseWriter, r *http.Request) {\n\tipn.Handler(w, r)\n}", "func RequestClientIP(req *http.Request) (net.IP, error) {\n\trealIp := req.Header.Get(\"X-Real-IP\")\n\t// ip, _, err := net.SplitHostPort(req.RemoteAddr)\n\t// if err != nil {\n\t// \treturn nil, fmt.Errorf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t// }\n\t//\n\t// userIP := net.ParseIP(ip)\n\t// if userIP == nil {\n\t// \treturn nil, fmt.Errorf(\"userip: %q is not IP:port\", req.RemoteAddr)\n\t// }\n\t// return userIP, nil\n\treturn net.ParseIP(realIp), nil\n}", "func (o *KeyOptions) GetIPKey(r *http.Request) string {\n\treturn GetIPWithMask(r, o).String()\n}", "func extractIP(r *http.Request) (string, error) {\n\t// if not a proper remote addr, return empty\n\tif !strings.ContainsRune(r.RemoteAddr, ':') {\n\t\treturn \"\", errors.New(\"lol\")\n\t}\n\tipAddr, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil || ipAddr == \"\" {\n\t\treturn \"\", errors.New(\"Request has failed origin validation. Please retry.\")\n\t}\n\treturn ipAddr, nil\n}", "func getOutboundIP() string {\n\tconn, _ := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tdefer conn.Close()\n\tlocalAddr := conn.LocalAddr().String()\n\tidx := strings.LastIndex(localAddr, \":\")\n\treturn localAddr[0:idx]\n}", "func (c *Context) ClientIP() string {\n\tclientIP := c.GetHeader(\"X-Forwarded-For\")\n\tclientIP = strings.TrimSpace(strings.Split(clientIP, \",\")[0])\n\tif clientIP == emptyString {\n\t\tclientIP = strings.TrimSpace(c.GetHeader(\"X-Real-Ip\"))\n\t}\n\tif clientIP != emptyString {\n\t\treturn clientIP\n\t}\n\tif ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Req.RemoteAddr)); err == nil {\n\t\treturn ip\n\t}\n\treturn emptyString\n}", "func (p *SignalChannel) HandleGet(req Request, customer *models.Customer) (res Response, err error) {\n\tlog.Debug(\"[HandleGet] SignalChannel\")\n\treturn p.forward(req, customer)\n}", "func (s *RestServer) getIPv4FlowRawMetricsHandler(r *http.Request) (interface{}, error) {\n\tlog.Infof(\"Got GET request IPv4FlowRawMetrics/%s\", mux.Vars(r)[\"Meta.Name\"])\n\treturn nil, nil\n}" ]
[ "0.6904953", "0.6875331", "0.68298227", "0.67149943", "0.66577065", "0.6657287", "0.66470385", "0.66094744", "0.64891714", "0.6166702", "0.61413324", "0.6123653", "0.6099094", "0.60950434", "0.6008096", "0.59769636", "0.5930084", "0.5909029", "0.5889158", "0.5858818", "0.5842762", "0.5842762", "0.5822765", "0.58122545", "0.5749151", "0.574394", "0.5741936", "0.5684707", "0.56643116", "0.5604894", "0.56048304", "0.5598546", "0.5583984", "0.5582276", "0.5571896", "0.55161476", "0.55079454", "0.5507008", "0.5507008", "0.548992", "0.5476839", "0.5448198", "0.5439063", "0.5415496", "0.541295", "0.5407405", "0.54061496", "0.53919214", "0.5381229", "0.5373612", "0.5370047", "0.53653884", "0.53639567", "0.5298821", "0.5281557", "0.52739084", "0.5247455", "0.5244787", "0.5226523", "0.5225098", "0.52185714", "0.5207846", "0.520699", "0.51903516", "0.5190072", "0.5185182", "0.51843375", "0.51823735", "0.5176723", "0.5168508", "0.5140062", "0.51337373", "0.51298547", "0.5119703", "0.51172435", "0.5117025", "0.51144964", "0.5113516", "0.51122093", "0.5094574", "0.50840646", "0.5076805", "0.5074991", "0.50617725", "0.50506043", "0.50349194", "0.50325656", "0.50280106", "0.50273794", "0.5019219", "0.50161296", "0.50119716", "0.5010556", "0.5008234", "0.50059456", "0.500387", "0.49999222", "0.49812627", "0.49797866", "0.49776694" ]
0.8459092
0
CheckSlotSpan checks if the slot is within the span of slots, with MAXIMUM_GOSSIP_CLOCK_DISPARITY margin in time.
func CheckSlotSpan(slotAfter func(delta time.Duration) common.Slot, slot common.Slot, span common.Slot) error { if slot+span < slot { return fmt.Errorf("slot overflow: %d", slot) } // check minimum, with account for clock disparity if minSlot := slotAfter(-MAXIMUM_GOSSIP_CLOCK_DISPARITY); slot+span < minSlot { return fmt.Errorf("slot %d is too old, minimum slot is %d", slot, minSlot) } // check maximum, with account for clock disparity if maxSlot := slotAfter(MAXIMUM_GOSSIP_CLOCK_DISPARITY); slot > maxSlot { return fmt.Errorf("slot %d is too new, maximum slot is %d", slot, maxSlot) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (config *generator) validateSlots() {\n\n\t// default return value if validation fails\n\temptySlots := make([][2]int64, 0)\n\tif len(config.Slots) == 0 {\n\t\treturn\n\t}\n\n\treturnEmptySlots := false\n\n\t// check slot with 0 values\n\t// remove them from config.Slots\n\temptySlotCount := 0\n\tfor index, slot := range config.Slots {\n\t\tif slot[0] == 0 || slot[1] == 0 {\n\t\t\tutil.Logf(\"WARNING:Slot[%v][%v] is having 0 duration\\n\", index, slot)\n\t\t\temptySlotCount++\n\t\t\tcontinue\n\t\t}\n\n\t\t// check slot boundaries\n\t\tif slot[1] < config.requested.slotMinDuration || slot[1] > config.requested.slotMaxDuration {\n\t\t\tutil.Logf(\"ERROR: Slot%v Duration %v sec is out of either requested.slotMinDuration (%v) or requested.slotMaxDuration (%v)\\n\", index, slot[1], config.requested.slotMinDuration, config.requested.slotMaxDuration)\n\t\t\treturnEmptySlots = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// remove empty slot\n\tif emptySlotCount > 0 {\n\t\toptimizedSlots := make([][2]int64, len(config.Slots)-emptySlotCount)\n\t\tfor index, slot := range config.Slots {\n\t\t\tif slot[0] == 0 || slot[1] == 0 {\n\t\t\t} else {\n\t\t\t\toptimizedSlots[index][0] = slot[0]\n\t\t\t\toptimizedSlots[index][1] = slot[1]\n\t\t\t}\n\t\t}\n\t\tconfig.Slots = optimizedSlots\n\t\tutil.Logf(\"Removed %v empty slots\\n\", emptySlotCount)\n\t}\n\n\tif int64(len(config.Slots)) < config.requested.minAds || int64(len(config.Slots)) > config.requested.maxAds {\n\t\tutil.Logf(\"ERROR: slotSize %v is either less than Min Ads (%v) or greater than Max Ads (%v)\\n\", len(config.Slots), config.requested.minAds, config.requested.maxAds)\n\t\treturnEmptySlots = true\n\t}\n\n\t// ensure if min pod duration = max pod duration\n\t// config.TotalSlotTime = pod duration\n\tif config.requested.podMinDuration == config.requested.podMaxDuration && *config.totalSlotTime != config.requested.podMaxDuration {\n\t\tutil.Logf(\"ERROR: Total Slot Duration %v sec is not matching with Total Pod Duration %v sec\\n\", *config.totalSlotTime, config.requested.podMaxDuration)\n\t\treturnEmptySlots = true\n\t}\n\n\t// ensure slot duration lies between requested min pod duration and requested max pod duration\n\t// Testcase #15\n\tif *config.totalSlotTime < config.requested.podMinDuration || *config.totalSlotTime > config.requested.podMaxDuration {\n\t\tutil.Logf(\"ERROR: Total Slot Duration %v sec is either less than Requested Pod Min Duration (%v sec) or greater than Requested Pod Max Duration (%v sec)\\n\", *config.totalSlotTime, config.requested.podMinDuration, config.requested.podMaxDuration)\n\t\treturnEmptySlots = true\n\t}\n\n\tif returnEmptySlots {\n\t\tconfig.Slots = emptySlots\n\t\tconfig.freeTime = config.requested.podMaxDuration\n\t}\n}", "func (me TxsdTspanTypeLengthAdjust) IsSpacing() bool { return me.String() == \"spacing\" }", "func (a *BookAppointment) TimeSlotValidation() *apierrors.RestErr{\r\n\r\n\t//Loop to check the booking timeslot in available timeslot array\r\n\tfor _, value := range AvailableTimeSlot {\r\n\t\tif a.TimeSlot == value {\r\n\t\t\treturn nil\r\n\t\t}\r\n\t}\r\n\r\n\treturn apierrors.NewBadRequestError(\r\n\t\tfmt.Sprintf(\"Selected Slot is not available for the time %s,Please choose between 9.30 am to 11.30 am /2pm to 4pm /6pm to 8pm\",a.TimeSlot))\r\n\r\n}", "func (config generator) shouldAdjustSlotWithZeroDuration() bool {\n\tif config.requested.minAds == config.requested.maxAds {\n\t\treturn true\n\t}\n\treturn false\n}", "func checkOverlaps(a, ap Span) bool {\n\tif len(a.EndKey) == 0 {\n\t\treturn bytes.Compare(ap.EndKey, a.StartKey) > 0\n\t}\n\treturn bytes.Compare(a.StartKey, ap.EndKey) < 0 && bytes.Compare(ap.StartKey, a.EndKey) < 0\n}", "func (s *Slot) HasEnoughMsg(phase, round uint32) bool {\n\treturn s.RecvBCMsgsT[phase][round-1] >= config.Conf.NMinusF\n}", "func (s *SPService) checkTurn(slot, round int64, verbose bool) bool {\n\tconfig := s.config\n\tbest := config.Chain.BestSnapshot()\n\tif best.Height > 0 && config.IsCurrent() != true {\n\t\tlog.Infof(\"downloading blocks: wait!!!!!!!!!!!\")\n\t\treturn false\n\t}\n\t// check whether block with round/slot already exist\n\tnode := config.Chain.GetNodeByRoundSlot(uint32(round), uint16(slot))\n\tif node != nil {\n\t\treturn false\n\t}\n\n\tvalidators, _, err := s.getValidators(uint32(round), verbose)\n\tif err != nil {\n\t\tlog.Errorf(\"[checkTurn] %v\", err.Error())\n\t\treturn false\n\t}\n\n\tisTurn := *validators[slot] == *s.config.Account.Address\n\tlog.Infof(\"[checkTurn] slot change slot=%d, round=%d, height=%d, isTurn=%v, interval=%v\",\n\t\tslot, round, best.Height+1, isTurn, s.context.RoundInterval)\n\treturn isTurn\n}", "func computeTimeForEachAdSlot(cfg generator, totalAds int64) int64 {\n\t// Compute time for each ad\n\tif totalAds <= 0 {\n\t\tutil.Logf(\"totalAds = 0, Hence timeForEachSlot = 0\")\n\t\treturn 0\n\t}\n\ttimeForEachSlot := cfg.requested.podMaxDuration / totalAds\n\n\tutil.Logf(\"Computed timeForEachSlot = %v (podMaxDuration/totalAds) (%v/%v)\\n\", timeForEachSlot, cfg.requested.podMaxDuration, totalAds)\n\n\tif timeForEachSlot < cfg.internal.slotMinDuration {\n\t\ttimeForEachSlot = cfg.internal.slotMinDuration\n\t\tutil.Logf(\"Computed timeForEachSlot < requested slotMinDuration (%v). Hence, setting timeForEachSlot = slotMinDuration = %v\\n\", cfg.internal.slotMinDuration, timeForEachSlot)\n\t}\n\n\tif timeForEachSlot > cfg.internal.slotMaxDuration {\n\t\ttimeForEachSlot = cfg.internal.slotMaxDuration\n\t\tutil.Logf(\"Computed timeForEachSlot > requested slotMaxDuration (%v). Hence, setting timeForEachSlot = slotMaxDuration = %v\\n\", cfg.internal.slotMaxDuration, timeForEachSlot)\n\t}\n\n\t// Case - Exact slot duration is given. No scope for finding multiples\n\t// of given number. Prefer to return computed timeForEachSlot\n\t// In such case timeForEachSlot no necessarily to be multiples of given number\n\tif cfg.requested.slotMinDuration == cfg.requested.slotMaxDuration {\n\t\tutil.Logf(\"requested.slotMinDuration = requested.slotMaxDuration = %v. Hence, not computing multiples of %v value.\", cfg.requested.slotMaxDuration, multipleOf)\n\t\treturn timeForEachSlot\n\t}\n\n\t// Case II - timeForEachSlot*totalAds > podmaxduration\n\t// In such case prefer to return cfg.podMaxDuration / totalAds\n\t// In such case timeForEachSlot no necessarily to be multiples of given number\n\tif (timeForEachSlot * totalAds) > cfg.requested.podMaxDuration {\n\t\tutil.Logf(\"timeForEachSlot*totalAds (%v) > cfg.requested.podMaxDuration (%v) \", timeForEachSlot*totalAds, cfg.requested.podMaxDuration)\n\t\tutil.Logf(\"Hence, not computing multiples of %v value.\", multipleOf)\n\t\t// need that division again\n\t\treturn cfg.requested.podMaxDuration / totalAds\n\t}\n\n\t// ensure timeForEachSlot is multipleof given number\n\tif cfg.internal.slotDurationComputed && !isMultipleOf(timeForEachSlot, multipleOf) {\n\t\t// get close to value of multiple\n\t\t// here we muse get either cfg.SlotMinDuration or cfg.SlotMaxDuration\n\t\t// these values are already pre-computed in multiples of given number\n\t\ttimeForEachSlot = getClosestFactor(timeForEachSlot, multipleOf)\n\t\tutil.Logf(\"Computed closet factor %v, in multiples of %v for timeForEachSlot\\n\", timeForEachSlot, multipleOf)\n\t}\n\tutil.Logf(\"Computed Final timeForEachSlot = %v [%v <= %v <= %v]\\n\", timeForEachSlot, cfg.requested.slotMinDuration, timeForEachSlot, cfg.requested.slotMaxDuration)\n\treturn timeForEachSlot\n}", "func inTimeSpan(start, end, check time.Time) bool {\n\treturn check.After(start) && check.Before(end)\n}", "func InTimeSpan(start, end, check time.Time) bool {\n\treturn check.After(start) && check.Before(end)\n}", "func Leave(slot int) error {\n\tthis := GetInstance()\n\tif _, err := this.isparkingLotCreated(); err != nil {\n\t\treturn err\n\t}\n\n\t// Validate if the slot has some car parked there or not\n\tif car, exists := this.slotCarMap[slot]; exists {\n\t\t// Complexity : O(log n)\n\t\theap.Push(&this.emptySlots, slot)\n\t\tthis.unmapRegNo(car.GetRegNo())\n\t\tthis.unmapRegNoFromColorMap(car.GetColor(), car.GetRegNo())\n\t\tthis.unmapSlot(slot)\n\t\tfmt.Println(\"Slot number \" + strconv.Itoa(slot) + \" is free\")\n\t\treturn nil\n\t} else {\n\t\terr := errors.New(NOT_FOUND_ERROR)\n\t\treturn err\n\t}\n}", "func (config generator) addTime(timeForEachSlot int64, fillZeroSlotsOnPriority bool) (int64, bool) {\n\ttime := int64(0)\n\n\t// iterate over each ad\n\tslotCountFullWithCapacity := 0\n\tfor ad := int64(0); ad < int64(len(config.Slots)); ad++ {\n\n\t\tslot := &config.Slots[ad]\n\t\t// check\n\t\t// 1. time(slot(0)) <= config.SlotMaxDuration\n\t\t// 2. if adding new time to slot0 not exeeding config.SlotMaxDuration\n\t\t// 3. if sum(slot time) + timeForEachSlot <= config.RequestedPodMaxDuration\n\t\tcanAdjustTime := (slot[1]+timeForEachSlot) <= config.requested.slotMaxDuration && (slot[1]+timeForEachSlot) >= config.requested.slotMinDuration\n\t\ttotalSlotTimeWithNewTimeLessThanRequestedPodMaxDuration := *config.totalSlotTime+timeForEachSlot <= config.requested.podMaxDuration\n\n\t\t// if fillZeroSlotsOnPriority= true ensure current slot value = 0\n\t\tallowCurrentSlot := !fillZeroSlotsOnPriority || (fillZeroSlotsOnPriority && slot[1] == 0)\n\t\tif slot[1] <= config.internal.slotMaxDuration && canAdjustTime && totalSlotTimeWithNewTimeLessThanRequestedPodMaxDuration && allowCurrentSlot {\n\t\t\tslot[0] += timeForEachSlot\n\n\t\t\t// if we are adjusting the free time which will match up with config.RequestedPodMaxDuration\n\t\t\t// then set config.SlotMinDuration as min value for this slot\n\t\t\t// TestCase #16\n\t\t\t//if timeForEachSlot == maxPodDurationMatchUpTime {\n\t\t\tif timeForEachSlot < multipleOf {\n\t\t\t\t// override existing value of slot[0] here\n\t\t\t\tslot[0] = config.requested.slotMinDuration\n\t\t\t}\n\n\t\t\t// check if this slot duration was zero\n\t\t\tif slot[1] == 0 {\n\t\t\t\t// decrememt config.slotsWithZeroTime as we added some time for this slot\n\t\t\t\t*config.slotsWithZeroTime--\n\t\t\t}\n\n\t\t\tslot[1] += timeForEachSlot\n\t\t\t*config.totalSlotTime += timeForEachSlot\n\t\t\ttime += timeForEachSlot\n\t\t\tutil.Logf(\"Slot %v = Added %v sec (New Time = %v)\\n\", ad, timeForEachSlot, slot[1])\n\t\t}\n\t\t// check slot capabity\n\t\t// !canAdjustTime - TestCase18\n\t\t// UOE-5268 - Check with Requested Slot Max Duration\n\t\tif slot[1] == config.requested.slotMaxDuration || !canAdjustTime {\n\t\t\t// slot is full\n\t\t\tslotCountFullWithCapacity++\n\t\t}\n\t}\n\tutil.Logf(\"adjustedTime = %v\\n \", time)\n\treturn time, slotCountFullWithCapacity == len(config.Slots)\n}", "func (v WidgetLiveSpan) IsValid() bool {\n\tfor _, existing := range allowedWidgetLiveSpanEnumValues {\n\t\tif existing == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func IsSpan(name string) bool {\n\treturn strings.Contains(name, \".span-\")\n}", "func checkTimeRange(db *db.DB, mint, maxt int64) (int64, int64) {\n\n\tlogger := log.With(logger, \"stage\", \"checkTimeRange\")\n\n\tvar actualMint int64 = math.MaxInt64\n\tvar actualMaxt int64 = math.MinInt64\n\n\tif db.ReadOnly {\n\t\tblocks, _ := db.BlockReader()\n\t\t//Look time ranges for blocks\n\t\tfor _, block := range blocks {\n\t\t\tif actualMint > block.Meta().MinTime {\n\t\t\t\tactualMint = block.Meta().MinTime\n\t\t\t}\n\n\t\t\tif actualMaxt < block.Meta().MaxTime {\n\t\t\t\tactualMaxt = block.Meta().MaxTime\n\t\t\t}\n\t\t}\n\t} else {\n\t\tblocks := db.Blocks()\n\t\t//Look time ranges for blocks\n\t\tfor _, block := range blocks {\n\t\t\tif actualMint > block.Meta().MinTime {\n\t\t\t\tactualMint = block.Meta().MinTime\n\t\t\t}\n\n\t\t\tif actualMaxt < block.Meta().MaxTime {\n\t\t\t\tactualMaxt = block.Meta().MaxTime\n\t\t\t}\n\t\t}\n\t}\n\n\tlogger.Log(\"status\", fmt.Sprintf(\"According to Blocks Mint: %d, Maxt: %d\", actualMint, actualMaxt))\n\n\thead := db.Head() // If tsdb opened in write mode\n\tif head != nil {\n\t\t//Look the time range for head\n\t\tif head.MinTime() < actualMint {\n\t\t\tactualMint = head.MinTime()\n\t\t}\n\n\t\tif head.MaxTime() > actualMaxt {\n\t\t\tactualMaxt = head.MaxTime()\n\t\t}\n\n\t\tlogger.Log(\"status\", fmt.Sprintf(\"According to Head Mint: %d, Maxt: %d\", actualMint, actualMaxt))\n\t}\n\n\tif actualMint < mint {\n\t\tactualMint = mint\n\t} // else use calculated actualMint\n\n\tif actualMaxt > maxt {\n\t\tactualMaxt = maxt\n\t} // else use calculated actualMaxt\n\n\treturn actualMint, actualMaxt\n\n}", "func (me TxsdTspanTypeLengthAdjust) IsSpacingAndGlyphs() bool {\n\treturn me.String() == \"spacingAndGlyphs\"\n}", "func SlotTime(n int64, latest time.Time, step time.Duration, size int64) time.Time {\n\tlatestN := SlotIndex(latest, step, size)\n\tdistance := IndexDistance(n, latestN, size)\n\treturn latest.Add(time.Duration(distance*-1) * step)\n}", "func CheckTokenMovementLimits(tx *model.DbTransaction, conf conf.TokenMovementConfig, blockID int64) {\n\tvar messages []string\n\tif needCheck(networkPerDayEvent) {\n\t\tamount, err := model.GetExcessCommonTokenMovementPerDay(tx)\n\n\t\tif err != nil {\n\n\t\t\tlog.WithFields(log.Fields{\"type\": consts.DBError, \"error\": err}).Error(\"check common token movement\")\n\t\t} else if amount.GreaterThanOrEqual(decimal.NewFromFloat(networkPerDayLimit)) {\n\n\t\t\tmessages = append(messages, fmt.Sprintf(networkPerDayMsgTemplate, amount.String()))\n\t\t\tlastLimitEvents[networkPerDayEvent] = time.Now()\n\t\t}\n\t}\n\n\tif needCheck(fromToDayLimitEvent) {\n\t\ttransfers, err := model.GetExcessFromToTokenMovementPerDay(tx)\n\t\tif err != nil {\n\t\t\tlog.WithFields(log.Fields{\"type\": consts.DBError, \"error\": err}).Error(\"check from to token movement\")\n\t\t} else {\n\t\t\tfor _, transfer := range transfers {\n\t\t\t\tmessages = append(messages, fmt.Sprintf(fromToDayLimitMsgTemplate, transfer.SenderID, transfer.RecipientID, transfer.Amount))\n\t\t\t}\n\n\t\t\tif len(transfers) > 0 {\n\t\t\t\tlastLimitEvents[fromToDayLimitEvent] = time.Now()\n\t\t\t}\n\t\t}\n\t}\n\n\texcesses, err := model.GetExcessTokenMovementQtyPerBlock(tx, blockID)\n\tif err != nil {\n\t\tlog.WithFields(log.Fields{\"type\": consts.DBError, \"error\": err}).Error(\"check token movement per block\")\n\t} else {\n\t\tfor _, excess := range excesses {\n\t\t\tmessages = append(messages, fmt.Sprintf(perBlockTokenMovementTemplate, excess.SenderID, excess.TxCount, blockID))\n\t\t}\n\t}\n\n\tif len(messages) > 0 {\n\t\tsendEmail(conf, strings.Join(messages, \"\\n\"))\n\t}\n}", "func TestMissedBlockAndRankStreakCounter(t *testing.T) {\n\tapp := simapp.Setup(false)\n\tctx := app.BaseApp.NewContext(false, tmproto.Header{})\n\n\taddrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction))\n\tvalAddrs := simapp.ConvertAddrsToValAddrs(addrDels)\n\tpks := simapp.CreateTestPubKeys(1)\n\taddr, val := valAddrs[0], pks[0]\n\tvalAddr := sdk.ValAddress(addr)\n\ttstaking := teststaking.NewHelper(t, ctx, app.CustomStakingKeeper, app.CustomGovKeeper)\n\tctx = ctx.WithBlockHeight(1)\n\n\t// Validator created\n\ttstaking.CreateValidator(addr, val, true)\n\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\n\t// Now a validator, for two blocks\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, true)\n\tctx = ctx.WithBlockHeight(2)\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, false)\n\n\tv := tstaking.CheckValidator(valAddr, stakingtypes.Active)\n\trequire.Equal(t, v.Rank, int64(1))\n\trequire.Equal(t, v.Streak, int64(1))\n\n\tinfo, found := app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address()))\n\trequire.True(t, found)\n\trequire.Equal(t, int64(1), info.MischanceConfidence)\n\trequire.Equal(t, int64(0), info.Mischance)\n\trequire.Equal(t, int64(1), info.MissedBlocksCounter)\n\trequire.Equal(t, int64(1), info.ProducedBlocksCounter)\n\n\theight := ctx.BlockHeight() + 1\n\tfor i := int64(0); i < 10; i++ {\n\t\tctx = ctx.WithBlockHeight(height + i)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, false)\n\t}\n\tctx = ctx.WithBlockHeight(height + 10)\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, true)\n\tinfo, found = app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address()))\n\trequire.True(t, found)\n\trequire.Equal(t, int64(0), info.MischanceConfidence)\n\trequire.Equal(t, int64(0), info.Mischance)\n\trequire.Equal(t, int64(11), info.MissedBlocksCounter)\n\trequire.Equal(t, int64(2), info.ProducedBlocksCounter)\n\n\tv = tstaking.CheckValidator(valAddr, stakingtypes.Active)\n\trequire.Equal(t, v.Rank, int64(1))\n\trequire.Equal(t, v.Streak, int64(1))\n\n\t// sign 100 blocks successfully\n\theight = ctx.BlockHeight() + 1\n\tfor i := int64(0); i < 100; i++ {\n\t\tctx = ctx.WithBlockHeight(height + i)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, true)\n\t}\n\n\tv = tstaking.CheckValidator(valAddr, stakingtypes.Active)\n\trequire.Equal(t, v.Rank, int64(101))\n\trequire.Equal(t, v.Streak, int64(101))\n\n\t// miss one block\n\tctx = ctx.WithBlockHeight(height + 100)\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, false)\n\tv = tstaking.CheckValidator(valAddr, stakingtypes.Active)\n\trequire.Equal(t, v.Rank, int64(101))\n\trequire.Equal(t, v.Streak, int64(101))\n\n\tapp.CustomSlashingKeeper.Inactivate(ctx, sdk.ConsAddress(val.Address()))\n\tv = tstaking.CheckValidator(valAddr, stakingtypes.Inactive)\n\trequire.Equal(t, v.Rank, int64(50))\n\trequire.Equal(t, v.Streak, int64(0))\n\n\tapp.CustomSlashingKeeper.Activate(ctx, valAddr)\n\t// miss 5 blocks\n\theight = ctx.BlockHeight() + 1\n\tfor i := int64(0); i < 5; i++ {\n\t\tctx = ctx.WithBlockHeight(height + i)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 100, false)\n\t}\n\tv = tstaking.CheckValidator(valAddr, stakingtypes.Active)\n\trequire.Equal(t, v.Rank, int64(50))\n\trequire.Equal(t, v.Streak, int64(0))\n}", "func MaxSlot(a, b Slot) Slot {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}", "func TestMSApp_BlockHeight(t *testing.T) {\n\tt.Parallel()\n\n\tapp, appStop := NewTestDnAppMockVM()\n\tdefer appStop()\n\n\tgenAccs, genAddrs, _, genPrivKeys := CreateGenAccounts(7, GenDefCoins(t))\n\tCheckSetGenesisMockVM(t, app, genAccs)\n\n\tCreateCurrency(t, app, currency1Denom, 0)\n\n\t// generate blocks to reach multisig call reject condition\n\tsenderAddr, senderPrivKey := genAddrs[0], genPrivKeys[0]\n\tmsIntervalToExecute := app.msKeeper.GetIntervalToExecute(GetContext(app, true))\n\tblockCountToLimit := int(msIntervalToExecute*2 + 1)\n\tfor curIssueIdx := 0; curIssueIdx < blockCountToLimit; curIssueIdx++ {\n\t\t// start block\n\t\tapp.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{ChainID: chainID, Height: app.LastBlockHeight() + 1}})\n\t\t// generate submit message\n\t\tissueId, msgId := fmt.Sprintf(\"issue%d\", curIssueIdx), strconv.Itoa(curIssueIdx)\n\t\tissueMsg := currencies.NewMsgIssueCurrency(issueId, coin1, senderAddr)\n\t\tsubmitMsg := msClient.NewMsgSubmitCall(issueMsg, msgId, senderAddr)\n\t\t// emit transaction\n\t\tsenderAcc := GetAccount(app, senderAddr)\n\t\ttx := GenTx([]sdk.Msg{submitMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\t_, res, err := app.Deliver(tx)\n\t\trequire.NoError(t, err, ResultErrorMsg(res, err))\n\t\t// commit block\n\t\tapp.EndBlock(abci.RequestEndBlock{})\n\t\tapp.Commit()\n\t}\n\n\t// check rejected calls (request one by one as they are not in queue)\n\tfor i := int64(0); i <= msIntervalToExecute; i++ {\n\t\tcall := multisig.CallResp{}\n\t\tCheckRunQuery(t, app, multisig.CallReq{CallID: dnTypes.NewIDFromUint64(uint64(i))}, queryMsGetCallPath, &call)\n\t\trequire.True(t, call.Call.Rejected)\n\t}\n\n\t// check non-rejected calls (request all as they are in the queue)\n\t{\n\t\tcalls := multisig.CallsResp{}\n\t\tCheckRunQuery(t, app, nil, queryMsGetCallsPath, &calls)\n\t\tfor _, call := range calls {\n\t\t\trequire.False(t, call.Call.Rejected)\n\t\t}\n\t}\n\n\t// vote for rejected call\n\t{\n\t\t// prev recipient has already voted, pick a new one\n\t\tsenderAcc, senderPrivKey := GetAccountCheckTx(app, genAddrs[1]), genPrivKeys[1]\n\t\t// pick a rejected callId\n\t\tmsgId := dnTypes.NewIDFromUint64(0)\n\t\t// emit transaction\n\t\tconfirmMsg := msClient.NewMsgConfirmCall(msgId, senderAcc.GetAddress())\n\t\ttx := GenTx([]sdk.Msg{confirmMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\tCheckDeliverSpecificErrorTx(t, app, tx, multisig.ErrVoteAlreadyRejected)\n\t}\n\n\t// vote for already confirmed call (vote ended)\n\t{\n\t\t// pick a non-rejected once voted callId\n\t\tmsgId := dnTypes.NewIDFromUint64(uint64(blockCountToLimit - 1))\n\t\t// vote and approve call\n\t\tfor i := 1; i < len(genAccs)/2+1; i++ {\n\t\t\tsenderAcc, senderPrivKey := GetAccountCheckTx(app, genAddrs[i]), genPrivKeys[i]\n\t\t\tconfirmMsg := msClient.NewMsgConfirmCall(msgId, senderAcc.GetAddress())\n\t\t\ttx := GenTx([]sdk.Msg{confirmMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\t\tCheckDeliverTx(t, app, tx)\n\t\t}\n\n\t\t// vote for approved call\n\t\t{\n\t\t\tidx := len(genAddrs) - 1\n\t\t\tsenderAcc, senderPrivKey := GetAccountCheckTx(app, genAddrs[idx]), genPrivKeys[idx]\n\t\t\tconfirmMsg := msClient.NewMsgConfirmCall(msgId, senderAcc.GetAddress())\n\t\t\ttx := GenTx([]sdk.Msg{confirmMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\t\tCheckDeliverSpecificErrorTx(t, app, tx, multisig.ErrVoteAlreadyApproved)\n\t\t}\n\t}\n\n\t// revoke rejected call\n\t{\n\t\t// pick a rejected callId\n\t\tmsgId := dnTypes.NewIDFromUint64(0)\n\t\t// emit transaction\n\t\tsenderAcc, senderPrivKey := GetAccountCheckTx(app, genAddrs[0]), genPrivKeys[0]\n\t\trevokeMsg := msClient.MsgRevokeConfirm{CallID: msgId, Sender: senderAcc.GetAddress()}\n\t\ttx := GenTx([]sdk.Msg{revokeMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\tCheckDeliverSpecificErrorTx(t, app, tx, multisig.ErrVoteAlreadyRejected)\n\t}\n\n\t// revoke approved call\n\t{\n\t\t// pick an approved callId\n\t\tmsgId := dnTypes.NewIDFromUint64(uint64(blockCountToLimit - 1))\n\t\t// emit transaction\n\t\tsenderAcc, senderPrivKey := GetAccountCheckTx(app, genAddrs[0]), genPrivKeys[0]\n\t\trevokeMsg := msClient.MsgRevokeConfirm{CallID: msgId, Sender: senderAcc.GetAddress()}\n\t\ttx := GenTx([]sdk.Msg{revokeMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey)\n\t\tCheckDeliverSpecificErrorTx(t, app, tx, multisig.ErrVoteAlreadyApproved)\n\t}\n}", "func ProcessSlots(ctx context.Context, spec *Spec, epc *EpochsContext, state UpgradeableBeaconState, slot Slot) error {\n\t// happens at the start of every CurrentSlot\n\tcurrentSlot, err := state.Slot()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif currentSlot >= slot {\n\t\treturn errors.New(\"cannot transition from pre-state with higher or equal slot than transition target\")\n\t}\n\tfor currentSlot < slot {\n\t\tif err := ctx.Err(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := ProcessSlot(ctx, spec, state); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Per-epoch transition happens at the start of the first slot of every epoch.\n\t\t// (with the slot still at the end of the last epoch)\n\t\tisEpochEnd := spec.SlotToEpoch(currentSlot+1) != spec.SlotToEpoch(currentSlot)\n\t\tif isEpochEnd {\n\t\t\tif err := state.ProcessEpoch(ctx, spec, epc); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tcurrentSlot += 1\n\t\tif err := state.SetSlot(currentSlot); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif isEpochEnd {\n\t\t\tif err := epc.RotateEpochs(state); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif err := state.UpgradeMaybe(ctx, spec, epc); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (node *AkhNode) timeValid(s Signable) bool {\n\tcurrentTimeStamp := GetTimeStamp()\n\tcurrentSlotStart := node.poll.GetCurrentSlotStart(currentTimeStamp)\n\treturn s.GetTimestamp() > currentSlotStart && s.GetTimestamp() < currentTimeStamp\n}", "func needCheck(event uint8) bool {\n\tt, ok := lastLimitEvents[event]\n\tif !ok {\n\t\treturn true\n\t}\n\n\treturn time.Now().Sub(t) >= 24*time.Hour\n}", "func (bd *BlockDAG) checkLayerGap(parents []*hash.Hash) bool {\n\tif len(parents) == 0 {\n\t\treturn false\n\t}\n\tparentsNode := []IBlock{}\n\tfor _, v := range parents {\n\t\tib := bd.getBlock(v)\n\t\tif ib == nil {\n\t\t\treturn false\n\t\t}\n\t\tparentsNode = append(parentsNode, ib)\n\t}\n\n\tpLen := len(parentsNode)\n\tif pLen == 0 {\n\t\treturn false\n\t}\n\tvar gap float64\n\tif pLen == 1 {\n\t\treturn true\n\t} else if pLen == 2 {\n\t\tgap = math.Abs(float64(parentsNode[0].GetLayer()) - float64(parentsNode[1].GetLayer()))\n\t} else {\n\t\tvar minLayer int64 = -1\n\t\tvar maxLayer int64 = -1\n\t\tfor i := 0; i < pLen; i++ {\n\t\t\tparentLayer := int64(parentsNode[i].GetLayer())\n\t\t\tif maxLayer == -1 || parentLayer > maxLayer {\n\t\t\t\tmaxLayer = parentLayer\n\t\t\t}\n\t\t\tif minLayer == -1 || parentLayer < minLayer {\n\t\t\t\tminLayer = parentLayer\n\t\t\t}\n\t\t}\n\t\tgap = math.Abs(float64(maxLayer) - float64(minLayer))\n\t}\n\tif gap > MaxTipLayerGap {\n\t\tlog.Error(fmt.Sprintf(\"Parents gap is %f which is more than %d\", gap, MaxTipLayerGap))\n\t\treturn false\n\t}\n\n\treturn true\n}", "func ValidTrace(span *ssf.SSFSpan) bool {\n\treturn span.Id != 0 &&\n\t\tspan.TraceId != 0 &&\n\t\tspan.StartTimestamp != 0 &&\n\t\tspan.EndTimestamp != 0 &&\n\t\tspan.Name != \"\"\n}", "func (cs *CommissionSchedule) validateWithinBound(now epochtime.EpochTime) error {\n\tif len(cs.Rates) == 0 && len(cs.Bounds) == 0 {\n\t\t// Nothing to check.\n\t\treturn nil\n\t}\n\n\tif len(cs.Rates) == 0 {\n\t\treturn fmt.Errorf(\"rates missing\")\n\t}\n\tcurrentRateIndex := 0\n\tcurrentRate := &cs.Rates[currentRateIndex]\n\n\tif len(cs.Bounds) == 0 {\n\t\treturn fmt.Errorf(\"bounds missing\")\n\t}\n\tcurrentBoundIndex := 0\n\tcurrentBound := &cs.Bounds[currentBoundIndex]\n\n\tvar diagnosticTime epochtime.EpochTime\n\tif currentRate.Start > now || currentBound.Start > now {\n\t\t// We only care if the two schedules start simultaneously if they will start in the future.\n\t\t// Steps that already started my have started at different times with older steps pruned.\n\t\tif currentRate.Start != currentBound.Start {\n\t\t\treturn fmt.Errorf(\"rate schedule start epoch %d and bound schedule start epoch %d don't match\", currentRate.Start, currentBound.Start)\n\t\t}\n\t\tdiagnosticTime = currentRate.Start\n\t} else {\n\t\tdiagnosticTime = now\n\t}\n\n\tfor {\n\t\tif currentRate.Rate.Cmp(&currentBound.RateMin) < 0 {\n\t\t\treturn fmt.Errorf(\"rate %v/%v from rate step %d less than minimum rate %v/%v from bound step %d at epoch %d\",\n\t\t\t\tcurrentRate.Rate, CommissionRateDenominator, currentRateIndex,\n\t\t\t\tcurrentBound.RateMin, CommissionRateDenominator, currentBoundIndex,\n\t\t\t\tdiagnosticTime,\n\t\t\t)\n\t\t}\n\t\tif currentRate.Rate.Cmp(&currentBound.RateMax) > 0 {\n\t\t\treturn fmt.Errorf(\"rate %v/%v from rate step %d greater than maximum rate %v/%v from bound step %d at epoch %d\",\n\t\t\t\tcurrentRate.Rate, CommissionRateDenominator, currentRateIndex,\n\t\t\t\tcurrentBound.RateMax, CommissionRateDenominator, currentBoundIndex,\n\t\t\t\tdiagnosticTime,\n\t\t\t)\n\t\t}\n\n\t\t// Determine what changes next.\n\t\tnextRateIndex := currentRateIndex + 1\n\t\tvar nextRate *CommissionRateStep\n\t\tif nextRateIndex < len(cs.Rates) {\n\t\t\tnextRate = &cs.Rates[nextRateIndex]\n\t\t} else {\n\t\t\tnextRate = nil\n\t\t}\n\t\tnextBoundIndex := currentBoundIndex + 1\n\t\tvar nextBound *CommissionRateBoundStep\n\t\tif nextBoundIndex < len(cs.Bounds) {\n\t\t\tnextBound = &cs.Bounds[nextBoundIndex]\n\t\t} else {\n\t\t\tnextBound = nil\n\t\t}\n\n\t\tif nextRate == nil && nextBound == nil {\n\t\t\t// Current rate and bound continue happily ever after.\n\t\t\tbreak\n\t\t}\n\n\t\tif nextRate != nil {\n\t\t\tif nextBound == nil || nextRate.Start <= nextBound.Start {\n\t\t\t\t// Rate changes. Check with the new rate on next iteration.\n\t\t\t\tcurrentRateIndex = nextRateIndex\n\t\t\t\tcurrentRate = nextRate\n\t\t\t\tdiagnosticTime = nextRate.Start\n\t\t\t}\n\t\t}\n\n\t\tif nextBound != nil {\n\t\t\tif nextRate == nil || nextBound.Start <= nextRate.Start {\n\t\t\t\t// Bound changes. Check with the new bound on the next iteration.\n\t\t\t\tcurrentBoundIndex = nextBoundIndex\n\t\t\t\tcurrentBound = nextBound\n\t\t\t\tdiagnosticTime = nextBound.Start\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func TestBTreeSeekOverlap(t *testing.T) {\n\tconst count = 513\n\tconst size = 2 * maxItems\n\n\tvar tr btree\n\tfor i := 0; i < count; i++ {\n\t\ttr.Set(newItem(spanWithEnd(i, i+size+1)))\n\t}\n\n\t// Iterate over overlaps with a point scan.\n\tit := tr.MakeIter()\n\tfor i := 0; i < count+size; i++ {\n\t\tscanItem := newItem(spanWithEnd(i, i))\n\t\tit.FirstOverlap(scanItem)\n\t\tfor j := 0; j < size+1; j++ {\n\t\t\texpStart := i - size + j\n\t\t\tif expStart < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif expStart >= count {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !it.Valid() {\n\t\t\t\tt.Fatalf(\"%d/%d: expected valid iterator\", i, j)\n\t\t\t}\n\t\t\titem := it.Cur()\n\t\t\texpected := spanWithEnd(expStart, expStart+size+1)\n\t\t\tif !expected.Equal(spanFromItem(item)) {\n\t\t\t\tt.Fatalf(\"%d: expected %s, but found %s\", i, expected, spanFromItem(item))\n\t\t\t}\n\n\t\t\tit.NextOverlap(scanItem)\n\t\t}\n\t\tif it.Valid() {\n\t\t\tt.Fatalf(\"%d: expected invalid iterator %v\", i, it.Cur())\n\t\t}\n\t}\n\tit.FirstOverlap(newItem(span(count + size + 1)))\n\tif it.Valid() {\n\t\tt.Fatalf(\"expected invalid iterator\")\n\t}\n\n\t// Iterate over overlaps with a range scan.\n\tit = tr.MakeIter()\n\tfor i := 0; i < count+size; i++ {\n\t\tscanItem := newItem(spanWithEnd(i, i+size+1))\n\t\tit.FirstOverlap(scanItem)\n\t\tfor j := 0; j < 2*size+1; j++ {\n\t\t\texpStart := i - size + j\n\t\t\tif expStart < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif expStart >= count {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !it.Valid() {\n\t\t\t\tt.Fatalf(\"%d/%d: expected valid iterator\", i, j)\n\t\t\t}\n\t\t\titem := it.Cur()\n\t\t\texpected := spanWithEnd(expStart, expStart+size+1)\n\t\t\tif !expected.Equal(spanFromItem(item)) {\n\t\t\t\tt.Fatalf(\"%d: expected %s, but found %s\", i, expected, spanFromItem(item))\n\t\t\t}\n\n\t\t\tit.NextOverlap(scanItem)\n\t\t}\n\t\tif it.Valid() {\n\t\t\tt.Fatalf(\"%d: expected invalid iterator %v\", i, it.Cur())\n\t\t}\n\t}\n\tit.FirstOverlap(newItem(span(count + size + 1)))\n\tif it.Valid() {\n\t\tt.Fatalf(\"expected invalid iterator\")\n\t}\n}", "func ValidateTransactionLockTime(transactionLockTime uint32) (bool) {\n if transactionLockTime <= SatoshiConst && transactionLockTime != 16777216 {\n return true\n }\n return false\n}", "func checkVerticalSplit(ctx context.Context, tconn *chrome.TestConn, displayWorkArea coords.Rect) error {\n\toverActivityWInfo, err := ash.GetARCAppWindowInfo(ctx, tconn, wm.Pkg24Secondary)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get arc app window info for over activity\")\n\t}\n\tunderActivityWInfo, err := ash.GetARCAppWindowInfo(ctx, tconn, wm.Pkg24)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get arc app window info for under activity\")\n\t}\n\t// Over activity must be snapped to the left.\n\tif overActivityWInfo.BoundsInRoot.Left != 0 ||\n\t\toverActivityWInfo.BoundsInRoot.Top != 0 ||\n\t\toverActivityWInfo.BoundsInRoot.Width >= displayWorkArea.Width/2 ||\n\t\toverActivityWInfo.BoundsInRoot.Height != displayWorkArea.Height {\n\t\treturn errors.Errorf(\"invalid snapped to the left activity bounds, got: Left = %d, Top = %d, Width = %d, Height = %d; want: Left = 0, Top = 0, Width < %d, Height = %d\",\n\t\t\toverActivityWInfo.BoundsInRoot.Left, overActivityWInfo.BoundsInRoot.Top, overActivityWInfo.BoundsInRoot.Width, overActivityWInfo.BoundsInRoot.Height, displayWorkArea.Width/2, displayWorkArea.Height)\n\t}\n\t// Under activity must be snapped to the right.\n\tif underActivityWInfo.BoundsInRoot.Left <= displayWorkArea.Width/2 ||\n\t\tunderActivityWInfo.BoundsInRoot.Top != 0 ||\n\t\tunderActivityWInfo.BoundsInRoot.Width >= displayWorkArea.Width/2 ||\n\t\tunderActivityWInfo.BoundsInRoot.Height != displayWorkArea.Height ||\n\t\tunderActivityWInfo.BoundsInRoot.Left+underActivityWInfo.BoundsInRoot.Width != displayWorkArea.Width {\n\t\treturn errors.Errorf(\"invalid snapped to the right activity bounds, got: Left = %d, Top = %d, Width = %d, Height = %d, Right = %d; want: Left > %d, Top = 0, Width < %d, Height = %d, Right = %d\",\n\t\t\tunderActivityWInfo.BoundsInRoot.Left, underActivityWInfo.BoundsInRoot.Top, underActivityWInfo.BoundsInRoot.Width, underActivityWInfo.BoundsInRoot.Height,\n\t\t\tunderActivityWInfo.BoundsInRoot.Left+underActivityWInfo.BoundsInRoot.Width, displayWorkArea.Width/2, displayWorkArea.Width/2, displayWorkArea.Height, displayWorkArea.Width)\n\t}\n\n\treturn nil\n}", "func (m *SlotInfo) 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 slotsBelongsToNode(cnode *ClusterNode, slots []int) bool {\n\tcpos, spos := 0, 0\n\tfor cpos < len(cnode.Assigned_slots) && spos < len(slots) {\n\t\tif cnode.Assigned_slots[cpos] > slots[spos] {\n\t\t\treturn false\n\t\t} else if cnode.Assigned_slots[cpos] < slots[spos] {\n\t\t\tcpos++\n\t\t} else {\n\t\t\tcpos++\n\t\t\tspos++\n\t\t}\n\t}\n\treturn spos == len(slots)\n}", "func TestHandleAlreadyInactive(t *testing.T) {\n\t// initial setup\n\tapp := simapp.Setup(false)\n\tctx := app.BaseApp.NewContext(false, tmproto.Header{})\n\n\taddrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction))\n\tvalAddrs := simapp.ConvertAddrsToValAddrs(addrDels)\n\tpks := simapp.CreateTestPubKeys(1)\n\taddr, val := valAddrs[0], pks[0]\n\tpower := int64(100)\n\ttstaking := teststaking.NewHelper(t, ctx, app.CustomStakingKeeper, app.CustomGovKeeper)\n\n\ttstaking.CreateValidator(addr, val, true)\n\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\n\t// 1000 first blocks OK\n\theight := int64(0)\n\tfor ; height < 1000; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, true)\n\t}\n\n\tproperties := app.CustomGovKeeper.GetNetworkProperties(ctx)\n\t// miss 11 blocks for mischance confidence\n\tfor ; height < 1000+int64(properties.MischanceConfidence)+1; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, false)\n\t}\n\n\t// info correctness after the overflow of mischance confidence\n\tinfo, found := app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address()))\n\trequire.True(t, found)\n\trequire.Equal(t, int64(10), info.MischanceConfidence)\n\trequire.Equal(t, int64(1), info.Mischance)\n\trequire.Equal(t, int64(999), info.LastPresentBlock)\n\n\t// miss 110 blocks after mischance confidence happen\n\tfor ; height < 1000+int64(properties.MaxMischance+properties.MischanceConfidence)+1; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, false)\n\t}\n\n\t// end block\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\n\t// validator should have been inactivated\n\tvalidator, _ := app.CustomStakingKeeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val))\n\trequire.Equal(t, stakingtypes.Inactive, validator.GetStatus())\n\n\t// another block missed\n\tctx = ctx.WithBlockHeight(height)\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, false)\n\n\t// validator should be in inactive status yet\n\tvalidator, _ = app.CustomStakingKeeper.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val))\n\trequire.Equal(t, stakingtypes.Inactive, validator.GetStatus())\n}", "func checkIfSeatIsOccupied(rowIndexDelta int, seatIndexDelta int, rowIndex int, seatIndex int, seatRows [][]byte) int {\n\n\tfor {\n\t\trowIndex += rowIndexDelta\n\t\tseatIndex += seatIndexDelta\n\t\tif rowIndex < 0 || rowIndex >= numRows {\n\t\t\treturn 0\n\t\t}\n\t\tif seatIndex < 0 || seatIndex >= numSeats {\n\t\t\treturn 0\n\t\t}\n\t\tswitch seatRows[rowIndex][seatIndex] {\n\t\tcase '#':\n\t\t\treturn 1\n\t\tcase '.':\n\t\t\tcontinue\n\t\tcase 'L':\n\t\t\treturn 0\n\t\t}\n\t}\n}", "func (s *slotted) HasSlot() bool { return atomic.LoadInt32((*int32)(s)) == 0 }", "func (wa *WaitingArea) withinBounds(x, y int) bool {\n\t// we'll assume all lines have the same width as the first one.\n\treturn x >= 0 && y >= 0 && x < len(wa.seats[0]) && y < len(wa.seats)\n}", "func (a *Airlock) checkConsistency(ctx context.Context, group string, maxSlots uint64) {\n\tif a == nil {\n\t\tlogrus.Error(\"consistency check, nil Airlock\")\n\t\treturn\n\t}\n\n\tinnerCtx, cancel := context.WithTimeout(ctx, a.EtcdTxnTimeout)\n\tdefer cancel()\n\n\t// TODO(lucab): re-arrange so that the manager can be re-used.\n\tmanager, err := lock.NewManager(innerCtx, a.EtcdEndpoints, a.ClientCertPubPath, a.ClientCertKeyPath, a.EtcdTxnTimeout, group, maxSlots)\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"reason\": err.Error(),\n\t\t}).Warn(\"consistency check, manager creation failed\")\n\t\treturn\n\t}\n\tdefer manager.Close()\n\n\tsemaphore, err := manager.FetchSemaphore(innerCtx)\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"reason\": err.Error(),\n\t\t}).Warn(\"consistency check, semaphore fetch failed\")\n\t\treturn\n\t}\n\n\t// Update metrics.\n\tdatabaseLocksGauge.WithLabelValues(group).Set(float64(len(semaphore.Holders)))\n\tdatabaseSlotsGauge.WithLabelValues(group).Set(float64(semaphore.TotalSlots))\n\n\t// Log any inconsistencies.\n\tif semaphore.TotalSlots != maxSlots {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"config\": maxSlots,\n\t\t\t\"database\": semaphore.TotalSlots,\n\t\t\t\"group\": group,\n\t\t}).Warn(\"semaphore max slots consistency check failed\")\n\t}\n\tif semaphore.TotalSlots < uint64(len(semaphore.Holders)) {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"group\": group,\n\t\t\t\"holder\": len(semaphore.Holders),\n\t\t\t\"slots\": semaphore.TotalSlots,\n\t\t}).Warn(\"semaphore locks consistency check failed\")\n\t}\n}", "func TestValidatorDippingInAndOut(t *testing.T) {\n\t// initial setup\n\tapp := simapp.Setup(false)\n\tctx := app.BaseApp.NewContext(false, tmproto.Header{})\n\tapp.CustomSlashingKeeper.SetParams(ctx, testslashing.TestParams())\n\n\tpower := int64(100)\n\n\tpks := simapp.CreateTestPubKeys(3)\n\tsimapp.AddTestAddrsFromPubKeys(app, ctx, pks, sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction))\n\n\taddr, val := pks[0].Address(), pks[0]\n\tconsAddr := sdk.ConsAddress(addr)\n\ttstaking := teststaking.NewHelper(t, ctx, app.CustomStakingKeeper, app.CustomGovKeeper)\n\tvalAddr := sdk.ValAddress(addr)\n\n\ttstaking.CreateValidator(valAddr, val, true)\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\n\t// 100 first blocks OK\n\theight := int64(0)\n\tfor ; height < int64(100); height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), power, true)\n\t}\n\n\t// add one more validator into the set\n\ttstaking.CreateValidator(sdk.ValAddress(pks[1].Address()), pks[1], true)\n\tvalidatorUpdates := staking.EndBlocker(ctx, app.CustomStakingKeeper)\n\trequire.Equal(t, 1, len(validatorUpdates))\n\ttstaking.CheckValidator(valAddr, stakingtypes.Active)\n\ttstaking.CheckValidator(sdk.ValAddress(pks[1].Address()), stakingtypes.Active)\n\n\t// 600 more blocks happened\n\theight = 700\n\tctx = ctx.WithBlockHeight(height)\n\n\tvalidatorUpdates = staking.EndBlocker(ctx, app.CustomStakingKeeper)\n\trequire.Equal(t, 0, len(validatorUpdates))\n\ttstaking.CheckValidator(valAddr, stakingtypes.Active)\n\n\t// shouldn't be inactive/kicked yet\n\ttstaking.CheckValidator(valAddr, stakingtypes.Active)\n\n\t// validator misses 500 more blocks, 501 total\n\tlatest := height\n\tfor ; height < latest+501; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, addr, 1, false)\n\t}\n\n\t// should now be inactive & kicked\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Inactive)\n\n\t// check all the signing information\n\tsignInfo, found := app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, consAddr)\n\trequire.True(t, found)\n\trequire.Equal(t, int64(10), signInfo.MischanceConfidence)\n\trequire.Equal(t, int64(111), signInfo.Mischance)\n\trequire.Equal(t, int64(99), signInfo.LastPresentBlock)\n\trequire.Equal(t, int64(121), signInfo.MissedBlocksCounter)\n\trequire.Equal(t, int64(100), signInfo.ProducedBlocksCounter)\n\n\t// some blocks pass\n\theight = int64(5000)\n\tctx = ctx.WithBlockHeight(height)\n\n\t// Try pausing on inactive node here, should fail\n\terr := app.CustomSlashingKeeper.Pause(ctx, valAddr)\n\trequire.Error(t, err)\n\n\t// validator rejoins and starts signing again\n\tapp.CustomSlashingKeeper.Activate(ctx, valAddr)\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 1, true)\n\theight++\n\n\t// validator should be active after signing next block after active\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Active)\n\n\t// miss one block after pause\n\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 1, false)\n\theight++\n\n\t// Try pausing on active node here, should success\n\terr = app.CustomSlashingKeeper.Pause(ctx, valAddr)\n\trequire.NoError(t, err)\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Paused)\n\n\t// validator misses 501 blocks\n\tlatest = height\n\tfor ; height < latest+501; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 1, false)\n\t}\n\n\t// validator should not be in inactive status since node is paused\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Paused)\n\n\t// After reentering after unpause, check if signature info is recovered correctly\n\tsignInfo, found = app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, consAddr)\n\trequire.True(t, found)\n\trequire.Equal(t, int64(1), signInfo.MischanceConfidence)\n\trequire.Equal(t, int64(0), signInfo.Mischance)\n\trequire.Equal(t, int64(5000), signInfo.LastPresentBlock)\n\trequire.Equal(t, int64(122), signInfo.MissedBlocksCounter)\n\trequire.Equal(t, int64(101), signInfo.ProducedBlocksCounter)\n\n\t// Try activating paused node: should unpause but it's activating - should fail\n\terr = app.CustomSlashingKeeper.Activate(ctx, valAddr)\n\trequire.Error(t, err)\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Paused)\n\n\t// Unpause node and it should be active\n\terr = app.CustomSlashingKeeper.Unpause(ctx, valAddr)\n\trequire.NoError(t, err)\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Active)\n\n\t// After reentering after unpause, check if signature info is recovered correctly\n\tsignInfo, found = app.CustomSlashingKeeper.GetValidatorSigningInfo(ctx, consAddr)\n\trequire.True(t, found)\n\trequire.Equal(t, int64(1), signInfo.MischanceConfidence)\n\trequire.Equal(t, int64(0), signInfo.Mischance)\n\trequire.Equal(t, int64(5000), signInfo.LastPresentBlock)\n\trequire.Equal(t, int64(122), signInfo.MissedBlocksCounter)\n\trequire.Equal(t, int64(101), signInfo.ProducedBlocksCounter)\n\n\t// Miss another 501 blocks\n\tlatest = height\n\tfor ; height < latest+501; height++ {\n\t\tctx = ctx.WithBlockHeight(height)\n\t\tapp.CustomSlashingKeeper.HandleValidatorSignature(ctx, val.Address(), 1, false)\n\t}\n\n\t// validator should be in inactive status\n\tstaking.EndBlocker(ctx, app.CustomStakingKeeper)\n\ttstaking.CheckValidator(valAddr, stakingtypes.Inactive)\n}", "func isGapOverThreshold(start, end string, gapThreshold time.Duration) bool {\n\tstartTime, err := time.Parse(timestampFormat, start)\n\tif err != nil {\n\t\tl.Fatal(err.Error())\n\t}\n\tendTime, err := time.Parse(timestampFormat, end)\n\tif err != nil {\n\t\tl.Fatal(err.Error())\n\t}\n\tif endTime.After(startTime) {\n\t\treturn endTime.Sub(startTime) > gapThreshold\n\t}\n\treturn startTime.Sub(endTime) > gapThreshold\n}", "func canReach(s string, minJump int, maxJump int) bool {\n\tsSplit := strings.Split(s, \"\")\n\tif sSplit[0] != \"0\" || sSplit[len(s)-1] != \"0\" {\n\t\treturn false\n\t}\n\tstack := []int{0}\n\n\tlastProcessedMax := minJump\n\tfor len(stack) != 0 {\n\t\tpoppedElement := stack[0]\n\t\tif len(stack) > 1 {\n\t\t\tstack = stack[1:]\n\t\t} else {\n\t\t\tstack = []int{}\n\t\t}\n\t\tif poppedElement+minJump > len(s)-1 {\n\t\t\tcontinue\n\t\t}\n\t\tmax := poppedElement + maxJump\n\t\tif poppedElement+maxJump > len(s)-1 {\n\t\t\tmax = len(s) - 1\n\t\t}\n\t\tmin := poppedElement + minJump\n\t\tif poppedElement+minJump < lastProcessedMax {\n\t\t\tmin = lastProcessedMax\n\t\t}\n\t\tfor i := min; i <= max; i++ {\n\t\t\tif sSplit[i] == \"0\" {\n\t\t\t\tif i == len(s)-1 {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tstack = append(stack, i)\n\t\t\t}\n\t\t}\n\t\tlastProcessedMax = max + 1\n\t}\n\treturn false\n}", "func TestValidateMaxQueryLength(t *testing.T) {\n\tt.Parallel()\n\tctx := context.Background()\n\tnow := time.Now()\n\tfor _, tc := range []struct {\n\t\tname string\n\t\tstart time.Time\n\t\tend time.Time\n\t\texpectedStartMs int64\n\t\texpectedEndMs int64\n\t\tmaxQueryLength time.Duration\n\t\texceedQueryLength bool\n\t}{\n\t\t{\n\t\t\tname: \"normal params, not hit max query length\",\n\t\t\tstart: now.Add(-time.Hour),\n\t\t\tend: now,\n\t\t\texpectedStartMs: util.TimeToMillis(now.Add(-time.Hour)),\n\t\t\texpectedEndMs: util.TimeToMillis(now),\n\t\t\tmaxQueryLength: 24 * time.Hour,\n\t\t\texceedQueryLength: false,\n\t\t},\n\t\t{\n\t\t\tname: \"normal params, hit max query length\",\n\t\t\tstart: now.Add(-100 * time.Hour),\n\t\t\tend: now,\n\t\t\texpectedStartMs: util.TimeToMillis(now.Add(-100 * time.Hour)),\n\t\t\texpectedEndMs: util.TimeToMillis(now),\n\t\t\tmaxQueryLength: 24 * time.Hour,\n\t\t\texceedQueryLength: true,\n\t\t},\n\t\t{\n\t\t\tname: \"negative start\",\n\t\t\tstart: time.Unix(-1000, 0),\n\t\t\tend: now,\n\t\t\texpectedStartMs: 0,\n\t\t\texpectedEndMs: util.TimeToMillis(now),\n\t\t\tmaxQueryLength: 24 * time.Hour,\n\t\t\texceedQueryLength: true,\n\t\t},\n\t} {\n\t\tt.Run(tc.name, func(t *testing.T) {\n\t\t\t//parallel testing causes data race\n\t\t\tlimits := DefaultLimitsConfig()\n\t\t\toverrides, err := validation.NewOverrides(limits, nil)\n\t\t\trequire.NoError(t, err)\n\t\t\tstartMs, endMs, err := validateQueryTimeRange(ctx, \"test\", util.TimeToMillis(tc.start), util.TimeToMillis(tc.end), overrides, 0)\n\t\t\trequire.NoError(t, err)\n\t\t\tstartTime := model.Time(startMs)\n\t\t\tendTime := model.Time(endMs)\n\t\t\tif tc.maxQueryLength > 0 {\n\t\t\t\trequire.Equal(t, tc.exceedQueryLength, endTime.Sub(startTime) > tc.maxQueryLength)\n\t\t\t}\n\t\t})\n\t}\n}", "func areEnoughSeatsAvailable(table model.Table, newGuests int) (bool, error) {\n\tdb := database.Get()\n\n\t// Lets all reservations for our table\n\tvar existingTableReservations []model.Reservation\n\tresult := db.Where(\"table_id = ?\", table.ID).Find(&existingTableReservations)\n\tif result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {\n\t\treturn false, result.Error\n\t}\n\n\tseatsUsed := 0\n\tif len(existingTableReservations) > 0 {\n\t\tfor _, r := range existingTableReservations {\n\t\t\tseatsUsed = seatsUsed + r.AccompanyingGuests + 1 // Plus one to account the primary guest\n\t\t}\n\t}\n\tif (table.Seats - seatsUsed) >= newGuests {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (n *NodeBlockMaker) checkGoodTimeToMakeBlock() bool {\n\treturn true\n}", "func TestCheckBlockSanity(t *testing.T) {\n\tpocLimit := config.ChainParams.PocLimit\n\tblock, err := loadNthBlk(22)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tblk0, err := loadNthBlk(1)\n\tassert.Nil(t, err)\n\n\terr = CheckBlockSanity(block, blk0.MsgBlock().Header.ChainID, pocLimit)\n\tassert.Nil(t, err)\n\n\t// Ensure a block that has a timestamp with a precision higher than one\n\t// second fails.\n\ttimestamp := block.MsgBlock().Header.Timestamp\n\tblock.MsgBlock().Header.Timestamp = timestamp.Add(time.Nanosecond)\n\terr = CheckBlockSanity(block, blk0.MsgBlock().Header.ChainID, pocLimit)\n\tassert.Equal(t, ErrInvalidTime, err)\n}", "func (w *windowTransformation2) getWindowSpan(ts, indexes *array.Int, bound execute.Bounds, offset int) (start, stop int) {\n\t// Find the start offset that fits in this boundary.\n\tn := indexes.Len()\n\tfor ; offset < n; offset++ {\n\t\tt := ts.Value(int(indexes.Value(offset)))\n\t\tif values.Time(t) >= bound.Start {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Determine the stop offset.\n\tstop = offset + 1\n\tfor ; stop < n; stop++ {\n\t\tt := ts.Value(int(indexes.Value(stop)))\n\t\tif !bound.Contains(values.Time(t)) {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn offset, stop\n}", "func CheckSizeBlocks(start, end uint64) error {\n\ttxn := globalOpt.Txn(true)\n\tdefer txn.Commit()\n\n\tlist := make([]interface{}, 0, 64)\n\n\tit, err := txn.Get(TableBlockKey, HeightBlockKey)\n\tif err != nil {\n\t\ttxn.Abort()\n\t\treturn err\n\t}\n\tfor obj := it.Next(); obj != nil; obj = it.Next() {\n\t\tv, ok := obj.(*fabclient.MiddleCommonBlock)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tif v.Number < start || v.Number > end {\n\t\t\tlist = append(list, obj)\n\t\t}\n\t}\n\n\tfor _, one := range list {\n\t\terr = txn.Delete(TableBlockKey, one)\n\t\tif err != nil {\n\t\t\ttxn.Abort()\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func TestCheckSplitStopsTooManyInputs(t *testing.T) {\n\n\tdata := createStdTestData(20)\n\tsplit, _ := data.createTestTransactions()\n\n\tfor len(split.TxIn) < 30 {\n\t\tsplit.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, 0, nil))\n\t}\n\n\terr := data.checkSplit(split)\n\tif err == nil {\n\t\tt.Fatalf(\"a split with too many inputs should not be valid\")\n\t}\n}", "func assert_schedule_improved(w map[int]float64, final, init vrp.Allocation) bool {\n\treturn weighted_reward(w, final) >= weighted_reward(w, init)\n}", "func isSpan(n *html.Node) bool {\n\treturn n.Type == html.ElementNode && n.Data == \"span\"\n}", "func TestCheckBlockSanity(t *testing.T) {\n\tparams := chaincfg.RegNetParams()\n\ttimeSource := NewMedianTime()\n\tblock := dcrutil.NewBlock(&badBlock)\n\terr := CheckBlockSanity(block, timeSource, params)\n\tif err == nil {\n\t\tt.Fatalf(\"block should fail.\\n\")\n\t}\n}", "func (b *Board) IsValid(d int, s int, e int) bool { // s = start, e = end\n\tif (GetPieces(b.Turn, b.Bar) != 0) && (s >= 0) { // If trying to move from the bar, put a neg num as input\n\t\treturn false // Has pieces in the Bar but trying to move pieces not in the bar\n\t}\n\tabsChange := (e - s) * Dir(b.Turn)\n\tif absChange != d { // Handles Dice AND going counterclockwise/clockwise\n\t\treturn false\n\t}\n\tif GetPieces(!b.Turn, b.Tris[e]) >= 2 { // Spot is not open\n\t\treturn false\n\t}\n\tif GetPieces(b.Turn, b.Tris[s]) <= 0 { // No Pieces to move\n\t\treturn false\n\t}\n\tif GetPieces(!b.Turn, b.Tris[e]) == 1 { // Blot! - Increase in bar\n\t\tb.Tris[e] = SetPieces(!b.Turn, b.Tris[e], 0)\n\t\tb.Bar = SetPieces(!b.Turn, b.Bar, GetPieces(!b.Turn, b.Bar)+1)\n\t}\n\treturn true\n}", "func (r FieldRule) ValidateRangeStmt(expr *ast.RangeStmt) error {\n\tbatchError := pepperlint.NewBatchError()\n\n\t// TODO Also check if key or value is being assigned to a deprecated field\n\tswitch t := expr.X.(type) {\n\tcase *ast.SelectorExpr:\n\t\tif err := r.isDeprecatedField(t); err != nil {\n\t\t\tbatchError.Add(err)\n\t\t}\n\t}\n\n\treturn batchError.Return()\n}", "func (me *XsdGoPkgHasElems_TimeSpan) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_TimeSpan; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor _, x := range me.TimeSpans {\r\n\t\t\tif err = x.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (gdb *Gdb) checkTimeStampsInDb(itemName string, startTime, endTime int, sn *leveldb.Snapshot) error {\n\ts := itemName + joiner + strconv.Itoa(startTime)\n\te := itemName + joiner + strconv.Itoa(endTime)\n\tit := sn.NewIterator(&util.Range{Start: convertStringToByte(s), Limit: convertStringToByte(e)}, nil)\n\tdefer it.Release()\n\tif !it.First() {\n\t\treturn nil\n\t}\n\tif it.Value() != nil {\n\t\tst, _ := strconv.ParseInt(strings.Replace(string(it.Key()), itemName+joiner, \"\", -1), 10, 64)\n\t\tit.Last()\n\t\tet, _ := strconv.ParseInt(strings.Replace(string(it.Key()), itemName+joiner, \"\", -1), 10, 64)\n\t\treturn fmt.Errorf(\"time from \"+time.Unix(st, 0).Format(timeFormatString), \" to \"+time.Unix(et, 0).Format(timeFormatString)+\" has history data\")\n\t}\n\tfor it.Next() {\n\t\tif len(it.Value()) == 0 {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tst, _ := strconv.ParseInt(strings.Replace(string(it.Key()), itemName+joiner, \"\", -1), 10, 64)\n\t\t\tit.Last()\n\t\t\tet, _ := strconv.ParseInt(strings.Replace(string(it.Key()), itemName+joiner, \"\", -1), 10, 64)\n\t\t\treturn fmt.Errorf(\"time from \"+time.Unix(st, 0).Format(timeFormatString), \" to \"+time.Unix(et, 0).Format(timeFormatString)+\" has history data\")\n\t\t}\n\t}\n\treturn nil\n}", "func (s *State) InEvictedSlot(id models.BlockID) bool {\n\ts.evictionMutex.RLock()\n\tdefer s.evictionMutex.RUnlock()\n\n\treturn id.Index() <= s.lastEvictedSlot\n}", "func ValidateTrace(span *ssf.SSFSpan) error {\n\tif !ValidTrace(span) {\n\t\treturn &InvalidTrace{span}\n\t}\n\treturn nil\n}", "func (s *Service) SlotDuration(ctx context.Context) (time.Duration, error) {\n\tval, err := s.ChainSpecValue(ctx, \"SECONDS_PER_SLOT\")\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"failed to obtain SECONDS_PER_SLOT\")\n\t}\n\tspecVal, ok := val.(time.Duration)\n\tif !ok {\n\t\treturn 0, errors.New(\"invalid type for SECONDS_PER_SLOT\")\n\t}\n\treturn specVal, nil\n}", "func (dtk *DcmTagKey) IsPrivateReservation() bool {\n\treturn dtk.IsPrivate() && dtk.element >= 0x10 && dtk.element <= 0xFF\n}", "func IsValidHgt(val string) bool {\n\tif strings.HasSuffix(val, \"cm\") {\n\t\tcm, err := strconv.Atoi(strings.TrimSuffix(val, \"cm\"))\n\t\treturn err == nil && cm >= 150 && cm <= 193\n\t}\n\n\tif strings.HasSuffix(val, \"in\") {\n\t\tin, err := strconv.Atoi(strings.TrimSuffix(val, \"in\"))\n\t\treturn err == nil && in >= 59 && in <= 76\n\t}\n\n\treturn false\n}", "func CheckSizeInRange(buf []byte, min int, max int, descrip string) {\n\tif len(buf) < min || len(buf) > max {\n\t\tpanic(fmt.Sprintf(\"Incorrect %s buffer size, expected (%d - %d), got (%d).\", descrip, min, max, len(buf)))\n\t}\n}", "func TestValidateTimeRange(t *testing.T) {\n\tnow := time.Now()\n\thourAgo := now.Add(time.Hour * -1)\n\tfuture := now.Add(time.Hour)\n\n\ttests := []struct {\n\t\tname string\n\t\tstartTime time.Time\n\t\tendTime time.Time\n\t\topts []ValidateRangeOption\n\t\texpectedErr error\n\t}{\n\t\t{\n\t\t\tname: \"start before end\",\n\t\t\tstartTime: hourAgo,\n\t\t\tendTime: now,\n\t\t\texpectedErr: nil,\n\t\t},\n\t\t{\n\t\t\t// We allow equal ranges when we do not have an\n\t\t\t// additional check in place.\n\t\t\tname: \"start equals end\",\n\t\t\tstartTime: hourAgo,\n\t\t\tendTime: hourAgo,\n\t\t\texpectedErr: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"start equals end disallowed\",\n\t\t\tstartTime: hourAgo,\n\t\t\tendTime: hourAgo,\n\t\t\topts: []ValidateRangeOption{\n\t\t\t\tDisallowZeroRange,\n\t\t\t},\n\t\t\texpectedErr: errZeroRange,\n\t\t},\n\t\t{\n\t\t\tname: \"end before start\",\n\t\t\tstartTime: now,\n\t\t\tendTime: hourAgo,\n\t\t\texpectedErr: errEndBeforeStart,\n\t\t},\n\t\t{\n\t\t\t// Range in future is ok when we don't have another\n\t\t\t// check.\n\t\t\tname: \"range in future\",\n\t\t\tstartTime: now,\n\t\t\tendTime: future,\n\t\t\texpectedErr: nil,\n\t\t},\n\t\t{\n\t\t\tname: \"range in future disallowed\",\n\t\t\tstartTime: now,\n\t\t\tendTime: future,\n\t\t\topts: []ValidateRangeOption{\n\t\t\t\tDisallowFutureRange,\n\t\t\t},\n\t\t\texpectedErr: errFutureRange,\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\ttest := test\n\n\t\tt.Run(test.name, func(t *testing.T) {\n\t\t\tt.Parallel()\n\n\t\t\terr := ValidateTimeRange(\n\t\t\t\ttest.startTime, test.endTime, test.opts...,\n\t\t\t)\n\t\t\tif err != test.expectedErr {\n\t\t\t\tt.Fatalf(\"expected %v, got: %v\",\n\t\t\t\t\ttest.expectedErr, err)\n\t\t\t}\n\t\t})\n\t}\n}", "func (b *Balance) RangeCheck() int {\n\tvar check int\n\tif b.a0 < 0 {\n\t\tcheck = -1\n\t} else if b.a0 > MaxAtom {\n\t\tcheck = 1\n\t}\n\tif b.a1 < 0 {\n\t\tcheck += -2\n\t} else if b.a1 > MaxAtom {\n\t\tcheck += 2\n\t}\n\treturn check\n}", "func TestSelectVoterReasonableStakingPower(t *testing.T) {\n\t// Raise LoopCount to get smaller gap over 10000. But large LoopCount takes a lot of time\n\tconst LoopCount = 100\n\tfor minMaxRate := 1; minMaxRate <= 1000000; minMaxRate *= 100 {\n\t\tfindLargestStakingPowerGap(t, LoopCount, minMaxRate, 10)\n\t\tfindLargestStakingPowerGap(t, LoopCount, minMaxRate, 20)\n\t\tfindLargestStakingPowerGap(t, LoopCount, minMaxRate, 29)\n\t}\n}", "func checkIntervalIsSubset(toCheck []kv.KeyRange, subsetOf []kv.KeyRange) error {\n\ti := 0\n\tsi := 0\n\n\tfor {\n\t\t// We have checked all ranges.\n\t\tif si >= len(subsetOf) {\n\t\t\treturn nil\n\t\t}\n\t\t// There are some ranges doesn't reach the end.\n\t\tif i >= len(toCheck) {\n\t\t\treturn errors.Annotatef(berrors.ErrPiTRMalformedMetadata,\n\t\t\t\t\"there remains a range doesn't be fully consumed: %s\",\n\t\t\t\tlogutil.StringifyRange(subsetOf[si]))\n\t\t}\n\n\t\tchecking := toCheck[i]\n\t\tprobing := subsetOf[si]\n\t\t// checking: |___________|\n\t\t// probing: |_________|\n\t\t// A rare case: the \"first\" range is out of bound or not fully covers the probing range.\n\t\tif utils.CompareBytesExt(checking.StartKey, false, probing.StartKey, false) > 0 {\n\t\t\tholeEnd := checking.StartKey\n\t\t\tif utils.CompareBytesExt(holeEnd, false, probing.EndKey, true) > 0 {\n\t\t\t\tholeEnd = probing.EndKey\n\t\t\t}\n\t\t\treturn errors.Annotatef(berrors.ErrPiTRMalformedMetadata, \"probably a hole in key ranges: %s\", logutil.StringifyRange{\n\t\t\t\tStartKey: probing.StartKey,\n\t\t\t\tEndKey: holeEnd,\n\t\t\t})\n\t\t}\n\n\t\t// checking: |_____|\n\t\t// probing: |_______|\n\t\t// Just move forward checking.\n\t\tif utils.CompareBytesExt(checking.EndKey, true, probing.StartKey, false) < 0 {\n\t\t\ti += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// checking: |_________|\n\t\t// probing: |__________________|\n\t\t// Given all of the ranges are \"collapsed\", the next checking range must\n\t\t// not be adjacent with the current checking range.\n\t\t// And hence there must be a \"hole\" in the probing key space.\n\t\tif utils.CompareBytesExt(checking.EndKey, true, probing.EndKey, true) < 0 {\n\t\t\tnext := probing.EndKey\n\t\t\tif i+1 < len(toCheck) {\n\t\t\t\tnext = toCheck[i+1].EndKey\n\t\t\t}\n\t\t\treturn errors.Annotatef(berrors.ErrPiTRMalformedMetadata, \"probably a hole in key ranges: %s\", logutil.StringifyRange{\n\t\t\t\tStartKey: checking.EndKey,\n\t\t\t\tEndKey: next,\n\t\t\t})\n\t\t}\n\t\t// checking: |________________|\n\t\t// probing: |_____________|\n\t\t// The current checking range fills the current probing range,\n\t\t// or the current checking range is out of the current range.\n\t\t// let's move the probing forward.\n\t\tsi += 1\n\t}\n}", "func (buf *requestBuffer) evictSlot(pos uint16) error {\n\n\terr := buf.validatePos(pos)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq := buf.slots[pos]\n\tbuf.slots[pos] = nil\n\n\tif req != nil {\n\t\tbuf.empty_slots_pos <- pos\n\n\t\t//increase sequence\n\t\tif buf.sequences[pos]+1 > 65535 {\n\t\t\tbuf.sequences[pos] = 0\n\t\t} else {\n\t\t\tbuf.sequences[pos] = buf.sequences[pos] + 1\n\t\t}\n\n\t\tif buf.size-uint16(len(buf.empty_slots_pos)) <= buf.notify_threshold {\n\t\t\tif buf.notifych != nil {\n\t\t\t\tselect {\n\t\t\t\tcase buf.notifych <- true:\n\t\t\t\t\tbuf.logger.Debugf(\"buffer's occupied slots is below threshold %v, notify\", buf.notify_threshold)\n\t\t\t\tdefault:\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbuf.logger.Debugf(\"buffer's occupied slots is below threshold %v, no notify channel is specified though\", buf.notify_threshold)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n\n}", "func (li *gridLayoutItem) spannedHeight(info *gridLayoutItemInfo, heights []int) int {\n\tspacing := IntFrom96DPI(li.spacing96dpi, li.ctx.dpi)\n\n\tvar height int\n\n\tfor i := info.cell.row; i < info.cell.row+info.spanVert; i++ {\n\t\tif h := heights[i]; h > 0 {\n\t\t\theight += h\n\t\t\tif i > info.cell.row {\n\t\t\t\theight += spacing\n\t\t\t}\n\t\t}\n\t}\n\n\treturn height\n}", "func TestCheckForbidden(t *testing.T) {\n\terr := initDB()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tm, err := mysql.New(\"localhost\", port, \"root\", password, \"chaosmonkey\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tins, loc, appCfg := testSetup(t)\n\n\ttrm := c.Termination{Instance: ins, Time: time.Now(), Leashed: false}\n\n\t// First check should succeed\n\terr = m.Check(trm, appCfg, endHour, loc)\n\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Second check should fail\n\terr = m.Check(trm, appCfg, endHour, loc)\n\tif err == nil {\n\t\tt.Fatal(\"Check() succeeded when it should have failed\")\n\t}\n\n\tif _, ok := err.(c.ErrViolatesMinTime); !ok {\n\t\tt.Fatalf(\"Expected Err.ViolatesMinTime, got %v\", err)\n\t}\n}", "func overlapQuantBounds(amin, amax, bmin, bmax [3]uint16) bool {\n\toverlap := true\n\tif amin[0] > bmax[0] || amax[0] < bmin[0] {\n\t\toverlap = false\n\t}\n\tif amin[1] > bmax[1] || amax[1] < bmin[1] {\n\t\toverlap = false\n\t}\n\tif amin[2] > bmax[2] || amax[2] < bmin[2] {\n\t\toverlap = false\n\t}\n\treturn overlap\n}", "func checkPallocBits(t *testing.T, got, want *PallocBits) bool {\n\td := DiffPallocBits(got, want)\n\tif len(d) != 0 {\n\t\tt.Errorf(\"%d range(s) different\", len(d))\n\t\tfor _, bits := range d {\n\t\t\tt.Logf(\"\\t@ bit index %d\", bits.I)\n\t\t\tt.Logf(\"\\t| got: %s\", StringifyPallocBits(got, bits))\n\t\t\tt.Logf(\"\\t| want: %s\", StringifyPallocBits(want, bits))\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}", "func checkNodeMaxGap(n *gapnode) error {\n\tvar max int\n\tif !n.hasChildren {\n\t\tmax = n.calculateMaxGapLeaf()\n\t} else {\n\t\tfor i := 0; i <= n.nrSegments; i++ {\n\t\t\tchild := n.children[i]\n\t\t\tif err := checkNodeMaxGap(child); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif temp := child.maxGap.Get(); i == 0 || temp > max {\n\t\t\t\tmax = temp\n\t\t\t}\n\t\t}\n\t}\n\tif max != n.maxGap.Get() {\n\t\treturn fmt.Errorf(\"maxGap wrong in node\\n%vexpected: %d got: %d\", n, max, n.maxGap)\n\t}\n\treturn nil\n}", "func (c spanContext) IsValid() bool {\n\treturn c.TraceID != 0 && c.SpanID != 0\n}", "func checkRange(cells []Cell) (bool, error) {\n\tfull := true\n\tsize := len(cells)\n\tcounters := []int{0, 0}\n\n\tvar prevCell Cell\n\tvar prevCellCount int\n\n\tfor _, c := range cells {\n\t\tif !c.Defined {\n\t\t\tfull = false\n\t\t\tprevCell.Defined = false\n\t\t\tprevCellCount = 0\n\t\t\tcontinue\n\t\t}\n\t\tcounters[c.Value]++\n\t\tif prevCellCount == 0 {\n\t\t\tprevCellCount = 1\n\t\t} else {\n\t\t\tif c.Value == prevCell.Value {\n\t\t\t\tprevCellCount++\n\t\t\t\tif prevCellCount > 2 {\n\t\t\t\t\tv := c.Value\n\t\t\t\t\treturn full, validationError{\n\t\t\t\t\t\tErrorType: ErrorTooManyAdjacentValues,\n\t\t\t\t\t\tCellValue: &v,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tprevCellCount = 1\n\t\t\t}\n\n\t\t}\n\t\tprevCell = c\n\t}\n\tif counters[0] > size/2 {\n\t\tv := 0\n\t\treturn full, validationError{\n\t\t\tErrorType: ErrorTooManyValues,\n\t\t\tCellValue: &v,\n\t\t}\n\t}\n\tif counters[1] > size/2 {\n\t\tv := 1\n\t\treturn full, validationError{\n\t\t\tErrorType: ErrorTooManyValues,\n\t\t\tCellValue: &v,\n\t\t}\n\t}\n\treturn full, nil\n}", "func (r *Recorder) shouldFlushLocked(now time.Time) bool {\n\tif now.Add(minReportingPeriod).Sub(r.lastReportAttempt) > r.maxReportingPeriod {\n\t\t// Flush timeout.\n\t\tr.maybeLogInfof(\"--> timeout\")\n\t\treturn true\n\t} else if r.buffer.isHalfFull() {\n\t\t// Too many queued span records.\n\t\tr.maybeLogInfof(\"--> span queue\")\n\t\treturn true\n\t}\n\treturn false\n}", "func checkTimeRange(check time.Time) time.Time {\n\tend, _ := time.Parse(time.RFC3339, \"9000-01-02T15:04:05Z07:00\")\n\tif check.Before(end) {\n\t\treturn check\n\t} else {\n\t\treturn end\n\t}\n}", "func TestStraddleMinute(t *testing.T) {\n\tcd := NewCountData(5)\n\t// fill up to the allowed max\n\tfor j := 0; j <= 3; j++ {\n\t\tcd.ShouldBlock()\n\t}\n\ttime.Sleep(55)\n\tfor j := 0; j <= 3; j++ {\n\t\tif cd.ShouldBlock() {\n\t\t\tt.Log(\"straddle\", j)\n\t\t\tif j != 2 {\n\t\t\t\tt.Error(\"StraddleMinute - did not expected to be blocked yet\")\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(2)\n\t}\n}", "func (*NetworkInstance_Mpls_Global_ReservedLabelBlock_UpperBound_Union_Uint32) Is_NetworkInstance_Mpls_Global_ReservedLabelBlock_UpperBound_Union() {\n}", "func SlotIndex(slotEnd time.Time, step time.Duration, size int64) int64 {\n\treturn ((slotEnd.UnixNano() / 1e6) / (step.Nanoseconds() / 1e6)) % size\n}", "func (c SpanContext) IsValid() bool {\n\treturn c.traceID.IsValid() && c.spanID != 0\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 (me Tokens) AreEnclosing(pos0ByteOffset int) bool {\n\tif len(me) > 0 {\n\t\treturn me[0].Pos.Off0 <= pos0ByteOffset && pos0ByteOffset <= (me[len(me)-1].Pos.Off0+len(me[len(me)-1].Lexeme))\n\t}\n\treturn false\n}", "func (h *Checkpoints) ConsistencyCheck(rangesIn []kv.KeyRange) error {\n\th.mu.Lock()\n\trangesReal := make([]kv.KeyRange, 0, 1024)\n\th.tree.Ascend(func(i btree.Item) bool {\n\t\trangesReal = append(rangesReal, i.(*RangesSharesTS).Ranges...)\n\t\treturn true\n\t})\n\th.mu.Unlock()\n\n\tr := CollapseRanges(len(rangesReal), func(i int) kv.KeyRange { return rangesReal[i] })\n\tri := CollapseRanges(len(rangesIn), func(i int) kv.KeyRange { return rangesIn[i] })\n\n\treturn errors.Annotatef(checkIntervalIsSubset(r, ri), \"ranges: (current) %s (not in) %s\", logutil.StringifyKeys(r),\n\t\tlogutil.StringifyKeys(ri))\n}", "func (pool *TxPool) isBadSeq(seq *tx_types.Sequencer) error {\n\t// check if the nonce is duplicate\n\tseqindag := pool.dag.GetTxByNonce(seq.Sender(), seq.GetNonce())\n\tif seqindag != nil {\n\t\treturn fmt.Errorf(\"bad seq,duplicate nonce %d found in dag, existing %s \", seq.GetNonce(), seqindag)\n\t}\n\tif pool.dag.LatestSequencer().Height+1 != seq.Height {\n\t\treturn fmt.Errorf(\"bad seq hieght mismatch height %d old_height %d\", seq.Height, pool.dag.latestSequencer.Height)\n\t}\n\treturn nil\n}", "func boundariesNegativeTest(t *testing.T) {\n\n\tresult := newFooter(1, 15, 1, -1).List\n\texpected := []string{}\n\tfor i := 0; i < len(expected); i++ {\n\t\tif result[i] != expected[i] {\n\t\t\tt.Error()\n\t\t}\n\t}\n\n}", "func (o *StorageEnclosure) HasNumSlots() bool {\n\tif o != nil && o.NumSlots != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func HeightSanityCheck(blockNumber *big.Int, heightDeployed int64) bool {\n\treturn (blockNumber.Cmp(big.NewInt(heightDeployed)) >= 0)\n}", "func checkInterval(t *testing.T, desiredPrefix string, keySize int, networkName string, magic [2]byte) {\n\t// min and max possible keys\n\t// all zeroes\n\tminKey := bytes.Repeat([]byte{0x00}, keySize)\n\t// all ones\n\tmaxKey := bytes.Repeat([]byte{0xff}, keySize)\n\n\tbase58interval := [2]string{\n\t\tbase58.CheckEncode(minKey, magic),\n\t\tbase58.CheckEncode(maxKey, magic),\n\t}\n\tcheckPrefix(t, desiredPrefix, base58interval[0], networkName)\n\tcheckPrefix(t, desiredPrefix, base58interval[1], networkName)\n}", "func LimitsTimeoutValidation(timeout *int) bool {\n\tif timeout == nil {\n\t\treturn true\n\t}\n\tif *timeout < 100 || *timeout > 300000 {\n\t\twskprint.PrintlnOpenWhiskWarning(wski18n.T(wski18n.ID_WARN_LIMITS_TIMEOUT))\n\t\treturn false\n\t}\n\treturn true\n}", "func TestBaseGradedBlock_Invalid(t *testing.T) {\n\tt.Run(\"V1\", func(t *testing.T) {\n\t\ttestBaseGradedBlock_Invalid(t, 1)\n\t})\n\tt.Run(\"V2\", func(t *testing.T) {\n\t\ttestBaseGradedBlock_Invalid(t, 2)\n\t})\n\tt.Run(\"V3\", func(t *testing.T) {\n\t\ttestBaseGradedBlock_Invalid(t, 3)\n\t})\n\tt.Run(\"V4\", func(t *testing.T) {\n\t\ttestBaseGradedBlock_Invalid(t, 4)\n\t})\n\tt.Run(\"V5\", func(t *testing.T) {\n\t\ttestBaseGradedBlock_Invalid(t, 5)\n\t})\n}", "func (d *Dao) IdleSlots(ctx context.Context, count int) (slots []int64, err error) {\n\trows, err := d.db.Query(ctx, _getIdelSlots, count)\n\tif err != nil {\n\t\tlog.Error(\"db.Query(%s) args(%d) error(%v)\", _getIdelSlots, count, err)\n\t\treturn\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar slot int64\n\t\tif err = rows.Scan(&slot); err != nil {\n\t\t\tlog.Error(\"rows.Scan() error(%v)\", err)\n\t\t\treturn\n\t\t}\n\t\tslots = append(slots, slot)\n\t}\n\t// 槽位不够新创建实验组\n\tif len(slots) < count {\n\t\tslots = nil\n\t\terr = errors.New(\"out of slot\")\n\t\treturn\n\t}\n\tif err = rows.Err(); err != nil {\n\t\tlog.Error(\"rows.Err() error(%v)\", err)\n\t}\n\treturn\n}", "func (v *Verifier) isSpent(spentKey string, simulator ledger.LedgerReader) (bool, error) {\n\tverifierLogger.Debugf(\"checking if input with ID '%s' has been spent\", spentKey)\n\tresult, err := simulator.GetState(tokenNameSpace, spentKey)\n\treturn result != nil, err\n}", "func isBalanceEnough(nam string, qty float64) bool {\n\tvar balanceQty float64\n\tfor n := 0; n < len(ds.Items); n++ {\n\t\tif nam == ds.Items[n].Name {\n\t\t\tbalanceQty = ds.Items[n].WeeklyCapacity - ds.Items[n].WeeklyOrder\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif qty <= balanceQty {\n\t\treturn true\n\t}\n\treturn false\n}", "func GeneralCheckSlotbacay(models *Models, data map[string]interface{}, playerId int64) (\n\t*slotbacay.SlotbacayGame, *player.Player, error) {\n\n\tgameCode := slotbacay.SLOTBACAY_GAME_CODE\n\tcurrencyType := utils.GetStringAtPath(data, \"currency_type\")\n\tcurrencyType = currency.Money\n\n\tgameInstance := models.GetGameMini(gameCode, currencyType)\n\tif gameInstance == nil {\n\t\treturn nil, nil, errors.New(\"err:invalid_currency_type\")\n\t}\n\tslotbacayGame, isOk := gameInstance.(*slotbacay.SlotbacayGame)\n\tif !isOk {\n\t\treturn nil, nil, errors.New(\"err:cant_happen\")\n\t}\n\tplayer, err := models.GetPlayer(playerId)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treturn slotbacayGame, player, nil\n}", "func (h *InterfaceVppHandler) DumpSpan() ([]*vppcalls.InterfaceSpanDetails, error) {\n\tvar spans []*vppcalls.InterfaceSpanDetails\n\n\tisL2Spans, err := h.dumpSpan(&vpp_span.SwInterfaceSpanDump{IsL2: 1})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tspans = append(spans, isL2Spans...)\n\n\tisNotL2Spans, err := h.dumpSpan(&vpp_span.SwInterfaceSpanDump{IsL2: 0})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tspans = append(spans, isNotL2Spans...)\n\n\treturn spans, nil\n}", "func (k Keeper) IsProofSessionHeightWithinTolerance(ctx sdk.Ctx, relaySessionBlockHeight int64) bool {\n\t// Session block height can never be zero.\n\tif relaySessionBlockHeight <= 0 {\n\t\treturn false\n\t}\n\tlatestSessionHeight := k.GetLatestSessionBlockHeight(ctx)\n\ttolerance := types.GlobalPocketConfig.ClientSessionSyncAllowance * k.posKeeper.BlocksPerSession(ctx)\n\tminHeight := latestSessionHeight - tolerance\n\treturn sdk.IsBetween(relaySessionBlockHeight, minHeight, latestSessionHeight)\n}", "func checkTimeValid(id ulid.ULID) error {\n\tcurTime := time.Now()\n\ttime2 := time.Unix(int64(id.Time()), 0)\n\n\tif uint64(curTime.Sub(time2).Minutes()) > WORKERIDEXPIRE {\n\t\treturn fmt.Errorf(fmt.Sprintf(\"time has lapsed, diff=%v\", curTime.Sub(time2).Seconds()))\n\t}\n\treturn nil\n}", "func (wm *WalletManager) checkTimeout() {\n\tif wm.timeOut != tstampMax {\n\t\tnow := time.Now()\n\t\tif exp := now.After(wm.timeOutTime); exp {\n\t\t\t// lockAll()\n\t\t\tlog.Debug(\"wallet has been locked,please unlock firstly\") //TODO\n\t\t}\n\t\twm.timeOutTime = now.Add(wm.timeOut)\n\t}\n}", "func verifyPointerCaptureBounds(ctx context.Context, s *testing.State, t pointerCaptureSubtestState) {\n\tdelta := coords.NewPoint(-100, -100)\n\n\tfor i := 0; i < 20; i++ {\n\t\tif err := ensureRelativeMovement(ctx, t, delta); err != nil {\n\t\t\ts.Fatal(\"Failed to verify relative movement: \", err)\n\t\t}\n\t}\n}", "func checkSetMaxGap(s *gapSet) error {\n\tn := s.root\n\treturn checkNodeMaxGap(&n)\n}", "func TestAdvanceTimeTxRemoveSubnetValidator(t *testing.T) {\n\trequire := require.New(t)\n\tenv := newEnvironment(t, false /*=postBanff*/, false /*=postCortina*/)\n\tenv.ctx.Lock.Lock()\n\tdefer func() {\n\t\trequire.NoError(shutdownEnvironment(env))\n\t}()\n\n\tsubnetID := testSubnet1.ID()\n\tenv.config.TrackedSubnets.Add(subnetID)\n\tenv.config.Validators.Add(subnetID, validators.NewSet())\n\n\tdummyHeight := uint64(1)\n\t// Add a subnet validator to the staker set\n\tsubnetValidatorNodeID := ids.NodeID(preFundedKeys[0].PublicKey().Address())\n\t// Starts after the corre\n\tsubnetVdr1StartTime := defaultValidateStartTime\n\tsubnetVdr1EndTime := defaultValidateStartTime.Add(defaultMinStakingDuration)\n\ttx, err := env.txBuilder.NewAddSubnetValidatorTx(\n\t\t1, // Weight\n\t\tuint64(subnetVdr1StartTime.Unix()), // Start time\n\t\tuint64(subnetVdr1EndTime.Unix()), // end time\n\t\tsubnetValidatorNodeID, // Node ID\n\t\tsubnetID, // Subnet ID\n\t\t[]*secp256k1.PrivateKey{preFundedKeys[0], preFundedKeys[1]},\n\t\tids.ShortEmpty,\n\t)\n\trequire.NoError(err)\n\n\tstaker, err := state.NewCurrentStaker(\n\t\ttx.ID(),\n\t\ttx.Unsigned.(*txs.AddSubnetValidatorTx),\n\t\t0,\n\t)\n\trequire.NoError(err)\n\n\tenv.state.PutCurrentValidator(staker)\n\tenv.state.AddTx(tx, status.Committed)\n\tenv.state.SetHeight(dummyHeight)\n\trequire.NoError(env.state.Commit())\n\n\t// The above validator is now part of the staking set\n\n\t// Queue a staker that joins the staker set after the above validator leaves\n\tsubnetVdr2NodeID := ids.NodeID(preFundedKeys[1].PublicKey().Address())\n\ttx, err = env.txBuilder.NewAddSubnetValidatorTx(\n\t\t1, // Weight\n\t\tuint64(subnetVdr1EndTime.Add(time.Second).Unix()), // Start time\n\t\tuint64(subnetVdr1EndTime.Add(time.Second).Add(defaultMinStakingDuration).Unix()), // end time\n\t\tsubnetVdr2NodeID, // Node ID\n\t\tsubnetID, // Subnet ID\n\t\t[]*secp256k1.PrivateKey{preFundedKeys[0], preFundedKeys[1]}, // Keys\n\t\tids.ShortEmpty, // reward address\n\t)\n\trequire.NoError(err)\n\n\tstaker, err = state.NewPendingStaker(\n\t\ttx.ID(),\n\t\ttx.Unsigned.(*txs.AddSubnetValidatorTx),\n\t)\n\trequire.NoError(err)\n\n\tenv.state.PutPendingValidator(staker)\n\tenv.state.AddTx(tx, status.Committed)\n\tenv.state.SetHeight(dummyHeight)\n\trequire.NoError(env.state.Commit())\n\n\t// The above validator is now in the pending staker set\n\n\t// Advance time to the first staker's end time.\n\tenv.clk.Set(subnetVdr1EndTime)\n\ttx, err = env.txBuilder.NewAdvanceTimeTx(subnetVdr1EndTime)\n\trequire.NoError(err)\n\n\tonCommitState, err := state.NewDiff(lastAcceptedID, env)\n\trequire.NoError(err)\n\n\tonAbortState, err := state.NewDiff(lastAcceptedID, env)\n\trequire.NoError(err)\n\n\texecutor := ProposalTxExecutor{\n\t\tOnCommitState: onCommitState,\n\t\tOnAbortState: onAbortState,\n\t\tBackend: &env.backend,\n\t\tTx: tx,\n\t}\n\trequire.NoError(tx.Unsigned.Visit(&executor))\n\n\t_, err = executor.OnCommitState.GetCurrentValidator(subnetID, subnetValidatorNodeID)\n\trequire.ErrorIs(err, database.ErrNotFound)\n\n\t// Check VM Validators are removed successfully\n\trequire.NoError(executor.OnCommitState.Apply(env.state))\n\n\tenv.state.SetHeight(dummyHeight)\n\trequire.NoError(env.state.Commit())\n\trequire.False(validators.Contains(env.config.Validators, subnetID, subnetVdr2NodeID))\n\trequire.False(validators.Contains(env.config.Validators, subnetID, subnetValidatorNodeID))\n}", "func CheckTime(liveHours string) {\n\tif liveHours != \"\" {\n\t\tallowedTime := strings.Split(liveHours, \"-\")\n\t\tstartTime := strings.Split(allowedTime[0], \":\")\n\t\tendTime := strings.Split(allowedTime[1], \":\")\n\t\tcurrent := time.Now()\n\t\tstartHour, _ := strconv.Atoi(startTime[0])\n\t\tstartMin, _ := strconv.Atoi(startTime[1])\n\t\tendHour, _ := strconv.Atoi(endTime[0])\n\t\tendMin, _ := strconv.Atoi(endTime[1])\n\t\tstart := time.Date(current.Year(), current.Month(), current.Day(), startHour, startMin, current.Second(), current.Nanosecond(), current.Location())\n\t\tend := time.Date(current.Year(), current.Month(), current.Day(), endHour, endMin, current.Second(), current.Nanosecond(), current.Location())\n\t\tif current.After(start) && current.Before(end) {\n\t\t\treturn\n\t\t} else {\n\t\t\ttime.Sleep(start.Sub(current))\n\t\t\treturn\n\t\t}\n\t}\n}" ]
[ "0.5193167", "0.4879843", "0.48535728", "0.48291674", "0.48017627", "0.47425237", "0.4740814", "0.47318655", "0.4716447", "0.47095585", "0.44937378", "0.44892377", "0.44621602", "0.44400433", "0.44194394", "0.43774757", "0.43323845", "0.4319009", "0.43089962", "0.43024915", "0.4279676", "0.42578223", "0.42555222", "0.42480654", "0.42297783", "0.4189873", "0.41882107", "0.41774064", "0.41535214", "0.41445744", "0.41351783", "0.41159514", "0.41021413", "0.40937656", "0.4077943", "0.4072621", "0.40699434", "0.40553847", "0.40511122", "0.4018785", "0.40109405", "0.40046218", "0.39917532", "0.39731854", "0.39594454", "0.39576024", "0.39543155", "0.39539212", "0.39512584", "0.39434266", "0.39405924", "0.39392892", "0.3930958", "0.3923623", "0.39194807", "0.3918978", "0.39058453", "0.39031976", "0.38966104", "0.3895657", "0.38949534", "0.38887635", "0.38845518", "0.38820806", "0.38639593", "0.38621512", "0.38606852", "0.38596448", "0.38575786", "0.38545838", "0.38421535", "0.38309154", "0.38305002", "0.38208157", "0.3818982", "0.38142645", "0.38108942", "0.38105467", "0.3797462", "0.37942117", "0.3793242", "0.37925774", "0.3788487", "0.37871346", "0.37826884", "0.3777277", "0.37763453", "0.3764703", "0.37646228", "0.3764214", "0.37478903", "0.37468842", "0.37460718", "0.37455553", "0.37454668", "0.37397245", "0.37351006", "0.37295187", "0.37245622", "0.3712798" ]
0.8348721
0
Status checks the status of the service.
func (c *Client) Status() error { client, err := c.client(false) if err != nil { return err } rel, err := url.Parse("status") if err != nil { // This indicates a programming error. panic(err) } resp, err := client.Get(c.baseURL.ResolveReference(rel).String()) if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != http.StatusNoContent { return ErrInvalidServiceBehavior } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Reconciler) CheckServiceStatus(srv *corev1.Service, status *nbv1.ServiceStatus, portName string) {\n\n\tlog := r.Logger.WithField(\"func\", \"CheckServiceStatus\").WithField(\"service\", srv.Name)\n\t*status = nbv1.ServiceStatus{}\n\tservicePort := nb.FindPortByName(srv, portName)\n\tproto := \"http\"\n\tif strings.HasSuffix(portName, \"https\") {\n\t\tproto = \"https\"\n\t}\n\n\t// Node IP:Port\n\t// Pod IP:Port\n\tpods := corev1.PodList{}\n\tpodsListOptions := &client.ListOptions{\n\t\tNamespace: r.Request.Namespace,\n\t\tLabelSelector: labels.SelectorFromSet(srv.Spec.Selector),\n\t}\n\terr := r.Client.List(r.Ctx, podsListOptions, &pods)\n\tif err == nil {\n\t\tfor _, pod := range pods.Items {\n\t\t\tif pod.Status.Phase == corev1.PodRunning {\n\t\t\t\tif pod.Status.HostIP != \"\" {\n\t\t\t\t\tstatus.NodePorts = append(\n\t\t\t\t\t\tstatus.NodePorts,\n\t\t\t\t\t\tfmt.Sprintf(\"%s://%s:%d\", proto, pod.Status.HostIP, servicePort.NodePort),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif pod.Status.PodIP != \"\" {\n\t\t\t\t\tstatus.PodPorts = append(\n\t\t\t\t\t\tstatus.PodPorts,\n\t\t\t\t\t\tfmt.Sprintf(\"%s://%s:%s\", proto, pod.Status.PodIP, servicePort.TargetPort.String()),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Cluster IP:Port (of the service)\n\tif srv.Spec.ClusterIP != \"\" {\n\t\tstatus.InternalIP = append(\n\t\t\tstatus.InternalIP,\n\t\t\tfmt.Sprintf(\"%s://%s:%d\", proto, srv.Spec.ClusterIP, servicePort.Port),\n\t\t)\n\t\tstatus.InternalDNS = append(\n\t\t\tstatus.InternalDNS,\n\t\t\tfmt.Sprintf(\"%s://%s.%s:%d\", proto, srv.Name, srv.Namespace, servicePort.Port),\n\t\t)\n\t}\n\n\t// LoadBalancer IP:Port (of the service)\n\tif srv.Status.LoadBalancer.Ingress != nil {\n\t\tfor _, lb := range srv.Status.LoadBalancer.Ingress {\n\t\t\tif lb.IP != \"\" {\n\t\t\t\tstatus.ExternalIP = append(\n\t\t\t\t\tstatus.ExternalIP,\n\t\t\t\t\tfmt.Sprintf(\"%s://%s:%d\", proto, lb.IP, servicePort.Port),\n\t\t\t\t)\n\t\t\t}\n\t\t\tif lb.Hostname != \"\" {\n\t\t\t\tstatus.ExternalDNS = append(\n\t\t\t\t\tstatus.ExternalDNS,\n\t\t\t\t\tfmt.Sprintf(\"%s://%s:%d\", proto, lb.Hostname, servicePort.Port),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t// External IP:Port (of the service)\n\tif srv.Spec.ExternalIPs != nil {\n\t\tfor _, ip := range srv.Spec.ExternalIPs {\n\t\t\tstatus.ExternalIP = append(\n\t\t\t\tstatus.ExternalIP,\n\t\t\t\tfmt.Sprintf(\"%s://%s:%d\", proto, ip, servicePort.Port),\n\t\t\t)\n\t\t}\n\t}\n\n\tlog.Infof(\"Collected addresses: %+v\", status)\n}", "func (client *Client) ServiceStatus(request *ServiceStatusRequest) (response *ServiceStatusResponse, err error) {\nresponse = CreateServiceStatusResponse()\nerr = client.DoAction(request, response)\nreturn\n}", "func Example_checkStatus() {\n\t//Create client.\n\tc := APIClient{\n\t\tClient: client.New(\n\t\t\tfunc(c *client.Client) {\n\t\t\t\tc.User = \"myusername\"\n\t\t\t\tc.Password = \"mypassword\"\n\t\t\t},\n\t\t),\n\t\tBaseUrl: \"https://url.to.publit\",\n\t}\n\n\t// Check if service is up.\n\tok := c.StatusCheck()\n\n\tif !ok {\n\t\tlog.Fatal(\"Service is not up.\")\n\t}\n\n\tlog.Println(\"Service is up!\")\n\n\t// Do something\n}", "func (s *Service) CheckStatus() bool {\n\t_, err := exec.Command(SERVICE, s.name, STATUS).Output()\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func CheckService(client *nomad.Client, opts *CheckServiceOpts) Status {\n\tjobInfo, _, err := client.Jobs().Info(opts.Job, &nomad.QueryOptions{})\n\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"404\") {\n\t\t\tprintln(\"job '\", opts.Job, \"' not found\")\n\t\t\treturn CRITICAL\n\t\t}\n\n\t\tprintln(err.Error())\n\t\treturn UNKNOWN\n\t}\n\n\tsummary, _, _ := client.Jobs().Summary(*jobInfo.ID, nil)\n\tdeployment, _, _ := client.Jobs().LatestDeployment(*jobInfo.ID, &nomad.QueryOptions{})\n\n\tif deployment == nil {\n\t\tdeployment = &nomad.Deployment{}\n\t}\n\n\tstatus := OK\n\tprintln(\"status=\" + *jobInfo.Status)\n\n\tif *jobInfo.Status != \"running\" {\n\t\tstatus = CRITICAL\n\t}\n\n\tif *jobInfo.Type != opts.Type {\n\t\tprintln(\"type is not '\" + opts.Type + \"'\")\n\t\tstatus = CRITICAL\n\t}\n\n\tfor key, value := range deployment.TaskGroups {\n\t\trunning := summary.Summary[key].Running\n\t\tdesired := value.DesiredTotal\n\n\t\tif running < desired {\n\t\t\tprintln(key+\".summary.running=\"+strconv.Itoa(running), \"<\", key+\".desiredTotal=\"+strconv.Itoa(desired))\n\t\t\tstatus = CRITICAL\n\t\t} else {\n\t\t\tprintln(key+\".summary.running=\"+strconv.Itoa(running), \">=\", key+\".desiredTotal=\"+strconv.Itoa(desired))\n\t\t}\n\n\t}\n\n\tprintln(createJobLink(client.Address(), *jobInfo.ID))\n\tfor key, value := range jobInfo.Meta {\n\t\tif strings.HasPrefix(key, \"OWNER\") {\n\t\t\tprintln(\"owner=\" + value)\n\t\t}\n\t}\n\n\treturn status\n}", "func (dateService) Status(ctx context.Context) (string, error) {\n\treturn \"ok\", nil\n}", "func ServiceStatus(serviceName string) string {\n\treturn \"\"\n}", "func (fsm *DeployFSMContext) checkServiceReady() (bool, error) {\n\truntime := fsm.Runtime\n\t// do not check if nil for compatibility\n\tif fsm.Deployment.Extra.ServicePhaseStartAt != nil {\n\t\tstartCheckPoint := fsm.Deployment.Extra.ServicePhaseStartAt.Add(30 * time.Second)\n\t\tif time.Now().Before(startCheckPoint) {\n\t\t\tfsm.pushLog(fmt.Sprintf(\"checking too early, delay to: %s\", startCheckPoint.String()))\n\t\t\t// too early to check\n\t\t\treturn false, nil\n\t\t}\n\t}\n\tisReplicasZero := false\n\tfor _, s := range fsm.Spec.Services {\n\t\tif s.Deployments.Replicas == 0 {\n\t\t\tisReplicasZero = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif isReplicasZero {\n\t\tfsm.pushLog(\"checking status by inspect\")\n\t\t// we do double check to prevent `fake Healthy`\n\t\t// runtime.ScheduleName must have\n\t\tsg, err := fsm.getServiceGroup()\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn sg.Status == \"Ready\" || sg.Status == \"Healthy\", nil\n\t}\n\n\t// 获取addon状态\n\tserviceGroup, err := fsm.getServiceGroup()\n\tif err != nil {\n\t\tfsm.pushLog(fmt.Sprintf(\"获取service状态失败,%s\", err.Error()))\n\t\treturn false, nil\n\t}\n\tfsm.pushLog(fmt.Sprintf(\"checking status: %s, servicegroup: %v\", serviceGroup.Status, runtime.ScheduleName))\n\t// 如果状态是failed,说明服务或者job运行失败\n\tif serviceGroup.Status == apistructs.StatusFailed {\n\t\treturn false, errors.New(serviceGroup.LastMessage)\n\t}\n\t// 如果状态是ready或者healthy,说明服务已经发起来了\n\truntimeStatus := apistructs.RuntimeStatusUnHealthy\n\tif serviceGroup.Status == apistructs.StatusReady || serviceGroup.Status == apistructs.StatusHealthy {\n\t\truntimeStatus = apistructs.RuntimeStatusHealthy\n\t}\n\truntimeItem := fsm.Runtime\n\tif runtimeItem.Status != runtimeStatus {\n\t\truntimeItem.Status = runtimeStatus\n\t\tif err := fsm.db.UpdateRuntime(runtime); err != nil {\n\t\t\tlogrus.Errorf(\"failed to update runtime status changed, runtime: %v, err: %v\", runtime.ID, err.Error())\n\t\t\treturn false, nil\n\t\t}\n\t}\n\tif runtimeStatus == apistructs.RuntimeStatusHealthy {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (ac *ApiConfig) CheckStatus(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodGet {\n\t\thttp.Error(w, r.Method+\" is not available\", http.StatusInternalServerError)\n\t\tzerolog.Error().Msg(r.Method + \" is not available\")\n\t\treturn\n\t}\n\n\tstat := &models.StatusIdentifier{\n\t\tOk: true,\n\t\tMessage: \"Everything is alright\",\n\t}\n\n\terr := dResponseWriter(w, stat, http.StatusOK)\n\tif err != nil {\n\t\tzerolog.Error().Msg(err.Error())\n\t\treturn\n\t}\n\n\treturn\n}", "func (s *SystemService) Status() (status *ServiceStatus, err error) {\n\tname := s.Command.Name\n\tstatus = &ServiceStatus{}\n\n\tlogger.Log(\"connecting to service manager: \", name)\n\n\t// Connect to Windows service manager\n\tm, err := mgr.Connect()\n\tif err != nil {\n\t\tlogger.Log(\"error connecting to service manager: \", err)\n\t\treturn status, fmt.Errorf(\"could not connect to service manager: %v\", err)\n\t}\n\tdefer m.Disconnect()\n\n\tlogger.Log(\"opening system service\")\n\n\t// Open the service so we can manage it\n\tsrv, err := m.OpenService(name)\n\tif err != nil {\n\t\tlogger.Log(\"error opening service: \", err)\n\t\treturn status, fmt.Errorf(\"could not access service: %v\", err)\n\t}\n\tdefer srv.Close()\n\n\tstat, err := srv.Query()\n\tif err != nil {\n\t\tlogger.Log(\"error getting service status: \", err)\n\t\treturn status, fmt.Errorf(\"could not get service status: %v\", err)\n\t}\n\n\tlogger.Logf(\"service status: %#v\", stat)\n\n\tstatus.PID = int(stat.ProcessId)\n\tstatus.Running = stat.State == svc.Running\n\treturn status, nil\n}", "func (c *Client) Status(ctx context.Context) error {\n\treturn c.PingContext(ctx)\n}", "func (c *QueueController) checkAndUpdateServiceHealth(exitCode errors.ExitCode) {\n\tvar svcStatusErr error\n\tmarkUnhealthy := false\n\tif c.isCriticalError(exitCode) {\n\t\tsvcStatusErr = fmt.Errorf(\"critical error (%d) occurred. Marking worker unhealthy\", exitCode)\n\t\tmarkUnhealthy = true\n\t}\n\tif c.isPersistentError(exitCode) {\n\t\tsvcStatusErr = fmt.Errorf(\"errors (%d) occurred multiple times in a row. Marking worker unhealthy\", exitCode)\n\t\tmarkUnhealthy = true\n\t}\n\tif markUnhealthy {\n\t\tsvcStatus := c.statusManager.svcStatus\n\t\tsvcStatus.IsHealthy = false\n\t\tsvcStatus.Error = svcStatusErr\n\t\tc.statusManager.UpdateService(svcStatus)\n\t\tc.inv.stat.Gauge(stats.WorkerUnhealthy).Update(1)\n\t}\n}", "func (s *Server) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {\n\tresp := &grpc_health_v1.HealthCheckResponse{}\n\tif len(in.Service) == 0 || in.Service == serviceName {\n\t\tresp.Status = grpc_health_v1.HealthCheckResponse_SERVING\n\t}\n\treturn resp, nil\n}", "func Status() error {\n\treturn err\n}", "func getServiceCheckStatus(state string, mapping map[string]string) servicecheck.ServiceCheckStatus {\n\tswitch mapping[state] {\n\tcase \"ok\":\n\t\treturn servicecheck.ServiceCheckOK\n\tcase \"warning\":\n\t\treturn servicecheck.ServiceCheckWarning\n\tcase \"critical\":\n\t\treturn servicecheck.ServiceCheckCritical\n\t}\n\treturn servicecheck.ServiceCheckUnknown\n}", "func (s *Shell) Status(_ *cli.Context) error {\n\tresp, err := s.HTTP.Get(\"/health?full=1\", nil)\n\tif err != nil {\n\t\treturn s.errorOut(err)\n\t}\n\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil {\n\t\t\terr = multierr.Append(err, cerr)\n\t\t}\n\t}()\n\n\treturn s.renderAPIResponse(resp, &HealthCheckPresenters{})\n}", "func (s *taskService) checkBasicStatus(c context.Context, date time.Time) (ok bool, err error) {\n\treturn s.dp.SendBasicDataRequest(c, fmt.Sprintf(\"{\\\"select\\\": [], \\\"where\\\":{\\\"job_name\\\":{\\\"in\\\":[\\\"ucs_%s\\\"]}}}\", date.Format(\"20060102\")))\n}", "func (_SmartTgStats *SmartTgStatsCaller) Status(opts *bind.CallOpts) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _SmartTgStats.contract.Call(opts, out, \"status\")\n\treturn *ret0, err\n}", "func checkStatus() error {\n\tif kvstoreEnabled() {\n\t\tif client := kvstore.Client(); client == nil {\n\t\t\treturn fmt.Errorf(\"kvstore client not configured\")\n\t\t} else if _, err := client.Status(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif _, err := k8s.Client().Discovery().ServerVersion(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (f *FakeTunnel) CheckStatus() error {\n\treturn nil\n}", "func (avisess *AviSession) CheckControllerStatus() (bool, *http.Response, error) {\n\turl := avisess.prefix + \"/api/cluster/status\"\n\tvar isControllerUp bool\n\tfor round := 0; round < avisess.ctrlStatusCheckRetryCount; round++ {\n\t\tcheckReq, err := http.NewRequest(\"GET\", url, nil)\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"CheckControllerStatus Error %v while generating http request.\", err)\n\t\t\treturn false, nil, err\n\t\t}\n\t\t//Getting response from controller's API\n\t\tif stateResp, err := avisess.client.Do(checkReq); err == nil {\n\t\t\tdefer stateResp.Body.Close()\n\t\t\t//Checking controller response\n\t\t\tif stateResp.StatusCode != 503 && stateResp.StatusCode != 502 && stateResp.StatusCode != 500 {\n\t\t\t\tisControllerUp = true\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tglog.Infof(\"CheckControllerStatus Error while generating http request %d %v\",\n\t\t\t\t\tstateResp.StatusCode, err)\n\t\t\t}\n\t\t} else {\n\t\t\tglog.Errorf(\"CheckControllerStatus Error while generating http request %v %v\", url, err)\n\t\t}\n\t\t// if controller status check interval is not set during client init, use the default SDK\n\t\t// behaviour.\n\t\tif avisess.ctrlStatusCheckRetryInterval == 0 {\n\t\t\ttime.Sleep(getMinTimeDuration((time.Duration(math.Exp(float64(round))*3) * time.Second), (time.Duration(30) * time.Second)))\n\t\t} else {\n\t\t\t// controller status will be polled at intervals specified during client init.\n\t\t\ttime.Sleep(time.Duration(avisess.ctrlStatusCheckRetryInterval) * time.Second)\n\t\t}\n\t\tglog.Errorf(\"CheckControllerStatus Controller %v Retrying. round %v..!\", url, round)\n\t}\n\treturn isControllerUp, &http.Response{Status: \"408 Request Timeout\", StatusCode: 408}, nil\n}", "func (p *Plugin) Status(ctx context.Context, in *plugin.StatusRequest) (*plugin.StatusResponse, error) {\n\terr := p.Service.Status(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &plugin.StatusResponse{}, nil\n}", "func CheckStatus(w http.ResponseWriter, r *http.Request) {\n\tjson.NewEncoder(w).Encode(Status{Message : \"Alive\"})\n}", "func (adm *AdminClient) ServiceStatus() (ServiceStatusMetadata, error) {\n\n\t// Prepare web service request\n\treqData := requestData{}\n\treqData.queryValues = make(url.Values)\n\treqData.queryValues.Set(\"service\", \"\")\n\treqData.customHeaders = make(http.Header)\n\treqData.customHeaders.Set(minioAdminOpHeader, \"status\")\n\n\t// Execute GET on bucket to list objects.\n\tresp, err := adm.executeMethod(\"GET\", reqData)\n\tdefer closeResponse(resp)\n\tif err != nil {\n\t\treturn ServiceStatusMetadata{}, err\n\t}\n\n\t// Check response http status code\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn ServiceStatusMetadata{}, httpRespToErrorResponse(resp)\n\t}\n\n\t// Unmarshal the server's json response\n\tvar serviceStatus ServiceStatusMetadata\n\n\trespBytes, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn ServiceStatusMetadata{}, err\n\t}\n\n\terr = json.Unmarshal(respBytes, &serviceStatus)\n\tif err != nil {\n\t\treturn ServiceStatusMetadata{}, err\n\t}\n\n\treturn serviceStatus, nil\n}", "func Status(expected int) echo.Checker {\n\texpectedStr := \"\"\n\tif expected > 0 {\n\t\texpectedStr = strconv.Itoa(expected)\n\t}\n\treturn Each(func(r echoClient.Response) error {\n\t\tif r.Code != expectedStr {\n\t\t\treturn fmt.Errorf(\"expected response code `%s`, got %q. Response: %s\", expectedStr, r.Code, r)\n\t\t}\n\t\treturn nil\n\t})\n}", "func (jj *Juju) Status(user, service string) (*simplejson.Json, error) {\n //TODO Without id, should return every services matching {user}-*, not everything\n id := jj.id(user, service)\n args := []string{\"status\", \"--format\", \"json\"}\n if service != \"\" {\n args = append(args, id)\n }\n log.Infof(\"fetch juju status (%s)\\n\", id)\n\n cmd := exec.Command(\"juju\", args...)\n output, err := cmd.CombinedOutput()\n if err != nil {\n return EmptyJSON(), err\n }\n log.Debugf(\"successful request: %v\\n\", string(output))\n\n jsonOutput, err := simplejson.NewJson(output)\n if err != nil {\n return EmptyJSON(), err\n }\n\n mapping, _ := vmSshForward(user, jj.Controller, jsonOutput)\n jsonOutput.Set(\"ssh-port\", mapping)\n\n return jsonOutput, err\n}", "func CheckStatus(uri string) error {\n\tvar err error\n\tvar S Status\n\n\tresp, err := http.Get(uri)\n\tif err != nil {\n\t\terror2.LogError(err)\n\t\treturn err\n\t}\n\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tjsonUnmarshalErr := json.Unmarshal(body, S)\n\tif err == nil && jsonUnmarshalErr == nil && S.Status == \"ok\" {\n\t\treturn nil\n\t}\n\n\terr = errors.New(\"unable to complete status request\")\n\terror2.LogError(err)\n\treturn err\n}", "func checkStatus(currentStatus, wantedStatus int8) (err error) {\n\tswitch currentStatus {\n\tcase constant.RUNNING_STATUS_PREPARING:\n\t\terr = ErrSchedulerBeingInitilated\n\tcase constant.RUNNING_STATUS_STARTING:\n\t\terr = ErrSchedulerBeingStarted\n\tcase constant.RUNNING_STATUS_STOPPING:\n\t\terr = ErrSchedulerBeingStopped\n\tcase constant.RUNNING_STATUS_PAUSING:\n\t\terr = ErrSchedulerBeingPaused\n\t}\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif currentStatus == constant.RUNNING_STATUS_UNPREPARED &&\n\t\twantedStatus != constant.RUNNING_STATUS_PREPARING {\n\t\terr = ErrSchedulerNotInitialized\n\t\treturn\n\t}\n\n\tif currentStatus == constant.RUNNING_STATUS_STOPPED {\n\t\terr = ErrSchedulerStopped\n\t\treturn\n\t}\n\n\tswitch wantedStatus {\n\tcase constant.RUNNING_STATUS_PREPARING:\n\t\tif currentStatus != constant.RUNNING_STATUS_UNPREPARED {\n\t\t\terr = ErrSchedulerInitialized\n\t\t}\n\tcase constant.RUNNING_STATUS_STARTING:\n\t\tif currentStatus != constant.RUNNING_STATUS_PREPARED {\n\t\t\terr = ErrSchedulerStarted\n\t\t}\n\tcase constant.RUNNING_STATUS_PAUSING:\n\t\tif currentStatus != constant.RUNNING_STATUS_STARTED {\n\t\t\terr = ErrSchedulerNotStarted\n\t\t}\n\tcase constant.RUNNING_STATUS_STOPPING:\n\t\tif currentStatus != constant.RUNNING_STATUS_STARTED &&\n\t\t\tcurrentStatus != constant.RUNNING_STATUS_PAUSED {\n\t\t\terr = ErrSchedulerNotStarted\n\t\t}\n\tdefault:\n\t\terr = ErrStatusUnsupported\n\t}\n\treturn\n}", "func (s *svc) Status() router.Status {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\t// check if its stopped\n\tselect {\n\tcase <-s.exit:\n\t\treturn router.Status{\n\t\t\tCode: router.Stopped,\n\t\t\tError: nil,\n\t\t}\n\tdefault:\n\t\t// don't block\n\t}\n\n\t// check the remote router\n\trsp, err := s.router.Status(context.Background(), &pb.Request{}, s.callOpts...)\n\tif err != nil {\n\t\treturn router.Status{\n\t\t\tCode: router.Error,\n\t\t\tError: err,\n\t\t}\n\t}\n\n\tcode := router.Running\n\tvar serr error\n\n\tswitch rsp.Status.Code {\n\tcase \"running\":\n\t\tcode = router.Running\n\tcase \"advertising\":\n\t\tcode = router.Advertising\n\tcase \"stopped\":\n\t\tcode = router.Stopped\n\tcase \"error\":\n\t\tcode = router.Error\n\t}\n\n\tif len(rsp.Status.Error) > 0 {\n\t\tserr = errors.New(rsp.Status.Error)\n\t}\n\n\treturn router.Status{\n\t\tCode: code,\n\t\tError: serr,\n\t}\n}", "func (r *ManagedServiceGetResponse) Status() int {\n\tif r == nil {\n\t\treturn 0\n\t}\n\treturn r.status\n}", "func (ds *dockerService) Status(_ context.Context, r *runtimeapi.StatusRequest) (*runtimeapi.StatusResponse, error) {\n\truntimeReady := &runtimeapi.RuntimeCondition{\n\t\tType: runtimeapi.RuntimeReady,\n\t\tStatus: true,\n\t}\n\tnetworkReady := &runtimeapi.RuntimeCondition{\n\t\tType: runtimeapi.NetworkReady,\n\t\tStatus: true,\n\t}\n\tconditions := []*runtimeapi.RuntimeCondition{runtimeReady, networkReady}\n\tif _, err := ds.client.Version(); err != nil {\n\t\truntimeReady.Status = false\n\t\truntimeReady.Reason = \"DockerDaemonNotReady\"\n\t\truntimeReady.Message = fmt.Sprintf(\"docker: failed to get docker version: %v\", err)\n\t}\n\n\tstatus := &runtimeapi.RuntimeStatus{Conditions: conditions}\n\treturn &runtimeapi.StatusResponse{Status: status}, nil\n}", "func (a *Api) Status(w http.ResponseWriter, r *http.Request) error {\n\treturn nil\n}", "func (c *cephStatusChecker) checkStatus() {\n\tlogger.Debugf(\"checking health of cluster\")\n\tstatus, err := client.Status(c.context, c.namespace, true)\n\tif err != nil {\n\t\tlogger.Errorf(\"failed to get ceph status. %+v\", err)\n\t\treturn\n\t}\n\n\tlogger.Debugf(\"Cluster status: %+v\", status)\n\tif err := c.updateCephStatus(&status); err != nil {\n\t\tlogger.Errorf(\"failed to query cluster status in namespace %s\", c.namespace)\n\t}\n}", "func (i IDology) CheckStatus(referenceID string) (res common.KYCResult, err error) {\n\terr = errors.New(\"IDology doesn't support a verification status check\")\n\treturn\n}", "func (b *baseSysInit) Status(svcName string) (Status, error) {\n\tb.StatusCmd.AppendArgs(sysInitCmdArgs(b.sysInitType, svcName, \"status\")...)\n\tstatus, err := b.StatusCmd.RunCombined()\n\tif err != nil {\n\t\treturn Unknown, err\n\t}\n\tswitch {\n\tcase strings.Contains(status, svcStatusOut[\"running\"][b.sysInitType]):\n\t\treturn Running, nil\n\tcase strings.Contains(status, svcStatusOut[\"stopped\"][b.sysInitType]):\n\t\treturn Stopped, nil\n\t}\n\treturn Unknown, fmt.Errorf(\"Unable to determine %s status\", svcName)\n}", "func StatusCheck(ctx context.Context, db *DB) error {\n\tctx, span := otel.Tracer(\"database\").Start(ctx, \"foundation.database.statuscheck\")\n\tdefer span.End()\n\n\t// First check we can ping the database.\n\tvar pingError error\n\tfor attempts := 1; ; attempts++ {\n\t\tpingError = db.Ping(ctx)\n\t\tif pingError == nil {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(time.Duration(attempts) * 100 * time.Millisecond)\n\t\tif ctx.Err() != nil {\n\t\t\treturn ctx.Err()\n\t\t}\n\t}\n\n\t// Make sure we didn't timeout or be cancelled.\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\t// Run a simple query to determine connectivity. Running this query forces\n\t// a round trip to the database.\n\tconst q = `SELECT true`\n\tvar tmp bool\n\treturn db.QueryRow(ctx, q).Scan(&tmp)\n}", "func (h Handler) Status(w http.ResponseWriter, r *http.Request) {\n\tresponses := h.healthchecker.Status()\n\tfor _, r := range responses {\n\t\tif r.Error != nil {\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n}", "func checkStatus() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.JSON(http.StatusOK, \"Server is running successfully !!!!!\")\n\t}\n}", "func (c *Collection) Status(w http.ResponseWriter, req *http.Request) {\n\t// responds with current status of the analysis\n\t// checks systemtap is running, this is probably done via global variable?\n}", "func (env *Env) getServiceStatus(w http.ResponseWriter, r *http.Request) (error, int) {\n\tserviceName, err := httputil.ParseQuery(r, \"serviceName\")\n\tif err != nil {\n\t\treturn err, http.StatusBadRequest\n\t}\n\n\tserviceStatus, err := env.serviceRepo.GetServiceStatus(serviceName)\n\tif err != nil {\n\t\treturn err, http.StatusInternalServerError\n\t}\n\treturn httputil.SendJSON(w, serviceStatus)\n}", "func (s *Service) Status(ctx context.Context) *sdk.MonitoringStatus {\n\treturn s.NewMonitoringStatus()\n}", "func (manager *NetworkPolicyManager) CheckUpdatedService(serv, prev *core_v1.Service) {\n\tlogger.Infof(\"[Network Policies Manager](CheckUpdatedService) Service %s has been updated. Going to check for policies...\", serv.Name)\n\tmanager.checkService(serv, \"update\")\n}", "func (c *rpcServices) UpdateStatus(rpcService *v1.RpcService) (result *v1.RpcService, err error) {\n\tresult = &v1.RpcService{}\n\terr = c.client.Put().\n\t\tNamespace(c.ns).\n\t\tResource(\"rpcservices\").\n\t\tName(rpcService.Name).\n\t\tSubResource(\"status\").\n\t\tBody(rpcService).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (o LookupServiceResultOutput) Status() ServiceStatusResponseOutput {\n\treturn o.ApplyT(func(v LookupServiceResult) ServiceStatusResponse { return v.Status }).(ServiceStatusResponseOutput)\n}", "func CheckAliveStatus(devs DevsResponse, name string) {\n\tfor i := 0; i < len(devs.Devs); i++ {\n\t\tvar dev = &devs.Devs[i]\n\t\tif dev.Status != \"Alive\" {\n\t\t\t//Send the restart command\n\t\t\tlog.Printf(\"Dev #%s on %s got %s status so sending restart command\\n\", dev.GPU, name, dev.Status)\n\t\t\trestartMiner(name)\n\t\t}\n\t}\n}", "func (s *Service) Status(ctx context.Context) *sdk.MonitoringStatus {\n\tm := s.NewMonitoringStatus()\n\n\tif !s.Cfg.EnableLogProcessing {\n\t\treturn m\n\t}\n\tdb := s.mustDBWithCtx(ctx)\n\n\tnbCompleted, err := storage.CountItemCompleted(db)\n\tm.AddLine(addMonitoringLine(nbCompleted, \"items/completed\", err, sdk.MonitoringStatusOK))\n\n\tnbIncoming, err := storage.CountItemIncoming(db)\n\tm.AddLine(addMonitoringLine(nbIncoming, \"items/incoming\", err, sdk.MonitoringStatusOK))\n\n\tm.AddLine(s.LogCache.Status(ctx)...)\n\tm.AddLine(s.getStatusSyncLogs()...)\n\n\tfor _, st := range s.Units.Storages {\n\t\tm.AddLine(st.Status(ctx)...)\n\t\tsize, err := storage.CountItemUnitByUnit(db, st.ID())\n\t\tif nbCompleted-size >= 100 {\n\t\t\tm.AddLine(addMonitoringLine(size, \"backend/\"+st.Name()+\"/items\", err, sdk.MonitoringStatusWarn))\n\t\t} else {\n\t\t\tm.AddLine(addMonitoringLine(size, \"backend/\"+st.Name()+\"/items\", err, sdk.MonitoringStatusOK))\n\t\t}\n\t}\n\n\tm.AddLine(s.DBConnectionFactory.Status(ctx))\n\n\treturn m\n}", "func TestServiceStatusHandler(t *testing.T) {\n\ttestServicesCmdHandler(statusCmd, t)\n}", "func checkServiceRequestStatus(config Config, requestID string) (string, string, error) {\n\n\turl := \"api/service_requests/\" + requestID\n\trequest, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\tlog.Printf(\"[ERROR] Error in creating http Request %s\", err)\n\t\treturn \"\", \"\", fmt.Errorf(\"[ERROR] Error in creating http Request %s\", err)\n\t}\n\tresponse, err := config.GetResponse(request)\n\tif err != nil {\n\t\tlog.Printf(\"[ERROR] Error in getting response %s\", err)\n\t\treturn \"\", \"\", fmt.Errorf(\"[ERROR] Error in getting response %s\", err)\n\t}\n\n\tdata := string(response)\n\t// get request status\n\tstatusFromResult := gjson.Get(data, \"status\")\n\tstatus := statusFromResult.String()\n\n\t// get request_state\n\trequestStateFromResult := gjson.Get(data, \"request_state\")\n\trequestState := requestStateFromResult.String()\n\n\treturn status, requestState, nil\n}", "func Status(status string) error {\n\treturn SdNotify(\"STATUS=\" + status)\n}", "func (m *hostConfiguredContainer) Status() error {\n\t// If container does not exist, skip checking the status of it, as it won't work.\n\tif !m.container.Status().Exists() {\n\t\treturn fmt.Errorf(\"can't check status of non existing container\")\n\t}\n\n\treturn m.withForwardedRuntime(m.container.UpdateStatus)\n}", "func status(cmd *cobra.Command, _ []string) error {\n\tif err := daemonStatus(cmd); err != nil {\n\t\treturn err\n\t}\n\n\tif err := connectorStatus(cmd); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func RunStatus(cmd *cobra.Command, args []string) {\n\tc := LoadOperatorConf(cmd)\n\tLoadAdmissionConf(c)\n\tutil.KubeCheck(c.NS)\n\tif util.KubeCheck(c.SA) && util.KubeCheck(c.SAEndpoint) {\n\t\t// in OLM deployment the roles and bindings have generated names\n\t\t// so we list and lookup bindings to our service account to discover the actual names\n\t\tDetectRole(c)\n\t\tDetectClusterRole(c)\n\t}\n\tutil.KubeCheck(c.Role)\n\tutil.KubeCheck(c.RoleBinding)\n\tutil.KubeCheck(c.RoleEndpoint)\n\tutil.KubeCheck(c.RoleBindingEndpoint)\n\tutil.KubeCheck(c.ClusterRole)\n\tutil.KubeCheck(c.ClusterRoleBinding)\n\tutil.KubeCheckOptional(c.WebhookConfiguration)\n\tutil.KubeCheckOptional(c.WebhookSecret)\n\tutil.KubeCheckOptional(c.WebhookService)\n\tnoDeploy, _ := cmd.Flags().GetBool(\"no-deploy\")\n\tif !noDeploy {\n\t\tutil.KubeCheck(c.Deployment)\n\t}\n}", "func (s *Service) Status() (string, time.Time) {\n\tif m := s.mgr; m != nil {\n\t\tm.lock()\n\t\tdefer m.unlock()\n\t}\n\treturn s.reason, s.stamp\n}", "func GetStatus(cfg *Config) Status {\n\tnow := time.Now().Unix()\n\n\ts := Status{\n\t\tPID: os.Getpid(),\n\t\tService: \"list-service\",\n\t}\n\n\ts.Status = \"ok\"\n\ts.Version = Version()\n\ts.CPUs = runtime.NumCPU()\n\ts.GoVers = runtime.Version()\n\ts.TimeStamp = now\n\ts.UpTime = now - InstanceStartTime\n\ts.LogLevel = log.GetLevel()\n\n\tif host, err := os.Hostname(); err == nil {\n\t\ts.Hostname = host\n\t}\n\n\treturn s\n}", "func (s *ServiceStorage) WatchStatus(ctx context.Context, service chan *types.Service) error {\n\n\tlog.V(logLevel).Debug(\"storage:etcd:service:> watch service\")\n\n\tconst filter = `\\b\\/` + serviceStorage + `\\/(.+):(.+)/status\\b`\n\tclient, destroy, err := getClient(ctx)\n\tif err != nil {\n\t\tlog.V(logLevel).Errorf(\"storage:etcd:service:> watch service err: %s\", err.Error())\n\t\treturn err\n\t}\n\tdefer destroy()\n\n\tr, _ := regexp.Compile(filter)\n\tkey := keyCreate(serviceStorage)\n\tcb := func(action, key string, _ []byte) {\n\t\tkeys := r.FindStringSubmatch(key)\n\t\tif len(keys) < 3 {\n\t\t\treturn\n\t\t}\n\n\t\tif action == \"delete\" {\n\t\t\treturn\n\t\t}\n\n\t\tif d, err := s.Get(ctx, keys[1], keys[2]); err == nil {\n\t\t\tservice <- d\n\t\t}\n\t}\n\n\tif err := client.Watch(ctx, key, filter, cb); err != nil {\n\t\tlog.V(logLevel).Errorf(\"storage:etcd:service:> watch service err: %s\", err.Error())\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (sry *Sryun) Status(user *model.User, repo *model.Repo, build *model.Build, link string) error {\n\treturn nil\n}", "func (c *APIClient) StatusCheck() (bool, error) {\n\turl, err := c.compileStatusCheckURL()\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treq, err := http.NewRequest(http.MethodGet, url, nil)\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\t// Use CallRaw since no authentication is needed for status check.\n\tr, err := c.Client.CallRaw(req)\n\tc.addResponseCode(r.StatusCode)\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tif r.StatusCode != http.StatusOK {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func (controller *playgroundController) CheckStatus(ctx context.Context, info *pb.CheckStatusRequest) (*pb.CheckStatusResponse, error) {\n\tpipelineId, err := uuid.Parse(info.PipelineUuid)\n\terrorMessage := \"Error during getting status of the code processing\"\n\tif err != nil {\n\t\tlogger.Errorf(\"%s: CheckStatus(): pipelineId has incorrect value and couldn't be parsed as uuid value: %s\", info.PipelineUuid, err.Error())\n\t\treturn nil, cerrors.InvalidArgumentError(errorMessage, \"pipelineId has incorrect value and couldn't be parsed as uuid value: %s\", info.PipelineUuid)\n\t}\n\tstatus, err := code_processing.GetProcessingStatus(ctx, controller.cacheService, pipelineId, errorMessage)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &pb.CheckStatusResponse{Status: status}, nil\n}", "func GetStatus(\n\tprincipal savedstate.Principal,\n\titself string,\n\ttmpDir string,\n\ttimeout time.Duration,\n\tlogger *structlog.Logger,\n) (statusType, statusType) {\n\tstatus := getStatus(principal.ID)\n\tif status < StatusUpdated || status == StatusReady {\n\t\treturn StatusReady, status\n\t}\n\n\tclusterName := principal.Sess.Name + \".\" + principal.Sess.Domain\n\tif strings.HasSuffix(clusterName, \".\") {\n\t\tclusterName = clusterName[:len(clusterName)-1]\n\t}\n\tapiHost := \"api.\" + clusterName\n\n\tres, err := net.LookupHost(apiHost)\n\tif err != nil {\n\t\tlogger.Debug(\"Kubernetes API host has not domain resolve\", \"Host\", apiHost)\n\t\treturn StatusReady, status\n\t}\n\tlogger.Debug(\"Kubernetes API host resolved to\", res)\n\n\thomeDir := filepath.Join(tmpDir, principal.ID)\n\n\t// Validate //////////////////////////////////////////////////////////////\n\tcmdParams := []string{\n\t\t\"--kopsValidate\",\n\t\tfmt.Sprintf(\"--name=%v\", clusterName),\n\t\tfmt.Sprintf(\"--state=s3://%v\", principal.Sess.Bucket),\n\t\tfmt.Sprintf(\"--timeout=%v\", timeout),\n\t}\n\n\tlogger.Debug(\"Calling Kops validate\", \"params\", cmdParams)\n\n\tcmd := exec.Command(itself, cmdParams...) // #nosec\n\tcmd.Env = []string{\n\t\tfmt.Sprintf(\"HOME=%v\", homeDir),\n\t\t// ToDo: replace with file in $HOME\n\t\tfmt.Sprintf(\"AWS_ACCESS_KEY=%v\", principal.Sess.AccessKey),\n\t\tfmt.Sprintf(\"AWS_SECRET_KEY=%v\", principal.Sess.SecretKey),\n\t}\n\n\tcmdOut, err := cmd.CombinedOutput()\n\n\tif err != nil {\n\t\tlogger.PrintErr(\"Kops validate failed\", \"err\", err, \"out\", string(cmdOut))\n\t\treturn StatusReady, status\n\t}\n\n\tlogger.Debug(\"Kops validate done\", \"out\", string(cmdOut))\n\n\tif !readyRegexp.Match(cmdOut) {\n\t\tlogger.Debug(\"Cluster is not ready yet\", \"total\", StatusReady, \"current\", status)\n\t\treturn StatusReady, status\n\t}\n\n\tsetStatus(principal.ID, StatusReady)\n\n\tlogger.Info(\"Cluster ready\")\n\n\treturn StatusReady, StatusReady\n}", "func Status(args ...string) {\n runInstances(\"Status\", func(i int, id string) error {\n on := running()\n logger.Log(fmt.Sprintf(\"Container ID: %s\\n\", id))\n logger.Log(fmt.Sprintf(\" Running: %s\\n\", strconv.FormatBool(on)))\n\n if on {\n net := networkSettings(i)\n logger.Log(fmt.Sprintf(\" IP: %s\\n\", net.Ip))\n logger.Log(fmt.Sprintf(\" Public Port: %s\\n\", net.Public.tcp))\n logger.Log(fmt.Sprintf(\"Private Port: %s\\n\", net.Private.tcp))\n }\n\n return nil\n })\n}", "func (t *Tileset) CheckJobStatus() error {\n\tfmt.Println(\"Awaiting job completion. This may take some time...\")\n\tfor {\n\t\tstatusResponse := &StatusResponse{}\n\t\tres, err := t.base.SimpleGET(t.postURL() + \"/status\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tjson.Unmarshal(res, statusResponse)\n\t\tif statusResponse.Status == \"failed\" {\n\t\t\tfmt.Println(\"Job failed\")\n\t\t\treturn nil\n\t\t}\n\t\tif statusResponse.Status == \"success\" {\n\t\t\tfmt.Println(\"Job complete\")\n\t\t\treturn nil\n\t\t}\n\t\tfmt.Println(statusResponse.Status)\n\t\ttime.Sleep(5 * time.Second)\n\n\t}\n\n}", "func GetStatusOfSomeService(serviceName string) *service.Status {\n\tsrv := service.NewDefaultService(serviceName)\n\tstatus, _ := srv.Status()\n\treturn status\n}", "func (r *client) Status(ctx context.Context) (*pb.SystemStatus, error) {\n\tresp, err := r.AgentClient.Status(ctx, &pb.StatusRequest{}, r.callOptions...)\n\tif err != nil {\n\t\treturn nil, ConvertGRPCError(err)\n\t}\n\treturn resp.Status, nil\n}", "func (dstv Dstv) Status(serialNumber string) (*StatusResponse, error) {\n\tdstv.AddQueryData(paymenex.PActId, \"STATUS\")\n\tdstv.AddQueryData(paymenex.PSerialNumber, serialNumber)\n\txml, err := dstv.MakeRequest()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// writeFile(\"status.xml\", xml) // DEBUG\n\tresponse := new(StatusResponse)\n\tok := dstv.ParseAndVerifyResponse(xml, response)\n\tif !ok {\n\t\treturn response, errors.New(errVerifyMsg)\n\t}\n\treturn response, nil\n}", "func (r *ManagedServiceUpdateResponse) Status() int {\n\tif r == nil {\n\t\treturn 0\n\t}\n\treturn r.status\n}", "func (service *ServiceObject) setServiceStatus(status uint32) {\n\tif service.serviceStatusHandle == 0 {\n\t\treturn\n\t}\n\n\tservice.currentServiceStatus.currentState = status\n\tsetServiceStatusFunction(service.serviceStatusHandle, &service.currentServiceStatus)\n}", "func (s *Service) Check() error {\n\tif s.mgr == nil {\n\t\treturn ErrNoManager\n\t}\n\treturn s.checkService()\n}", "func CheckServerStatus(sConf *genconf.ServerConf) error {\n\tsList := make([]string, 0)\n\tfor _, sv := range sConf.Adapters {\n\t\tsList = append(sList, sv.Endpoint)\n\t}\n\tsList = append(sList, sConf.LocalEndpoint)\n\tfor _, sv := range sList {\n\t\tnetwork, host, port := \"\", \"\", \"\"\n\t\tarr := strings.Fields(sv)\n\t\tfor i := range arr {\n\t\t\tif i == 0 {\n\t\t\t\tnetwork = arr[0]\n\t\t\t} else if arr[i] == \"-h\" && i+1 < len(arr) {\n\t\t\t\thost = arr[i+1]\n\t\t\t} else if arr[i] == \"-p\" && i+1 < len(arr) {\n\t\t\t\tport = arr[i+1]\n\t\t\t}\n\t\t}\n\t\tif network == \"\" || host == \"\" || port == \"\" {\n\t\t\treturn fmt.Errorf(\"host/port or network can not be empty\")\n\t\t}\n\t\tif err := checkAddr(network, host+\":\"+port); err != nil {\n\t\t\treturn fmt.Errorf(\"Connect failed %s:%v\", sv, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (c BasicController) UpdateServicesStatus(status model.ServiceStatus, keys ...string) error {\n\treturn c.serviceRepo.UpdateServicesStatus(status, keys...)\n}", "func (h HealthController) Status(c *gin.Context) {\n\tc.String(http.StatusOK, \"Working!\")\n}", "func (o ServiceOutput) Status() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Service) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)\n}", "func (c *Stats) ServiceCheck(check, message string, status client.Status, tags []string) error {\n\treturn c.client.SendServiceCheck(&client.DDServiceCheck{\n\t\tCheck: prependNamespace(c.namespace, check),\n\t\tHostname: c.host,\n\t\tMessage: message,\n\t\tStatus: status,\n\t\tTags: combineTags(c.tags, tags),\n\t\tTimestamp: time.Now().Unix(),\n\t})\n}", "func (s *TiFlashSpec) Status(ctx context.Context, timeout time.Duration, tlsCfg *tls.Config, pdList ...string) string {\n\tstoreAddr := utils.JoinHostPort(s.Host, s.FlashServicePort)\n\tstate := checkStoreStatus(ctx, storeAddr, tlsCfg, pdList...)\n\tif s.Offline && strings.ToLower(state) == \"offline\" {\n\t\tstate = \"Pending Offline\" // avoid misleading\n\t}\n\treturn state\n}", "func (h *Handler) UpdateStatus(w http.ResponseWriter, r *http.Request) {\n\n\tcmd := sigstat.Command{\n\t\tStatus: \"running\",\n\t}\n\n\th.client.CommandService().UpdateStatus(cmd)\n}", "func GetServiceStatus(name string) (string, error) {\n\tfmt.Printf(\"Executing GetServiceStatus for: %s\\n\", name)\n\n\tvar status string\n\tm, err := mgr.Connect()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer m.Disconnect()\n\ts, err := m.OpenService(name)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer s.Close()\n\n\tstate, err := s.Query()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tswitch state.State {\n\tdefault:\n\t\tstatus = \"Huh?\"\n\tcase 0:\n\t\tstatus = \"unknown\"\n\tcase 1:\n\t\tstatus = \"stopped\"\n\tcase 2:\n\t\tstatus = \"start_pending\"\n\tcase 3:\n\t\tstatus = \"stop_pending\"\n\tcase 4:\n\t\tstatus = \"running\"\n\tcase 5:\n\t\tstatus = \"continue_pending\"\n\tcase 6:\n\t\tstatus = \"pause_pending\"\n\tcase 7:\n\t\tstatus = \"paused\"\n\tcase 8:\n\t\tstatus = \"service_not_found\"\n\tcase 9:\n\t\tstatus = \"server_not_found\"\n\t}\n\n\tfmt.Printf(\"State returned is: %v\\n\", status)\n\treturn status, nil\n}", "func CheckStatus(database string) error {\n\treturn nil\n}", "func (api *API) Status(request *restful.Request, response *restful.Response) {\n\tresponse.WriteHeader(http.StatusOK)\n}", "func (s *SailTrim) Status(ctx context.Context, opt StatusOption) error {\n\t_sv, err := s.conf.loadService()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to load service config\")\n\t}\n\tout, err := s.svc.GetContainerServicesWithContext(ctx, &lightsail.GetContainerServicesInput{\n\t\tServiceName: _sv.ContainerServiceName,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tsv := out.ContainerServices[0]\n\tif opt.Detail {\n\t\tfmt.Print(MarshalJSONString(sv))\n\t\treturn nil\n\t}\n\n\tp := func(k, v string) {\n\t\tfmt.Printf(\"%-17s %s\\n\", k, v)\n\t}\n\tp(\"ServiceName:\", *sv.ContainerServiceName)\n\tp(\"State:\", *sv.State)\n\tp(\"Power:\", *sv.Power)\n\tp(\"Scale:\", strconv.FormatInt(*sv.Scale, 10))\n\tp(\"URL:\", *sv.Url)\n\tfor _, ns := range sv.PublicDomainNames {\n\t\tfor _, n := range ns {\n\t\t\tp(\"PublicDomainName:\", *n)\n\t\t}\n\t}\n\tp(\"IsDisabled:\", strconv.FormatBool(*sv.IsDisabled))\n\treturn nil\n}", "func (m *Meduza) Status() error {\n\n\t// TODO: Add more checks here\n\treturn m.drv.Status()\n\n}", "func (r *TokenExpiredRepair) Status() (bool, error) {\n\trequest := req.Status{\n\t\tItem: req.MachineStatus,\n\t\tMachineName: r.MachineName,\n\t}\n\n\tif err := r.Klient.RemoteStatus(request); err != nil {\n\t\t// If the error is not what this repairer is designed to handle, return ok.\n\t\t// This seems counter intuitive, but if this Status() returns false, it is\n\t\t// expected to fix the error. We don't know what that error is, so we shouldn't\n\t\t// report a bad status. Log it, for debugging purposes though, and hope the\n\t\t// next repairer in the list knows how to deal with this issue.\n\t\tkErr, ok := err.(*kite.Error)\n\t\tif !ok || kErr.Type != kiteerrortypes.AuthErrTokenIsExpired {\n\t\t\tr.Log.Warning(\"Encountered error not in scope of this repair. err:%s\", err)\n\t\t\treturn true, nil\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func CheckStatus() error {\n\tdial := setUpMgoConn()\n\tlogger.Infof(\"\\n - Dial details: %+v \\n\", dial)\n\tsess, err := mgo.DialWithInfo(dial)\n\tif err != nil {\n\t\tlogger.Errorf(\"\\nError: %s \\n\", err.Error())\n\t\treturn err\n\t}\n\tdefer sess.Close()\n\terr = sess.Ping()\n\tif err != nil {\n\t\tlogger.Errorf(\"\\nError: %s \\n\", err.Error())\n\t\treturn err\n\t}\n\tlogger.Infof(\"MongoDB server is healthy.\")\n\treturn nil\n}", "func TestStatus() {\n\tfmt.Println(\"\")\n\tfmt.Println(\"=============================================================================================\")\n\tfmt.Printf(\"TOTAL TEST SUITES : %d\\n\", counters.suitesCount)\n\tfmt.Printf(\"TOTAL TEST CASES : %d\\n\", counters.testCaseCount)\n\tfmt.Printf(\"TOTAL TEST METHODS : %d\\n\", counters.methodsCount)\n\tfmt.Printf(\"TOTAL TEST METHODS PASS : %d\\n\", counters.methodsPassedCount)\n\tfmt.Printf(\"TOTAL TEST METHODS FAIL : %d\\n\", counters.methodsFailedCount)\n\tfmt.Println(\"\")\n\tif TestPassed {\n\t\tfmt.Println(\"TEST STATUS : PASS\")\n\t} else {\n\t\tfmt.Println(\"TEST STATUS : FAIL\")\n\t}\n\tfmt.Println(\"=============================================================================================\")\n\tfmt.Println(\"\")\n}", "func (s *Server) HandleGetServicesStatus() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdefer utils.CloseTheCloser(r.Body)\n\n\t\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\t\tdefer cancel()\n\n\t\t// Verify token\n\t\t_, err := s.auth.VerifyToken(utils.GetToken(r))\n\t\tif err != nil {\n\t\t\t_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), \"Failed to apply service\", err, nil)\n\t\t\t_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)\n\t\t\treturn\n\t\t}\n\n\t\t// var result []interface{}\n\t\tvars := mux.Vars(r)\n\t\tprojectID := vars[\"project\"]\n\t\tserviceID, serviceIDExists := r.URL.Query()[\"serviceId\"]\n\t\tversion, versionExists := r.URL.Query()[\"version\"]\n\n\t\tresult, err := s.driver.GetServiceStatus(ctx, projectID)\n\t\tif err != nil {\n\t\t\t_ = helpers.Logger.LogError(helpers.GetRequestID(ctx), \"Failed to get service status\", err, nil)\n\t\t\t_ = helpers.Response.SendErrorResponse(ctx, w, http.StatusUnauthorized, err)\n\t\t\treturn\n\t\t}\n\n\t\tarr := make([]interface{}, 0)\n\t\tif serviceIDExists && versionExists {\n\t\t\tfor _, serviceStatus := range result {\n\t\t\t\tif serviceStatus.ServiceID == serviceID[0] && serviceStatus.Version == version[0] {\n\t\t\t\t\tarr = append(arr, serviceStatus)\n\t\t\t\t}\n\t\t\t}\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: arr})\n\t\t\treturn\n\t\t}\n\n\t\tif serviceIDExists {\n\t\t\tfor _, serviceStatus := range result {\n\t\t\t\tif serviceStatus.ServiceID == serviceID[0] {\n\t\t\t\t\tarr = append(arr, serviceStatus)\n\t\t\t\t}\n\t\t\t}\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: arr})\n\t\t\treturn\n\t\t}\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_ = json.NewEncoder(w).Encode(model.Response{Result: result})\n\t}\n}", "func (r *remoteRuntimeService) Status(ctx context.Context, verbose bool) (*runtimeapi.StatusResponse, error) {\n\tklog.V(10).InfoS(\"[RemoteRuntimeService] Status\", \"timeout\", r.timeout)\n\tctx, cancel := context.WithTimeout(ctx, r.timeout)\n\tdefer cancel()\n\n\treturn r.statusV1(ctx, verbose)\n}", "func (j Jumio) CheckStatus(referenceID string) (result common.KYCResult, err error) {\n\tif len(referenceID) == 0 {\n\t\terr = errors.New(\"empty Jumio’s reference number of an existing scan\")\n\t\treturn\n\t}\n\n\tstatus, errorCode, err := j.retrieveScanStatus(referenceID)\n\tif err != nil {\n\t\tif errorCode != nil {\n\t\t\tresult.ErrorCode = fmt.Sprintf(\"%d\", *errorCode)\n\t\t}\n\t\terr = fmt.Errorf(\"during sending request: %s\", err)\n\t\treturn\n\t}\n\n\tswitch status {\n\tcase PendingStatus:\n\t\tresult.Status = common.Unclear\n\t\tresult.StatusCheck = &common.KYCStatusCheck{\n\t\t\tProvider: common.Jumio,\n\t\t\tReferenceID: referenceID,\n\t\t\tLastCheck: time.Now(),\n\t\t}\n\tcase DoneStatus, FailedStatus:\n\t\tscanDetails := &DetailsResponse{}\n\t\tscanDetails, errorCode, err = j.retrieveScanDetails(referenceID)\n\t\tif err != nil {\n\t\t\tif errorCode != nil {\n\t\t\t\tresult.ErrorCode = fmt.Sprintf(\"%d\", *errorCode)\n\t\t\t}\n\t\t\terr = fmt.Errorf(\"during sending request: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tresult, err = scanDetails.toResult()\n\tdefault:\n\t\terr = fmt.Errorf(\"unknown status of the verification: %s\", status)\n\t}\n\n\treturn\n}", "func checkProcessStatus() error {\n\tstatus := serverProcessStatus.Val()\n\tif status > 0 {\n\t\tswitch status {\n\t\tcase adminActionRestarting:\n\t\t\treturn gerror.NewCode(gcode.CodeInvalidOperation, \"server is restarting\")\n\n\t\tcase adminActionShuttingDown:\n\t\t\treturn gerror.NewCode(gcode.CodeInvalidOperation, \"server is shutting down\")\n\t\t}\n\t}\n\treturn nil\n}", "func (sys *Daemon) Status() (st Status, err error) {\n\tst = Status{Since: sys.since}\n\n\tfor _, u := range sys.Units() {\n\t\tswitch {\n\t\tcase u.job == nil:\n\t\t\tcontinue\n\t\tcase u.job.IsRunning():\n\t\t\tst.Jobs++\n\t\tcase u.job.Failed():\n\t\t\tst.Failed++\n\t\t}\n\t}\n\n\tif st.Failed > 0 {\n\t\tst.State = Degraded\n\t} else {\n\t\tst.State = Running\n\t}\n\n\tst.Log, err = ioutil.ReadAll(sys.Log)\n\n\treturn\n}", "func (s *Server) Status(c *gin.Context) {\n\tc.JSON(200, system.Info())\n}", "func runStatus(args []string) int {\n\n\treturn 0\n}", "func (o GetVpcEndpointServicesServiceOutput) Status() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetVpcEndpointServicesService) string { return v.Status }).(pulumi.StringOutput)\n}", "func statusCheck(w http.ResponseWriter, r *http.Request) {\n\tLog.Printf(\"/status\")\n\tproxiStatus.IndexSize = repo.GetIndexSize()\n\tstatus,_ := json.Marshal(proxiStatus)\n\tio.WriteString(w, string(status))\n}", "func (controller *playgroundController) CheckStatus(ctx context.Context, info *pb.CheckStatusRequest) (*pb.CheckStatusResponse, error) {\n\tpipelineId, err := uuid.Parse(info.PipelineUuid)\n\tif err != nil {\n\t\tlogger.Errorf(\"%s: CheckStatus(): pipelineId has incorrect value and couldn't be parsed as uuid value: %s\", info.PipelineUuid, err.Error())\n\t\treturn nil, errors.InvalidArgumentError(\"CheckStatus\", \"pipelineId has incorrect value and couldn't be parsed as uuid value: \"+info.PipelineUuid)\n\t}\n\tstatus, err := code_processing.GetProcessingStatus(ctx, controller.cacheService, pipelineId, \"CheckStatus\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &pb.CheckStatusResponse{Status: status}, nil\n}", "func (c *Seaweed) Status() (result *SystemStatus, err error) {\n\tdata, _, err := c.client.get(encodeURI(*c.master, \"/dir/status\", nil), nil)\n\tif err == nil {\n\t\tresult = &SystemStatus{}\n\t\terr = json.Unmarshal(data, result)\n\t}\n\treturn\n}", "func (sh *StatusHandler) Status(ctx context.Context, in *empty.Empty, out *proto.StatusResponse) error {\n\tout.OK = true\n\tout.Address = sh.address\n\n\treturn nil\n}", "func (c *Client) Status() (*http.Response, error) {\n\tresp, err := c.get(\"/status\", nil)\n\tif err != nil &&\n\t\t(strings.Contains(err.Error(), \"EOF\") || strings.Contains(err.Error(), \"refused\")) {\n\t\treturn nil, fmt.Errorf(\"daemon on remote %s appears offline or inaccessible\", c.Name)\n\t}\n\treturn resp, err\n}", "func getStatus(pods []*v1.Pod) (succeeded, failed int32) {\n\tsucceeded = int32(filterPods(pods, v1.PodSucceeded))\n\tfailed = int32(filterPods(pods, v1.PodFailed))\n\treturn\n}", "func (h HealthController) Status(c *gin.Context) {\n\tc.JSON(200, gin.H{\n\t\t\"status\": \"ok\",\n\t})\n}", "func (d *DockerDriver) Status() bool {\n\tcli := d.getClient()\n\n\t_, err := cli.ServerVersion(context.TODO())\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func cmdStatus() {\n\tstate := status(B2D.VM)\n\tfmt.Printf(\"%s is %s.\\n\", B2D.VM, state)\n\tif state != vmRunning {\n\t\tos.Exit(1)\n\t}\n}", "func (m *postgresDBRepo) UpdateHostServiceStatus(hostID, serviceID, active int) error {\n\tctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)\n\tdefer cancel()\n\n\tstmt := `\n\t\tupdate host_services set active = $1 where host_id = $2 and service_id = $3\n\t`\n\n\t_, err := m.DB.ExecContext(ctx, stmt, active, hostID, serviceID)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\n\treturn nil\n}" ]
[ "0.76565826", "0.7390111", "0.7249484", "0.7007388", "0.69533503", "0.68541384", "0.68333125", "0.6717001", "0.667491", "0.64619255", "0.6460216", "0.64545316", "0.6449681", "0.6425185", "0.63878804", "0.6379933", "0.6376746", "0.6363784", "0.6363674", "0.6358225", "0.63561726", "0.6327297", "0.6320621", "0.6315368", "0.6303918", "0.6299488", "0.629665", "0.62894326", "0.62803596", "0.62706494", "0.6267097", "0.6248015", "0.62262565", "0.6205792", "0.62009406", "0.61815214", "0.61812764", "0.61582655", "0.61557424", "0.61488515", "0.61398226", "0.6134052", "0.61183184", "0.6116343", "0.6105054", "0.60928917", "0.60889816", "0.6087727", "0.6085478", "0.60835844", "0.6075499", "0.60747534", "0.6063766", "0.6052695", "0.60507137", "0.6019679", "0.6017006", "0.6005791", "0.6003225", "0.59943616", "0.5989109", "0.59795725", "0.59776163", "0.59746987", "0.597328", "0.59697145", "0.5962698", "0.5961666", "0.59542483", "0.5952328", "0.59493065", "0.5948906", "0.5933473", "0.592773", "0.5923297", "0.5916185", "0.5897797", "0.58910537", "0.5888299", "0.58824795", "0.58820254", "0.58743775", "0.5864603", "0.586089", "0.58574045", "0.5856931", "0.58548576", "0.5853909", "0.58494264", "0.5846619", "0.5845075", "0.58425826", "0.5841763", "0.5838568", "0.58383906", "0.5833815", "0.5827851", "0.5825184", "0.58152497", "0.58130354" ]
0.66327935
9
Score calculate your scrabble score
func Score(word string) int { var totalScore int scoresPerLetter := map[int][]string{ 1: {"A", "E", "I", "O", "U", "L", "N", "R", "S", "T"}, 2: {"D", "G"}, 3: {"B", "C", "M", "P"}, 4: {"F", "H", "V", "W", "Y"}, 5: {"K"}, 8: {"J", "X"}, 10: {"Q", "Z"}, } for _, _letter := range word { letter := strings.ToUpper(string(_letter)) for score, letterList := range scoresPerLetter { for _, l := range letterList { if letter == l { totalScore += score } } } } return totalScore }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Score(word string) int {\n\tvar outScore = 0\n\tif word == \"\" {\n\t\treturn outScore\n\t}\n\tfor i := 0; i < len(word); i++ {\n\t\tc := string(word[i])\n\t\tfor _, scores := range scrabbleScores {\n\t\t\tif strings.ToLower(c) == strings.ToLower(scores.letter) {\n\t\t\t\toutScore += scores.score\n\t\t\t}\n\t\t}\n\t}\n\n\treturn outScore\n\n}", "func Score(word string) int {\n\tscore := 0\n\tfor _, c := range strings.ToUpper(word) {\n\t\tscore = score + letterValues.getScore(c)\n\t}\n\treturn score\n}", "func Score(word string) int {\n\tvar score int\n\tif word == \"\" {\n\t\treturn score\n\t}\n\n\tfor _, letter := range word {\n\t\tscore += grading[unicode.ToUpper(letter)]\n\t}\n\treturn score\n}", "func Score(word string) {\n\tpoints := 0\n\tsum, count := 0, 0\n\tfor _, item := range strings.Split(word, \"\") {\n\n\t\t// fmt.Println(\"Index e item \", in, item)\n\n\t\tfor index, point := range letters {\n\n\t\t\tif index == strings.ToUpper(item) {\n\t\t\t\t// fmt.Println(\"Index y point \", index, point)\n\t\t\t\tfmt.Println(\"Points: \", point)\n\n\t\t\t\tcount = strings.Count(strings.ToUpper(item), index)\n\t\t\t\tif count > 1 {\n\t\t\t\t\tpoints += count * point\n\t\t\t\t}\n\t\t\t\tsum = point\n\t\t\t\tpoints += sum\n\t\t\t\t// fmt.Println(\"Puntos actuales: \", points)\n\t\t\t}\n\t\t}\n\t}\n\n\tfmt.Println(\"Puntos totales: \", points)\n}", "func Score(word string) int {\n\tword = strings.ToUpper(word)\n\n\tscore := 0\n\tfor i := 0; i < len(word); i++ {\n\t\tscore += letterValues[word[i]]\n\t}\n\n\treturn score\n}", "func Score(input string) int {\n\tresult := 0\n\n\tfor _, char := range strings.ToUpper(input) {\n\t\tresult += SingleScore(char)\n\t}\n\n\treturn result\n}", "func Score(word string) int {\n\tvar score int\n\n\tfor _, c := range word {\n\t\tscore += pointValue(c)\n\t}\n\n\treturn score\n}", "func score (nilai int) string{\r\n\r\n\t//untuk posisi kondisi c dan b bisa ditukar, namun untuk posisi kondisi a tidak bisa.\r\n\t//dikarenakan kondisi a itu selain dari kondisi c dan b.\r\n\tif nilai <= 40 {\r\n\t\treturn \"C\"\r\n\t} else if nilai >40 && nilai <=70 {\r\n\t\treturn \"B\"\r\n\t} else {\r\n\t\treturn \"A\"\r\n\t}\r\n\r\n}", "func Score(value string) int {\n\tresult := 0\n\tvalueAllUpper := strings.ToUpper(value)\n\tfor i := 0; i < len(valueAllUpper); i++ {\n\t\tfor key, val := range scores {\n\t\t\tif strings.IndexByte(key, valueAllUpper[i]) >= 0 {\n\t\t\t\tresult += val\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}", "func Score(letters string) (score int) {\n\tfor _, char := range letters {\n\t\tscore += scoreForLetter(char)\n\t}\n\n\treturn score\n}", "func (b *Board) Score() int {\n\tif !b.Finish {\n\t\treturn 0\n\t}\n\n\t// yaku ? or finish move\n\t// b.HasYaku() //TODO: yaku score\n\ts := b.LastAttackMove.Attack.GetScore()\n\tif b.LastAttackMove.FaceDown && b.LastAttackMove.Block == b.LastAttackMove.Attack {\n\t\ts = s * 2\n\t}\n\treturn s\n}", "func Score(word string) (score int) {\n\tfor _, l := range word {\n\t\tl = unicode.ToUpper(l)\n\t\tif s, ok := letterScores[l]; ok {\n\t\t\tscore += s\n\t\t}\n\t}\n\treturn\n}", "func Score(input string) int {\n\truneValue := func(r rune) int {\n\t\tswitch {\n\t\tcase strings.ContainsRune(\"DG\", r):\n\t\t\treturn 2\n\t\tcase strings.ContainsRune(\"BCMP\", r):\n\t\t\treturn 3\n\t\tcase strings.ContainsRune(\"FHVWY\", r):\n\t\t\treturn 4\n\t\tcase strings.ContainsRune(\"K\", r):\n\t\t\treturn 5\n\t\tcase strings.ContainsRune(\"JX\", r):\n\t\t\treturn 8\n\t\tcase strings.ContainsRune(\"QZ\", r):\n\t\t\treturn 10\n\t\tdefault:\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tscore := 0\n\tfor _, r := range strings.ToUpper(input) {\n\t\tscore += runeValue(r)\n\t}\n\treturn score\n}", "func Score(word string) int {\n\tscore := 0\n\n\tfor _, r := range word {\n\t\tscore += processLetter(unicode.ToUpper(r))\n\t}\n\treturn score\n}", "func Score(tiles string) int {\n\ttotal := 0\n\n\t//convert all tile to lower case ascii\n\ts := strings.ToLower(tiles)\n\n\t//look up the tiles value in array and add it to the running total\n\tfor _, v := range s {\n\t\ttotal += tileValues[v-0x61] //0x61 is the hex value of char 'a'\n\t}\n\n\treturn total\n}", "func Score(dice []int, category string) int {\n\tswitch category {\n\tcase \"ones\":\n\t\tif count, ok := groupDice(dice)[1]; ok {\n\t\t\treturn count * 1\n\t\t}\n\tcase \"twos\":\n\t\tif count, ok := groupDice(dice)[2]; ok {\n\t\t\treturn count * 2\n\t\t}\n\tcase \"threes\":\n\t\tif count, ok := groupDice(dice)[3]; ok {\n\t\t\treturn count * 3\n\t\t}\n\tcase \"fours\":\n\t\tif count, ok := groupDice(dice)[4]; ok {\n\t\t\treturn count * 4\n\t\t}\n\tcase \"fives\":\n\t\tif count, ok := groupDice(dice)[5]; ok {\n\t\t\treturn count * 5\n\t\t}\n\tcase \"sixes\":\n\t\tif count, ok := groupDice(dice)[6]; ok {\n\t\t\treturn count * 6\n\t\t}\n\tcase \"full house\":\n\t\treturn scoreFullHouse(groupDice(dice))\n\tcase \"four of a kind\":\n\t\tfor num, count := range groupDice(dice) {\n\t\t\tif count >= 4 {\n\t\t\t\treturn num * 4\n\t\t\t}\n\t\t}\n\tcase \"little straight\":\n\t\tif sortAndCompare(dice, []int{1, 2, 3, 4, 5}) {\n\t\t\treturn 30\n\t\t}\n\tcase \"big straight\":\n\t\tif sortAndCompare(dice, []int{2, 3, 4, 5, 6}) {\n\t\t\treturn 30\n\t\t}\n\tcase \"choice\":\n\t\tsum := 0\n\t\tfor _, die := range dice {\n\t\t\tsum += die\n\t\t}\n\t\treturn sum\n\tcase \"yacht\":\n\t\tif len(groupDice(dice)) == 1 {\n\t\t\treturn 50\n\t\t}\n\t}\n\n\treturn 0\n}", "func Score(s string) int {\n\tcount := 0\n\tfor _, r := range strings.ToUpper(s) {\n\t\tcount += letterValue[r]\n\t}\n\n\treturn count\n}", "func (v *Vote) Score(r []int) int {\n\tif DumbScore {\n\t\treturn v.DumbScore(r)\n\t}\n\th := make(map[int]int) //map candidates to index\n\tfor k, v := range v.C {\n\t\tki, err := strconv.Atoi(k)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\th[v] = ki\n\t}\n\n\tres := 0\n\tfor i := 0; i < len(r); i++ {\n\t\tif r[i] == -1 {\n\t\t\tcontinue\n\t\t}\n\t\tw := (r[i] - len(r)/2)\n\t\tif w < 0 {\n\t\t\tw = -w\n\t\t\tw += len(r) - r[i]\n\t\t} else {\n\t\t\tw++\n\t\t}\n\t\trx := (i - h[r[i]]) * w\n\t\tif rx < 0 {\n\t\t\tres += -rx\n\t\t} else {\n\t\t\tres += rx\n\t\t}\n\t}\n\treturn res\n}", "func Score(word string) int {\n\tvar score int\n\tword = strings.ToUpper(word)\n\tfor _, letter := range word {\n\t\tfor lettersWithPrice := range prices {\n\t\t\tif strings.ContainsRune(lettersWithPrice, letter) {\n\t\t\t\tscore += prices[lettersWithPrice]\n\t\t\t}\n\t\t}\n\t}\n\treturn score\n}", "func Score(s string) (result int) {\n\tscoreMap := map[string]int{\n\t\t\"a\": 1, \"e\": 1, \"i\": 1, \"o\": 1, \"u\": 1,\n\t\t\"l\": 1, \"n\": 1, \"r\": 1, \"s\": 1, \"t\": 1,\n\t\t\"d\": 2, \"g\": 2,\n\t\t\"b\": 3, \"c\": 3, \"m\": 3, \"p\": 3,\n\t\t\"f\": 4, \"h\": 4, \"v\": 4, \"w\": 4, \"y\": 4,\n\t\t\"k\": 5,\n\t\t\"j\": 8, \"x\": 8,\n\t\t\"q\": 10, \"z\": 10,\n\t}\n\ts = strings.ToLower(s)\n\tfor _, v := range s {\n\t\tresult += scoreMap[string(v)]\n\t}\n\treturn result\n}", "func Score(s string) int {\n\ts = strings.ToUpper(s)\n\tvar sum int\n\tfor _, r := range s {\n\t\tsum += runeScore(r)\n\t}\n\treturn sum\n}", "func Score(state State) float32 {\n\tswitch state {\n\tcase Unknown:\n\t\treturn 0\n\tcase Outage:\n\t\treturn 0.25\n\tcase Major:\n\t\treturn 0.50\n\tcase Minor:\n\t\treturn 0.75\n\tcase OK:\n\t\treturn 1.00\n\tdefault:\n\t\treturn 0\n\t}\n}", "func (va VAScore) Score() float64 {\n\tif va.Err != nil {\n\t\treturn 0.0\n\t}\n\treturn va.Achieved - va.Expected\n}", "func Score(cards set.Cards) *Pnts {\n\tsum := Pnts(0)\n\tfor _, c := range cards {\n\t\tsum += Pnts(Points(c))\n\t}\n\treturn &sum\n}", "func (c Cookie) Score() (s int) {\n\tvar sC, sD, sF, sT int\n\n\tfor _, i := range c {\n\t\t//fmt.Printf(\"%v\", i)\n\t\tsC += i.Quantity * i.Capacity\n\t\tsD += i.Quantity * i.Durability\n\t\tsF += i.Quantity * i.Flavor\n\t\tsT += i.Quantity * i.Texture\n\n\t}\n\tif sC < 0 {\n\t\tsC = 0\n\t}\n\tif sD < 0 {\n\t\tsD = 0\n\t}\n\tif sF < 0 {\n\t\tsF = 0\n\t}\n\tif sT < 0 {\n\t\tsT = 0\n\t}\n\treturn sC * sD * sF * sT\n}", "func (p Problem) Score(correct []int, actual []int) float64 {\n\tgap := 0.0\n\tfor i:=0 ; i < len(correct) && i < len(actual); i++ {\n\t\tgap += math.Abs(float64(correct[i]) - float64(actual[i]))\n\t}\n\n\treturn -gap\n}", "func (solution Solution) Score() int {\n\tscore := 0\n\tfor _, order := range solution {\n\t\tscore += order.score\n\t}\n\n\treturn score\n}", "func Score(s string) int {\n\ts = strings.ToUpper(s)\n\tscore := 0\n\tvar letterScore = map[string]int{\n\t\t\"A, E, I, O, U, L, N, R, S, T\": 1,\n\t\t\"D, G\": 2,\n\t\t\"B, C, M, P\": 3,\n\t\t\"F, H, V, W, Y\": 4,\n\t\t\"K\": 5,\n\t\t\"J, X\": 8,\n\t\t\"Q, Z\": 10,\n\t}\n\tfor _, c := range s {\n\t\tfor key := range letterScore {\n\t\t\tif strings.ContainsRune(key, c) {\n\t\t\t\tscore += letterScore[key]\n\t\t\t}\n\t\t}\n\t}\n\treturn score\n}", "func calcScore2(opp string, me string) int {\n\tif me == \"X\" {\n\t\t/*\n\t\t* LOSE\n\t\t* A -> Rock 3\n\t\t* B -> Paper 1\n\t\t* C -> Scissor 2\n\t\t */\n\t\tswitch opp {\n\t\tcase \"A\":\n\t\t\treturn LOSE + 3\n\t\tcase \"B\":\n\t\t\treturn LOSE + 1\n\t\tcase \"C\":\n\t\t\treturn LOSE + 2\n\t\tdefault:\n\t\t\treturn 0\n\t\t}\n\t} else if me == \"Y\" {\n\t\tswitch opp {\n\t\tcase \"A\":\n\t\t\treturn TIE + 1\n\t\tcase \"B\":\n\t\t\treturn TIE + 2\n\t\tcase \"C\":\n\t\t\treturn TIE + 3\n\t\tdefault:\n\t\t\treturn 0\n\t\t}\n\t} else {\n\t\t/*\n\t\t* WIN\n\t\t* A -> Rock 2\n\t\t* B -> Paper 3\n\t\t* C -> Scissor 1\n\t\t */\n\t\tswitch opp {\n\t\tcase \"A\":\n\t\t\treturn WIN + 2\n\t\tcase \"B\":\n\t\t\treturn WIN + 3\n\t\tcase \"C\":\n\t\t\treturn WIN + 1\n\t\tdefault:\n\t\t\treturn 0\n\t\t}\n\t}\n}", "func (move Move) Score() uint16 {\n\treturn uint16(move & 0xffff)\n}", "func Score(input string) int {\n\n\tvar score int\n\tupCaseInput := strings.ToUpper(input)\n\tfor i := range upCaseInput {\n\n\t\tif upCaseInput[i] >= 'A' && upCaseInput[i] <= 'Z' {\n\t\t\tscore += lookupLetterValue(upCaseInput[i])\n\t\t}\n\t}\n\n\treturn score\n\n}", "func Score(x, y float64) int {\n\tdistance := math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))\n\n\tswitch {\n\tcase distance <= 1:\n\t\treturn 10\n\tcase distance <= 5:\n\t\treturn 5\n\tcase distance <= 10:\n\t\treturn 1\n\tdefault:\n\t\treturn 0\n\t}\n}", "func score(s string) float64 {\n charmap := generateCharacterMap()\n score := 0.0\n for i := 0; i < len(s); i++ {\n char := s[i]\n if _, ok := charmap[string(char)]; ok {\n score = score + charmap[string(char)]\n } \n }\n return score\n}", "func (g *G) Score() int {\n\t/* Fill in this Function */\n\treturn 0\n}", "func (pl *RepeatPriority) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {\n\n rnode := pl.handle.GetNodeUsageFactor(nodeName)\n rhigh := pl.handle.GetHighestUsageFactor()\n\n nodeRF := float64(rnode)/float64(rhigh)\n score := math.Exp(-5*float64(nodeRF))\n return int64(score*100), nil\n}", "func errorScore(text string, errors int) float64 {\n\treturn 1. / (1. + float64(errors))\n}", "func (g *Game) scoreOf() [3]int {\n\tcb := 0\n\tcw := 0\n\tfor x := 0; x < 8; x++ {\n\t\tfor y := 0; y < 8; y++ {\n\t\t\tb := g.Board[x][y]\n\t\t\tif b == Black {\n\t\t\t\tcb++\n\t\t\t} else if b == White {\n\t\t\t\tcw++\n\t\t\t}\n\t\t}\n\t}\n\n\treturn [3]int{cb, cw, cb + cw}\n}", "func (r Round)countScore(players map[string]*Player, master *Player,countInTotal,countBadAnswer bool)(map[string]int,map[string]*DetailScore){\n\troundScore := make(map[string]int,len(players))\n\tdetailScore := make(map[string]*DetailScore,len(players))\n\tfor _,p := range players {\n\t\troundScore[p.Name] = 0\n\t\tdetailScore[p.Name] = &DetailScore{false,0,0}\n\t}\n\tfor playerID,vote := range r.votes {\n\t\tname := players[playerID].Name\n\t\tif r.playersDefinition[vote].isCorrect {\n\t\t\tif countInTotal {\n\t\t\t\tplayers[playerID].Score+=2\n\t\t\t}\n\t\t\troundScore[name] += 2\n\t\t\tg := detailScore[name]\n\t\t\tg.GoodDef = true\n\t\t}else{\n\t\t\tidDefinitionPlayer := r.playersDefinition[vote].playerId\n\t\t\tif countInTotal {\n\t\t\t\tplayers[idDefinitionPlayer].Score++\n\t\t\t}\n\t\t\troundScore[players[idDefinitionPlayer].Name] ++\n\t\t\tdetailScore[players[idDefinitionPlayer].Name].VotePoint++\n\t\t\t// Point bad response for master\n\t\t\tif countBadAnswer {\n\t\t\t\tif countInTotal {\n\t\t\t\t\tmaster.Score++\n\t\t\t\t}\n\t\t\t\troundScore[master.Name] ++\n\t\t\t\tdetailScore[master.Name].ErrorPoint++\n\t\t\t}\n\t\t}\n\t}\n\treturn roundScore,detailScore\n}", "func Score(needle, haystack string) float64 {\n\tneedleLength := len(needle)\n\thaystackLength := len(haystack)\n\tif needleLength > haystackLength {\n\t\treturn -1\n\t}\n\n\tif needleLength == 0 {\n\t\treturn 0\n\t}\n\n\tlowerNeedle := strings.ToLower(needle)\n\tlowerHaystack := strings.ToLower(haystack)\n\tscore := 0.0\n\tfor i, j := 0, 0; i < needleLength && j < haystackLength; i, j = i+1, j+1 {\n\n\t\tletter := lowerNeedle[i]\n\t\tletterIndex := strings.IndexByte(lowerHaystack[j:], letter) + j\n\t\tif (letterIndex - j) < 0 {\n\t\t\treturn -1\n\t\t}\n\n\t\tif areLettersSameCase(needle[i], haystack[j]) {\n\t\t\tscore += 0.5\n\t\t}\n\n\t\tif letterIndex == j {\n\t\t\t// Letter was consecutive\n\t\t\tscore += 8\n\t\t} else {\n\t\t\tscore += 1 - (0.1 * float64(letterIndex))\n\t\t\t// Move j up to the next found letter.\n\t\t\tj = letterIndex\n\t\t}\n\n\t\tif j == haystackLength-1 && i < needleLength-1 {\n\t\t\treturn -1\n\t\t}\n\t}\n\treturn score\n}", "func Score(hand ...deck.Card) int {\n\tminScore := minScore(hand...)\n\tif minScore > 11 {\n\t\t// we can't increase 12 to 22, because that will be a bust\n\t\treturn minScore\n\t}\n\n\tfor _, c := range hand {\n\t\tif c.Rank == deck.Ace {\n\t\t\t// ace is currently worth 1, and we are changing it to be worth 11\n\t\t\t// 11 - 1 = 10\n\t\t\treturn minScore + 10\n\t\t}\n\t}\n\treturn minScore\n}", "func Score(x, y float64) int {\n\tswitch dist := math.Sqrt(x*x + y*y); {\n\tcase dist <= inner:\n\t\treturn 10\n\tcase dist <= middle:\n\t\treturn 5\n\tcase dist <= outer:\n\t\treturn 1\n\tdefault:\n\t\treturn 0\n\t}\n}", "func (s *Survey) Score() (score uint) {\n\tfor _, a := range s.Answers {\n\t\tswitch t := a[\"answer\"].(map[string]interface{})[\"score\"].(type) {\n\t\tcase int: // FIXME score came from models_test.newSurvey test case is int type\n\t\t\tscore = score + uint(t)\n\t\tcase float64:\n\t\t\tscore = score + uint(t)\n\t\t}\n\t}\n\treturn\n}", "func (ap *AnimeParser) getScore(eachTop *goquery.Selection) float64 {\n\tscore := eachTop.Find(\"td:nth-of-type(3)\").Text()\n\tscore = strings.TrimSpace(strings.Replace(score, \"N/A\", \"\", -1))\n\treturn utils.StrToFloat(score)\n}", "func (c *category) score(tally map[rule]int, conf *config, ruleScores map[string]ruleScore) int {\n\ttotal := 0\n\tweights := c.weights\n\tfor r, count := range tally {\n\t\tw := weights[r]\n\t\tif w.points == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tp := w.points * count\n\t\tif conf.CountOnce {\n\t\t\tp = w.points\n\t\t}\n\t\tif w.maxPoints != 0 && (p > 0 && p > w.maxPoints || p < 0 && p < w.maxPoints) {\n\t\t\tp = w.maxPoints\n\t\t}\n\t\ttotal += p\n\t\tif ruleScores != nil {\n\t\t\truleScores[r.String()] = ruleScore{count, p}\n\t\t}\n\t}\n\treturn total\n}", "func Score(hand ...deck.Card) int {\n\tminScore := minScore(hand...)\n\tif minScore > 11 {\n\t\treturn minScore\n\t}\n\tfor _, c := range hand {\n\t\tif int(c.Rank) == 1 {\n\t\t\t// ace is currently worth 1, and we are changing it to be worth 11\n\t\t\t// 11 - 1 = 10\n\t\t\treturn minScore + 10\n\t\t}\n\t}\n\treturn minScore\n}", "func (dist Beta) Score(vars, params []float64) float64 {\n\treturn Beta{Alpha: params[0], Beta: params[1]}.PDF(vars[0])\n}", "func (s PositionEvaluator) Evaluate(p *position.Position) float64 {\n\t// calculate initial material\n\tmaterial := p.GetMaterial()\n\tpceCount := p.GetPieceCount()\n\tpceList := p.GetPieceList()\n\n\tscore := material[position.WHITE] - material[position.BLACK]\n\n\t//calculate\n\t//piece\n\t//squares\n\tpce := position.PwP\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore += pawnTable[position.SQ64(sq120)]\n\t}\n\n\tpce = position.PbP\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore -= pawnTable[mirror64[position.SQ64(sq120)]]\n\t}\n\n\tpce = position.PwN\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore += knightTable[position.SQ64(sq120)]\n\t}\n\n\tpce = position.PbN\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore -= knightTable[mirror64[position.SQ64(sq120)]]\n\t}\n\n\tpce = position.PwB\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore += bishopTable[position.SQ64(sq120)]\n\t}\n\n\tpce = position.PbB\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore -= bishopTable[mirror64[position.SQ64(sq120)]]\n\t}\n\n\tpce = position.PwR\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore += rookTable[position.SQ64(sq120)]\n\t}\n\n\tpce = position.PbR\n\tfor i := 0; i < pceCount[pce]; i++ {\n\t\tsq120 := pceList[pce][i]\n\t\tscore -= rookTable[mirror64[position.SQ64(sq120)]]\n\t}\n\n\treturn float64(score)\n}", "func (g *Game) Score() int {\n\trollIndex := 0\n\tfor frame := 0; frame < frameNumberPerGame; frame++ {\n\t\tif g.isStrike(rollIndex) {\n\t\t\tg.score += cleanPinNumber + g.getStrikeBonus(rollIndex)\n\t\t\trollIndex++\n\t\t} else if g.isSpare(rollIndex) {\n\t\t\tg.score += cleanPinNumber + g.getSpareBonus(rollIndex)\n\t\t\trollIndex += 2\n\t\t} else {\n\t\t\tg.score += g.getFrameScore(rollIndex)\n\t\t\trollIndex += 2\n\t\t}\n\n\t}\n\treturn g.score\n}", "func (d *diff) CalcScore(key interface{}) float64 {\n\treturn 0\n}", "func (eng *Engine) Score() int32 {\n\treturn Evaluate(eng.Position).GetCentipawnsScore() * eng.Position.Us().Multiplier()\n}", "func (v vvalue) Score(n int) float64 {\n\treturn v.f(n)\n}", "func Score(fileOptions map[string]interface{}) {\n\toptions, err := parseFlags(fileOptions)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tinputFiles := readSharedInputFiles(options)\n\n\tscores := preyScore{\n\t\tBait: calculateBaitComponent(options, inputFiles),\n\t\tDomain: calculateDomainComponent(options, inputFiles),\n\t\tStudy: calculateStudyComponent(options, inputFiles),\n\t\tText: calculateTextComponent(options, inputFiles),\n\t}\n\n\twriteScores(scores, inputFiles, options.outFile)\n}", "func (b *Board) score() Player {\n\tstatic_eval := b.evaluate_static()\n\tif static_eval != NoPlayer {\n\t\treturn static_eval\n\t}\n\n\tif len(b.vacantSquares()) == 0 {\n\t\treturn NoPlayer\n\t}\n\n\tbranch_evals := func() []Player {\n\t\tout := []Player{}\n\t\tfor _, branch := range b.possibleMoves() {\n\t\t\tout = append(out, branch.score())\n\t\t}\n\t\treturn out\n\t}()\n\n\tswitch b.NextPlayer() {\n\tcase Player1:\n\t\tif playerInList(Player1, branch_evals) {\n\t\t\treturn Player1\n\t\t} else if playerInList(NoPlayer, branch_evals) {\n\t\t\treturn NoPlayer\n\t\t} else {\n\t\t\treturn Player2\n\t\t}\n\tcase Player2:\n\t\tif playerInList(Player2, branch_evals) {\n\t\t\treturn Player2\n\t\t} else if playerInList(NoPlayer, branch_evals) {\n\t\t\treturn NoPlayer\n\t\t} else {\n\t\t\treturn Player1\n\t\t}\n\t}\n\n\treturn NoPlayer\n}", "func Score(x, y float64) int {\n\tswitch {\n\tcase inCircle(x, y, 1):\n\t\treturn 10\n\tcase inCircle(x, y, 5):\n\t\treturn 5\n\tcase inCircle(x, y, 10):\n\t\treturn 1\n\tdefault:\n\t\treturn 0\n\t}\n}", "func (am *Antman) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {\n\tklog.Infof(\"in Score for podName : %v\", pod.Name)\n\tnodeInfo, err := am.frameworkHandle.SnapshotSharedLister().NodeInfos().Get(nodeName)\n\tif err != nil {\n\t\treturn 0, framework.NewStatus(framework.Error, fmt.Sprintf(\"getting node %q from Snapshot: %v\", nodeName, err))\n\t}\n\n\tpodInfo := am.getOrCreatePodInfo(pod, time.Now())\n\tpodKey := podInfo.key\n\tif len(podKey) == 0 {\n\t\t// normal pod, not opportunistic pod in antman\n\t\t// return 100 for every node to bypass the scoring\n\t\treturn int64(100), nil\n\t}\n\n\t// note that, because there are multiple score plugins in k8s\n\t// it is not the final score for this node\n\treturn am.GpuScore(state, pod, nodeInfo)\n}", "func (p *Puzzle) ComputeScore(words []string) int {\n\tisPangram := func(word string) bool {\n\t\tletters := map[string]struct{}{\n\t\t\tp.CenterLetter: {},\n\t\t}\n\t\tfor _, letter := range p.Letters {\n\t\t\tletters[letter] = struct{}{}\n\t\t}\n\n\t\tfor _, letter := range word {\n\t\t\tdelete(letters, string(letter))\n\t\t}\n\n\t\treturn len(letters) == 0\n\t}\n\n\tvar score int\n\tfor _, word := range words {\n\t\tif len(word) == 4 {\n\t\t\tscore += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tscore += len(word)\n\n\t\t// pangrams get a 7 point bonus\n\t\tif isPangram(word) {\n\t\t\tscore += 7\n\t\t}\n\t}\n\n\treturn score\n}", "func Score(x, y float64) (score int) {\n\t// in order to lie within the circle area the distance of the point (x,y) from (0,0) coordinates\n\t// must be less or equal to the radius of the circle\n\tr := radius(x, y)\n\tswitch {\n\tcase r <= 1.0:\n\t\tscore = 10\n\tcase r <= 5.0:\n\t\tscore = 5\n\tcase r <= 10.0:\n\t\tscore = 1\n\tdefault:\n\t\tscore = 0\n\t}\n\treturn\n}", "func speedScore(text string, time time.Duration) float64 {\n\tspc := time.Seconds() / float64(utf8.RuneCountInString(text))\n\treturn 1. / (1. + 2*spc)\n}", "func Score(c *fiber.Ctx) {\n\tShopID := c.Params(\"shop_id\")\n\tUserID := c.Params(\"user_id\")\n\tvar Score ScoreSQL\n\tvar Response ResponseScore\n\n\tErrorScore := sq.Select(\n\t\t\"AVG(score) as score\",\n\t).\n\t\tFrom(\"shop_score_users\").\n\t\tWhere(\"shop_id = ? AND user_id = ?\", ShopID, UserID).\n\t\tRunWith(database).\n\t\tQueryRow().\n\t\tScan(\n\t\t\t&Score.Score,\n\t\t)\n\n\tif ErrorScore != nil {\n\t\tfmt.Println(ErrorScore, \"Error get score\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Problem with get score\"})\n\t\tc.SendStatus(400)\n\t\treturn\n\t}\n\n\tResponse.Score = &Score.Score.String\n\n\tc.JSON(Response)\n}", "func (game *Game) Score() int {\n\treturn game.score\n}", "func (s *Scanner) Score() {\n\tsort.Slice(s.Freqs, func(i, j int) bool {\n\t\treturn s.Freqs[i].Freq > s.Freqs[j].Freq\n\t})\n}", "func Score(hand ...deck.Card) int { // using variadic so user can pass in just one card if desired\n\tminScore := minScore(hand...)\n\tif minScore > 11 {\n\t\treturn minScore\n\t}\n\tfor _, c := range hand {\n\t\tif c.Rank == deck.Ace {\n\t\t\treturn minScore + 10 // ace is currently worth 1, so adding 10 to make it worth 11\n\t\t}\n\t\t// only 1 ace can be used as 11 and still be under 21\n\t}\n\treturn minScore\n}", "func beautyScore(line string) int {\n\tfreqs := make(map[rune]int)\n\tc := Counter{}\n\tfor _, char := range line {\n\t\tif unicode.IsLetter(char) {\n\t\t\tchar = unicode.ToLower(char)\n\t\t\tfreqs[char] += 1\n\t\t\tc.Add(char)\n\t\t}\n\t}\n\tmc := c.MostCommon(0)\n\tscore := 26 // We know we must start at 26 and then go down\n\tbeauty := 0\n\tfor ix, item := range mc {\n\t\tcount := item.Count\n\t\tbeauty += count * (score - ix)\n\t}\n\treturn beauty\n}", "func (no *NetworkOverhead) Score(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) {\n\tscore := framework.MinNodeScore\n\n\t// Get PreFilterState\n\tpreFilterState, err := getPreFilterState(cycleState)\n\tif err != nil {\n\t\tklog.ErrorS(err, \"Failed to read preFilterState from cycleState\", \"preFilterStateKey\", preFilterStateKey)\n\t\treturn score, framework.NewStatus(framework.Error, \"not eligible due to failed to read from cycleState, return min score\")\n\t}\n\n\t// If scoreEqually, return minScore\n\tif preFilterState.scoreEqually {\n\t\treturn score, framework.NewStatus(framework.Success, \"scoreEqually enabled: minimum score\")\n\t}\n\n\t// Return Accumulated Cost as score\n\tscore = preFilterState.finalCostMap[nodeName]\n\tklog.V(4).InfoS(\"Score:\", \"pod\", pod.GetName(), \"node\", nodeName, \"finalScore\", score)\n\treturn score, framework.NewStatus(framework.Success, \"Accumulated cost added as score, normalization ensures lower costs are favored\")\n}", "func (m *LogLoss) Score() float64 {\n\tm.mu.RLock()\n\tlogsum := m.logsum\n\tweight := m.weight\n\tm.mu.RUnlock()\n\n\tif weight > 0 {\n\t\treturn -logsum / weight\n\t}\n\treturn -math.Log(m.epsilon)\n}", "func (el *gameStruct) Score() int {\n\treturn el.points\n}", "func bagOfTokensScore(tokens []int, p int) int {\n\t// 先找到最小的能量值,用于换取分数\n\t// 用换到的分数,换取最大的能量\n\t// 循环以往\n\tsort.Ints(tokens)\n\tif p < tokens[0] {\n\t\treturn 0\n\t}\n\n\tpoints := 0\n//\tcnt := 0\n\tfor h, t := 0, len(tokens)-1; h <= t; {\n\t\tfmt.Println(\"h, t, points, p:\", h, t, points, p)\n\t\tif p > tokens[h] {\n\t\t\tp -= tokens[h]\n\t\t\tpoints++\n\t\t\th++\n//\t\t\tcnt++\n\t\t}\n\n\t\tif p >= tokens[t] {\n\t\t\tp -= tokens[t]\n\t\t\tpoints++\n\t\t\tt--\n//\t\t\tcnt++\n\t\t\tcontinue\n\t\t}\n\n\t\tif h == t {\n\t\t\tbreak\n\t\t}\n\n\t\tif points > 0 {\n\t\t\tp += tokens[t]\n\t\t\tpoints--\n\t\t\tt--\n\t\t}\n\t}\n\tfmt.Println(points)\n\treturn points\n}", "func (g *Game) renderScore(f *Frame) {\n\tcol, row := scoreCoords()\n\tf.Draw(fmt.Sprintf(\"Score: %d\", g.score), col, row, ColorDefault, ColorDefault)\n}", "func FinalScore(scorers []*card.Item) (sum uint8) {\n\tfor _, s := range scorers {\n\t\tsum += Points(s)\n\t}\n\treturn\n}", "func incrementScore(b *bot.SlackBot, team, user string) (int, error) {\n\n\tscore := 0\n\n\tsess, err := session.NewSession(&aws.Config{Region: aws.String(b.Region)})\n\tif err != nil {\n\t\treturn score, errors.Wrap(err, \"unable to create session\")\n\t}\n\n\tddb := dynamodb.New(sess)\n\n\tinput := &dynamodb.UpdateItemInput{\n\t\tExpressionAttributeValues: map[string]*dynamodb.AttributeValue{\":s\": {N: aws.String(\"1\")}},\n\t\tTableName: aws.String(b.ScoreTable),\n\t\tKey: map[string]*dynamodb.AttributeValue{\"uid\": {S: aws.String(team + \":\" + user)}},\n\t\tReturnValues: aws.String(\"UPDATED_NEW\"),\n\t\tUpdateExpression: aws.String(\"add score :s\"),\n\t}\n\n\tv, err := ddb.UpdateItem(input)\n\tif err != nil {\n\t\treturn score, errors.Wrap(err, \"unable to update database\")\n\t}\n\n\terr = dynamodbattribute.Unmarshal(v.Attributes[\"score\"], &score)\n\n\tif err != nil {\n\t\treturn score, errors.Wrap(err, \"unable to unmarshal return value\")\n\t}\n\n\treturn score, nil\n}", "func (g *Game) getFrameScore(rollIndex int) int {\n\treturn g.rolls[rollIndex] + g.rolls[rollIndex+1]\n}", "func (b *Block) Score() int64 {\n\treturn b.work\n}", "func calculateScore(bestClass base.Feature, classes map[base.Feature][]float64) float64 {\n var sum float64 = 0;\n for class, distances := range(classes) {\n for _, distance := range(distances) {\n if (class == bestClass) {\n sum += distance;\n } else {\n sum -= distance;\n }\n }\n }\n\n return (1.0 / (sum + float64(util.Sign(sum)))) + (2.0 * float64(len(classes[bestClass])));\n}", "func evaluate(board [8][8]int, player int) float32 {\n\tvar score float32\n\n\t//Created a grid of relative score values for each cell\n\t//Based on Reversi strategy\n\t//Corners are stable and valuable, but adjacent cells can lead to losing a corner\n\t//Edge pieces are somewhat stable and valuable otherwise\n\t//Cells 2 away from corner facilitate corner capturing\n\t//All other tiles are weighted at 1\n\n\tcellValue := [][]int{\n\t\t{50, -20, 10, 5, 5, 10, -20, 50},\n\t\t{-20, -20, 1, 1, 1, 1, -20, -20},\n\t\t{10, 1, 5, 1, 1, 5, 1, 10},\n\t\t{5, 1, 1, 1, 1, 1, 1, 5},\n\t\t{5, 1, 1, 1, 1, 1, 1, 5},\n\t\t{10, 1, 5, 1, 1, 5, 1, 10},\n\t\t{-20, -20, 1, 1, 1, 1, -20, -20},\n\t\t{50, -20, 10, 5, 5, 10, -20, 50},\n\t}\n\n\t//Coin Parity\n\tvar pScore float32\n\tvar pCoin float32\n\tvar oCoin float32\n\n\t//Score player and opponent cell\n\tfor i := 0; i < 8; i++ {\n\t\tfor j := 0; j < 8; j++ {\n\t\t\tif board[i][j] == player {\n\t\t\t\tpCoin += float32(cellValue[i][j])\n\t\t\t} else if board[i][j] == enemy(player) {\n\t\t\t\toCoin += float32(cellValue[i][j])\n\t\t\t}\n\t\t}\n\t}\n\n\t//Parity score is difference in scores over total score\n\tpScore = (pCoin - oCoin) / (pCoin + oCoin)\n\n\t//Difference in Mobility\n\t//Create games assuming board state and turn to calculate size of valid moves\n\tvar mScore float32\n\n\tpMob := createGame(board, player)\n\toMob := createGame(board, enemy(player))\n\n\tplayerMobility := len(pMob.validMoves)\n\tenemyMobility := len(oMob.validMoves)\n\n\tswitch{\n\tcase playerMobility > enemyMobility:\n\t\tmScore = float32(playerMobility)/float32(playerMobility + enemyMobility)\n\tcase enemyMobility > playerMobility:\n\t\tmScore = -float32(enemyMobility)/float32(playerMobility + enemyMobility)\n\tdefault:\n\t\tmScore = 0\n\t}\n\n\t//fmt.Printf(\"Parity:%v Mobility:%v\\n\", pScore, mScore)\n\t//Total evaluated score\n\tscore = (pScore * 500) + (mScore * 600)\n\n\treturn score\n}", "func SingleScore(char rune) int {\n\n\tif char < 'A' || char > 'Z' {\n\t\terrors.New(\"wrong character\")\n\t\treturn -1\n\t}\n\n\tswitch char {\n\tcase 'D', 'G':\n\t\treturn 2\n\tcase 'B', 'C', 'M', 'P':\n\t\treturn 3\n\tcase 'F', 'H', 'V', 'W', 'Y':\n\t\treturn 4\n\tcase 'K':\n\t\treturn 5\n\tcase 'J', 'X':\n\t\treturn 8\n\tcase 'Q', 'Z':\n\t\treturn 10\n\tdefault:\n\t\treturn 1\n\t}\n}", "func (c *Claim) Score(ctx *ServerContext) (float32, Error) {\n\tif c.QueryAt == nil {\n\t\treturn c.Truth, nil\n\t}\n\treturn c.scoreAt(ctx)\n}", "func score_text(tst_txt string) float64 {\n\tstrLen := len(tst_txt)\n\tscore := 0.0\n\tfreq := make(map[byte]float64)\n\tfor i := 0; i < strLen; i++{\n\t\t_, ok := englishLetterHist[tst_txt[i]]\n\t\tif ok {\n\t\t\t_, ok = freq[tst_txt[i]]\n\t\t\tif ok {\n\t\t\t\tfreq[tst_txt[i]] += 1.0\n\t\t\t} else{\n\t\t\t\tfreq[tst_txt[i]] = 1.0\n\t\t\t}\n\t\t} else if tst_txt[i] != ' ' {\n\t\t\t//return math.MaxFloat64\n\t\t\t//score += 100.0/float64(strLen)\n\t\t\tscore += 1000.0/float64(strLen)\n\n\t\t}\n\t}\n\t\n\tfor char, fr := range freq {\n\t\th := (fr/float64(strLen)) * 100.0\n\t\tscore += (h - englishLetterHist[char]) * (h - englishLetterHist[char])\n\t\t//score += math.Abs(h - englishLetterHist[char])\n\t}\n\n\treturn score\n}", "func ScoreHSTS(p *HSTSProfile) (s int) {\n\treturn sm[p.Maxage > 0] + sm[p.IncludeSubdomains] + sm[p.Preload]\n}", "func (r *Race) Score(atlas *Atlas) int {\n\tcoins := 0\n\tf := func(region RegionI) {\n\t\tcoins += 1\n\t}\n\tr.ApplyToOccupied(atlas, f)\n\treturn coins\n}", "func (eng *Engine) cachedScore(e *hashEntry) int32 {\n\tif e.kind&hasStatic == 0 {\n\t\te.kind |= hasStatic\n\t\te.static = int16(eng.Score())\n\t}\n\treturn int32(e.static)\n}", "func (d *Dispatcher) calScore(numReqs, restSpace int, avgResponseTime float) score int {\n\t//\n\treturn\n}", "func (l *LexerEngine) Score() int {\n\treturn l.score\n}", "func GetScore(str string) int {\n\tprobTable := map[uint8]int{\n\t\t\"e\"[0]: 13, \"E\"[0]: 13,\n\t\t\"t\"[0]: 9, \"T\"[0]: 9,\n\t\t\"a\"[0]: 8, \"A\"[0]: 8,\n\t\t\"o\"[0]: 8, \"O\"[0]: 8,\n\t\t\"n\"[0]: 7, \"N\"[0]: 7,\n\t\t\"i\"[0]: 7, \"I\"[0]: 7,\n\t\t\"r\"[0]: 7, \"R\"[0]: 7,\n\t\t\"s\"[0]: 6, \"S\"[0]: 6,\n\t\t\"h\"[0]: 6, \"H\"[0]: 6,\n\t\t\"l\"[0]: 4, \"L\"[0]: 4,\n\t\t\"d\"[0]: 4, \"D\"[0]: 4,\n\t\t\"c\"[0]: 3, \"C\"[0]: 3,\n\t\t\"u\"[0]: 3, \"U\"[0]: 3,\n\t\t\"p\"[0]: 3, \"P\"[0]: 3,\n\t\t\"f\"[0]: 3, \"F\"[0]: 3,\n\t\t\"m\"[0]: 2, \"M\"[0]: 2,\n\t\t\"w\"[0]: 2, \"W\"[0]: 2,\n\t\t\"y\"[0]: 2, \"Y\"[0]: 2,\n\t\t\"b\"[0]: 1, \"B\"[0]: 1,\n\t\t\"g\"[0]: 1, \"G\"[0]: 1,\n\t\t\"v\"[0]: 1, \"V\"[0]: 1,\n\t\t\" \"[0]: 4,\n\t}\n\n\tscore := 0\n\tfor i := range str {\n\t\tscore += probTable[str[i]]\n\t}\n\n\treturn score\n}", "func (s *State) ApplyScore(north, south, west, east string, nsScore, weScore int) error {\n\tseating := s.CurrentRound().FindSeating(north, south, west, east)\n\tif seating == nil {\n\t\treturn fmt.Errorf(\"Couldn't find a seating with these players: N %s, S %s, W %s, E %s\", north, south, west, east)\n\t}\n\n\tseating.Finished = true\n\tseating.NSScore = nsScore\n\tseating.WEScore = weScore\n\tif nsScore >= weScore {\n\t\tseating.NSWins = true\n\t}\n\n\treturn nil\n}", "func minScore(hand ...deck.Card) int {\n\tscore := 0\n\tfor _, c := range hand {\n\t\t// because J, Q, K has rank 11, 12, 13..\n\t\t// we'll either add 10 or less than 10\n\t\tscore += min(int(c.Rank), 10)\n\t}\n\treturn score\n}", "func UpdateScore(amount int) {\n\tgs.Score += amount\n\tsp.ScoreText.SetText(fmt.Sprintf(\"Score: %d\", gs.Score))\n}", "func (d Dispatcher) Score() float64 {\n\treturn d.GetBench().GetScore()\n}", "func addScore(s int){\n\tscoreData.Scores = append(scoreData.Scores, s)\n\t\t\t\n\t\t\t// TODO: check if there is a score to check with\n\t\t\tsort.Slice(scoreData.Scores, func(i, j int) bool { return scoreData.Scores[i] > scoreData.Scores[j] })\n\t\t\tif scoreData.Scores[0] > scoreData.Highscore {\n\t\t\t\ttmp := scoreData.Highscore\n\t\t\t\tscoreData.Highscore = scoreData.Scores[0]\n\t\t\t\tscoreData.Scores[0] = tmp\n\t\t\t}\n\t\t\t\n}", "func (g *Game) UpdateScore() error {\n\tswitch g.Winner {\n\tcase RIGHT:\n\t\tright, _ := g.GameScore()\n\t\tg.RightScore = int(right)\n\t\tg.LeftScore = -int(right)\n\t\treturn nil\n\tcase LEFT:\n\t\t_, left := g.GameScore()\n\t\tg.RightScore = -int(left)\n\t\tg.LeftScore = int(left)\n\t\treturn nil\n\tcase DRAW:\n\t\tscore := g.TournamentTable.Tournament.GameScore / 2\n\t\tg.RightScore = int(score)\n\t\tg.LeftScore = int(score)\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"no winner in this game\")\n\t}\n}", "func (sqlite *SQLiteDB) OveralScore(from time.Time, to time.Time) (int32, error) {\n\tvar score int32\n\terr := sqlite.db.Get(&score,\n\t\t`SELECT round(AVG(rating * weight)/AVG($1 * weight)*100) as score\n\t\tFROM ratings\n\t\tINNER JOIN tickets ON ratings.ticket_id=tickets.id\n\t\tINNER JOIN rating_categories ON ratings.rating_category_id=rating_categories.id\n\t\tWHERE tickets.created_at BETWEEN $2 AND $3;`,\n\t\tdb.MaxRating, from.Format(db.SimpleDateFormat), to.Format(db.SimpleDateFormat))\n\n\tif err != nil {\n\t\treturn score, err\n\t}\n\treturn score, err\n}", "func SetScore(c *fiber.Ctx) {\n\tShopID := c.Params(\"shop_id\")\n\tUserID := userIDF(c.Get(\"token\"))\n\n\tvar Data ScoreStruct\n\n\tif errorParse := c.BodyParser(&Data); errorParse != nil {\n\t\tfmt.Println(\"Error parsing data\", errorParse)\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Error al parsear información\"})\n\t\tc.Status(400)\n\t\treturn\n\t}\n\n\tif Data.Score <= 0 {\n\t\tfmt.Println(\"score can't be empty\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Score can't be empty\"})\n\t\tc.Status(400)\n\t\treturn\n\t}\n\n\tvar Score ScoreSQL\n\tvar Response ResponseScore\n\n\t_, errorInsert := sq.Insert(\"shop_score_users\").\n\t\tColumns(\n\t\t\t\"user_id\",\n\t\t\t\"shop_id\",\n\t\t\t\"score\",\n\t\t).\n\t\tValues(\n\t\t\tUserID,\n\t\t\tShopID,\n\t\t\tData.Score,\n\t\t).\n\t\tRunWith(database).\n\t\tExec()\n\n\tif errorInsert != nil {\n\t\tfmt.Println(\"Error to save score\", errorInsert)\n\t}\n\n\tErrorScore := sq.Select(\n\t\t\"AVG(score) as score\",\n\t).\n\t\tFrom(\"shop_score_users\").\n\t\tWhere(\"shop_id = ?\", ShopID).\n\t\tRunWith(database).\n\t\tQueryRow().\n\t\tScan(\n\t\t\t&Score.Score,\n\t\t)\n\n\tif ErrorScore != nil {\n\t\tfmt.Println(ErrorScore, \"Error get score\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Problem with get score\"})\n\t\tc.SendStatus(400)\n\t\treturn\n\t}\n\n\tqueryUpdateValue := sq.Update(\"shop\")\n\n\tScoreFloat, _ := strconv.ParseFloat(Score.Score.String, 64)\n\n\tNewScore := fmt.Sprintf(\"%.0f\", ScoreFloat)\n\n\t_, ErrorUpdateOffer := queryUpdateValue.\n\t\tSet(\"score_shop\", NewScore).\n\t\tWhere(\"shop_id = ? \", ShopID).\n\t\tRunWith(database).\n\t\tExec()\n\n\tif ErrorUpdateOffer != nil {\n\t\tfmt.Println(ErrorUpdateOffer, \"Problem with update score\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Problem with update score\"})\n\t\tc.SendStatus(500)\n\t\treturn\n\t}\n\n\tResponse.Score = &NewScore\n\n\tc.JSON(Response)\n}", "func (g Gun)evaluate()int{\n\trangeScore := g.EffectiveRange\n\tdamageScore := g.MaxDamage\n\taccuracyScore := 2.5*(g.Accuracy/100)\n\tROFScore := (MAX_GUN_TIME_BETWEEN_SHOTS+0.2*MAX_GUN_TIME_BETWEEN_SHOTS-g.TimeBetweenShots)/MAX_GUN_TIME_BETWEEN_SHOTS\n\trecoilScore := ((110-g.Recoil)/100)/ROFScore\n\treloadScore := (MAX_GUN_RELOAD_TIME+0.2*MAX_GUN_RELOAD_TIME-g.ReloadTime)/MAX_GUN_RELOAD_TIME\n\tweightScore := (MAX_GUN_WEIGHT+0.2*MAX_GUN_WEIGHT-g.Weight)/MAX_GUN_WEIGHT\n\tdurabilityScore := g.Durability/100\n\tprice := int(rangeScore*damageScore*accuracyScore*ROFScore*recoilScore*reloadScore*weightScore*durabilityScore)\n\tif LOG_MODE >=1{\n\t\tfmt.Printf(\"Valued %s at %d%c\\n\",g.Name,price,RUBLE)\n\t}\n\tif LOG_MODE==DEBUG{\n\t\tfmt.Printf(\"Range score: %f\\n\",rangeScore)\n\t\tfmt.Printf(\"Damage score: %f\\n\",damageScore)\n\t\tfmt.Printf(\"Accuracy score: %f\\n\",accuracyScore)\n\t\tfmt.Printf(\"Recoil score: %f\\n\",recoilScore)\n\t\tfmt.Printf(\"Rate of fire score: %f\\n\",ROFScore)\n\t\tfmt.Printf(\"Reload speed score: %f\\n\",reloadScore)\n\t\tfmt.Printf(\"Weight score: %f\\n\",weightScore)\n\t\tfmt.Printf(\"Durability score: %f\\n\",durabilityScore)\n\t\tfmt.Println()\n\t}\n\treturn price\n}", "func encodeScore(timestamp int64, tries uint16) float64 {\n\treturn float64(((timestamp & 0xffffffff) << 16) | int64(tries&0xffff))\n}", "func CreatePlayerScore(gameName string, kills int, deaths int, assists int, cs int, tripleKills int, quadraKills int, pentaKills int) *PlayerScore {\n\tscore := PlayerScore{\n\t\tSummonerName: gameName,\n\t\tKills: float32(kills) * PointValues[KillsString],\n\t\tDeaths: float32(deaths) * PointValues[DeathsString],\n\t\tAssists: float32(assists) * PointValues[AssistsString],\n\t\tCS: float32(cs) * PointValues[CSString],\n\t\tTripleKills: float32(tripleKills) * PointValues[TripleKillsString],\n\t\tQuadraKills: float32(quadraKills) * PointValues[QuadraKillsString],\n\t\tPentakills: float32(pentaKills) * PointValues[PentakillsString],\n\t}\n\tscore.CSString = fmt.Sprintf(\"%.2f\", score.CS)\n\n\t//Bonus points for getting at least 10 kills/assists in the same game\n\tif kills+assists >= 10 {\n\t\tscore.TenKA = PointValues[TenKAString]\n\t}\n\n\tscore.Score = score.Kills + score.Deaths + score.Assists + score.CS + score.TenKA + score.TripleKills +\n\t\tscore.QuadraKills + score.Pentakills\n\tscore.ScoreString = fmt.Sprintf(\"%.2f\", score.Score)\n\n\treturn &score\n}", "func nameScore(names []string) int {\n\tvar sum int\n\tfor i := 0; i < len(names); i++ {\n\t\tvar nameSum int\n\t\tfor j := 0; j < len(names[i]); j++ {\n\t\t\tnameSum += int(names[i][j]) - 64\n\t\t}\n\t\tsum += nameSum * (i + 1)\n\t}\n\treturn sum\n}", "func ColorScore(score float64) string {\n\ttextScore := fmt.Sprintf(\"%.2f\", score)\n\tif score >= .75 {\n\t\treturn Green + textScore + Normal\n\t} else if score >= .5 {\n\t\treturn Yellow + textScore + Normal\n\t} else {\n\t\treturn Red + textScore + Normal\n\t}\n}", "func UpdateScore(c *fiber.Ctx) {\n\tShopID := c.Params(\"shop_id\")\n\tUserID := userIDF(c.Get(\"token\"))\n\n\tvar Data ScoreStruct\n\n\tif errorParse := c.BodyParser(&Data); errorParse != nil {\n\t\tfmt.Println(\"Error parsing data\", errorParse)\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Error al parsear información\"})\n\t\tc.Status(400)\n\t\treturn\n\t}\n\n\tif Data.Score <= 0 {\n\t\tfmt.Println(\"score can't be empty\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Score can't be empty\"})\n\t\tc.Status(400)\n\t\treturn\n\t}\n\n\tvar Score ScoreSQL\n\n\t_, ErrorUpdateScoreUser := sq.Update(\"shop_score_users\").\n\t\tSet(\"score\", Data.Score).\n\t\tWhere(\"user_id = ? AND shop_id = ?\", UserID, ShopID).\n\t\tRunWith(database).\n\t\tExec()\n\n\tif ErrorUpdateScoreUser != nil {\n\t\tfmt.Println(\"Error to update score\", ErrorUpdateScoreUser)\n\t}\n\n\tErrorScore := sq.Select(\n\t\t\"AVG(score) as score\",\n\t).\n\t\tFrom(\"shop_score_users\").\n\t\tWhere(\"shop_id = ?\", ShopID).\n\t\tRunWith(database).\n\t\tQueryRow().\n\t\tScan(\n\t\t\t&Score.Score,\n\t\t)\n\n\tif ErrorScore != nil {\n\t\tfmt.Println(ErrorScore, \"Error get score\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Problem with get score\"})\n\t\tc.SendStatus(400)\n\t\treturn\n\t}\n\n\tqueryUpdateValue := sq.Update(\"shop\")\n\n\tScoreFloat, _ := strconv.ParseFloat(Score.Score.String, 64)\n\n\tNewScore := fmt.Sprintf(\"%.0f\", ScoreFloat)\n\n\t_, ErrorUpdateScoreShop := queryUpdateValue.\n\t\tSet(\"score_shop\", NewScore).\n\t\tWhere(\"shop_id = ? \", ShopID).\n\t\tRunWith(database).\n\t\tExec()\n\n\tif ErrorUpdateScoreShop != nil {\n\t\tfmt.Println(ErrorUpdateScoreShop, \"Problem with update score\")\n\t\tc.JSON(ErrorResponse{MESSAGE: \"Problem with update score\"})\n\t\tc.SendStatus(500)\n\t\treturn\n\t}\n\n\tc.JSON(SuccessResponse{MESSAGE: \"Calificación actualizada\"})\n}", "func ageScore(donorAge int, recipientAge int) float64 {\n\t// âge des priorités : 2 mineurs ou 2 seniors\n\tif (donorAge <= 18 && recipientAge <= 18) || (donorAge >= 65 && recipientAge >= 65) {\n\t\treturn 1.0\n\t}\n\n\tageDiff := int(math.Abs(float64(donorAge - recipientAge)))\n\tif (ageDiff >= 0) && (ageDiff <= 5) {\n\t\treturn 1.0\n\t} else if (ageDiff >= 6) && (ageDiff <= 10) {\n\t\treturn 0.8\n\t} else if (ageDiff >= 11) && (ageDiff <= 20) {\n\t\treturn 0.6\n\t} else if (ageDiff >= 21) && (ageDiff <= 30) {\n\t\treturn 0.3\n\t} else if (ageDiff >= 31) && (ageDiff <= 40) {\n\t\treturn 0.1\n\t}\n\treturn 0.0\n}", "func (h *Hand) Scores() []int {\n\tscores := []int{0}\n\tfor _, card := range h.Cards {\n\t\tif !card.faceUp {\n\t\t\tcontinue\n\t\t}\n\t\tfor i, score := range scores {\n\t\t\t// Add the first value to each score branch.\n\t\t\tscores[i] += card.Values()[0]\n\t\t\tfor _, cardValue := range card.Values()[1:] {\n\t\t\t\t// Make more score branches for further card values.\n\t\t\t\t// In other words, branch on aces.\n\t\t\t\tscores = append(scores, score+cardValue)\n\t\t\t}\n\t\t}\n\t}\n\t// If we have blackjack then return that alone\n\tfor _, score := range scores {\n\t\tif score == 21 {\n\t\t\treturn []int{21}\n\t\t}\n\t}\n\tscores = util.UniqueInts(scores)\n\tscores = sanitiseScores(scores)\n\tsort.Ints(scores)\n\treturn scores\n}", "func FormatScore(game responses.FantasyGame) string {\n\thomeTeam := game.Home.Name\n\tawayTeam := game.Away.Name\n\n\thomeScore := game.HomeScore.Score.Value\n\tawayScore := game.AwayScore.Score.Value\n\n\tif homeScore > awayScore {\n\t\treturn fmt.Sprintf(\"%v beat %v with a score of %.2f-%.2f.\\n\", homeTeam, awayTeam, homeScore, awayScore)\n\t} else if awayScore > homeScore {\n\t\treturn fmt.Sprintf(\"%v beat %v with a score of %.2f-%.2f.\\n\", awayTeam, homeTeam, awayScore, homeScore)\n\t} else {\n\t\treturn fmt.Sprintf(\"Whaaaat....%v and %v tied with a score of %.2f-%.2f.\\n\", homeTeam, awayTeam, homeScore, awayScore)\n\t}\n}" ]
[ "0.7726904", "0.73985106", "0.7207054", "0.71976393", "0.71702987", "0.7127209", "0.7111534", "0.7051714", "0.7018535", "0.7013469", "0.70032245", "0.6995374", "0.6980295", "0.69591767", "0.6959122", "0.68864274", "0.68750316", "0.68546194", "0.68500453", "0.6849642", "0.6783423", "0.6739941", "0.67320675", "0.67311954", "0.6728567", "0.6641273", "0.6639878", "0.66158056", "0.6590001", "0.6576017", "0.65704185", "0.65599626", "0.65455025", "0.65410966", "0.64824307", "0.6473429", "0.64677083", "0.64297146", "0.63836855", "0.6383581", "0.6378809", "0.6370363", "0.63682526", "0.6368149", "0.6367884", "0.6365073", "0.63468045", "0.63318247", "0.6325294", "0.6325068", "0.6306185", "0.6263331", "0.62539136", "0.6247157", "0.6244844", "0.6239447", "0.6237554", "0.6235109", "0.62285024", "0.6227411", "0.6218847", "0.6153732", "0.61242", "0.61152685", "0.6111177", "0.6103288", "0.60726005", "0.60332423", "0.60274935", "0.6024858", "0.6023637", "0.60030395", "0.5998632", "0.5991546", "0.5975026", "0.5972597", "0.5969233", "0.5962584", "0.5940714", "0.5909106", "0.59001863", "0.589954", "0.5873456", "0.5855564", "0.5824338", "0.58200926", "0.5815354", "0.58062154", "0.5799616", "0.5795928", "0.579122", "0.5774734", "0.5769203", "0.5754133", "0.57487124", "0.5720369", "0.5713759", "0.5711202", "0.570605", "0.5703375" ]
0.6599822
28
FromRepository recreate object DO NOT use as constructor.
func FromRepository( id scalar.ID, dir string, versionIDs []scalar.ID, collaboratorIDs []scalar.ID, isPublicVisible bool, title string, albumIDs []scalar.ID, projectIDs []scalar.ID, deleted time.Time, deletedByID scalar.ID, created time.Time, createdByID scalar.ID, lastUpdated time.Time, lastUpdatedByID scalar.ID, ) (obj *VideoEditingProject, err error) { obj = &VideoEditingProject{ id: id, dir: dir, versionIDs: versionIDs, collaboratorIDs: collaboratorIDs, isPublicVisible: isPublicVisible, title: title, albumIDs: albumIDs, projectIDs: projectIDs, deleted: deleted, deletedByID: deletedByID, created: created, createdByID: createdByID, lastUpdated: lastUpdated, lastUpdatedByID: lastUpdatedByID, } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func R() Repository {\n\t// make sure to instantiate the Repository only once\n\tonceRepo.Do(func() {\n\t\trepo = newRepository()\n\t})\n\treturn repo\n}", "func newRepository(\n\tid borges.RepositoryID,\n\tsto storage.Storer,\n\tfs billy.Filesystem,\n\tm borges.Mode,\n\ttransactional bool,\n\tl *Location,\n) (*Repository, error) {\n\trepo, err := git.Open(sto, nil)\n\tif err != nil {\n\t\tif err == git.ErrRepositoryNotExists {\n\t\t\trepo, err = git.Init(sto, nil)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, borges.ErrLocationNotExists.Wrap(err, id)\n\t\t}\n\t}\n\n\treturn &Repository{\n\t\tid: id,\n\t\trepo: repo,\n\t\ts: sto,\n\t\tfs: fs,\n\t\tmode: m,\n\t\ttransactional: transactional,\n\t\tlocation: l,\n\t\tcreateVersion: -1,\n\t}, nil\n}", "func newRepository() Repository {\n\tif cfg == nil {\n\t\tpanic(fmt.Errorf(\"missing configuration\"))\n\t}\n\tif log == nil {\n\t\tpanic(fmt.Errorf(\"missing logger\"))\n\t}\n\n\tp2p.SetConfig(cfg)\n\tp2p.SetLogger(log)\n\n\t// create connections\n\tcaBridge, dbBridge, rpcBridge, geoBridge, err := connect(cfg, log)\n\tif err != nil {\n\t\tlog.Fatal(\"repository init failed\")\n\t\treturn nil\n\t}\n\n\t// construct the proxy instance\n\tp := proxy{\n\t\tcache: caBridge,\n\t\tdb: dbBridge,\n\t\trpc: rpcBridge,\n\t\tgeoip: geoBridge,\n\t\tlog: log,\n\t\tcfg: cfg,\n\n\t\t// get the map of governance contracts\n\t\tgovContracts: governanceContractsMap(cfg.Governance),\n\n\t\t// keep reference to the SOL compiler\n\t\tsolCompiler: cfg.Compiler.DefaultSolCompilerPath,\n\t}\n\n\t// return the proxy\n\treturn &p\n}", "func createRepo(repoConstructorFunc interface{}, convMock interface{}) interface{} {\n\tv := reflect.ValueOf(repoConstructorFunc)\n\tif v.Kind() != reflect.Func {\n\t\tpanic(\"Repo constructor should be a function\")\n\t}\n\tt := v.Type()\n\n\tif t.NumOut() != 1 {\n\t\tpanic(\"Repo constructor should return only one argument\")\n\t}\n\n\tif t.NumIn() == 0 {\n\t\treturn v.Call(nil)[0].Interface()\n\t}\n\n\tif t.NumIn() != 1 {\n\t\tpanic(\"Repo constructor should accept zero or one arguments\")\n\t}\n\n\tmockVal := reflect.ValueOf(convMock)\n\treturn v.Call([]reflect.Value{mockVal})[0].Interface()\n}", "func New() backing.Repo {\n\treturn &Repo{}\n}", "func New(prototype Aggregate, opts ...Option) *Repository {\n\tt := reflect.TypeOf(prototype)\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\n\tr := &Repository{\n\t\tprototype: t,\n\t\tstore: newMemoryStore(),\n\t\tserializer: NewJSONSerializer(),\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(r)\n\t}\n\n\treturn r\n}", "func New(db *sql.DB, logger log.Logger) (todo.Repository, error) {\n\t// return repository\n\treturn &repository{\n\t\tdb: db,\n\t\tlogger: log.With(logger, \"rep\", \"cockroachdb\"),\n\t}, nil\n}", "func newRepo(r *github.Repository) Repo {\n\tvar lang string\n\tif r.Language != nil {\n\t\tlang = *r.Language\n\t} else {\n\t\tlang = \"-\"\n\t}\n\treturn Repo{*r.HTMLURL, lang, *r.StargazersCount, *r.ForksCount}\n}", "func MakeRepository(db *sql.DB) journal.Repository {\n\tr := &repository{db}\n\n\treturn r\n}", "func newOrderRepo(db *sql.DB) *orderRepo {\n\treturn &orderRepo{\n\t\tdb: db,\n\t}\n}", "func (a StoriesAllStoriesNotModified) construct() StoriesAllStoriesClass { return &a }", "func convertRepository(src *scm.Repository, visibility string, trusted bool) *core.Repository {\n\treturn &core.Repository{\n\t\tUID: src.ID,\n\t\tNamespace: src.Namespace,\n\t\tName: src.Name,\n\t\tSlug: scm.Join(src.Namespace, src.Name),\n\t\tHTTPURL: src.Clone,\n\t\tSSHURL: src.CloneSSH,\n\t\tLink: src.Link,\n\t\tPrivate: src.Private,\n\t\tVisibility: convertVisibility(src, visibility),\n\t\tBranch: src.Branch,\n\t\tTrusted: trusted,\n\t}\n}", "func newGreetingRepository(db *sql.DB) engine.GreetingRepository {\n\treturn &greetingRepository{db}\n}", "func newUserRepo(db *sql.DB) *userRepo {\n\treturn &userRepo{\n\t\tdb: db,\n\t}\n}", "func New(cfg config.DataConfig, path string) (Repo, error) {\n\tvar repo Repo\n\n\tvcs, err := detectVCS(path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch vcs {\n\tcase Git:\n\t\tvar useTmpDir bool\n\t\ttmpPath := path\n\t\tif strings.HasSuffix(path, \".tar\") {\n\t\t\tif fi, err := os.Stat(path); err == nil && (bytesToGigaBytes(fi.Size()) < cfg.TmpDirFileSizeLimit) {\n\t\t\t\ttmpPath, err = ioutil.TempDir(cfg.TmpDir, \"repotool-git-\")\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttmpPath = strings.TrimSuffix(tmpPath, \".tar\")\n\t\t\t}\n\n\t\t\tif err = untarGitFolder(tmpPath, path); err != nil {\n\t\t\t\t_ = os.RemoveAll(tmpPath)\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tpath = strings.TrimSuffix(path, \".tar\")\n\t\t\t// since we extracted the archive, we need to remove it afterwards\n\t\t\t// hence, tell the gitrepo constructor that git directory is a\n\t\t\t// temporary directory\n\t\t\tuseTmpDir = true\n\t\t}\n\t\tcloneURL, err := extractGitURL(tmpPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tbranch, err := extractGitDefaultBranch(tmpPath)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\trepository := model.Repository{\n\t\t\tName: extractName(path),\n\t\t\tVCS: vcs,\n\t\t\tCloneURL: *cloneURL,\n\t\t\tClonePath: path,\n\t\t\tDefaultBranch: *branch,\n\t\t}\n\t\trepo, err = newGitRepo(cfg, repository, tmpPath, useTmpDir)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn repo, nil\n\t}\n\n\treturn nil, errors.New(\"unsupported repository type\")\n}", "func newService(repo Repository) Service {\n\n\tif repo == nil {\n\t\treturn nil\n\t}\n\treturn &service{repo}\n}", "func New(connection *gorm.DB) Interface {\n\treturn &Repository{connection: connection}\n}", "func New(db *bolt.DB) Repository {\n\treturn Repository{\n\t\tdb: db,\n\t}\n}", "func (r *Repository) FromJSON(jsonData string) error {\n\tif len(jsonData) == 0 {\n\t\treturn errors.New(\"empty json data to construct repository\")\n\t}\n\n\treturn json.Unmarshal([]byte(jsonData), r)\n}", "func InitRepository() appcontext.Component {\n\n\treturn RepositoryMock{}\n}", "func New() *Repository {\n\treturn &Repository{\n\t\tagents: map[string]*adagio.Agent{},\n\t\truns: map[string]runState{},\n\t\tclaims: map[string]struct {\n\t\t\trun *adagio.Run\n\t\t\tnode *adagio.Node\n\t\t}{},\n\t\tlisteners: listenerSet{},\n\t}\n}", "func toDomain(model repositoryModel) helm.Repository {\n\treturn helm.Repository{\n\t\tName: model.Name,\n\t\tURL: model.URL,\n\t\tPasswordSecretID: model.PasswordSecretID,\n\t\tTlsSecretID: model.TlsSecretID,\n\t}\n}", "func New(conn *sqlx.DB) *Repository {\n\treturn &Repository{\n\t\tconn: conn,\n\t}\n}", "func NewRepository(repoName string) *Repository {\n\n\tclientIndex := model.ByEquality(\"ClientId\")\n\tclientIndex.Unique = true\n\t//\tuserIndex := model.ByEquality(\"UserId\")\n\t//\tuserIndex.Unique = true\n\n\treturn &Repository{\n\t\tName: repoName,\n\t\tmesssages: model.NewTable(store.DefaultStore, repoName, model.Indexes(clientIndex), nil),\n\t}\n}", "func New(db *sql.DB, logger log.Logger) (order.Repository, error) {\n\t// return repository\n\treturn &repository{\n\t\tdb: db,\n\t\tlogger: log.With(logger, \"rep\", \"cockroachdb\"),\n\t}, nil\n}", "func Repository() *repository {\n\tif r == nil {\n\t\tr = &repository{\n\t\t\titems: make(map[string]string),\n\t\t}\n\t}\n\treturn r\n}", "func New(sqlConn string) (*Repository, error) {\n\tdb, err := connectDatabase(sqlConn)\n\tif err != nil {\n\t\tlogger.Error(\"error connecting to db\", zap.Error(err))\n\t\treturn nil, err\n\t}\n\treturn &Repository{\n\t\tdb: db,\n\t}, nil\n}", "func NewRepository(data []byte) Repository {\n\treturn Repository{\n\t\tdata: data,\n\t}\n}", "func newRepoImpl(ctx context.Context, gs gitstore.GitStore, repo *gitiles.Repo, gcsClient gcs.GCSClient, gcsPath string, p *pubsub.Publisher, includeBranches, excludeBranches []string) (repograph.RepoImpl, error) {\n\tindexCommits, err := gs.RangeByTime(ctx, vcsinfo.MinTime, vcsinfo.MaxTime, gitstore.ALL_BRANCHES)\n\tif err != nil {\n\t\treturn nil, skerr.Wrapf(err, \"Failed loading IndexCommits from GitStore.\")\n\t}\n\tvar commits []*vcsinfo.LongCommit\n\tif len(indexCommits) > 0 {\n\t\thashes := make([]string, 0, len(indexCommits))\n\t\tfor _, c := range indexCommits {\n\t\t\thashes = append(hashes, c.Hash)\n\t\t}\n\t\tcommits, err = gs.Get(ctx, hashes)\n\t\tif err != nil {\n\t\t\treturn nil, skerr.Wrapf(err, \"Failed loading LongCommits from GitStore.\")\n\t\t}\n\t}\n\tgb, err := gs.GetBranches(ctx)\n\tif err != nil {\n\t\treturn nil, skerr.Wrapf(err, \"Failed loading branches from GitStore.\")\n\t}\n\tbranches := make([]*git.Branch, 0, len(gb))\n\tfor name, branch := range gb {\n\t\tbranches = append(branches, &git.Branch{\n\t\t\tName: name,\n\t\t\tHead: branch.Head,\n\t\t})\n\t}\n\tcommitsMap := make(map[string]*vcsinfo.LongCommit, len(commits))\n\tfor _, c := range commits {\n\t\tcommitsMap[c.Hash] = c\n\t}\n\tsklog.Infof(\"Repo %s has %d commits and %d branches.\", repo.URL(), len(commits), len(branches))\n\tfor _, b := range branches {\n\t\tsklog.Infof(\" branch %s @ %s\", b.Name, b.Head)\n\t}\n\treturn &repoImpl{\n\t\tMemCacheRepoImpl: repograph.NewMemCacheRepoImpl(commitsMap, branches),\n\t\tgcsClient: gcsClient,\n\t\tgcsPath: gcsPath,\n\t\tgitiles: repo,\n\t\tgitstore: gs,\n\t\tpubsub: p,\n\t\tincludeBranches: includeBranches,\n\t\texcludeBranches: excludeBranches,\n\t}, nil\n}", "func NewresortRepository(Conn *sql.DB) resort.Repository {\n\treturn &resortRepository{Conn}\n}", "func New(db *gorm.DB) *Repository {\n\treturn &Repository{\n\t\tdb: db,\n\t}\n}", "func New(db *gorm.DB) *Repository {\n\treturn &Repository{\n\t\tdb: db,\n\t}\n}", "func New(db *gorm.DB) *Repository {\n\treturn &Repository{\n\t\tdb: db,\n\t}\n}", "func (*repositoryR) NewStruct() *repositoryR {\n\treturn &repositoryR{}\n}", "func newObject(db *StateDB, key math.Hash, data meta.Account) *StateObject {\n\treturn &StateObject{\n\t\tdb: db,\n\t\tkey: key,\n\t\tdata: data,\n\t\toriginStorage: make(Storage),\n\t\tdirtyStorage: make(Storage),\n\t}\n}", "func New(conn *pgx.Conn) *RepositoryImpl {\n\treturn &RepositoryImpl{conn: conn}\n}", "func New() (Repo, error) {\n\t// Open the my.db data file in your current directory.\n\t// It will be created if it doesn't exist.\n\tlogrus.Infof(\"Using database file %s\\n\", conf.Options.DB.ConnectString)\n\tdb, err := bolt.Open(conf.Options.DB.ConnectString, 0600, &bolt.Options{Timeout: 1 * time.Second})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = db.Update(func(tx *bolt.Tx) error {\n\t\t_, err := tx.CreateBucketIfNotExists([]byte(\"users\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"teams\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"teamusers\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"oauth\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"channels\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"joinslack\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = tx.CreateBucketIfNotExists([]byte(\"convicted\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := &repo{\n\t\tdb: db,\n\t\tstop: make(chan bool),\n\t}\n\tgo r.cleanOAuthState()\n\treturn r, nil\n}", "func createRepository(t *testing.T) *git.Repository {\n\t// Create the repo\n\tr, err := git.Init(memory.NewStorage(), memfs.New())\n\tif err != nil {\n\t\tt.Errorf(\"Unable to create repository for testing: %s\", err.Error())\n\t}\n\n\treturn r\n}", "func NewRepo(a *config.AppConfig) *Repository {\n\treturn &Repository{ //returns the referenc to a Repository\n\t\tApp: a, // populate in \"App\" from type \"Repository\n\t}\n}", "func New(db *gorm.DB) (Repository, error) {\n\treturn &repo{\n\t\tDB: db,\n\t}, nil\n}", "func (s *Storage) initRepository() error {\n\tnewRepositoryConfig, err := state.NewRepositoryConfig(s.config.RepositoryConfig)\n\tif err != nil {\n\t\ts.log.Error(\"convent repository config failed\", zap.Error(err))\n\t\treturn err\n\t}\n\tif err := state.New(s.config.RepositoryType, newRepositoryConfig); err != nil {\n\t\ts.log.Error(\"init repository failed\", zap.Error(err))\n\t\treturn err\n\t}\n\treturn nil\n}", "func NewRepository() dish.Repository {\n\tdb, err := sql.Open(\"sqlite3\", \"./internal/database/test.sqlite\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn &repository{\n\t\tdb: db,\n\t}\n}", "func testRepo() *library.Repo {\n\treturn &library.Repo{\n\t\tID: new(int64),\n\t\tUserID: new(int64),\n\t\tBuildLimit: new(int64),\n\t\tTimeout: new(int64),\n\t\tCounter: new(int),\n\t\tPipelineType: new(string),\n\t\tHash: new(string),\n\t\tOrg: new(string),\n\t\tName: new(string),\n\t\tFullName: new(string),\n\t\tLink: new(string),\n\t\tClone: new(string),\n\t\tBranch: new(string),\n\t\tVisibility: new(string),\n\t\tPreviousName: new(string),\n\t\tPrivate: new(bool),\n\t\tTrusted: new(bool),\n\t\tActive: new(bool),\n\t\tAllowPull: new(bool),\n\t\tAllowPush: new(bool),\n\t\tAllowDeploy: new(bool),\n\t\tAllowTag: new(bool),\n\t\tAllowComment: new(bool),\n\t}\n}", "func New(\n\tredis *redis.Client, mongo *mongo.Collection,\n) Interface {\n\treturn &Repository{mongo: mongo, redis: redis}\n}", "func New() *Repo {\n\treturn &Repo{}\n}", "func Repository_FromRepositoryAttributes(scope constructs.Construct, id *string, attrs *RepositoryAttributes) IRepository {\n\t_init_.Initialize()\n\n\tvar returns IRepository\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_ecr.Repository\",\n\t\t\"fromRepositoryAttributes\",\n\t\t[]interface{}{scope, id, attrs},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func NewRepository(db *sql.DB) *repository {\n\treturn &repository{db: db}\n}", "func New(path string) (Repo, error) {\n\tif path == \"\" {\n\t\treturn nil, errors.New(\"store path not specified\")\n\t}\n\n\tdir, _ := filepath.Split(path)\n\tif _, err := os.Stat(dir); !os.IsNotExist(err) {\n\t\treturn &RepoGob{path: path}, nil\n\t}\n\n\terr := os.MkdirAll(dir, os.ModePerm)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &RepoGob{path: path}, nil\n}", "func NewRepository(MongoClient *mongo.Client) Repository {\n\treturn &repository{\n\t\tdatabaseAccess{\n\t\t\tdb: MongoClient,\n\t\t},\n\t}\n}", "func New(cfg config.DataConfig, repository model.Repository) (*GitRepo, error) {\n\tr, err := g2g.OpenRepository(repository.ClonePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &GitRepo{Repository: repository, cfg: cfg, r: r}, nil\n}", "func newObject(db *StateDB, address helper.Address, data Account, onDirty func(addr helper.Address)) *StateObject {\n\tif data.Balance == nil {\n\t\tdata.Balance = new(big.Int)\n\t}\n\tif data.CodeHash == nil {\n\t\tdata.CodeHash = emptyCodeHash\n\t}\n\treturn &StateObject{db: db, address: address, data: data, cachedStorage: make(Storage), dirtyStorage: make(Storage), onDirty: onDirty}\n}", "func newClientMongoRepository() repository.ClientRepository {\n\tmongoAddr := os.Getenv(\"DATABASE_CONN\")\n\tfmt.Println(\"mongoAddr => \", mongoAddr)\n\tclient := repositoryimpl.Connect(mongoAddr)\n\treturn repositoryimpl.NewRepository(client)\n}", "func New() *Repository {\n\tr := &Repository{}\n\tr.buildChain()\n\treturn r\n}", "func NewRepository(db *sqlx.DB, log log.Logger) Repository {\n\treturn repository{db: db, logger: log}\n}", "func NewWorkbook()(*Workbook) {\n m := &Workbook{\n Entity: *NewEntity(),\n }\n return m\n}", "func New(path string, gcs *storage.Client) (*Repo, error) {\n\tindexFileURL, err := resolveReference(path, \"index.yaml\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"resolve reference\")\n\t}\n\treturn &Repo{\n\t\tentry: nil,\n\t\tindexFileURL: indexFileURL,\n\t\tgcs: gcs,\n\t}, nil\n}", "func NewInMemoryRepository(scheme string) *InMemoryRepository {\n\treturn &InMemoryRepository{\n\t\tData: make(map[string][]byte),\n\t\tscheme: scheme,\n\t}\n}", "func toModel(orgID uint, repository helm.Repository) repositoryModel {\n\treturn repositoryModel{\n\t\tOrganizationID: orgID,\n\t\tName: repository.Name,\n\t\tURL: repository.URL,\n\t\tPasswordSecretID: repository.PasswordSecretID,\n\t\tTlsSecretID: repository.TlsSecretID,\n\t}\n}", "func NewRepository(conn *pgx.Conn) *RepositoryImpl {\n\treturn &RepositoryImpl{conn: conn}\n}", "func (o *Repository) Reload(ctx context.Context, exec boil.ContextExecutor) error {\n\tret, err := FindRepository(ctx, exec, o.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func New(cfg *config.Config, log logger.Logger) (Repository, error) {\n\t// create new in-memory cache bridge\n\tcaBridge, err := cache.New(cfg, log)\n\tif err != nil {\n\t\tlog.Criticalf(\"can not create in-memory cache bridge, %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\t// create new database connection bridge\n\tdbBridge, err := db.New(cfg, log)\n\tif err != nil {\n\t\tlog.Criticalf(\"can not connect backend persistent storage, %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\t// create new Lachesis RPC bridge\n\trpcBridge, err := rpc.New(cfg, log)\n\tif err != nil {\n\t\tlog.Criticalf(\"can not connect Lachesis RPC interface, %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\t// try to validate the solidity compiler by asking for it's version\n\tif _, err := compiler.SolidityVersion(cfg.SolCompilerPath); err != nil {\n\t\tlog.Criticalf(\"can not invoke the Solidity compiler, %s\", err.Error())\n\t\treturn nil, err\n\t}\n\n\t// construct the proxy instance\n\tp := proxy{\n\t\tcache: caBridge,\n\t\tdb: dbBridge,\n\t\trpc: rpcBridge,\n\t\tlog: log,\n\n\t\t// keep reference to the SOL compiler\n\t\tsolCompiler: cfg.SolCompilerPath,\n\n\t\t// keep the ballot sources ref\n\t\tballotSources: cfg.VotingSources,\n\t}\n\n\t// inform about voting sources\n\tlog.Infof(\"voting ballots accepted from %s\", cfg.VotingSources)\n\n\t// propagate callbacks\n\tdbBridge.SetBalance(p.AccountBalance)\n\n\t// make the service orchestrator\n\tp.orc = newOrchestrator(&p, log)\n\n\t// return the proxy\n\treturn &p, nil\n}", "func NewRepository() Repository {\n\tclient := redis.NewClient(&redis.Options{\n\t\tAddr: \"127.0.0.1:6379\",\n\t\tPassword: \"\",\n\t\tDB: 0,\n\t})\n\n\treturn Repository{Client: client}\n}", "func initializeRepo(database *string) repository.ClientRepository {\n\tswitch *database {\n\tcase \"mongo\":\n\t\treturn newClientMongoRepository()\n\tdefault:\n\t\treturn nil // we can have several implementation like in memory, postgress etc\n\t}\n}", "func newPRMExactRepository(dockerRepository string) (*prmExactRepository, error) {\n\tif _, err := reference.ParseNormalizedNamed(dockerRepository); err != nil {\n\t\treturn nil, InvalidPolicyFormatError(fmt.Sprintf(\"Invalid format of dockerRepository %s: %s\", dockerRepository, err.Error()))\n\t}\n\treturn &prmExactRepository{\n\t\tprmCommon: prmCommon{Type: prmTypeExactRepository},\n\t\tDockerRepository: dockerRepository,\n\t}, nil\n}", "func (classRepo *mockClassRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func init() {\n\tFakeRepo.Init()\n}", "func newRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *repoWalker {\n\tu, _ := url.Parse(repoURL)\n\treturn &repoWalker{\n\t\trepo: r,\n\t\trepoURL: u,\n\t\ttree: map[FileKey]BlobLocation{},\n\t\trepoCache: repoCache,\n\t\tsubRepoVersions: map[string]git.Oid{},\n\t\tignoreMissingSubmodules: true,\n\t}\n}", "func newObject(db *StateDB, address common.Address, data model.StateAccount) *stateObject {\n\tif data.Balance == nil {\n\t\tdata.Balance = new(big.Int)\n\t}\n\tif data.CodeHash == nil {\n\t\tdata.CodeHash = emptyCodeHash\n\t}\n\tif data.Root == (common.Hash{}) {\n\t\tdata.Root = emptyRoot\n\t}\n\treturn &stateObject{\n\t\tdb: db,\n\t\taddress: address,\n\t\taddrHash: crypto.Keccak256Hash(address[:]),\n\t\tdata: data,\n\t\toriginStorage: make(Storage),\n\t\tpendingStorage: make(Storage),\n\t\tdirtyStorage: make(Storage),\n\t}\n}", "func New(c Config) (*repo, error) {\n\tp, err := getAbsStoragePath(c.StoragePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := mkDirIfNotExists(p); err != nil {\n\t\treturn nil, err\n\t}\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb := repo{\n\t\tpath: p,\n\t\tcwd: cwd,\n\t\tbaseURL: c.BaseURL,\n\t\tlogFn: defaultLogFn,\n\t\terrFn: defaultLogFn,\n\t\tcache: cache.New(c.EnableCache),\n\t}\n\treturn &b, nil\n}", "func New(registry Registry, name string) *Repository {\n\treturn &Repository{\n\t\tname: name,\n\t\tregistry: registry,\n\t}\n}", "func NewRepository(repo *Repository, db *sql.DB) (*Repository, error) {\n\tfmt.Println(\"START NewRepository\")\n\tdefer fmt.Println(\"END START NewRepository\")\n\n\trepo.db = db\n\n\terr := db.Ping()\n\tif err != nil {\n\t\tfmt.Println(\"db err: \", err)\n\t\treturn nil, err\n\t}\n\n\tdb.SetMaxIdleConns(500)\n\tdb.SetMaxOpenConns(500)\n\n\treturn repo, nil\n}", "func NewRepository(db *sqlx.DB) *Repository {\n\treturn &Repository{\n\t\tDbConn: db,\n\t}\n}", "func NewRepository(db *sqlx.DB) *Repository {\n\treturn &Repository{\n\t\tDbConn: db,\n\t}\n}", "func NewRepository(db *sql.DB) payment.Repository {\n\treturn &repository{gq: goqu.New(\"postgres\", db)}\n}", "func (transactionRepo *mockTransactionRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func NewRepository(dbConn *sqlx.DB) Repository {\n\treturn &repository{\n\t\tdb: dbConn,\n\t}\n}", "func New(repository repository.Repository) Service {\n\treturn &service{repository: repository}\n}", "func ReposetFromPBData(encoded []byte) (ReposetProps, error) {\n\n in, err := IndexNodeFromBytes(encoded)\n if err != nil {\n return nil, err\n }\n\n if !in.IsReposetType() {\n return nil, fmt.Errorf(\"invalid reposet type encoding: %v\", in.Type())\n }\n\n rps := NewReposetProps()\n if err := rps.Unmarshal(in.format.GetData()); err != nil {\n return nil, err\n }\n\n return rps, nil\n}", "func New(db *sqlx.DB) promo.Repository {\n\treturn &promoRepository{db}\n}", "func NewWorkbookOperation()(*WorkbookOperation) {\n m := &WorkbookOperation{\n Entity: *NewEntity(),\n }\n return m\n}", "func New(repo rel.Repository) UserRepository {\n\treturn userRepository{\n\t\trepository: repo,\n\t}\n}", "func (e *RepoEntity) Refresh() error {\n\tvar err error\n\t// error can be ignored since the file already exists when app is loading\n\t// if the RepoEntity is only fast initialized, no need to refresh because\n\t// it won't contain its belongings\n\tif e.Branch == nil {\n\t\treturn nil\n\t}\n\tfile, _ := os.Open(e.AbsPath)\n\tfstat, _ := file.Stat()\n\t// re-initialize the go-git repository struct after supposed update\n\tr, err := git.PlainOpen(e.AbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\te.Repository = *r\n\t// modification date may be changed\n\te.ModTime = fstat.ModTime()\n\tif err := e.loadComponents(false); err != nil {\n\t\treturn err\n\t}\n\t// we could send an event data but we don't need for this topic\n\treturn e.Publish(RepositoryUpdated, nil)\n}", "func (s imageRepositoryStrategy) ResetBeforeCreate(obj runtime.Object) {\n\tir := obj.(*api.ImageRepository)\n\tir.Status = api.ImageRepositoryStatus{\n\t\tDockerImageRepository: \"\",\n\t\tTags: make(map[string]api.TagEventList),\n\t}\n}", "func (s *RepositoryService) Create(rs app.RequestScope, model *models.Repository) (*models.Repository, error) {\n\tif err := model.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := s.dao.Create(rs.DB(), model); err != nil {\n\t\treturn nil, err\n\t}\n\treturn s.dao.Get(rs.DB(), model.Name)\n}", "func newRepoCache(apiURL *url.URL, a auth.Authenticator) *rcache.Cache {\n\tvar cacheTTL time.Duration\n\tif urlIsGitHubDotCom(apiURL) {\n\t\tcacheTTL = 10 * time.Minute\n\t} else {\n\t\t// GitHub Enterprise\n\t\tcacheTTL = 30 * time.Second\n\t}\n\n\tkey := \"\"\n\tif a != nil {\n\t\tkey = a.Hash()\n\t}\n\treturn rcache.NewWithTTL(\"gh_repo:\"+key, int(cacheTTL/time.Second))\n}", "func newStorageObject(URL string, source interface{}, fileInfo os.FileInfo) storage.Object {\n\tabstract := storage.NewAbstractStorageObject(URL, source, fileInfo)\n\tresult := &object{\n\t\tAbstractObject: abstract,\n\t}\n\tresult.AbstractObject.Object = result\n\treturn result\n}", "func (g git) NewRepository(dst string) (WriteableRepository, error) {\n\t_, err := g.OpenRepository(dst)\n\tif err == nil {\n\t\treturn nil, ErrRepoExists\n\t}\n\tcmd := exec.Exec(dst, \"git\", \"init\")\n\tif cmd.Err != nil {\n\t\treturn nil, cmd.Err\n\t}\n\treturn &writeableRepo{\n\t\trepository{rootDir: dst, gitInterface: &g},\n\t}, nil\n}", "func NewRepo(db *db.DB) {\n\tPsql = db.SQL\n}", "func NewRepository(db *db.Database) *Repository {\n\treturn &Repository{db}\n}", "func NewRepository(funcs template.FuncMap) *Repository {\n\trepo := Repository{\n\t\tfiles: make(map[string]string),\n\t\ttemplates: make(map[string]*template.Template),\n\t\tfuncs: funcs,\n\t}\n\n\tif repo.funcs == nil {\n\t\trepo.funcs = make(template.FuncMap)\n\t}\n\n\treturn &repo\n}", "func (r *Repository) ReadFrom(ctx context.Context, id digest.Digest, u *url.URL) error {\n\tif ok, _ := r.Contains(id); ok {\n\t\treturn nil\n\t}\n\t_, err, _ := r.read.Do(id.String(), func() (interface{}, error) {\n\t\trepo, err := repository.Dial(u.String())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttype getFiler interface {\n\t\t\tGetFile(ctx context.Context, id digest.Digest, w io.WriterAt) (int64, error)\n\t\t}\n\t\tif gf, ok := repo.(getFiler); ok {\n\t\t\ttemp, err := r.TempFile(\"getfile-\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tdefer os.Remove(temp.Name())\n\t\t\t_, err = gf.GetFile(ctx, id, temp)\n\t\t\tif err != nil {\n\t\t\t\t_ = temp.Close()\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\terr = temp.Close()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tf, err := r.Install(temp.Name())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif id != f.ID {\n\t\t\t\tsrcSize := \"unknown size\"\n\t\t\t\tif srcStat, serr := repo.Stat(ctx, id); serr == nil {\n\t\t\t\t\tsrcSize = data.Size(srcStat.Size).String()\n\t\t\t\t}\n\t\t\t\tdstSize := \"unknown size\"\n\t\t\t\tif dstStat, derr := temp.Stat(); derr == nil {\n\t\t\t\t\tdstSize = data.Size(dstStat.Size()).String()\n\t\t\t\t}\n\t\t\t\treturn nil, errors.E(\"readfrom (GetFile)\", u.String(), errors.Integrity, errors.Errorf(\"%v (%s) != %v (%s)\", id, srcSize, f.ID, dstSize))\n\t\t\t}\n\t\t\treturn nil, nil\n\t\t}\n\n\t\trc, err := repo.Get(ctx, id)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdefer rc.Close()\n\t\tid2, err := r.Put(ctx, rc)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif id != id2 {\n\t\t\tsrcSize := \"unknown size\"\n\t\t\tif srcStat, serr := repo.Stat(ctx, id); serr == nil {\n\t\t\t\tsrcSize = data.Size(srcStat.Size).String()\n\t\t\t}\n\t\t\tdstSize := \"unknown size\"\n\t\t\tif dstStat, derr := r.Stat(ctx, id2); derr == nil {\n\t\t\t\tdstSize = data.Size(dstStat.Size).String()\n\t\t\t}\n\t\t\treturn nil, errors.E(\"readfrom (Get)\", u.String(), errors.Integrity, errors.Errorf(\"%v (%s) != %v (%s)\", id, srcSize, id2, dstSize))\n\t\t}\n\t\treturn nil, nil\n\t})\n\tif err != nil {\n\t\tr.Log.Debug(err)\n\t}\n\treturn err\n}", "func NewRepo(ac *config.App) *Repository {\n\treturn &Repository{\n\t\tApp: ac,\n\t}\n}", "func (announceRepo *mockAnnounceRepo) Initialize(ctx context.Context, db *sql.DB) {}", "func NewRepo(a *config.Appconfig) *Repository {\n\treturn &Repository{\n\t\tApp: a,\n\t}\n}", "func FromRepo(rs goolib.RepoSpec, repo, dir string, proxyServer string) (string, error) {\n\tpkgURL := strings.TrimSuffix(repo, filepath.Base(repo)) + rs.Source\n\tpn := goolib.PackageInfo{Name: rs.PackageSpec.Name, Arch: rs.PackageSpec.Arch, Ver: rs.PackageSpec.Version}.PkgName()\n\tdst := filepath.Join(dir, filepath.Base(pn))\n\treturn dst, Package(pkgURL, dst, rs.Checksum, proxyServer)\n}", "func (a StoriesAllStories) construct() StoriesAllStoriesClass { return &a }", "func New(c *config.Config) (*Repository, error) {\n\tDBURL := fmt.Sprintf(\"host=%s port=%d user=%s dbname=%s sslmode=disable password=%s\",\n\t\tc.Database.DBHost,\n\t\tc.Database.DBPort,\n\t\tc.Database.DBUser,\n\t\tc.Database.DBName,\n\t\tc.Database.DBPassword)\n\n\tdb, err := gorm.Open(dbDriver, DBURL)\n\tif err != nil {\n\t\tfmt.Printf(\"Unable to connect to database, %v\", err)\n\t\tdefer db.Close()\n\t\treturn nil, err\n\t}\n\n\tdb.LogMode(true)\n\n\tuserRepository := UserRepository{db}\n\n\tr := &Repository{db: db, UserRepository: &userRepository}\n\treturn r, nil\n}", "func NewRepository(db middleware.Pool) *Repository {\n\treturn &Repository{Database: db}\n}", "func NewRepository(region, tableName string) Repository {\n\treturn nil\n}", "func (g *GitChartProvider) initializeRepository() error {\n\tvar err error\n\tg.gitRepo, err = repo.NewGitChartRepo(g.config)\n\treturn err\n\n}" ]
[ "0.578056", "0.5608401", "0.56058925", "0.5605777", "0.5589131", "0.5565242", "0.5544813", "0.5523886", "0.5445551", "0.544034", "0.54346824", "0.5412524", "0.5403366", "0.5400339", "0.5372537", "0.5363286", "0.5362798", "0.53509206", "0.5343111", "0.5331616", "0.5308891", "0.5302947", "0.52784616", "0.52772146", "0.52594984", "0.5254755", "0.5235876", "0.5233005", "0.52067626", "0.5205222", "0.5192371", "0.5192371", "0.5192371", "0.51897776", "0.5186055", "0.5169995", "0.5164099", "0.51569515", "0.5135212", "0.5127153", "0.5125365", "0.51204485", "0.511028", "0.5099824", "0.5098749", "0.5096293", "0.50961846", "0.5086804", "0.50818366", "0.5071195", "0.5061378", "0.5048273", "0.5047451", "0.5037734", "0.50370854", "0.5036988", "0.5035184", "0.50327283", "0.5029016", "0.50143385", "0.4993938", "0.49912304", "0.49749792", "0.4971889", "0.4971101", "0.49710095", "0.4968655", "0.49629804", "0.4936852", "0.49201202", "0.49113634", "0.49096927", "0.49096927", "0.49081144", "0.4904738", "0.48900652", "0.48832", "0.4882378", "0.48799932", "0.4874446", "0.4874202", "0.48712385", "0.4868397", "0.48631483", "0.48607743", "0.48581275", "0.48575863", "0.48523033", "0.48517495", "0.4847612", "0.48462486", "0.48440877", "0.4826194", "0.4821457", "0.4811749", "0.4811456", "0.48076108", "0.4806269", "0.4804852", "0.48025256" ]
0.5211349
28
LoadLoginPage Render login page
func LoadLoginPage(w http.ResponseWriter, r *http.Request) { cookie, _ := cookies.Read(r) if cookie["token"] != "" { http.Redirect(w, r, "/feed", 302) return } utils.RunTemplate(w, "login.html", nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func showLoginPage(c *gin.Context) {\n\trender(c, gin.H{\n\t\t\"title\": \"Login\",\n\t\t\"ErrorMessage\": \"\",\n\t}, \"login.html\")\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\n\tpageVars := PageVars{}\n\taddPageVars(r, &pageVars)\n\trender(w, \"login\", pageVars)\n}", "func LoadViewLogin(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"login.html\", nil)\n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func loginPage(w http.ResponseWriter, r *http.Request){\n\terr := templ.ExecuteTemplate(w, \"login\", nil)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t}\n}", "func ShowLoginPage(c *gin.Context) {\n\trender(c, gin.H{\n\t\t\"title\": \"Login\",\n\t}, \"login.html\")\n}", "func (this *Handle) pageLogin(w http.ResponseWriter, r *http.Request) {\n\tif this.user.CheckLogin(w, r) == true {\n\t\tthis.ToURL(w, r, \"/center\")\n\t\treturn\n\t} else {\n\t\tthis.ShowTemplate(w, r, \"login.html\", nil)\n\t\treturn\n\t}\n}", "func LoginPageHandler(response http.ResponseWriter, request *http.Request) {\n\tChangePreferedLanguage(request)\n\tvar body, _ = LoadFile(\"login.html\")\n\tio.WriteString(response, body)\n}", "func LoginPage(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"Login.html\", gin.H{\n\t\t\"loginURL\": \"http://127.0.0.1:8080/user/login\",\n\t})\n}", "func genericLoginPage(s *data.Site, u *data.User) *contentBuffers {\n\tvar cb contentBuffers\n\n\tcb.head.WriteString(`<title>Log In</title><link rel=\"shortcut icon\" href=\"`)\n\tif s.Favicon == \"\" {\n\t\tcb.head.WriteString(userContentSrc + `favicon.png\">`)\n\t} else {\n\t\tcb.head.WriteString(s.Favicon + `\">`)\n\t}\n\n\tcb.head.WriteString(\"<style>#msg {color: #EF5350;}</style>\")\n\n\tcb.body.WriteString(\"<h2>Log in to your account</h2>\")\n\n\tif u.Role != users.RoleNone {\n\t\tcb.body.WriteString(`<h4 id=\"msg\">You are already logged in as the user: ` + u.Uname + `</h4>`)\n\t\tcb.body.WriteString(`<form action=\"/api/user/logout\" method=\"POST\"><input type=\"submit\" value=\"Log Out\"></form>`)\n\t} else {\n\t\tcb.body.WriteString(`<h4 id=\"msg\"></h4>\n\t\t<form action=\"/api/user/login-form\" method=\"POST\">\n\t\t\t<label for=\"user\">Username or Email Address</label><br>\n\t\t\t<input type=\"text\" name=\"user\" id=\"user\"><br>\n\t\t\t<label for=\"pass\">Password</label><br>\n\t\t\t<input type=\"password\" name=\"pass\" id=\"pass\"><br>\n\t\t\t<input type=\"submit\" value=\"Log In\">\n\t\t</form>\n\t\t<script>\n\t\t\tvar msgR = new RegExp(/msg=([^&]*)/);\n\t\t\tconst msgMatch = msgR.exec(window.location.search);\n\t\t\tif (msgMatch) {\n\t\t\t\tif (msgMatch[1] !== \"\") { document.getElementById(\"msg\").innerHTML = decodeURIComponent(msgMatch[1]); }\n\t\t\t}\n\t\t</script>`)\n\t}\n\n\treturn &cb\n}", "func Login(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\ttmp := []string{\n\t\t\"user.login\",\n\t\t\"default.layout\",\n\t\t\"default.navigation\",\n\t}\n\thelper.ProcessTemplates(w, \"layout\", nil, tmp...)\n}", "func LoginPage(c *fiber.Ctx) error {\n\tvar acc databasepack.Account\n\terr := c.BodyParser(&acc)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn c.Send([]byte(\"Wrong input.\"))\n\t}\n\troles := databasepack.FindUser(acc)\n\tif acc.Isnew {\n\t\t//fmt.Println(\"NEW\")\n\t\tif roles[0] == -2 {\n\t\t\tdatabasepack.CreateUser(acc)\n\t\t\treturn LoadPage(c, acc.Login, []int{0})\n\t\t}\n\t\treturn c.Send([]byte(\"Account with such login already exists.\"))\n\t}\n\t//fmt.Println(\"NOT NEW\")\n\tif roles[0] == -1 {\n\t\treturn c.Send([]byte(\"Wrong password!\"))\n\t} else if roles[0] == -2 {\n\t\treturn c.Send([]byte(\"No such username!\"))\n\t}\n\treturn LoadPage(c, acc.Login, roles)\n}", "func (u *UserView) ShowLoginPage(c *gin.Context) {\n\trender(c,\n\t\tgin.H{\"title\": \"Login\"},\n\t\t\"login.html\")\n}", "func loginPageHandler(w http.ResponseWriter, r *http.Request) {\n\tt := template.Must(template.ParseFiles(\"static/template/login.html\"))\n\ts := struct {\n\t\tProviders []idp.Provider\n\t\tPage string\n\t}{idp.Providers(), r.URL.Query().Get(\"page\")}\n\tt.Execute(w, s)\n}", "func Login(res http.ResponseWriter, req *http.Request) {\n\tdata := struct{ Title string }{\"Login\"}\n\ttemplates.ExecuteTemplate(res, \"login\", data)\n}", "func (a Authentic) login(c buffalo.Context) error {\n\treturn c.Render(200, a.Config.LoginPage)\n}", "func loginFormHandler(w http.ResponseWriter, r *http.Request) {\n\tb.pageDisplayer.DisplayPage(w, \"login_form.html\", nil)\n}", "func Login(ctx echo.Context) error {\n\n\tf := forms.New(utils.GetLang(ctx))\n\tutils.SetData(ctx, \"form\", f)\n\n\t// set page tittle to login\n\tutils.SetData(ctx, settings.PageTitle, \"login\")\n\n\treturn ctx.Render(http.StatusOK, tmpl.LoginTpl, utils.GetData(ctx))\n}", "func handleLoginGET(w http.ResponseWriter, req *http.Request) {\n\ttmpl, err := template.ParseFiles(\"./templates/login.html\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tdata := LoginPage {\n\t\tTitle: \"Login\",\n\t}\n\n\ttmpl.Execute(w, data)\n}", "func (m *Repository) GetLogin(w http.ResponseWriter, r *http.Request) {\n\tif m.App.Session.Exists(r.Context(), \"user_id\") {\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\trender.Template(w, r, \"login.page.tmpl\", &models.TemplateData{\n\t\tForm: forms.New(nil),\n\t})\n}", "func (h *webHandler) serveLoginPage(c *gin.Context) {\n\t// Check token\n\terr := h.checkToken(c.Request)\n\tif err == nil {\n\t\tredirectPage(c, \"/\")\n\t\treturn\n\t}\n\n\terr = serveFile(c, \"login.html\")\n\tutils.CheckError(err)\n}", "func (controller *Auth) ShowLoginPage() {\n\tif controller.AccountConnected {\n\t\tcontroller.Redirect(\"/\", 302)\n\t} else {\n\t\tcontroller.showLoginForm()\n\t}\n}", "func (db *MyConfigurations) showLoginPage(c echo.Context) error {\n\tstatus, message := getFlashMessages(&c) // gets the flash message and status if there was any\n\tusers := models.GetAllUsers(db.GormDB) // gets all the users that are in the database\n\tvaluesToReturn := echo.Map{\n\t\t\"status\": status, // pass the status of the flash message\n\t\t\"message\": message, // pass the message\n\t\t\"title\": \"تسجيل دخول\", // the title of the page\n\t\t\"hideNavBar\": true, // boolean to indicate weather or not the NavBar should be displayed\n\t\t\"users\": users, // pass the users array to display to the user\n\t}\n\tif checkIfRequestFromMobileDevice(c) {\n\t\treturn c.JSON(http.StatusOK, &valuesToReturn)\n\t}\n\treturn c.Render(http.StatusOK, \"login.html\", &valuesToReturn)\n}", "func LoginPage(w http.ResponseWriter, r *http.Request) { \n tmpl, err := template.ParseFiles(\"templates/loginPage.html\")\n if err != nil {\n fmt.Println(err)\n }\n var user helpers.User\n credentials := userCredentials{\n EmailId: r.FormValue(\"emailId\"),\n Password: r.FormValue(\"password\"), \n }\n\n login_info := dbquery.GetUserByEmail(credentials.EmailId)\n user = helpers.User{\n UserId: login_info.UserId,\n FirstName: login_info.FirstName,\n LastName: login_info.LastName, \n Role: login_info.Role,\n Email: login_info.Email,\n \n }\n\n var emailValidation string\n\n _userIsValid := CheckPasswordHash(credentials.Password, login_info.Password)\n\n if !validation(login_info.Email, credentials.EmailId, login_info.Password, credentials.Password) {\n emailValidation = \"Please enter valid Email ID/Password\"\n }\n\n if _userIsValid {\n setSession(user, w)\n http.Redirect(w, r, \"/dashboard\", http.StatusFound)\n }\n\n var welcomeLoginPage string\n welcomeLoginPage = \"Login Page\"\n\n tmpl.Execute(w, Response{WelcomeMessage: welcomeLoginPage, ValidateMessage: emailValidation}) \n \n}", "func (s TppHTTPServer) Login(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\tdata := LoginPageData{PageTitle: \"AXA Pay Bank Login\", BankID: s.BankID, PIN: s.PIN}\n\t//fmt.Fprint(w, \"TPP server reference PISP Login\\n\")\n\ttmpl := template.Must(template.ParseFiles(\"api/login.html\"))\n\tr.ParseForm()\n\tlog.Println(\"Form:\", r.Form)\n\ttmpl.Execute(w, data)\n\n}", "func (app *Application) LoginHandler(w http.ResponseWriter, r *http.Request) {\n\tvar data map[string]interface{}\n\tdata = make(map[string]interface{})\n\tfmt.Println(\"login.html\")\n\tif r.FormValue(\"submitted\") == \"true\" {\n\t\tuname := r.FormValue(\"username\")\n\t\tpword := r.FormValue(\"password\")\n\t\torg := r.FormValue(\"org\")\n\t\tprintln(uname, pword, org)\n\t\t//according uname, comparing pword with map[uname]\n\t\tfor _, v := range webutil.Orgnization[org] {\n\t\t\tfmt.Println(\"org user\", v.UserName)\n\t\t\tif v.UserName == uname {\n\t\t\t\tif v.Secret == pword {\n\t\t\t\t\twebutil.MySession.SetSession(uname, org, w)\n\t\t\t\t\thttp.Redirect(w, r, \"./home.html\", 302)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\t//login failed redirect to login page and show failed\n\t\tdata[\"LoginFailed\"] = true\n\t\tloginTemplate(w, r, \"login.html\", data)\n\t\treturn\n\t}\n\tloginTemplate(w, r, \"login.html\", data)\n}", "func (_ *Auth) Login(c *gin.Context) {\n\n\tflash := helper.GetFlash(c)\n\tc.HTML(http.StatusOK, \"auth/login.tpl\", gin.H{\n\t\t\"title\": \"Gin Blog\",\n\t\t\"flash\": flash,\n\t})\n}", "func (app *application) loginForm(w http.ResponseWriter, r *http.Request) {\n\tapp.render(w, r, \"login.page.tmpl\", &templateData{\n\t\tForm: forms.New(nil),\n\t})\n}", "func (c Control) ServeLogin(w http.ResponseWriter, r *http.Request) {\n\ttemplate := map[string]interface{}{\"error\": false}\n\tif r.Method == http.MethodPost {\n\t\t// Get their submitted hash and the real hash.\n\t\tpassword := r.PostFormValue(\"password\")\n\t\thash := HashPassword(password)\n\t\tc.Config.RLock()\n\t\trealHash := c.Config.AdminHash\n\t\tc.Config.RUnlock()\n\t\t// Check if they got the password correct.\n\t\tif hash == realHash {\n\t\t\ts, _ := Store.Get(r, \"sessid\")\n\t\t\ts.Values[\"authenticated\"] = true\n\t\t\ts.Save(r, w)\n\t\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t\t\treturn\n\t\t}\n\t\ttemplate[\"error\"] = true\n\t}\n\n\t// Serve login page with no template.\n\tdata, err := Asset(\"templates/login.mustache\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n\tcontent := mustache.Render(string(data), template)\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\tw.Write([]byte(content))\n}", "func (app *application) loginForm(w http.ResponseWriter, r *http.Request) {\n\tapp.renderLogin(w, r, \"login.page.tmpl\", &templateDataLogin {\n\t\tForm: \t\t\tforms.New(nil),\n\t})\n}", "func LoadPage(c *fiber.Ctx, login string, roles []int) error {\n\tquerypack.INFO.Roles = roles\n\tquerypack.INFO.Login = login\n\tquerypack.INFO.LoggedIn = true\n\tc.Method(\"GET\")\n\tc.Path(querypack.INFO.URL)\n\tquerypack.AddCookie(c)\n\treturn c.Next()\n}", "func LoginHandler(w http.ResponseWriter, r *http.Request) {\n\ttext, err := template.ParseFiles(views[\"login\"])\n\tif err == nil {\n\t\ttext.Execute(w, nil)\n\t}\n}", "func userPage(w http.ResponseWriter, r *http.Request){\n\tisLogged, name := CheckLoginStatus(w,r)\n\n\tif isLogged {\n\t\terr := templ.ExecuteTemplate(w, \"userHome\", name)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t} else {\n\t\thttp.Redirect(w,r,\"/unauthorized\",http.StatusSeeOther)\n\t}\n}", "func (c *UserController) ShowLogin() {\n\tuserName := c.Ctx.GetCookie(\"username\")\n\tif userName == \"\" {\n\t\tc.Data[\"checked\"] = \"\"\n\t\tc.Data[\"username\"] = \"\"\n\t} else {\n\t\tc.Data[\"checked\"] = \"checked\"\n\t\tc.Data[\"username\"] = userName\n\t}\n\n\tc.TplName = \"login.html\"\n}", "func (c *LoginController) ShowLogin(ctx *app.ShowLoginLoginContext) error {\n\t// LoginController_ShowLogin: start_implement\n\tloginError := map[string]interface{}{}\n\tc.SessionStore.GetAs(\"loginError\", &loginError, ctx.Request)\n\n\ttemplateContent, err := ioutil.ReadFile(\"public/login/login-form.html\")\n\tif err != nil {\n\t\treturn ctx.InternalServerError(err)\n\t}\n\n\tt, err := template.New(\"login-form\").Parse(string(templateContent))\n\tif err != nil {\n\t\treturn ctx.InternalServerError(err)\n\t}\n\n\tresponseCode := 200\n\n\tif loginErrorCode, ok := loginError[\"code\"]; ok {\n\t\tresponseCode = loginErrorCode.(int)\n\t}\n\n\trw := ctx.ResponseWriter\n\n\trw.Header().Set(\"Content-Type\", \"text/html\")\n\terr = t.Execute(rw, loginError)\n\trw.WriteHeader(responseCode)\n\tif err != nil {\n\t\tprintln(err.Error())\n\t}\n\t// LoginController_ShowLogin: end_implement\n\treturn nil\n}", "func (s *HttpServer) loginForm(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\ts.RenderTemplate(ctx, w, \"login\", nil)\n}", "func (h *Handler) LoginHandler(w http.ResponseWriter, r *http.Request) {\n\n\tchallenge, err := readURLChallangeParams(r, \"login\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif r.Method == \"POST\" {\n\t\tif r.Form == nil {\n\t\t\tif err := r.ParseForm(); err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tuserName := r.Form.Get(\"username\")\n\t\tpassword := r.Form.Get(\"password\")\n\t\tloginChallenge := r.Form.Get(\"challenge\")\n\t\tpass, err := h.LoginService.CheckPasswords(userName, password)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\n\t\tif pass {\n\n\t\t\tacceptLoginBody := h.ConfigService.FetchAcceptLoginConfig(userName)\n\t\t\trawJson, err := json.Marshal(acceptLoginBody)\n\n\t\t\tredirectURL, err := h.LoginService.SendAcceptBody(\"login\", loginChallenge, rawJson)\n\t\t\tif err != nil {\n\t\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\thttp.Redirect(w, r, redirectURL, http.StatusFound)\n\t\t}\n\n\t\tw.WriteHeader(http.StatusForbidden)\n\t\ttemplLogin := template.Must(template.ParseFiles(\"templates/login.html\"))\n\t\tloginData := h.ConfigService.FetchLoginConfig(challenge, true)\n\t\ttemplLogin.Execute(w, loginData)\n\t} else {\n\t\tchallengeBody, err := h.LoginService.ReadChallenge(challenge, \"login\")\n\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tlog.Print(err)\n\t\t}\n\n\t\tif !challengeBody.Skip {\n\t\t\ttemplLogin := template.Must(template.ParseFiles(\"templates/login.html\"))\n\t\t\tloginData := h.ConfigService.FetchLoginConfig(challenge, false)\n\t\t\ttemplLogin.Execute(w, loginData)\n\t\t} else {\n\n\t\t\tacceptLoginBody := h.ConfigService.FetchAcceptLoginConfig(challengeBody.Subject)\n\t\t\trawJson, err := json.Marshal(acceptLoginBody)\n\n\t\t\tredirectURL, err := h.LoginService.SendAcceptBody(\"login\", challenge, rawJson)\n\t\t\tif err != nil {\n\t\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\thttp.Redirect(w, r, redirectURL, http.StatusFound)\n\n\t\t}\n\t}\n}", "func LoginHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"login\")\n}", "func AdminLogin(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminLogin, w, data)\n}", "func LoginStart(w http.ResponseWriter, r *http.Request) {\n\tif !verifyLogin(r) {\n\t\thttp.Redirect(w, r, BASEURL, http.StatusFound)\n\t\treturn\n\t}\n\n\t// if user is not using https then redirect them\n\tif ( r.Header.Get(\"x-forwarded-proto\") != \"https\" && BASEURL != LOCALBASEURL) {\n\t\tfmt.Printf(\"TLS handshake is https=false x-forwarded-proto=%s\\n\", r.Header.Get(\"x-forwarded-proto\"))\n\t\thttp.Redirect(w, r, BASEURL, http.StatusFound)\n\t\treturn\n\t}\n\n\tstartPageTemplate.Execute(w, \"\")\n}", "func LoginHandler(ctx *gin.Context) {\n\tstate = randToken()\n\tsession := sessions.Default(ctx)\n\tsession.Set(\"state\", state)\n\tsession.Save()\n\tfmt.Println(\"LOGIN SESSION:\", session.Get(\"userid\"))\n\t// TODO create this page from a template\n\tloginPage := fmt.Sprintf(`\n\t<html>\n\t<title>Google Login</title>\n\t<body>\n\t<h3>Google Login</h3>\n\t<a href=\"%s\"><button>Login with Google</button></a>\n\t</body>\n\t</html>\n\t`, GetLoginURL(state))\n\tctx.Writer.Write([]byte(loginPage))\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"login called\")\n}", "func (as *AdminServer) Login(w http.ResponseWriter, r *http.Request) {\n\tparams := struct {\n\t\tUser models.User\n\t\tTitle string\n\t\tFlashes []interface{}\n\t\tToken string\n\t}{Title: \"Login\", Token: csrf.Token(r)}\n\tsession := ctx.Get(r, \"session\").(*sessions.Session)\n\tswitch {\n\tcase r.Method == \"GET\":\n\t\tparams.Flashes = session.Flashes()\n\t\tsession.Save(r, w)\n\t\ttemplates := template.New(\"template\")\n\t\t_, err := templates.ParseFiles(\"templates/login.html\", \"templates/flashes.html\")\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\ttemplate.Must(templates, err).ExecuteTemplate(w, \"base\", params)\n\tcase r.Method == \"POST\":\n\t\t// Find the user with the provided username\n\t\tusername, password := r.FormValue(\"username\"), r.FormValue(\"password\")\n\t\tu, err := models.GetUserByUsername(username)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tas.handleInvalidLogin(w, r, \"Invalid Username/Password\")\n\t\t\treturn\n\t\t}\n\t\t// Validate the user's password\n\t\terr = auth.ValidatePassword(password, u.Hash)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\tas.handleInvalidLogin(w, r, \"Invalid Username/Password\")\n\t\t\treturn\n\t\t}\n\t\tif u.AccountLocked {\n\t\t\tas.handleInvalidLogin(w, r, \"Account Locked\")\n\t\t\treturn\n\t\t}\n\t\tu.LastLogin = time.Now().UTC()\n\t\terr = models.PutUser(&u)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\t// If we've logged in, save the session and redirect to the dashboard\n\t\tsession.Values[\"id\"] = u.Id\n\t\tsession.Save(r, w)\n\t\tas.nextOrIndex(w, r)\n\t}\n}", "func GetLogin(w http.ResponseWriter, req *http.Request, app *App) {\n\tif models.UserCount(app.Db) > 0 {\n\t\trender(w, \"admin/login\", map[string]interface{}{\"hideNav\": true}, app)\n\t} else {\n\t\thttp.Redirect(w, req, app.Config.General.Prefix+\"/register\", http.StatusSeeOther)\n\t}\n\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\ttmpl := template.Must(template.ParseFiles(\"templates/login.html\"))\n\tif r.Method != http.MethodPost {\n\t\ttmpl.Execute(w, nil)\n\t}\n\n\tdetails := userLogin{\n\t\tUsername: r.FormValue(\"username\"),\n\t\tPassword: r.FormValue(\"psw\"),\n\t}\n\n\tlog.Println(details)\n\t//Attempt login by calling LDAP verify credentials\n\tlog.Println(\"Username: \" + details.Username)\n\tlog.Println(\"Pass: \" + details.Password)\n\tauth := verifyCredentials(details.Username, details.Password)\n\tlog.Println(auth)\n\n\t//authorize user and create JWT\n\tif auth {\n\t\tfmt.Println(\"starting auth ...\")\n\t\tfor _, cookie := range r.Cookies() {\n\t\t\tfmt.Print(\"Cookie User: \")\n\t\t\tfmt.Println(w, cookie.Name)\n\t\t\treadJWT(cookie.Name)\n\t\t}\n\t\ttoken := generateJWT(details.Username)\n\t\tsetJwtCookie(token, w, r)\n\t\thttp.Redirect(w, r, \"/dashboard\", http.StatusSeeOther)\n\t}\n\n}", "func homeHandler(w http.ResponseWriter, r *http.Request) {\n\tp := Profile{}\n\trenderTemplate(w, \"login\", &p)\n}", "func (uc UserController) AdminLoginPage(w http.ResponseWriter, req *http.Request, s httprouter.Params) {\n\terr := view.ExecuteTemplate(w, \"login.html\", nil)\n\tHandleError(w, err)\n}", "func AuthorizePages(w http.ResponseWriter, r *http.Request) {\n userData := getSession(r)\n if (len(userData.UserId) <= 0 || len(userData.FirstName) <= 0 ) {\n w.Write([]byte(\"<script>alert('Unauthorized Access!!,please login');window.location = '/login'</script>\"))\n }\n}", "func LoginGET(w http.ResponseWriter, r *http.Request) {\n\tsess := model.Instance(r)\n\tv := view.New(r)\n\tv.Name = \"login/login\"\n\tv.Vars[\"token\"] = csrfbanana.Token(w, r, sess)\n\t// Refill any form fields\n\tview.Repopulate([]string{\"cuenta\",\"password\"}, r.Form, v.Vars)\n\tv.Render(w)\n }", "func LoginHandler(c *gin.Context) {\n\tsess := sessions.Default(c)\n\tinfo := sess.Flashes(\"info\")\n\terrors := sess.Flashes(\"error\")\n\tsess.Save()\n\n\tc.HTML(http.StatusOK, \"login.html\", gin.H{\n\t\t\"errors\": errors,\n\t\t\"info\": info,\n\t})\n}", "func Login(c *gin.Context) {\n\tusername := c.PostForm(\"username\")\n\tpassword := c.PostForm(\"password\")\n\temail := c.PostForm(\"email\")\n\t//check if provided user credentials are valid or not\n\tif store.ValidUser(username, password, email) {\n\t\ttoken := generateSessionToken()\n\t\tc.SetCookie(\"token\", token, 3600, \"\", \"\", false, true)\n\t\tc.Set(\"is_logged_in\", true)\n\t\trender(c, gin.H{\n\t\t\t\"title\": \"Successful Login\"}, \"login-successful.html\")\n\t} else {\n\t\tc.HTML(http.StatusBadRequest, \"login.html\", gin.H{\n\t\t\t\"ErrorTitle\": \"Login Failed\",\n\t\t\t\"ErrorMessage\": \"Invalid credentials provided\"})\n\t}\n}", "func login(res http.ResponseWriter, req *http.Request, p httprouter.Params) {\n\t_, err := req.Cookie(\"login\")\n\tif err == nil {\n\t\thttp.Redirect(res, req, \"app\", http.StatusSeeOther)\n\t}\n\tTPL.ExecuteTemplate(res, \"login\", nil)\n}", "func getLoginHandler(w http.ResponseWriter, r *http.Request, _ map[string]string) {\n\tif database.RetrieveUsersCount() == 0 {\n\t\thttp.Redirect(w, r, \"/admin/register\", http.StatusFound)\n\t\treturn\n\t}\n\thttp.ServeFile(w, r, filepath.Join(filenames.AdminFilepath, \"login.html\"))\n\treturn\n}", "func loginFormHandler(w http.ResponseWriter, r *http.Request) {\n\t// Read the public key\n\tpemData, err := ioutil.ReadFile(PUBLIC_KEY_FILE)\n\tcheckHttpError(err, w)\n\tvar p = pageContent(r, \"Login\", pemData)\n\terr = templates[\"login\"].ExecuteTemplate(w, \"base\", p)\n\tcheckHttpError(err, w)\n}", "func (p *Base) Login() string {\n\treturn \"https://admin.thebase.in/users/login\"\n}", "func login(w http.ResponseWriter, r *http.Request) {\n clearCache(w)\n exists, _ := getCookie(r, LOGIN_COOKIE)\n if exists {\n http.Redirect(w, r, \"/home\", http.StatusSeeOther)\n return\n }\n if r.Method == http.MethodGet {\n LOG[INFO].Println(\"Login Page\")\n http.ServeFile(w, r, \"../../web/login.html\")\n } else if r.Method == http.MethodPost {\n LOG[INFO].Println(\"Executing Login\")\n r.ParseForm()\n LOG[INFO].Println(\"Form Values: Username\", r.PostFormValue(\"username\"))\n passhash := sha512.Sum512([]byte(r.PostFormValue(\"password\")))\n LOG[INFO].Println(\"Hex Encoded Passhash:\", hex.EncodeToString(passhash[:]))\n response := sendCommand(CommandRequest{CommandLogin, struct{\n Username string\n Password string\n }{\n r.PostFormValue(\"username\"),\n hex.EncodeToString(passhash[:]),\n }})\n if response == nil {\n http.SetCookie(w, genCookie(ERROR_COOKIE, \"Send Command Error\"))\n http.Redirect(w, r, \"/error\", http.StatusSeeOther)\n return\n }\n if !response.Success {\n LOG[WARNING].Println(StatusText(response.Status))\n http.Redirect(w, r, \"/login\", http.StatusSeeOther)\n return\n }\n\n LOG[INFO].Println(\"Successfully Logged In\")\n http.SetCookie(w, genCookie(LOGIN_COOKIE, r.PostFormValue(\"username\")))\n http.Redirect(w, r, \"/home\", http.StatusSeeOther)\n }\n}", "func (h *AuthHandler) RenderSignin(w http.ResponseWriter, r *http.Request) {\n\tview := NewView(r)\n\tview.Render(w, \"auth/signin\")\n}", "func Login(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tfmt.Println(\"Login\")\n}", "func (m *Manager) Login() error {\n\terr := m.useFreePort()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = m.openLoginPage()\n\tif err != nil {\n\t\tfmt.Println(\"Failed to open the login page, open the following link in your browser:\")\n\t}\n\tfmt.Println(loginURL)\n\terr = m.retrieveTokensFromServer()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func loginprompt(w http.ResponseWriter, r *http.Request) {\n\t_, tid := GetAndOrUpdateSession(w, r)\n\tif tid != \"\" {\n\t\tshowMessage(w, \"Error: already logged in\",\n\t\t\t\"You are already logged in\", tid, \"\")\n\t\treturn\n\t}\n\ttemplate.Must(template.New(\"\").Parse(tLoginPrompt)).Execute(w, map[string]string{\n\t\t\"PageTitle\": \"Please log in\",\n\t\t\"Team\": r.FormValue(\"team\"),\n\t\t// TODO URL escaping would be pretty sweet\n\t\t\"TeamURL\": url.QueryEscape(r.FormValue(\"team\")),\n\t})\n}", "func AdminLogin(w http.ResponseWriter, data *AdminLoginData) {\n\trender(tpAdminLogin, w, data)\n\tdata.Flash.Del(\"errors\")\n}", "func UsersLoginGet(c buffalo.Context) error {\n\treturn c.Render(200, r.HTML(\"users/login\"))\n}", "func LoadUserPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"userId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserIDLogged, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tif userID == userIDLogged {\n\t\thttp.Redirect(w, r, \"/profile\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"user.html\", struct {\n\t\tUser models.User\n\t\tUserLoggedID uint64\n\t}{\n\t\tUser: user,\n\t\tUserLoggedID: userIDLogged,\n\t})\n}", "func (c *UserController) Login() {\n\n\tisAjax := c.GetString(\"isajax\")\n\n\tif isAjax == \"1\" {\n\t\t// Captcha Verification.\n\t\tif !cpt.VerifyReq(c.Ctx.Request) {\n\t\t\tc.Resp(false, \"验证码错误!\")\n\t\t\treturn\n\t\t}\n\n\t\t// Passing Captcha Verify.\n\t\tusername := c.GetString(\"username\")\n\t\tpassword := c.GetString(\"password\")\n\n\t\tuser, err := doLogin(username, password)\n\t\tif err == nil {\n\t\t\tc.SetSession(\"userinfo\", user.Username)\n\t\t\tc.Resp(true, \"登陆成功\")\n\t\t\treturn\n\t\t}\n\t\tc.Resp(false, err.Error())\n\t\treturn\n\t}\n\t// Login Fail! relogin.\n\tc.Data[\"Title\"] = beego.AppConfig.String(\"login_title\")\n\tc.Data[\"Copyright\"] = beego.AppConfig.String(\"copyright\")\n\n\t// Get Verification Code.\n\tcpt = captcha.NewWithFilter(\"/captcha/\", store)\n\tcpt.ChallengeNums, _ = beego.AppConfig.Int(\"captcha_length\")\n\tcpt.StdWidth = 100\n\tcpt.StdHeight = 42\n\n\tc.TplName = \"login.tpl\"\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tappengineContext := appengine.NewContext(r)\n\tappengineUser := user.Current(appengineContext)\n\tif appengineUser != nil {\n\t\turl, err := user.LogoutURL(appengineContext, \"/\")\n\t\tif err == nil {\n\t\t\tw.Header().Set(\"Location\", url)\n\t\t\tw.WriteHeader(http.StatusFound)\n\t\t\treturn\n\t\t}\n\t}\n\tw.Header().Set(\"Location\", \"/\")\n\tw.WriteHeader(http.StatusFound)\n}", "func LoginGET(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"login.html\", gin.H{})\n}", "func logIn(res http.ResponseWriter, req *http.Request) {\n\t// retrive the name form URL\n\tname := req.FormValue(\"name\")\n\tname = html.EscapeString(name)\n\tif name != \"\" {\n\t\tuuid := generateUniqueId()\n\t\tsessionsSyncLoc.Lock()\n\t\tsessions[uuid] = name\n\t\tsessionsSyncLoc.Unlock()\n\n\t\t// save uuid in the cookie\n\t\tcookie := http.Cookie{Name: \"uuid\", Value: uuid, Path: \"/\"}\n\t\thttp.SetCookie(res, &cookie)\n\n\t\t// redirect to /index.html endpoint\n\t\thttp.Redirect(res, req, \"/index.html\", http.StatusFound)\n\t} else {\n\t\t// if the provided input - name is empty, display this message\n\t\tres.Header().Set(\"Content-Type\", \"text/html\")\n\t\tfmt.Fprintf(\n\t\t\tres,\n\t\t\t`<html>\n\t\t\t<body>\n\t\t\t<form action=\"login\">\n\t\t\t C'mon, I need a name.\n\t\t\t</form>\n\t\t\t</p>\n\t\t\t</body>\n\t\t\t</html>`,\n\t\t)\n\t}\n}", "func LogPage(c *fiber.Ctx) error {\n\treturn c.Send([]byte(\"You are on a default Login page.\"))\n}", "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func Login(c *gin.Context) {\n\tvar form model.LoginForm\n\terr := c.BindJSON(&form)\n\tif err != nil {\n\t\tfailMsg(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tvalid, errMsg := validInfo(form)\n\tif !valid {\n\t\tfailMsg(c, http.StatusBadRequest, errMsg)\n\t\treturn\n\t}\n\tvalid = model.VerifyLogin(form)\n\tif !valid {\n\t\tfailMsg(c, http.StatusUnauthorized, \"wrong username or password\")\n\t\treturn\n\t}\n\ttoken, err := model.GenerateToken(form.Username)\n\tif err != nil {\n\t\tfailMsg(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"success\": true,\n\t\t\"error\": \"\",\n\t\t\"data\": \"Bearer \" + token,\n\t})\n\n}", "func (controller *Auth) showLoginForm() {\n\trawSendMe := controller.GetString(\"sendMe\")\n\tcontroller.Data[\"sendMe\"] = strings.TrimSpace(rawSendMe)\n\tcontroller.SetCustomTitle(\"Login to Wisply\")\n\tcontroller.showForm(\"login\")\n\tcontroller.LoadCaptcha(\"login-form-page\")\n}", "func (a *App) Login(w http.ResponseWriter, r *http.Request) {\n\tvar resp = map[string]interface{}{\"status\": \"success\", \"message\": \"logged in\"}\n\n\tuser := &models.User{}\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tuser.Prepare() // here strip the text of white spaces\n\n\terr = user.Validate(\"login\") // fields(email, password) are validated\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tusr, err := user.GetUser(a.DB)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tif usr == nil { // user is not registered\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please signup\"\n\t\tresponses.JSON(w, http.StatusBadRequest, resp)\n\t\treturn\n\t}\n\n\terr = models.CheckPasswordHash(user.Password, usr.Password)\n\tif err != nil {\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please try again\"\n\t\tresponses.JSON(w, http.StatusForbidden, resp)\n\t\treturn\n\t}\n\ttoken, err := utils.EncodeAuthToken(usr.ID)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tresp[\"token\"] = token\n\tresponses.JSON(w, http.StatusOK, resp)\n\treturn\n}", "func LoginHandler(c *gin.Context) {\n\tval, _ := c.Cookie(\"auth\")\n\tif val != \"\" {\n\t\tc.Redirect(http.StatusOK, \"/dashboard\")\n\t\treturn\n\t}\n\n\tinfo := models.LoginInfo{\n\t\tEmail: c.Query(\"email\"),\n\t\tPassword: c.Query(\"password\"),\n\t}\n\n\tif info.Email == \"\" || info.Password == \"\" {\n\t\tc.Redirect(http.StatusTemporaryRedirect, \"/\")\n\t\treturn\n\t}\n\n\tif ok, err := crud.CheckLoginInfo(info); !ok || err != nil {\n\t\tc.HTML(http.StatusInternalServerError, \"login.html\", err.Error())\n\t}\n\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/\", \"127.0.0.1\", false, false)\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/dashboard\", \"127.0.0.1\", false, false)\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/data\", \"127.0.0.1\", false, false)\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/report\", \"127.0.0.1\", false, false)\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/config\", \"127.0.0.1\", false, false)\n\tc.SetCookie(\"auth\", \"yes\", 86400, \"/config/submit\", \"127.0.0.1\", false, false)\n\n\tc.Redirect(http.StatusTemporaryRedirect, \"/dashboard\")\n\treturn\n}", "func LoginHandler(w *http.ResponseWriter, r *http.Request, p *persistance.Persistance) {\n\tvar env s.Envelop\n\terr := env.FromEnvelop(r)\n\tcheckErr(err)\n\n}", "func (s *Server) Login(w http.ResponseWriter, r *http.Request) {\n\tvar acc data.Account\n\t// получение данных JSON account\n\tif err := json.NewDecoder(r.Body).Decode(&acc); err != nil {\n\t\thttp.Error(w, e.DecodeError.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\ttoken, err := s.service.Login(&acc)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tw.Header().Set(\"Token\", token)\n\tfmt.Fprint(w, \"See in tab Headers.\")\n}", "func loginActionHandler(w http.ResponseWriter, r *http.Request) {\n\n\t// Read the private key\n\tpemData, err := ioutil.ReadFile(PRIVATE_KEY_FILE)\n\tcheckHttpError(err, w)\n\n\t// Extract the PEM-encoded data block\n\tblock, _ := pem.Decode(pemData)\n\tif block == nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tif got, want := block.Type, \"RSA PRIVATE KEY\"; got != want {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Decode the RSA private key\n\tpriv, err := x509.ParsePKCS1PrivateKey(block.Bytes)\n\tcheckHttpError(err, w)\n\n\t// Decode the Base64 into binary\n\tcipheredValue, err := base64.StdEncoding.DecodeString(r.FormValue(\"CipheredValue\"))\n\tcheckHttpError(err, w)\n\n\t// Decrypt the data\n\tvar out []byte\n\tout, err = rsa.DecryptPKCS1v15(rand.Reader, priv, cipheredValue)\n\tcheckHttpError(err, w)\n\n\t//home or login\n\tsession, _ := store.Get(r, \"goServerView\")\n\th := sha512.New()\n\th.Write(out)\n\tstr := base64.StdEncoding.EncodeToString(h.Sum([]byte{}))\n\n\tif str == config.Password {\n\t\tsession.Values[\"isConnected\"] = true\n\t\tsession.Values[\"user\"] = r.FormValue(\"User\")\n\t\tsession.Save(r, w)\n\t\thomeHandler(w, r)\n\t} else {\n\t\tsession.Values[\"isConnected\"] = false\n\t\tsession.AddFlash(\"Either the username or the password provided is wrong\")\n\t\tsession.Save(r, w)\n\t\tloginFormHandler(w, r)\n\t}\n}", "func HandleLogin(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tServeHandleIncorrect(w, r)\n\t\treturn\n\t}\n\tvalues := LoginFormValues{}\n\tdecoder := schema.NewDecoder()\n\terr = decoder.Decode(&values, r.PostForm)\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\n\tacc, err := data.GetAccountByHandle(values.Handle)\n\tif err == mgo.ErrNotFound {\n\t\tServeHandleIncorrect(w, r)\n\t\treturn\n\t}\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\tm := acc.Password.Match(values.Password)\n\tif !m {\n\t\thttp.Redirect(w, r, \"/login\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\tsess, err := store.Get(r, \"s\")\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\tsess.Values[\"accountID\"] = acc.ID.Hex()\n\tsess.Save(r, w)\n\thttp.Redirect(w, r, \"/tasks\", http.StatusSeeOther)\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tuser := models.User{}\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\tuser.Prepare()\n\terr = user.Validate(\"login\")\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\ttoken, err := auth.SignIn(user.Email, user.Password)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tresponses.JSON(w, http.StatusOK, token)\n}", "func handleHomePage(w http.ResponseWriter, r *http.Request) {\n\n\tw.Header().Set(\"Content-type\", \"text/html; charset=utf-8\")\n\tcontext := appengine.NewContext(r)\n\tu := user.Current(context)\n\n\tloginURL, _ := user.LoginURL(context, \"/\")\n\tlogoutURL, _ := user.LogoutURL(context, \"/\")\n\n\td := struct {\n\t\tData interface{}\n\t\tAuthEnabled bool\n\t\tLoginURL string\n\t\tLogoutURL string\n\t}{\n\t\tData: nil,\n\t\tAuthEnabled: u != nil,\n\t\tLoginURL: loginURL,\n\t\tLogoutURL: logoutURL,\n\t}\n\n\tif err := tpl.ExecuteTemplate(w, \"homepage.html\", d); err != nil {\n\t\tlog.Errorf(context, \"%v\", err)\n\t}\n\n\t/*\n\t\tif u == nil {\n\t\t\turl, _ := user.LoginURL(context, \"/\")\n\t\t\tfmt.Fprintf(w, `<a href=\"%s\">Sign in or register</a>`, url)\n\t\t\treturn\n\t\t}\n\t\turl, _ := user.LogoutURL(context, \"/\")\n\t*/\n\t//\tfmt.Fprintf(w, `Welcome, %s! (<a href=\"%s\">sign out</a>)`, u, url)\n}", "func Vendorlogin(c buffalo.Context) error {\n\n\treturn c.Render(200, r.HTML(\"Vendor_Login.html\", \"master_page/login_tmp.html\"))\n}", "func loadPage(w http.ResponseWriter) {\n\tfmt.Fprintln(w, \"<!DOCTYPE html>\")\n\tfmt.Fprintln(w, \"<html>\")\n\tfmt.Fprintln(w, \" <head>\")\n\tfmt.Fprintln(w, \" <title>IRC Services Test</title>\")\n\tfmt.Fprintln(w, \" </head>\")\n\tfmt.Fprintln(w, \" <body>\")\n\tfmt.Fprintln(w, \" <h1 style=\\\"color: black; font-family: verdana; text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" IRC Services Tests Enabled\")\n\tfmt.Fprintln(w, \" </h1>\")\n\tfmt.Fprintln(w, \" <div style=\\\"margin: 0 auto;padding: 0;width: 600px;text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" View page source for the values and names of the associated POST methods.<br><br>\")\n\tfmt.Fprintln(w, \" </div>\")\n\tfmt.Fprintln(w, \" <form action=\\\"\"+NetservicesConfig.IRCservicesURI+\"\\\" method=\\\"post\\\">\")\n\tfmt.Fprintln(w, \" <table style=\\\"margin: 0 auto;padding: 0;width: 450px;text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" &nbsp;&nbsp;Test to check nickname and password authentication.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"checkAuthentication\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Nickname\\\" name=\\\"nick\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"password\\\" placeholder=\\\"Password\\\" name=\\\"password\\\">\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check command to a Network Service.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"command\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Service Name\\\" name=\\\"service\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Command\\\" name=\\\"command\\\">\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to request #channel information.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"channel\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"#channel\\\" name=\\\"channel\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\t\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to request user information.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"user\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Nickname\\\" name=\\\"user\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\t\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check status of Network Services.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"stats\\\">\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check for invalid POST Method.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"notvalid\\\">\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <br><button type=\\\"Submit\\\" value=\\\"Submit\\\">Submit</button>\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" </table>\")\n\tfmt.Fprintln(w, \" </form>\")\n\tfmt.Fprintln(w, \" </body>\")\n\tfmt.Fprintln(w, \"</html>\")\n}", "func loadPage(pn string, r *http.Request) (*Page, error) {\n\tdata := &Page{\n\t\tPageName: pn,\n\t}\n\n\t/* Get user name for filling in template too */\n\tsesh, _ := store.Get(r, \"loginSession\")\n\tuname, ok := sesh.Values[\"username\"].(string)\n\tif !ok {\n\t\treturn nil, &ClientSafeError{Msg: \"invalid username\"}\n\t}\n\tdata.Username = uname\n\t/* get user's role */\n\trole, err := getRoleNum(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch role {\n\tcase FACILITATOR:\n\t\tdata.Role = \"Facilitator\"\n\t\tdata.Messages, err = getNotifications(data.Username)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase TEACHER:\n\t\tdata.Role = \"Teacher\"\n\tcase ADMIN:\n\t\tdata.Role = \"Admin\"\n\tdefault:\n\t\treturn nil, &ClientSafeError{Msg: \"insufficient access rights\"}\n\t}\n\n\treturn data, nil\n}", "func loginHandler(res http.ResponseWriter, req *http.Request) {\n\tdefer server.LogRequest(req, http.StatusFound)\n\tcounter.Increment(\"login\")\n\n\t// get the requested username\n\tusername := req.FormValue(\"name\")\n\tif len(username) < 1 {\n\t\trenderBaseTemplate(res, \"login_error.html\", nil)\n\t} else {\n\t\terr := session.Create(res, username)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\thttp.Redirect(res, req, \"/index.html\", http.StatusFound)\n\t}\n}", "func displayHome(w http.ResponseWriter, r *http.Request) {\n\tlog.Printf(\"displayHome: url %s\", r.URL.Path)\n\n\t// Tell health check probes that we are alive\n\tif !httphandling.AcceptHTML(r) {\n\t\tfmt.Fprintln(w, \"OK\")\n\t\treturn\n\t}\n\n\ttitle := b.webConfig.GetVarWithDefault(\"Title\", defTitle)\n\tcontent := htmlContent{\n\t\tTitle: title,\n\t}\n\tif config.PasswordProtected() {\n\t\tctx := context.Background()\n\t\tif b.authenticator == nil {\n\t\t\tvar err error\n\t\t\tb.authenticator, err = initAuth(ctx)\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(\"displayHome authenticator could not be initialized\")\n\t\t\t\thttp.Error(w, \"Server error\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tsessionInfo := identity.InvalidSession()\n\t\tcookie, err := r.Cookie(\"session\")\n\t\tif err == nil {\n\t\t\tsessionInfo = b.authenticator.CheckSession(ctx, cookie.Value)\n\t\t} else {\n\t\t\tlog.Printf(\"displayHome error getting cookie: %v\", err)\n\t\t\tb.pageDisplayer.DisplayPage(w, \"login_form.html\", content)\n\t\t\treturn\n\t\t}\n\t\tif !sessionInfo.Valid {\n\t\t\tb.pageDisplayer.DisplayPage(w, \"login_form.html\", content)\n\t\t\treturn\n\t\t} else {\n\t\t\tlog.Printf(\"displayHome: using index_auth_template.html for url %s\", r.URL.Path)\n\t\t\tb.pageDisplayer.DisplayPage(w, \"index_auth_template.html\", content)\n\t\t\treturn\n\t\t}\n\t}\n\tlog.Printf(\"displayHome: template index.html for url %s\", r.URL.Path)\n\tb.pageDisplayer.DisplayPage(w, \"index.html\", content)\n}", "func (a *App) Login(w http.ResponseWriter, r *http.Request) {\n\tvar loginInfo uvm.UserLoginVM\n\n\tdecoder := json.NewDecoder(r.Body)\n\tvar err error\n\n\tif err = decoder.Decode(&loginInfo); err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid request body\")\n\t\treturn\n\t}\n\n\t//TODO validate user data\n\n\tuser := a.UserStore.GetUserByEmail(loginInfo.Email)\n\n\tif user.ID == \"\" || utils.CheckPasswordHash(loginInfo.Password, user.Password) {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid credentials\")\n\t\treturn\n\t}\n\n\ttoken := auth.GenerateToken(a.APISecret, user)\n\n\tresult := models.UserResult{\n\t\tUsername: user.Username,\n\t\tPicture: user.Picture,\n\t\tRole: user.Role.Name,\n\t\tToken: token,\n\t}\n\n\trespondWithJSON(w, http.StatusOK, result)\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\t/*\n\t\tTratamento dos dados vindos do front-end\n\t\tNesse caso, o request pega login e senha\n\t*/\n\tvar login models.Credentials\n\tbody := r.Body\n\tbytes, err := util.BodyToBytes(body)\n\terr = util.BytesToStruct(bytes, &login)\n\n\t// Checks if struct is a valid one\n\tif err = validation.Validator.Struct(login); err != nil {\n\n\t\tlog.Printf(\"[WARN] invalid user information, because, %v\\n\", err)\n\t\tw.WriteHeader(http.StatusPreconditionFailed) // Status 412\n\t\treturn\n\t}\n\n\t// err1 consulta o login no banco de dados\n\terr1 := database.CheckLogin(login.Login)\n\n\t// err2 consulta a senha referente ao login fornecido\n\terr2 := database.CheckSenha(login.Login, login.Senha)\n\n\t// Condicao que verifica se os dois dados constam no banco de dados\n\tif (err1 != nil) || (err2 != true) {\n\t\tlog.Println(\"[FAIL]\")\n\t\tw.WriteHeader(http.StatusForbidden) // Status 403\n\t} else {\n\t\tlog.Println(\"[SUCCESS]\")\n\t\tw.WriteHeader(http.StatusAccepted) // Status 202\n\t}\n\n\treturn\n}", "func (s *Server) Login(c *gin.Context) {\n\tvar login Login\n\tc.BindJSON(&login)\n\n\terr := login.Validate()\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"login\": true,\n\t})\n}", "func Login() gin.HandlerFunc {\r\n\tif gin.Mode() == \"debug\" {\r\n\t\treturn func(c *gin.Context) { c.Next() }\r\n\t}\r\n\treturn func(c *gin.Context) {\r\n\t\tsession := sessions.Default(c)\r\n\t\tUserID := session.Get(\"UserID\")\r\n\t\tIsLeader := session.Get(\"IsLeader\")\r\n\r\n\t\tfmt.Println(\"UserID, IsLeader\", UserID, IsLeader)\r\n\t\tif UserID == nil {\r\n\t\t\tstate := string([]byte(c.Request.URL.Path)[1:])\r\n\t\t\tc.Redirect(http.StatusFound, \"/login?state=\"+state)\r\n\t\t\tc.Abort()\r\n\t\t} else {\r\n\t\t\tc.Set(\"UserID\", UserID)\r\n\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\t\t\tc.Next()\r\n\t\t}\r\n\r\n\t}\r\n}", "func LoginHandler(conf *Config) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tsession, loggedIn, err := CheckLogin(w, r)\n\t\tif err != nil {\n\t\t\tlog.Println(\"error trying to retrieve session on login page:\", err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\t// if already logged in the user has already been redirected.\n\t\t// rest of logic can be ignored.\n\t\tif loggedIn {\n\t\t\thttp.Redirect(w, r, \"/control\", http.StatusFound)\n\t\t\treturn\n\t\t}\n\n\t\tif r.Method == \"GET\" {\n\n\t\t\ttempControl := TemplateHandler{\n\t\t\t\tfilename: \"login.html\",\n\t\t\t\tdata: map[string]interface{}{\n\t\t\t\t\t\"location\": conf.Location,\n\t\t\t\t},\n\t\t\t}\n\t\t\ttempControl.ServeHTTP(w, r)\n\t\t\treturn\n\t\t} else if r.Method != \"POST\" {\n\t\t\tlog.Println(\"Unsuported request type for Settings page:\", r.Method)\n\t\t\treturn\n\t\t}\n\n\t\t// process POST request\n\t\txForward := r.Header.Get(\"x-forwarded-for\")\n\t\tif conf.Debug {\n\t\t\tlog.Println(\"attempted login request from:\", xForward, r.RemoteAddr)\n\t\t}\n\t\tif err := r.ParseForm(); err != nil {\n\t\t\tlog.Println(\"Error trying to parse form in login page.\\n\", err)\n\t\t}\n\t\tusername := r.PostFormValue(\"username\")\n\t\tpassword := r.PostFormValue(\"password\")\n\n\t\t// if there's no login entry in the config file, add the default login details\n\t\tif conf.Login.Username == \"\" {\n\t\t\tif conf.Debug {\n\t\t\t\tlog.Println(\"no login details found in config file, creating default login details now.\")\n\t\t\t}\n\t\t\tvar err error\n\t\t\tif conf.Login, err = newLogin(); err != nil {\n\t\t\t\tlog.Println(\"error trying to save default username and password\")\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err := conf.Save(\"\"); err != nil {\n\t\t\t\tlog.Println(\"error trying to save config file:\", err)\n\t\t\t}\n\t\t}\n\n\t\tif username == conf.Login.Username && checkHash(password, conf.Login.Password) {\n\t\t\t// user successfully logged in\n\t\t\tsession.Values[\"x-forwarded-for\"] = xForward\n\t\t\tsession.Save(r, w)\n\t\t\thttp.Redirect(w, r, \"/control\", http.StatusFound)\n\t\t\treturn\n\t\t}\n\n\t\ttempControl := TemplateHandler{\n\t\t\tfilename: \"login.html\",\n\t\t\tdata: map[string]interface{}{\n\t\t\t\t\"location\": conf.Location,\n\t\t\t\t\"flashMessage\": \"Incorrect username or password\",\n\t\t\t},\n\t\t}\n\t\ttempControl.ServeHTTP(w, r)\n\t}\n}", "func (app *application) login(w http.ResponseWriter, r *http.Request) {\n\tsession, err := app.sessionStore.Get(r, \"session-name\")\n\tif err != nil {\n\t\tapp.serverError(w, err)\n\t\treturn\n\t}\n\terr = r.ParseForm()\n\tif err != nil {\n\t\tapp.clientError(w, http.StatusBadRequest)\n\t\treturn\n\t}\n\tform := forms.New(r.PostForm)\n\tform.Required(\"email\", \"password\")\n\tform.MatchesPattern(\"email\", forms.RxEmail)\n\tif !form.Valid() {\n\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\treturn\n\t}\n\tvar id int\n\tif form.Get(\"accType\") == \"customer\" {\n\t\tid, err = app.customers.Authenticate(form.Get(\"email\"), form.Get(\"password\"))\n\t\tif err == models.ErrInvalidCredentials {\n\t\t\tform.Errors.Add(\"generic\", \"Email or Password Incorrect. Please ensure you have selected correct account type\")\n\t\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\t\treturn\n\t\t} else if err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\tsession.Values[\"customerID\"] = id\n\t\terr = session.Save(r, w)\n\t\tif err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/customer/home\", http.StatusSeeOther)\n\t} else {\n\t\tid, err = app.vendors.Authenticate(form.Get(\"email\"), form.Get(\"password\"))\n\t\tif err == models.ErrInvalidCredentials {\n\t\t\tform.Errors.Add(\"generic\", \"Email or Password Incorrect. Please ensure you have selected correct account type\")\n\t\t\tapp.render(w, r, \"login.page.tmpl\", &templateData{Form: form})\n\t\t\treturn\n\t\t} else if err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\tsession.Values[\"vendorID\"] = id\n\t\terr = session.Save(r, w)\n\t\tif err != nil {\n\t\t\tapp.serverError(w, err)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/vendor/home\", http.StatusSeeOther)\n\t}\n}", "func Login(w http.ResponseWriter, r *http.Request) {\r\n\tlogin := strings.Trim(r.FormValue(\"login\"), \" \")\r\n\tpass := strings.Trim(r.FormValue(\"pass\"), \" \")\r\n\tlog.Println(\"login: \", login, \" pass: \", pass)\r\n\r\n\t// Check params\r\n\tif login == \"\" || pass == \"\" {\r\n\t\twriteResponse(w, \"Login and password required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Already authorized\r\n\tif savedPass, OK := Auth[login]; OK && savedPass == pass {\r\n\t\twriteResponse(w, \"You are already authorized\\n\", http.StatusOK)\r\n\t\treturn\r\n\t} else if OK && savedPass != pass {\r\n\t\t// it is not neccessary\r\n\t\twriteResponse(w, \"Wrong pass\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser := model.User{}\r\n\terr := user.Get(login, pass)\r\n\tif err == nil {\r\n\t\tAuth[login], Work[login] = pass, user.WorkNumber\r\n\t\twriteResponse(w, \"Succesfull authorization\\n\", http.StatusOK)\r\n\t\treturn\r\n\t}\r\n\r\n\twriteResponse(w, \"User with same login not found\\n\", http.StatusNotFound)\r\n}", "func (h *AuthHandlers) Login(w http.ResponseWriter, req *http.Request) {\n\tvar err error\n\tvar data []byte\n\n\tsystemContext, err := h.getSystemContext(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"request context retrevial failure\")\n\t\tmiddleware.ReturnError(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tif data, err = ioutil.ReadAll(req.Body); err != nil {\n\t\tlog.Error().Err(err).Msg(\"read body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\tdefer req.Body.Close()\n\n\tloginDetails := &authz.LoginDetails{}\n\tif err := json.Unmarshal(data, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Msg(\"marshal body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\n\tif err := h.validate.Struct(loginDetails); err != nil {\n\t\tmiddleware.ReturnError(w, \"validation failure \"+err.Error(), 500)\n\t\treturn\n\t}\n\tloginDetails.OrgName = strings.ToLower(loginDetails.OrgName)\n\tloginDetails.Username = strings.ToLower(loginDetails.Username)\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login attempt\")\n\n\torgData, err := h.getOrgByName(req.Context(), systemContext, loginDetails.OrgName)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"failed to get organization from name\")\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\n\tresults, err := h.authenticator.Login(req.Context(), orgData, loginDetails)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login failed\")\n\t\tif req.Context().Err() != nil {\n\t\t\tmiddleware.ReturnError(w, \"internal server error\", 500)\n\t\t\treturn\n\t\t}\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\t// add subscription id to response\n\tresults[\"subscription_id\"] = fmt.Sprintf(\"%d\", orgData.SubscriptionID)\n\n\trespData, err := json.Marshal(results)\n\tif err != nil {\n\t\tmiddleware.ReturnError(w, \"marshal auth response failed\", 500)\n\t\treturn\n\t}\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Str(\"OrgCID\", orgData.OrgCID).Msg(\"setting orgCID in cookie\")\n\tif err := h.secureCookie.SetAuthCookie(w, results[\"access_token\"], orgData.OrgCID, orgData.SubscriptionID); err != nil {\n\t\tmiddleware.ReturnError(w, \"internal cookie failure\", 500)\n\t\treturn\n\t}\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (a Authentic) loginHandler(c buffalo.Context) error {\n\tc.Request().ParseForm()\n\n\t//TODO: schema ?\n\tloginData := struct {\n\t\tUsername string\n\t\tPassword string\n\t}{}\n\n\tc.Bind(&loginData)\n\n\tu, err := a.provider.FindByUsername(loginData.Username)\n\tif err != nil || ValidatePassword(loginData.Password, u) == false {\n\t\tc.Flash().Add(\"danger\", \"Invalid Username or Password\")\n\t\treturn c.Redirect(http.StatusSeeOther, a.Config.LoginPath)\n\t}\n\n\tc.Session().Set(SessionField, u.GetID())\n\tc.Session().Save()\n\n\treturn c.Redirect(http.StatusSeeOther, a.Config.AfterLoginPath)\n}", "func (controller *AuthController) SignInPage(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/auth/signin\" {\n\t\thttp.Error(w, \"Not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, \"Method not allowed\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\thttp.ServeFile(w, r, \"./api/view/signin.html\")\n}", "func (h *TestAuth) Login(w http.ResponseWriter, req *http.Request) {\n\n\tresponse := make(map[string]string, 5)\n\n\tresponse[\"state\"] = authz.AuthNewPasswordRequired\n\tresponse[\"access_token\"] = \"access\"\n\t//response[\"id_token\"] = *authResult.IdToken\n\tresponse[\"refresh_token\"] = \"refersh\"\n\tresponse[\"expires\"] = \"3600\"\n\tresponse[\"token_type\"] = \"Bearer\"\n\trespData, _ := json.Marshal(response)\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {\n\tvar d UserLoginRequest\n\tif err := json.NewDecoder(r.Body).Decode(&d); err != nil {\n\t\trender.BadRequest(w, r, \"invalid json string\")\n\t\treturn\n\t}\n\n\t//Check if email exists\n\tuser, err := h.Client.User.\n\t\tQuery().\n\t\tWhere(usr.Email(d.Email)).\n\t\tOnly(r.Context())\n\tif err != nil {\n\t\tswitch {\n\t\tcase ent.IsNotFound(err):\n\t\t\trender.NotFound(w, r, \"Email Doesn't exists\")\n\t\tcase ent.IsNotSingular(err):\n\t\t\trender.BadRequest(w, r, \"Invalid Email\")\n\t\tdefault:\n\t\t\trender.InternalServerError(w, r, \"Server Error\")\n\t\t}\n\t\treturn\n\t}\n\n\t// Verify the password\n\tif user.Password == d.Password {\n\t\tfmt.Println(\"User Verified. Log In Successful\")\n\t\trender.OK(w, r, user)\n\t\treturn\n\t}\n\trender.Unauthorized(w, r, \"Invalid Email or Password.\")\n}", "func LoginController(res http.ResponseWriter, req *http.Request) {\n\tsession, _ := utils.GetValidSession(req)\n\tif session.Values[\"userid\"] != nil {\n\t\tcontext.Set(req, \"userid\", session.Values[\"userid\"])\n\t\thttp.Redirect(res, req, urls.HomePath, http.StatusSeeOther)\n\t} else {\n\t\tt, _ := template.ParseFiles(templates.LoginTemplate)\n\t\tt.Execute(res, nil)\n\t}\n}", "func LoginAction(w http.ResponseWriter, r *http.Request) {\n\n\tpageVars := PageVars{}\n\taddPageVars(r, &pageVars)\n\n\tuserName := r.FormValue(\"userName\")\n\t// validate username\n\tif len(userName) <= 0 {\n\t\thttp.Redirect(w, r, \"/login?errorM=Username specified\", http.StatusSeeOther)\n\t\treturn\n\t}\n\tpassword := r.FormValue(\"password\")\n\t// validate password\n\tif len(password) <= 0 {\n\t\thttp.Redirect(w, r, \"/login?errorM=Password specified\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\t// get expected password\n\texpectedPassword := getStringFromDB(\"Users\", userName)\n\n\t// verify the password\n\tif expectedPassword != password {\n\t\thttp.Redirect(w, r, \"/login?errorM=Invalid credentials\", http.StatusSeeOther)\n\t\treturn\n\t}\n\t\n\t// Create a new random session token\n\tsessionToken, err := uuid.NewUUID()\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/login?errorM=Unable to create token\", http.StatusSeeOther)\n\t}\n\t// Set the token in the db, along with the userName\n\tupdateDBString(\"Sessions\", userName, sessionToken.String())\n\n\t// set the expiration time\n\texpires := time.Now().Add(600 * time.Second)\n\tck := http.Cookie{\n Name: \"JSESSION_ID\",\n Path: \"/\",\n\t\tExpires: expires,\n\t\tValue: userName+\"_\"+sessionToken.String(),\n\t}\n\n // write the cookie to response\n http.SetCookie(w, &ck)\n\thttp.Redirect(w, r, \"/listbuckets\", http.StatusSeeOther)\n\n}", "func (uc *UserController) Login(w http.ResponseWriter, r *http.Request) {\n\tvar loginInfo models.User\n\tdecoder := json.NewDecoder(r.Body)\n\tdecoder.Decode(&loginInfo)\n\tresp, token, _, _, _ := uc.User.GET(loginInfo.Username, loginInfo.Password)\n\tif token != \"\" {\n\t\tjson.NewEncoder(w).Encode(resp)\n\t}\n}", "func LoginWeb(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"login.html\", gin.H{\n\t\t\"title\": \"登录\",\n\t})\n}" ]
[ "0.7429022", "0.74259853", "0.7377962", "0.7345556", "0.72520685", "0.7041095", "0.6994549", "0.68380016", "0.68097377", "0.67939055", "0.6738007", "0.6672215", "0.6645821", "0.6628835", "0.6621005", "0.6615827", "0.66071063", "0.6574048", "0.65529084", "0.6483829", "0.6481375", "0.64591587", "0.64546233", "0.64466876", "0.64125794", "0.634457", "0.63429", "0.6319779", "0.627307", "0.62217265", "0.6199566", "0.61265194", "0.6046424", "0.6035263", "0.5958298", "0.59460545", "0.59017766", "0.5890162", "0.58440197", "0.5842842", "0.5828704", "0.58198833", "0.5818855", "0.5804096", "0.57892424", "0.57820004", "0.5778438", "0.5778221", "0.5763763", "0.5760292", "0.5755667", "0.5747568", "0.57344717", "0.572583", "0.569713", "0.5689051", "0.5674521", "0.56642187", "0.56507015", "0.5624627", "0.56224275", "0.5613603", "0.56048644", "0.5604512", "0.55997354", "0.55969244", "0.55902994", "0.5580474", "0.5576055", "0.55705744", "0.556919", "0.5557352", "0.55566865", "0.5549891", "0.5540818", "0.5540387", "0.5534641", "0.55342424", "0.5522806", "0.5512615", "0.550107", "0.5497955", "0.54949385", "0.54874647", "0.5484516", "0.5483366", "0.54755497", "0.54543555", "0.54481983", "0.544734", "0.5446261", "0.5442198", "0.5429776", "0.5429068", "0.54275316", "0.54234475", "0.54108214", "0.5406622", "0.5384213", "0.5381066" ]
0.742975
0
LoadRegisterPage Render register page
func LoadRegisterPage(w http.ResponseWriter, r *http.Request) { utils.RunTemplate(w, "register.html", nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Register(ctx echo.Context) error {\n\t// set page tittle to register\n\tutils.SetData(ctx, \"PageTitle\", \"register\")\n\treturn ctx.Render(http.StatusOK, tmpl.RegisterTpl, utils.GetData(ctx))\n}", "func RegisterPageHandler(w http.ResponseWriter,r *http.Request) {\n\tvar body,_ = servers.LoadFile(\"static/register.html\")\n\tfmt.Fprintf(w, body)\n}", "func (c *UserController) ShowRegister() {\n\t//sum := sha256.Sum256([]byte(\"helloworda\"))\n\n\tc.TplName = \"register.html\"\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\n\tdata := map[string]interface{}{\n\t\t\"Title\": \"REGISTER\",\n\t}\n\tif err := controller.ModelosRegister.ExecuteTemplate(w, \"register.html\", data); err != nil {\n\t\thttp.Error(w, \"[CONTENT ERRO] Erro in the execute template\", http.StatusInternalServerError)\n\t\tlog.Fatal(err.Error())\n\t}\n}", "func ShowResgistrationPage(c *gin.Context) {\n\trender(c, gin.H{\n\t\t\"title\": \"Register\",\n\t}, \"register.html\")\n}", "func AdminRegister(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminRegister, w, data)\n}", "func (u *UserView) ShowRegistrationPage(c *gin.Context) {\n\trender(c,\n\t\tgin.H{\"title\": \"Register\"},\n\t\t\"register.html\")\n}", "func GetRegister(w http.ResponseWriter, req *http.Request, app *App) {\n\trender(w, \"admin/register\", nil, app)\n}", "func LoadViewCreateUser(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"register.html\", nil)\n}", "func (c *Controller) GetRegister() mvc.Result {\n\tif c.isLoggedIn() {\n\t\treturn c.logout()\n\t}\n\n\t// You could just use it as a variable to win some time in serve-time,\n\t// this is an exersise for you :)\n\treturn mvc.View{\n\t\tName: pathRegister.Path + \".html\",\n\t\tData: page{\"User Registration\"},\n\t}\n}", "func (rs accessResources) Register(w http.ResponseWriter, r *http.Request) {\n\tw.Write( []byte( \"Register...\" ) )\n}", "func (rs accessResources) Register(w http.ResponseWriter, r *http.Request) {\n\tw.Write( []byte( \"Register...\" ) )\n}", "func RegisterPage(page *types.Page, nav *navigation.Navigation) {\n\n\tif build.ModuleConsole {\n\t\tconsole.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleLogViewer {\n\t\tlogviewer.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleBackup {\n\t\tbackup.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleOpenESPM {\n\t\topenespm.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleFileshare {\n\t\tfileshare.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleHomepage {\n\t\thomepage.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleMeshFS {\n\t\tmeshfilesync.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleMesh || build.ModuleMessenger || build.ModuleMeshFS {\n\t\tmesh.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleMediaDownloader {\n\t\tmediadownloader.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleIPTracker {\n\t\tiptracker.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleGasPrice {\n\t\tgasprice.RegisterPage(page, nav)\n\t}\n\n\tif build.ModulePictureX {\n\t\tpicturex.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleS7Backup {\n\t\ts7backup.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleInstaBackup {\n\t\tinstabackup.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleMonMotion {\n\t\tmonmotion.RegisterPage(page, nav)\n\t}\n\n\tif build.ModuleGPSNav {\n\t\tgpsnav.RegisterPage(page, nav)\n\t}\n}", "func (u *User) GetRegister(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\t// If the user already has a session (is logged in), redirect\n\t// them back to the home page.\n\t// if ok := u.session.HasSession(r); ok {\n\t// http.Redirect(w, r, \"/\", http.StatusFound)\n\t// return\n\t// }\n\tu.template.Render(w, \"register\", nil)\n}", "func (r *Router) register() {\n\tpages := []Page{\n\t\tr.projectListPage,\n\t\tr.projectBuildListPage,\n\t\tr.buildJobListPage,\n\t\tr.jobLogPage,\n\t}\n\n\t// Register all the pages on the ui.\n\tfor _, page := range pages {\n\t\tpage.Register(r.pages)\n\t}\n}", "func register(writer http.ResponseWriter, request *http.Request) {\n\terr := request.ParseForm()\n\tif err != nil {\n\t\tfmt.Fprintln(writer, \"Cannot parse form\")\n\t}\n\tprint(request.PostFormValue(\"title\"))\n\tprint(request.PostFormValue(\"body\"))\n\tregisterfile(request.PostFormValue(\"title\"), request.PostFormValue(\"body\"))\n\n\thttp.Redirect(writer, request, \"/viewlist\", 302)\n}", "func RegistrationPage(w http.ResponseWriter, r *http.Request) {\n var flag bool\n var details helpers.User\n var targettmpl string\n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n userDetails := getSession(r)\n \n if (len(userDetails.FirstName) <= 0 && userDetails.Role == \"Admin\" ) {\n w.Write([]byte(\"<script>alert('Unauthorized Access!!,please login');window.location = '/login'</script>\"))\n }\n\n if (userDetails.Role == \"Admin\" || userDetails.Role == \"admin\"){ \n targettmpl = \"templates/registrationPage.html\" \n }else{\n targettmpl = \"templates/registrationUser.html\" \n }\n\n t := template.Must(template.ParseFiles(targettmpl))\n\n if r.Method != http.MethodPost {\n t.Execute(w, nil)\n return\n }\n \n\n details = helpers.User{\n UserId: r.FormValue(\"userid\"),\n FirstName: r.FormValue(\"fname\"),\n LastName: r.FormValue(\"lname\"),\n Email: r.FormValue(\"email\"),\n Password: r.FormValue(\"pwd\"),\n Role: r.FormValue(\"role\"),\n ManagerID : \"unassigned\",\n }\n \n if details.Role ==\"\" {\n details.Role = \"User\" \n }\n \n msg := dbquery.CheckDuplicateEmail(details.Email)\n\n details.Password, _ = HashPassword(details.Password)\n\n if msg == \"\"{\n fmt.Println(\" **** Inserting a record ****\")\n flag = dbquery.RegisterUser(details)\n } \n\n t.Execute(w, Allinfo{EmailId: details.Email, IssueMsg: msg, SuccessFlag: flag} )\n}", "func SignupPage(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"Signup.html\", gin.H{\n\t\t\"registerURL\": \"http://127.0.0.1:8080/user/register\",\n\t})\n}", "func (v *View) Register(g *echo.Group) {\n\tg.Use(wrapResponse, v.wrapSyncStores, v.logVisit, v.extractLocale)\n\tg.GET(\"/ping\", v.ping)\n\tg.GET(\"/health\", v.health)\n\tv.registerUserHandlers(g)\n\tv.registerScopeHandlers(g)\n\tv.registerRoleHandlers(g)\n\tv.registerSessionHandlers(g)\n\tv.registerContestHandlers(g)\n\tv.registerContestStandingsHandlers(g)\n\tv.registerContestMessageHandlers(g)\n\tv.registerProblemHandlers(g)\n\tv.registerSolutionHandlers(g)\n\tv.registerCompilerHandlers(g)\n\tv.registerSettingHandlers(g)\n\tv.registerLocaleHandlers(g)\n\tv.registerFileHandlers(g)\n}", "func (c *ProfileController) GetRegister() mvc.Result {\n\tif c.isProfileLoggedIn() {\n\t\tc.logout()\n\t}\n\n\treturn mvc.View{\n\t\tName: \"profile/register.html\",\n\t\tData: iris.Map{\"Title\": \"Profile Registration\"},\n\t}\n}", "func LoadPage(c *fiber.Ctx, login string, roles []int) error {\n\tquerypack.INFO.Roles = roles\n\tquerypack.INFO.Login = login\n\tquerypack.INFO.LoggedIn = true\n\tc.Method(\"GET\")\n\tc.Path(querypack.INFO.URL)\n\tquerypack.AddCookie(c)\n\treturn c.Next()\n}", "func RegisterWeb(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"register.html\", gin.H{\n\t\t\"title\": \"注册\",\n\t})\n}", "func (p *Pool) Register(name, leftDelim, rightDelim string) error {\n\tename := fmt.Sprintf(\"%s.tmpl.html\", name)\n\tfilename := path.Join(p.contentDir, ename)\n\tnt := &tmpl{name: name, files: singleFile(filename), leftDelim: leftDelim, rightDelim: rightDelim}\n\terr := nt.parse()\n\tif err != nil {\n\t\treturn err\n\t}\n\tp.tmpls[name] = nt\n\treturn nil\n}", "func (p *ProjectList) Register(pages *tview.Pages) {\n\tp.registerPageOnce.Do(func() {\n\t\tpages.AddPage(ProjectListPageName, p.layout, true, false)\n\t})\n}", "func Register(mux *http.ServeMux, token string) {\n\tif token == \"\" {\n\t\treturn\n\t}\n\tmux.HandleFunc(\n\t\tfmt.Sprintf(\"/loaderio-%s.txt\", url.PathEscape(token)),\n\t\tfunc(w http.ResponseWriter, r *http.Request) {\n\t\t\tw.Header().Set(\"Cache-Control\", \"public, max-age=10\")\n\t\t\tfmt.Fprintf(w, \"loaderio-%s\\n\", token)\n\t\t},\n\t)\n}", "func pageRegister(c *page.Component) error {\n\t// Handler for the timezone entry validation.\n\tc.HandleEvent(validateTZ, func(ctx context.Context, p live.Params) (interface{}, error) {\n\t\t// Get the current page component state.\n\t\tstate, _ := c.State.(*PageState)\n\n\t\t// Get the tz coming from the form.\n\t\ttz := p.String(\"tz\")\n\n\t\t// Try to make a new ClockState, this will return an error if the\n\t\t// timezone is not real.\n\t\tif _, err := NewClockState(tz); err != nil {\n\t\t\tstate.ValidationError = fmt.Sprintf(\"Timezone %s does not exist\", tz)\n\t\t\treturn state, nil\n\t\t}\n\n\t\t// If there was no error loading the clock state reset the\n\t\t// validation error.\n\t\tstate.ValidationError = \"\"\n\n\t\treturn state, nil\n\t})\n\n\t// Handler for adding a timezone.\n\tc.HandleEvent(addTime, func(ctx context.Context, p live.Params) (interface{}, error) {\n\t\t// Get the current page component state.\n\t\tstate, _ := c.State.(*PageState)\n\n\t\t// Get the timezone sent from the form input.\n\t\ttz := p.String(\"tz\")\n\t\tif tz == \"\" {\n\t\t\treturn state, nil\n\t\t}\n\n\t\t// Use the page.Init function to create a new clock, register it and mount it.\n\t\tclock, err := page.Init(context.Background(), func() (*page.Component, error) {\n\t\t\t// Each clock requires its own unique stable ID. Events for each clock can then find\n\t\t\t// their own component.\n\t\t\treturn NewClock(fmt.Sprintf(\"clock-%d\", len(state.Timezones)+1), c.Handler, c.Socket, tz)\n\t\t})\n\t\tif err != nil {\n\t\t\treturn state, err\n\t\t}\n\n\t\t// Update the page state with the new clock.\n\t\tstate.Timezones = append(state.Timezones, clock)\n\n\t\t// Return the state to have it persisted.\n\t\treturn state, nil\n\t})\n\n\treturn nil\n}", "func (c *Component) Register() {}", "func (mod *ModuleImpl) Register(method string, path string, handler gin.HandlerFunc, typeM string) {\n\tlog.Println(\"REGISTER - \", path)\n\tr := GetModManager().GetRouter()\n\tr.Handle(method, path, handler)\n\n\tif typeM == \"WEB\" {\n\t\tif len(path) > 1 {\n\t\t\tpath += \"/\"\n\t\t}\n\t\tr.HTMLRender = ginview.Default()\n\t\tr.Use(static.ServeRoot(path+mod.RessourcePath, \"./\"+mod.RessourcePath))\n\t}\n\tGetModManager().SetRouter(r)\n}", "func (h *Handler) Register(e *echo.Echo) {\n\t// Index Handler\n\te.GET(\"/\", h.index)\n\n\t// Groups\n\tapi := e.Group(\"/api\")\n\tadmin := e.Group(\"/admin\")\n\tu := e.Group(\"/utils\")\n\n\t// middlewares\n\tapi.Use(h.fireAuthMWare)\n\n\t// Register the routes\n\th.registerUtils(u)\n\th.registerAPI(api)\n\th.registerAdmin(admin)\n}", "func (r *MultithreadRegistry) Register(page *url.URL) {\n\tr.lock.Lock()\n\tdefer r.lock.Unlock()\n\tr.SimpleRegistry.Register(page)\n}", "func (controller *Auth) ShowRegisterForm() {\n\tcontroller.SetCustomTitle(\"Create a new account\")\n\tcontroller.showForm(\"register\")\n\tcontroller.LoadCaptcha(\"register-form-page\")\n}", "func (j *JobLog) Register(pages *tview.Pages) {\n\tj.registerPageOnce.Do(func() {\n\t\tpages.AddPage(JobLogPageName, j.layout, true, false)\n\t})\n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func (s SwxProxy) Register(_ context.Context, _ *protos.RegistrationRequest) (*protos.RegistrationAnswer, error) {\n\treturn &protos.RegistrationAnswer{}, nil\n}", "func loadPage(w http.ResponseWriter) {\n\tfmt.Fprintln(w, \"<!DOCTYPE html>\")\n\tfmt.Fprintln(w, \"<html>\")\n\tfmt.Fprintln(w, \" <head>\")\n\tfmt.Fprintln(w, \" <title>IRC Services Test</title>\")\n\tfmt.Fprintln(w, \" </head>\")\n\tfmt.Fprintln(w, \" <body>\")\n\tfmt.Fprintln(w, \" <h1 style=\\\"color: black; font-family: verdana; text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" IRC Services Tests Enabled\")\n\tfmt.Fprintln(w, \" </h1>\")\n\tfmt.Fprintln(w, \" <div style=\\\"margin: 0 auto;padding: 0;width: 600px;text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" View page source for the values and names of the associated POST methods.<br><br>\")\n\tfmt.Fprintln(w, \" </div>\")\n\tfmt.Fprintln(w, \" <form action=\\\"\"+NetservicesConfig.IRCservicesURI+\"\\\" method=\\\"post\\\">\")\n\tfmt.Fprintln(w, \" <table style=\\\"margin: 0 auto;padding: 0;width: 450px;text-align: center;\\\">\")\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" &nbsp;&nbsp;Test to check nickname and password authentication.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"checkAuthentication\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Nickname\\\" name=\\\"nick\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"password\\\" placeholder=\\\"Password\\\" name=\\\"password\\\">\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check command to a Network Service.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"command\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Service Name\\\" name=\\\"service\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Command\\\" name=\\\"command\\\">\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to request #channel information.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"channel\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"#channel\\\" name=\\\"channel\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\t\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to request user information.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"user\\\"> \")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"text\\\" placeholder=\\\"Nickname\\\" name=\\\"user\\\">&nbsp;&nbsp;\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\t\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check status of Network Services.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"stats\\\">\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <hr>&nbsp;&nbsp;Test to check for invalid POST Method.\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" <tr>\")\n\tfmt.Fprintln(w, \" <td>\")\n\tfmt.Fprintln(w, \" <input type=\\\"radio\\\" name=\\\"method\\\" value=\\\"notvalid\\\">\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td><td>\")\n\tfmt.Fprintln(w, \" </td>\")\n\tfmt.Fprintln(w, \" </tr>\")\n\n\tfmt.Fprintln(w, \" <th colspan=\\\"3\\\" style=\\\"margin: 0 auto;padding: 0;text-align: left;\\\">\")\n\tfmt.Fprintln(w, \" <br><button type=\\\"Submit\\\" value=\\\"Submit\\\">Submit</button>\")\n\tfmt.Fprintln(w, \" </th>\")\n\tfmt.Fprintln(w, \" </table>\")\n\tfmt.Fprintln(w, \" </form>\")\n\tfmt.Fprintln(w, \" </body>\")\n\tfmt.Fprintln(w, \"</html>\")\n}", "func Register(c *gin.Context) {\n\tr := c.Request\n\tsetUri := strings.TrimPrefix(r.RequestURI, uriPrefixRegister)\n\tbs, err := ioutil.ReadAll(r.Body)\n\tlogx.Debugfln(\" %s -> [%s]\\n\", setUri, bs)\n\tif err != nil {\n\t\terr = errors.Wrapf(err, \" body:%v\", bs)\n\t\tlogx.Errorf(\" getReq err %v bs [%s]\\n\", err, bs)\n\t\tc.AbortWithStatusJSON(401, err)\n\t\treturn\n\t}\n\turiMap[setUri] = bs\n\n\tc.Writer.WriteHeader(200)\n\tc.Writer.WriteString(fmt.Sprintf(\" %s -> [%s]\\n\", setUri, bs))\n\treturn\n}", "func (h Healthz) Register(g *echo.Group) {\n\tg.GET(\"/healthz\", h.Handle)\n}", "func (env *Env) Register(w http.ResponseWriter, r *http.Request) {\n\tdata := &RegisterRequest{}\n\tif err := render.Bind(r, data); err != nil {\n\t\trender.Render(w, r, ErrInvalidRequest(err))\n\t\treturn\n\t}\n\n\tif !emailRegexp.MatchString(data.Email) {\n\t\trender.Render(w, r, ErrRender(errors.New(\"invalid email\")))\n\t\treturn\n\t}\n\n\tpassword := data.User.Password\n\t_, err := env.userRepository.CreateNewUser(r.Context(), data.User)\n\tif err != nil {\n\t\trender.Render(w, r, ErrRender(err))\n\t\treturn\n\t}\n\n\tdata.User.Password = password\n\ttokenString, err := loginLogic(r.Context(), env.userRepository, data.User)\n\tif err != nil {\n\t\trender.Render(w, r, ErrUnauthorized(err))\n\t\treturn\n\t}\n\n\trender.JSON(w, r, tokenString)\n}", "func (r *router) Register(gin *gin.RouterGroup) {\n\tgin.POST(\"/login\", r.loginHandler)\n}", "func (loader *VueLoader) LoadVuePage(w io.Writer, pageTitle string, rootComponent string) {\n\tif loader.Config.CompileEveryRequest {\n\t\tif err := loader.compile(); err != nil {\n\t\t\tlog.Println(err)\n\t\t\treturn\n\t\t}\n\t}\n\terr := loader.layoutTemplate.Execute(w, vuePage{\n\t\tTitle: pageTitle,\n\t\tRootElement: template.HTML(rootComponent),\n\t\tScripts: template.HTML(loader.compiledScripts),\n\t\tStyles: template.HTML(loader.compiledStyles),\n\t\tTemplates: template.HTML(loader.compiledHTML),\n\t})\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func HandlerRegister(responseWriter http.ResponseWriter, request *http.Request) {\n\trequest.ParseForm()\n\n\tif request.Method == STR_GET {\n\t\tServeRegister(responseWriter, STR_EMPTY)\n\t} else {\n\t\temail := request.FormValue(API_KEY_email)\n\t\tpassword := request.FormValue(API_KEY_password)\n\t\tif email == STR_EMPTY || password == STR_EMPTY {\n\t\t\tServeRegister(responseWriter, STR_MSG_register)\n\t\t\treturn\n\t\t}\n\n\t\tisUserExists, isUserAdded, errorUser := DbAddUser(email, password, nil)\n\t\tif errorUser != nil {\n\t\t\tlog.Printf(\"handleRegister, errorUser=%s\", errorUser.Error())\n\t\t}\n\t\tif isUserExists {\n\t\t\tServeRegister(responseWriter, \"Username is already taken.\")\n\t\t} else if isUserAdded == false {\n\t\t\tServeRegister(responseWriter, \"Cannot create user.\")\n\t\t} else {\n\t\t\tServeLogin(responseWriter, STR_EMPTY)\n\t\t}\n\t}\n}", "func showSignUpPage(c echo.Context) error {\n\tstatus, message := getFlashMessages(&c) // gets the flash message and status if there was any\n\tformFields := getFormData(&c, []string{\"username\", \"classification\"})\n\treturn c.Render(http.StatusOK, \"signup.html\", echo.Map{\n\t\t\"status\": status, // pass the status of the flash message\n\t\t\"message\": message, // pass the message\n\t\t\"title\": \"مستخدم جديد\", // the title of the page\n\t\t\"hideNavBar\": true, // boolean to indicate weather or not the NavBar should be displayed\n\t\t\"buttonText\": \"تسجيل مستخدم جديد\", // the action button text the should be displayed to the user\n\t\t\"formAction\": \"/signup\", // the URL that the form should be submitted to\n\t\t\"adminPasswordPlaceholder\": \"كلمه السر الخاصه بالوزير\", // string that should be shown in the admin password input placeholder\n\t\t\"adminPasswordHelp\": \"هذا الحقل خاص بالوزير, ولا يمكن ان تضيف مستخدم جديد الا بالرجوع اليه\", // some helper text for the admin password field\n\t\t\"isSignUp\": true,\n\t\t\"username\": formFields[\"username\"],\n\t\t\"classification\": formFields[\"classification\"],\n\t})\n}", "func Register(g *echo.Group, apps *app.Container, m *middleware.Middleware) {\n\th := &handler{\n\t\tapps: apps,\n\t}\n\n\tg.GET(\"\", h.getAllAcompanhamento, m.Auth.Public)\n\tg.GET(\"/:acompanhamento_id\", h.getAcompanhamentoById, m.Auth.Public)\n\tg.GET(\"/byProcedimento/:procedimento_id\", h.getAcompanhamentoByIdProcedimento, m.Auth.Public)\n\tg.POST(\"/anything\", h.getAcompanhamentoByAnything, m.Auth.Public)\n\tg.POST(\"\", h.setAcompanhamento, m.Auth.Public)\n\tg.PUT(\"\", h.updateAcompanhamento, m.Auth.Public)\n\tg.DELETE(\"/:acompanhamento_id\", h.deleteAcompanhamento, m.Auth.Public)\n}", "func HandleRegister(w http.ResponseWriter, r *http.Request) {\n\terr := r.ParseForm()\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\tbody := RegisterFormValues{}\n\tdecoder := schema.NewDecoder()\n\terr = decoder.Decode(&body, r.PostForm)\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\n\tacc1 := data.Account{}\n\tacc1.Name = body.Name\n\tacc1.Handle = body.Handle\n\tacc1.University = body.University\n\tacc1.Country = body.Country\n\n\th := []byte(acc1.Handle)\n\tre := regexp.MustCompile(`[^[:word:]]`)\n\tm := re.Match(h)\n\tif m {\n\t\tServeHandlePatternNotMatch(w, r)\n\t\treturn\n\t}\n\n\tswitch {\n\tcase len(acc1.Name) < 5:\n\t\tServeNameShort(w, r)\n\t\treturn\n\tcase len(acc1.Handle) < 3:\n\t\tServeHandleShort(w, r)\n\t\treturn\n\tcase len(acc1.University) < 2:\n\t\tServeUniversityShort(w, r)\n\t\treturn\n\tcase len(acc1.Country) < 2:\n\t\tServeCountryShort(w, r)\n\t\treturn\n\t}\n\n\tae, err := data.NewAccountEmail(body.Email)\n\tif err != nil {\n\t\tServeInvalidEmail(w, r)\n\t\treturn\n\t}\n\tacc1.Emails = append(acc1.Emails, ae)\n\n\tap, err := data.NewAccountPassword(body.Password)\n\tif err != nil {\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\tacc1.Password = ap\n\n\tif acc1.IsDup() {\n\t\tServeHandleOREmailDuplicate(w, r)\n\t\treturn\n\t}\n\n\terr = acc1.Put()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tServeInternalServerError(w, r)\n\t\treturn\n\t}\n\n\thttp.Redirect(w, r, \"/tasks\", http.StatusSeeOther)\n}", "func (h *AuthHandler) RenderSignup(w http.ResponseWriter, r *http.Request) {\n\tview := NewView(r)\n\tview.Render(w, \"auth/signup\")\n}", "func registerDetailsHandler(w http.ResponseWriter, r *http.Request){\n\t//RefreshSession(w, r)\n\n\tconst (\n\t\t//kName = \"name\"\n\t\t//kZipCode = \"zipCode\"\n\t\tkBirthYear = \"birthYear\"\n\t\t//kCountry = \"country\"\n\t\tkGender = \"gender\"\n\t\tkParty = \"party\"\n\t\tkRace = \"race\"\n\t\t//kMaritalStatus = \"maritalStatus\"\n\t\tkSchoolCompleted = \"schoolCompleted\"\n\t)\n\n\t// Make sure all fields are skippable, since all this info is optional, and we don't want the login process to frustrate users.\n\tform := makeForm(\n\t\t//nuTextField(kName, \"Enter Full Name\", 50, 0, 100, \"full name\").noSpellCheck(),\n\t\t//nuTextField(kZipCode, \"Enter Zip Code\", 5, 0, 10, \"zip code\"),\n\t\tnuTextField(kBirthYear, \"Enter Birth Year\", 4, 0, 4, \"birth year\"),\n\t\t//nuSelectField(kCountry, \"Select Country\", countries, true, false, true, true, \"Please select your country\"),\n\t\t// nuOtherField(kCountry, \"Enter Country\", 50, 0, 100, \"country\"),\n\t\tnuSelectField(kGender, \"Select Gender\", genders, true, false, true, true, \"Please select your gender\"),\n\t\t nuOtherField(kGender, \"Enter Gender\", 50, 0, 100, \"gender\"),\n\t\tnuSelectField(kParty, \"Select Party\", parties, true, false, true, true, \"Please select your party\"),\n\t\t nuOtherField(kParty, \"Enter Party\", 50, 0, 100, \"party\"),\n\t\tnuSelectField(kRace, \"Select Race\", races, true, false, true, true, \"Please select your race\"),\n\t\t nuOtherField(kRace, \"Enter Race\", 50, 0, 100, \"race\"),\n\t\t//nuSelectField(kMaritalStatus, \"Select Marital Status\", maritalStatuses, true, false, true, true, \"Please select your marital status\"),\n\t\t// nuOtherField(kMaritalStatus, \"Enter Marital Status\", 50, 0, 100, \"marital status\"),\n\t\tnuSelectField(kSchoolCompleted, \"Select Furthest Schooling\", schoolDegrees, true, false, true, true, \"Please select your furthest schooling\"),\n\t\t nuOtherField(kSchoolCompleted, \"Enter Furthest Schooling\", 50, 0, 100, \"furthest schooling\"),\n\t)\n\n\t//form.field(kName).addRegexValidator(`^[\\p{L}]+( [\\p{L}]+)+$`, \"Enter a valid full name (i.e. 'John Doe').\") // No validation since we are letting them skip fields.\n\t//form.field(kZipCode).addRegexValidator(`^\\d{5}(?:[-\\s]\\d{4})?$`, \"Invalid zip code\") // TODO: different countries have different zip code formats.\n\tform.field(kBirthYear).addFnValidator(\n\t\tfunc(input string) (bool, string) {\n\t\t\tyear, err := strconv.Atoi(input)\n\t\t\tif err != nil {\n\t\t\t\treturn true, \"\" // If the input is blank, just let the user skip this.\n\n\t\t\t\t//return false, \"Please enter the year you were born.\"\n\t\t\t}\n\t\t\tcurrentYear := time.Now().Year()\n\t\t\tage := currentYear - year // true age would be either this expression, or this minus 1\n\t\t\tif age < 0 || age > 200 {\n\t\t\t\treturn false, \"Please enter the year you were born.\"\n\t\t\t} else {\n\t\t\t\treturn true, \"\"\n\t\t\t}\n\t\t})\n\n\tuserId := GetSession(w, r)\n\tif userId == -1 { // Secure cookie not found. Either session expired, or someone is hacking.\n\t\t// So go to the register page.\n\t\tpr(\"secure cookie not found\")\n\t\thttp.Redirect(w, r, \"/register\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\tbSkip := r.FormValue(\"skip_button\") != \"\"\n\tprVal(\"bSkip\", bSkip)\n\n\tprVal(\"form\", form)\n\n\tif r.Method == \"POST\" && (\t // If this is handling form POST data and...\n\t\tbSkip || // the user chose SKIP, or\n\t\tform.validateData(r)) { // the data is valid...\n\n\t\tif !bSkip {\n\t\t\tprVal(\"userId\", userId)\n\n\t\t\tpr(\"Updating vote info\")\n\n\t\t\t// Update the user record with registration details.\n\t\t\tDbQuery(\n\t\t\t\t`UPDATE $$User\n\t\t\t\t\tSET (BirthYear, Gender, Party, Race, Schooling,\n\t\t\t\t\t OtherGender, OtherParty, OtherRace, OtherSchoolCompleted)\n\t\t\t\t\t= ($2, $3, $4, $5, $6, $7, $8, $9, $10)\n\t\t\t\t\tWHERE Id = $1::bigint`,\n\t\t\t\tuserId,\n\t\t\t\t//form.val(kName),\n\t\t\t\t//form.val(kCountry),\n\t\t\t\t//form.val(kZipCode),\n\t\t\t\tform.intVal(kBirthYear, 0),\n\t\t\t\tform.val(kGender),\n\t\t\t\tform.val(kParty),\n\t\t\t\tform.val(kRace), // TODO: I think this should multi-select input, with a comma-delimited join of races here.\n\t\t\t\t//form.val(kMaritalStatus),\n\t\t\t\tform.val(kSchoolCompleted),\n\t\t\t\tform.otherVal(kGender),\n\t\t\t\tform.otherVal(kParty),\n\t\t\t\tform.otherVal(kRace),\n\t\t\t\t//form.otherVal(kCountry),\n\t\t\t\t//form.otherVal(kMaritalStatus),\n\t\t\t\tform.otherVal(kSchoolCompleted))\n\t\t} else {\n\t\t\tpr(\"Skipping vote info\")\n\t\t}\n\n\t\tgotoReturnAddress(w, r, userId, kWelcomeToVotezilla)\n\t\treturn\n\t}\n\n\texecuteTemplate(w, kRegisterDetails, makeFormFrameArgs(r, form, \"Voter Info\"))\n}", "func register(r router.Router) {\n\tr.GET(\"/\", home)\n}", "func (ctl *ClubTypesController) register() {\r\n\tClubTypes := ctl.router.Group(\"/ClubTypess\")\r\n\r\n\tClubTypes.GET(\"\", ctl.ListClubTypes)\r\n\r\n\t// CRUD\r\n\tClubTypes.POST(\"\", ctl.CreateClubTypes)\r\n\tClubTypes.GET(\":id\", ctl.GetClubTypes)\r\n\tClubTypes.PUT(\":id\", ctl.UpdateClubTypes)\r\n\tClubTypes.DELETE(\":id\", ctl.DeleteClubTypes)\r\n}", "func (router Cab) Register(group *echo.Group) {\n\tgroup.POST(\"/near-by-cab\", router.nearBycab)\n\tgroup.POST(\"/book-cab\", router.bookCab)\n\tgroup.POST(\"/booking-status\", router.updatebookingStatus)\n\tgroup.GET(\"/booking-history\", router.historyOfBooking)\n\n}", "func (c *Config) Register() string {\n\treturn c.Get(\"register\")\n}", "func (u *UserHandler) Register(parentGroup *gin.RouterGroup) error {\n\tuserGroup := parentGroup.Group(\"users\")\n\tauthenticatedUserGroup := parentGroup.Group(\"users\")\n\tauthenticatedUserGroup.Use(u.AuthMiddleware.HandleAuth())\n\t{\n\t\tuserGroup.POST(\"\", u.RegisterUser)\n\t\tuserGroup.GET(\"/:userid\", u.GetUser)\n\t\tauthenticatedUserGroup.GET(\"\", u.GetAllUsers)\n\t}\n\treturn nil\n}", "func Register(w http.ResponseWriter, r *http.Request, opt router.UrlOptions, sm session.ISessionManager, s store.IStore) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tparams := make(map[string]interface{})\n\t\tutils.RenderTemplate(w, r, \"register\", sm, s, params)\n\n\tcase \"POST\":\n\t\tvar newUser *user.User\n\n\t\tdfc := s.GetDataSource(\"persistence\")\n\n\t\tp, ok := dfc.(persistence.IPersistance)\n\t\tif !ok {\n\t\t\tutl.Log(\"Invalid store\")\n\t\t\treturn\n\t\t}\n\n\t\tc := p.GetCollection(\"users\")\n\n\t\tnewUser = &user.User{\n\t\t\tID: bson.NewObjectId(),\n\t\t\tUsername: r.PostFormValue(\"username\"),\n\t\t\tPassword: utils.HashString(r.PostFormValue(\"password\")),\n\t\t}\n\n\t\terr := c.Insert(newUser)\n\t\tif err != nil {\n\t\t\tutl.Log(err)\n\t\t}\n\n\t\tutl.Log(\"Registered user\", newUser)\n\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\tdefault:\n\t}\n}", "func Register(name string, builder WebHandlerBuilder) {\n\thmu.Lock()\n\thandlers[name] = builder\n\thmu.Unlock()\n}", "func (a *App) Register(w http.ResponseWriter, r *http.Request) {\n\tvar registerInfo uvm.UserRegisterVM\n\n\tdecoder := json.NewDecoder(r.Body)\n\tvar err error\n\n\tif err = decoder.Decode(&registerInfo); err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid request body\")\n\t\treturn\n\t}\n\n\t//TODO validate user data\n\n\tregisterInfo.Password, err = utils.HashPassword(registerInfo.Password)\n\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, \"Could not register user\")\n\t\treturn\n\t}\n\n\tvar user models.User\n\n\tuser, err = a.UserStore.AddUser(registerInfo)\n\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t}\n\n\ttoken := auth.GenerateToken(a.APISecret, user)\n\n\tresult := models.UserResult{\n\t\tUsername: user.Username,\n\t\tPicture: user.Picture,\n\t\tRole: user.Role.Name,\n\t\tToken: token,\n\t}\n\n\trespondWithJSON(w, http.StatusOK, result)\n}", "func (m *Monocular) Register(echoContext echo.Context) error {\n\tlog.Debug(\"Helm Repository Register...\")\n\treturn m.portalProxy.RegisterEndpoint(echoContext, m.Info)\n}", "func (u *UserView) Register(c *gin.Context) {\n\n\t// Obtain the POSTed username and password values\n\tusername := c.PostForm(\"username\")\n\tpassword := c.PostForm(\"password\")\n\n\tif _, err := models.RegisterNewUser(username, password); err == nil {\n\t\t// If the user is created, set the token in a cookie and log the user in\n\t\ttoken := generateSessionToken()\n\t\tc.SetCookie(\"token\", token, 3600, \"\", \"\", false, true)\n\t\tc.Set(\"is_logged_in\", true)\n\n\t\trender(c,\n\t\t\tgin.H{\"title\": \"Successful registration & Login\"},\n\t\t\t\"login-successful.html\")\n\n\t} else {\n\t\tc.HTML(http.StatusBadRequest,\n\t\t\t\"register.html\",\n\t\t\tgin.H{\"ErrorTitle\": \"Registration Failed\",\n\t\t\t\t\"ErrorMessage\": err.Error()})\n\t}\n}", "func (tqsc *Controller) Register() {\n}", "func Register(settings map[string]string) {\n\n\tSetConfigDir(settings[\"config_dir\"])\n\n\tbeego.AddFuncMap(\"pageStart\", PageStart)\n\tbeego.AddFuncMap(\"placefolder\", Placefolder)\n\tbeego.AddFuncMap(\"require\", Require)\n\tbeego.AddFuncMap(\"widget\", Widget)\n\tbeego.AddFuncMap(\"pageEnd\", PageEnd)\n}", "func (rs *RegistryService) Register(ctx context.Context, in *proto.RegisterType) (*proto.EmptyResponse, error) {\n\trs.mu.RLock()\n\tdefer rs.mu.RUnlock()\n\n\trs.hosts[in.GetName()] = in.GetHost()\n\n\treturn &proto.EmptyResponse{}, nil\n}", "func Register() int32 {\n\tresp, err := http.Get(REGISTER_SERVER)\n\tif err != nil {\n\t\tfmt.Printf(\"%s\", err)\n\t\tos.Exit(1)\n\t} else {\n\t\tdefer resp.Body.Close()\n\t\tbodyBytes, err2 := ioutil.ReadAll(resp.Body)\n\t\tif err2 != nil {\n\t\t\tfmt.Printf(\"%s\", err2)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tcontent, _ := strconv.ParseInt(string(bodyBytes), 10, 64)\n\t\treturn int32(content)\n\t}\n\treturn 0\n}", "func (controller *Controller) Register(v1 *echo.Group) {\n\temployees := v1.Group(\"/employee\")\n\temployees.POST(\"\", controller.CreateEmployee)\n\temployees.GET(\"\", controller.ListEmployees)\n\temployees.GET(\"/:id\", controller.GetEmployee)\n\temployees.PUT(\"/:id\", controller.UpdateEmployee)\n}", "func RouterRegister() *gin.Engine {\n\tfmt.Println(\"Linux Dashboard\")\n\trouter := gin.Default()\n\n\trouter.LoadHTMLFiles(\"linuxdashboard/godashboard/index.html\")\n\n\trouter.GET(\"/\", IndexAPI)\n\trouter.GET(\"/proc/stat\", ProcStat)\n\trouter.GET(\"/proc/loadavg\", ProcLoadavg)\n\trouter.GET(\"/proc/meminfo\", ProcMeminfo)\n\trouter.GET(\"/proc/tcp\", ProcTCP)\n\trouter.GET(\"/proc/udp\", ProcUDP)\n\trouter.GET(\"/proc/netdev\", ProcNetDev)\n\n\treturn router\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\n\tif r.Method == http.MethodGet {\n\t\tfmt.Println(\"http:GET:Register\")\n\t\tsession, _ := auth.GetCookieStore().Get(r, auth.GetSessionCookie())\n\t\tif e := session.Values[auth.USER_COOKIE_AUTH]; e != nil && e.(bool) {\n\t\t\thttp.Redirect(w, r, \"/login\", http.StatusFound)\n\t\t\treturn\n\t\t}\n\n\t}\n\n\tif r.Method == http.MethodPost {\n\t\tm := make(map[string]interface{})\n\t\tfmt.Println(\"http:POST:Register\")\n\t\te := r.FormValue(query.USER_EMAIL_ADDRESS)\n\n\t\tex, _, err := model.Check_User_By_Email(e, \"\")\n\t\tif ex || err != nil {\n\t\t\tm[query.SUCCESS] = false\n\t\t\tb, _ := json.MarshalIndent(m, \"\", \" \")\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.Write(b)\n\t\t\treturn\n\t\t}\n\n\t\tu, err := model.CreateUserEP(e, \"\")\n\t\tu.SendWelcomeEmail()\n\n\t\tif err != nil {\n\t\t\tprintln(err)\n\t\t}\n\t\tu.StoreUser()\n\n\t\tm[query.SUCCESS] = true\n\t\tb, _ := json.MarshalIndent(m, \"\", \" \")\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(b)\n\t\treturn\n\t}\n}", "func RegisterHandler(w http.ResponseWriter, r *http.Request, serv *AppServer) {\n\tswitch r.Method {\n\tcase http.MethodGet:\n\t\tsession, err := r.Cookie(\"UserID\")\n\t\ttempID, err := strconv.Atoi(session.Value)\n\t\tif err != nil || tempID == -1 {\n\t\t\tRenderFileTemplate(w, \"register\")\n\t\t} else {\n\t\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t\t}\n\tcase http.MethodPost:\n\t\tr.ParseForm()\n\n\t\tinvalid := false\n\t\tif r.PostFormValue(\"username\") == \"\" || r.PostFormValue(\"password\") == \"\" {\n\t\t\tinvalid = true\n\t\t} else if serv.UserSearch(\"username\") != -1 {\n\t\t\tinvalid = true\n\t\t}\n\n\t\tif invalid {\n\t\t\thttp.Redirect(w, r, \"/registerfail\", http.StatusTemporaryRedirect)\n\t\t} else {\n\t\t\tserv.AddUser(\n\t\t\t\tr.PostFormValue(\"username\"),\n\t\t\t\tr.PostFormValue(\"password\"),\n\t\t\t\tr.PostFormValue(\"color\"),\n\t\t\t)\n\t\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t\t}\n\t}\n}", "func (h *Headscale) RegisterWebAPI(c *gin.Context) {\n\tmKeyStr := c.Query(\"key\")\n\tif mKeyStr == \"\" {\n\t\tc.String(http.StatusBadRequest, \"Wrong params\")\n\t\treturn\n\t}\n\n\t// spew.Dump(c.Params)\n\n\tc.Data(http.StatusOK, \"text/html; charset=utf-8\", []byte(fmt.Sprintf(`\n\t<html>\n\t<body>\n\t<h1>headscale</h1>\n\t<p>\n\t\tRun the command below in the headscale server to add this machine to your network:\n\t</p>\n\n\t<p>\n\t\t<code>\n\t\t\t<b>headscale -n NAMESPACE nodes register %s</b>\n\t\t</code>\n\t</p>\n\n\t</body>\n\t</html>\n\n\t`, mKeyStr)))\n}", "func LoadPage() {\n\tb, _ := ioutil.ReadFile(\"./web/index.html\")\n\tPage = string(b)\n}", "func WelcomePage(w http.ResponseWriter, r *http.Request) { \n tmpl, err := template.ParseFiles(\"templates/welcomePage.html\")\n if err != nil {\n fmt.Println(err)\n }\n\n var welcomeHomePage string\n welcomeHomePage = \"Login & Registration Forms\"\n \n tmpl.Execute(w, Response{WelcomeMessage: welcomeHomePage})\n}", "func (ctl *ResearchController) register() {\n\tresearches := ctl.router.Group(\"/researches\")\n\tresearches.GET(\"\", ctl.ListResearch)\n\n searchresearchs := ctl.router.Group(\"/searchresearchs\")\n\tsearchresearchs.GET(\"\",ctl.GetSearchResearch)\n\n\t// CRUD\n\tresearches.POST(\"\", ctl.CreateResearch)\n\tresearches.GET(\":id\", ctl.GetResearch)\n\tresearches.PUT(\":id\", ctl.UpdateResearch)\n\tresearches.DELETE(\":id\", ctl.DeleteResearch)\n}", "func Register(r *mux.Router, register func(http.HandlerFunc) http.HandlerFunc) (err error) {\n\n\turls, err := newURLHandler()\n\tr.Methods(\"GET\").Subrouter().HandleFunc(\"/urls\", register(urls.list()))\n\tr.Methods(\"GET\").Subrouter().HandleFunc(\"/urls/{id:[a-zA-Z0-9]+}\", register(urls.item()))\n\tr.Methods(\"POST\").Subrouter().HandleFunc(\"/urls\", register(urls.add()))\n\n\treturn err\n}", "func (h *auth) Register(c echo.Context) error {\n\t// Filter params\n\tvar params service.RegisterParams\n\tif err := c.Bind(&params); err != nil {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"Could not get user's params.\"))\n\t}\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\tif params.Email == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No email provided.\"))\n\t}\n\tif params.RegistrationPassword == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No password provided.\"))\n\t}\n\tif params.PasswordNonce == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No nonce provided.\"))\n\t}\n\tif libsf.VersionLesser(libsf.APIVersion20200115, params.APIVersion) && params.PasswordCost <= 0 {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"No password cost provided.\"))\n\t}\n\n\tservice := service.NewUser(h.db, h.sessions, params.APIVersion)\n\tregister, err := service.Register(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn c.JSON(http.StatusOK, register)\n}", "func (ctl *SectionController) register() {\n\tsections := ctl.router.Group(\"/sections\")\n\n\tsections.GET(\"\", ctl.ListSection)\n\n\t// CRUD\n\tsections.POST(\"\", ctl.CreateSection)\n\tsections.GET(\":id\", ctl.GetSection)\n\tsections.PUT(\":id\", ctl.UpdateSection)\n\tsections.DELETE(\":id\", ctl.DeleteSection)\n}", "func UsersRegisterGet(c buffalo.Context) error {\n\t// Make user available inside the html template\n\tc.Set(\"user\", &models.User{})\n\treturn c.Render(200, r.HTML(\"users/register.html\"))\n}", "func renderPage(logger *Logger, config *Config, loadedPlugins map[string]pluginWithMeta, page *Page) {\n\tfor name, plugin := range loadedPlugins {\n\t\tif plugin.TitleHook != nil {\n\t\t\tpage.logger = logger.PluginPrefix(name)\n\t\t\tpage.title = plugin.TitleHook(plugin.meta, page)\n\t\t}\n\t}\n\tpage.logger = logger\n\n\tdata := make(map[string]interface{})\n\tdata[\"Page\"] = page\n\tfuncs := make(map[string]interface{})\n\n\tfor name, plugin := range loadedPlugins {\n\t\tpage.logger = logger.PluginPrefix(name)\n\t\tif plugin.TemplatingHook != nil {\n\t\t\tpluginData, pluginFuncs := plugin.TemplatingHook(plugin.meta, page)\n\t\t\tdata[name] = pluginData\n\t\t\tfor k, v := range pluginFuncs {\n\t\t\t\tfuncs[name+\"_\"+k] = v\n\t\t\t}\n\t\t}\n\t}\n\tpage.logger = logger\n\n\tvar head = \"\"\n\tvar before = \"\"\n\tvar after = \"\"\n\n\tfor name, plugin := range loadedPlugins {\n\t\tpage.logger = logger.PluginPrefix(name)\n\t\tif plugin.RenderHook != nil {\n\t\t\tpluginHead, pluginBefore, pluginAfter := plugin.RenderHook(plugin.meta, page)\n\t\t\thead += pluginHead\n\t\t\tbefore += pluginBefore\n\t\t\tafter += pluginAfter\n\t\t}\n\t}\n\tpage.logger = logger\n\n\tif t == nil {\n\t\tlogger.Debug(\"base template not initalized\")\n\t\topenTemplate(logger)\n\t}\n\n\textensions := parser.CommonExtensions | parser.AutoHeadingIDs\n\tparser := parser.NewWithExtensions(extensions)\n\n\thtmlFlags := html.CommonFlags\n\topts := html.RendererOptions{Flags: htmlFlags}\n\trenderer := html.NewRenderer(opts)\n\n\tt, err := t.Clone()\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to clone base template:\", err.Error())\n\t}\n\n\t_, err = t.New(\"__head__\").Parse(head)\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to parse __head__ template:\", err.Error())\n\t}\n\t_, err = t.New(\"__beforeContent__\").Parse(before)\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to parse __beforeContent__ template:\", err.Error())\n\t}\n\t_, err = t.New(\"__content__\").Parse(string(markdown.ToHTML([]byte(page.Content()), parser, renderer)))\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to parse __content__ template:\", err.Error())\n\t}\n\t_, err = t.New(\"__afterContent__\").Parse(after)\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to parse __afterContent__ template:\", err.Error())\n\t}\n\n\tpath := filepath.Join(config.OutputFolder, page.Slug(), \"index.html\")\n\terr = os.MkdirAll(filepath.Dir(path), os.ModeDir)\n\tif err != nil {\n\t\tlogger.Fatal(\"could not create directory structure for output file:\", err.Error())\n\t}\n\n\tout, err := os.Create(path)\n\tif err != nil {\n\t\tlogger.Fatal(\"could not open the output file:\", err.Error())\n\t}\n\tdefer out.Close()\n\n\terr = t.Funcs(funcs).Execute(out, data)\n\tif err != nil {\n\t\tlogger.Fatal(\"failed to execute template:\", err.Error())\n\t}\n}", "func getRegistrationHandler(w http.ResponseWriter, r *http.Request, _ map[string]string) {\n\tif database.RetrieveUsersCount() == 0 {\n\t\thttp.ServeFile(w, r, filepath.Join(filenames.AdminFilepath, \"registration.html\"))\n\t\treturn\n\t}\n\thttp.Redirect(w, r, \"/admin\", http.StatusFound)\n\treturn\n}", "func Register(name string, port int) (err error) {\n\tr := RegistryRequest{name, port}\n\n\tbyt, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresp, err := http.Post(\"http://127.0.0.1\" + _LOCAL_PORT, \"text/json\", bytes.NewBuffer(byt))\n\tif err != nil {\n\t\treturn\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\terr = fmt.Errorf(\"non 200 response %d: %s\", resp.StatusCode, resp.Status)\n\t\treturn\n\t}\n\n\tbyt, err = ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func Register() {\n\tglobalLock.Lock()\n\tdefer globalLock.Unlock()\n\tregister()\n}", "func (sh *SimHandlerState) Register(r *mango.Router) {\n\tr.Get(\"/api/simulation/{sim_id}\", sh.Get)\n\tr.Put(\"/api/simulation/{sim_id}\", sh.Put)\n\tr.Get(\"/api/simulation/{sim_id}/{stepResultsRunGenerate}\", sh.GetStepsOrResults)\n\tr.Post(\"/api/simulation/{sim_id}/{stepResultsRunGenerate}\", sh.RunGenerateParseNetwork)\n\tr.Delete(\"/api/simulation/{sim_id}/step/{step_id}\", sh.DeleteStep)\n}", "func Register(r *route.Router, reloadCh chan<- struct{}) {\n\tihf := prometheus.InstrumentHandlerFunc\n\n\tr.Get(\"/metrics\", prometheus.Handler().ServeHTTP)\n\n\tr.Get(\"/\", ihf(\"index\", func(w http.ResponseWriter, req *http.Request) {\n\t\tserveAsset(w, req, \"ui/app/index.html\")\n\t}))\n\n\tr.Get(\"/script.js\", ihf(\"app\", func(w http.ResponseWriter, req *http.Request) {\n\t\tserveAsset(w, req, \"ui/app/script.js\")\n\t}))\n\n\tr.Get(\"/favicon.ico\", ihf(\"app\", func(w http.ResponseWriter, req *http.Request) {\n\t\tserveAsset(w, req, \"ui/app/favicon.ico\")\n\t}))\n\n\tr.Get(\"/lib/*filepath\", ihf(\"lib_files\",\n\t\tfunc(w http.ResponseWriter, req *http.Request) {\n\t\t\tfp := route.Param(req.Context(), \"filepath\")\n\t\t\tserveAsset(w, req, filepath.Join(\"ui/lib\", fp))\n\t\t},\n\t))\n\n\t/*\tr.Post(\"/-/reload\", func(w http.ResponseWriter, req *http.Request) {\n\t\tw.Write([]byte(\"Reloading configuration file...\"))\n\t\treloadCh <- struct{}{}\n\t})*/\n\tr.Post(\"/-/reload\", func(w http.ResponseWriter, r *http.Request) {\n\t\tbcmCreReload(w, r, reloadCh)\n\t})\n\n\tr.Del(\"/-/reload\", func(w http.ResponseWriter, r *http.Request) {\n\t\tbcmDelReload(w, r, reloadCh)\n\t})\n\n\tr.Put(\"/-/reload\", func(w http.ResponseWriter, r *http.Request) {\n\t\tbcmUpdReload(w, r, reloadCh)\n\t})\n\tr.Get(\"/debug/*subpath\", http.DefaultServeMux.ServeHTTP)\n\tr.Post(\"/debug/*subpath\", http.DefaultServeMux.ServeHTTP)\n\n\t//for message with wangke`s API\n\tr.Post(\"/mobile\", func(w http.ResponseWriter, r *http.Request) {\n\t\tsendAlertWithMsg(w, r)\n\t})\n}", "func (ctl *EquipmentrentalController) register() {\n\tEqrentals := ctl.router.Group(\"/equipmentrentals\")\n\tEqrentalss := ctl.router.Group(\"/equipmentrentalbymembers\")\n\tEqrentalss.GET(\"\", ctl.GetEquipmentrentalbyMember)\n\tEqrentals.GET(\"\", ctl.ListEquipmentrental)\n\n\t// CRUD\n\tEqrentals.POST(\"\", ctl.CreateEquipmentrental)\n\tEqrentals.GET(\":id\", ctl.GetEquipmentrental)\n}", "func (ctl *UnitOfMedicineController) register() {\n\tUnitOfMedicine := ctl.router.Group(\"/UnitOfMedicine\")\n\n\tUnitOfMedicine.GET(\"\", ctl.ListUnitOfMedicine)\n\n\t// CRUD\n\tUnitOfMedicine.POST(\"\", ctl.CreateUnitOfMedicine)\n\tUnitOfMedicine.GET(\":id\", ctl.GetUnitOfMedicine)\n\tUnitOfMedicine.PUT(\":id\", ctl.UpdateUnitOfMedicine)\n\tUnitOfMedicine.DELETE(\":id\", ctl.DeleteUnitOfMedicine)\n}", "func renderPage(w io.Writer, name string, pageData PageData) {\n\trenderTemplate(w, name, pageData)\n}", "func (mock *MockUserCredentialsAPI) GETRegistrationPageHandler(route string) http.Handler {\n\treturn nil\n}", "func Register(g *gin.Context) {\n\t// init visitor User struct to validate request\n\tuser := new(models.User)\n\t/**\n\t* get request and parse it to validation\n\t* if there any error will return with message\n\t */\n\terr := validations.RegisterValidate(g, user)\n\t/***\n\t* return response if there an error if true you\n\t* this mean you have errors so we will return and bind data\n\t */\n\tif helpers.ReturnNotValidRequest(err, g) {\n\t\treturn\n\t}\n\t/**\n\t* check if this email exists database\n\t* if this email found will return\n\t */\n\tconfig.Db.Find(&user, \"email = ? \", user.Email)\n\tif user.ID != 0 {\n\t\thelpers.ReturnResponseWithMessageAndStatus(g, 400, \"this email is exist!\", false)\n\t\treturn\n\t}\n\t//set type 2\n\tuser.Type = 2\n\tuser.Password, _ = helpers.HashPassword(user.Password)\n\t// create new user based on register struct\n\tconfig.Db.Create(&user)\n\t// now user is login we can return his info\n\thelpers.OkResponse(g, \"Thank you for register in our system you can login now!\", user)\n}", "func Render(c http.ResponseWriter, r *http.Request, title, name string, data interface{}) {\n\tif WouldUseJson(r) {\n\t\tenc := json.NewEncoder(c)\n\t\terr := enc.Encode(data)\n\t\tif err != nil {\n\t\t\tError500(c, r, err)\n\t\t}\n\t\treturn\n\t}\n\tvar p PageInfo\n\tif title == \"\" {\n\t\ttitle = strings.ToTitle(moduleName)\n\t}\n\t// \tif moduleName == \"unknown\" {\n\t// \t\tlog.Println(\"Warning: Attempting to render a template without moduleName being set! Call SetModuleName during the initialization of your module in order to correct this (in main()).\")\n\t// \t}\n\tp.Title = title\n\t// Removed the modulename because it's not needed in the new framework. However, this will break things in the old framework. *sigh*...\n\tp.Name = /*moduleName + \"/\" + */ name\n\tp.Request = r\n\tperms, err := perms.Get(r)\n\tif err != nil {\n\t\tlog.Printf(\"Warning: Error getting page permissions for %s: %s\", r.URL, err)\n\t}\n\tp.Perms = perms\n\tp.Object = data\n\n\terr = Execute(c, &p)\n\tif err != nil {\n\t\tc.WriteHeader(500)\n\t\tfmt.Fprintln(c, \"FATAL ERROR:\", err)\n\t\treturn\n\t}\n}", "func (ctl *ClubController) register() {\n\tclub := ctl.router.Group(\"/club\")\n\n\tclub.GET(\"\", ctl.ListClub)\n\n\t// CRUD\n\tclub.POST(\"\", ctl.CreateClub)\n\tclub.GET(\":id\", ctl.GetClub)\n\tclub.PUT(\":id\", ctl.UpdateClub)\n\tclub.DELETE(\":id\", ctl.DeleteClub)\n}", "func Register(mux *http.ServeMux) {\n\tif mux == nil {\n\t\tmux = http.DefaultServeMux\n\t}\n\tmux.HandleFunc(\"/pastehere/\", Home)\n\tmux.HandleFunc(\"/pastehere/paste\", Paste)\n\tmux.HandleFunc(\"/pastehere/view/\", View)\n}", "func (a Auth) registerHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := r.URL.Query()\n\tif len(vars[\"username\"]) != 1 || len(vars[\"password\"]) != 1 || len(vars[\"email\"]) != 1 {\n\t\tlog.Printf(\"Bad registration!\\n\")\n\t\tresponseError(w)\n\t\treturn\n\t}\n\tusername := vars[\"username\"][0]\n\tpassword := vars[\"password\"][0]\n\temail := vars[\"email\"][0]\n\tif username == \"\" || password == \"\" || email == \"\" {\n\t\tlog.Printf(\"Bad registration!\\n\")\n\t\tresponseError(w)\n\t\treturn\n\t}\n\terr := a.RegisterNewUser(username, password, email)\n\tif err != nil {\n\t\tlog.Printf(\"%+v\\n\", err)\n\t\tresponseError(w)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, \"{'ok':'true'}\")\n}", "func (api *API) Register(r *route.Router) {\n\twrap := func(f apiFunc) http.HandlerFunc {\n\t\thf := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\tsetupHeader(w)\n\t\t\tresult := setUnavailStatusOnTSDBNotReady(f(r))\n\t\t\tif result.err != nil {\n\t\t\t\tapi.respondError(w, result.err, result.data)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif result.data != nil {\n\t\t\t\tapi.respond(w, result.data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tw.WriteHeader(http.StatusNoContent)\n\t\t})\n\t\treturn httputil.CompressionHandler{\n\t\t\tHandler: hf,\n\t\t}.ServeHTTP\n\t}\n\n\tr.Post(\"/query\", wrap(api.query))\n}", "func Register(cfg DrvCfg) {\n\tSetCfg(cfg)\n}", "func RegisterGetHandler(ctx *enliven.Context) {\n\tctx.Strings[\"FormErrors\"] = \"[]\"\n\tctx.ExecuteBaseTemplate(\"user_register\")\n}", "func Register(shutdown chan os.Signal, log *log.Logger) http.Handler {\n\tapp := web.NewApp(shutdown, middleware.Logger(log))\n\n\tapp.MountHandler(http.MethodGet, \"/\", home)\n\tapp.MountHandler(http.MethodPost, \"/v1/locate\", locate)\n\n\treturn app\n}", "func loadPage(pn string, r *http.Request) (*Page, error) {\n\tdata := &Page{\n\t\tPageName: pn,\n\t}\n\n\t/* Get user name for filling in template too */\n\tsesh, _ := store.Get(r, \"loginSession\")\n\tuname, ok := sesh.Values[\"username\"].(string)\n\tif !ok {\n\t\treturn nil, &ClientSafeError{Msg: \"invalid username\"}\n\t}\n\tdata.Username = uname\n\t/* get user's role */\n\trole, err := getRoleNum(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch role {\n\tcase FACILITATOR:\n\t\tdata.Role = \"Facilitator\"\n\t\tdata.Messages, err = getNotifications(data.Username)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase TEACHER:\n\t\tdata.Role = \"Teacher\"\n\tcase ADMIN:\n\t\tdata.Role = \"Admin\"\n\tdefault:\n\t\treturn nil, &ClientSafeError{Msg: \"insufficient access rights\"}\n\t}\n\n\treturn data, nil\n}", "func showLoginPage(c *gin.Context) {\n\trender(c, gin.H{\n\t\t\"title\": \"Login\",\n\t\t\"ErrorMessage\": \"\",\n\t}, \"login.html\")\n}", "func Register(ctx echo.Context) error {\n\treq := new(registerRequest)\n\tif err := ctx.Bind(req); err != nil {\n\t\treturn err\n\t}\n\tuser := User{Username: req.Username, Password: md5Pwd(req.Password), Type: req.Type}\n\terr := db.Model(&User{}).First(&user, &User{Username: req.Username}).Error\n\tif err == gorm.ErrRecordNotFound {\n\t\te := db.Create(&user).Error\n\t\tif e == nil {\n\t\t\tctx.SetCookie(&http.Cookie{Name: cookieKey, Value: user.Base.ID.String()})\n\t\t\treturn ctx.JSON(http.StatusOK, &response{\n\t\t\t\tCode: 0,\n\t\t\t\tMsg: \"\",\n\t\t\t\tData: registerResponse{\n\t\t\t\t\tUsername: user.Username,\n\t\t\t\t\tType: user.Type,\n\t\t\t\t\tID: user.Base.ID,\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\treturn e\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tres := &response{\n\t\tCode: 1,\n\t\tMsg: \"User name has been taken\",\n\t}\n\treturn ctx.JSON(http.StatusBadRequest, res)\n}", "func registerModules(){\n\tweb.Register()\t\t//http server.\n\tdevicetwin.Register()\t\n\teventhub.Register()\t\n}", "func (ctl *LevelOfDangerousController) register() {\n\tLevelOfDangerous := ctl.router.Group(\"/LevelOfDangerous\")\n\n\tLevelOfDangerous.GET(\"\", ctl.ListLevelOfDangerous)\n\n\t// CRUD\n\tLevelOfDangerous.POST(\"\", ctl.CreateLevelOfDangerous)\n\tLevelOfDangerous.GET(\":id\", ctl.GetLevelOfDangerous)\n\tLevelOfDangerous.PUT(\":id\", ctl.UpdateLevelOfDangerous)\n\tLevelOfDangerous.DELETE(\":id\", ctl.DeleteLevelOfDangerous)\n}", "func RegisterRoute(res http.ResponseWriter, req *http.Request) {\n if req.Method == \"GET\" {\n res.Write([]byte(`\n <html>\n <head>\n <title> Register </title>\n </head>\n <body>\n <h1> Register </h1>\n <form action = \"/register\" method = \"post\">\n Username:<br>\n <input type=\"text\" name=\"Username\"><br>\n Password:<br>\n <input type = \"password\" name = \"Password\">\n <input type = \"submit\" value = \"register\">\n </form>\n </body>\n </html>\n `))\n } else {\n req.ParseForm()\n username := req.FormValue(\"Username\")\n password := req.FormValue(\"Password\")\n\n salt := make([]byte, SaltLength)\n rand.Read(salt)\n saltedhash := pbkdf2.Key([]byte(password), salt, KeyHashIterations, KeyHashLength, KeyHashAlgo)\n err := AddUsers(username, salt, saltedhash)\n\n if err != nil {\n res.Write([]byte(err.Error()))\n }\n\n Redirect(\"/login\", res)\n }\n}", "func (d *DatabaseAPI) Register(route gin.IRoutes) {\n\troute.GET(DatabasePath, d.GetByName)\n}", "func (r *Router) Register(path string, v view.RestViewer, middleware ...gin.HandlerFunc) {\n\n\t// initialize Router\n\tr.prepare()\n\n\t// private middleware use\n\thandlers := append(middleware, http.AsHandlerFunc(v, r.restViewHandlerFunc))\n\n\t// Get formatPath\n\t// Call SetAutoPrefix to change value\n\tpath = r.formatPath(path)\n\n\t// register done\n\tr.group.Any(path, handlers...)\n}" ]
[ "0.71808773", "0.6795434", "0.66623235", "0.6616067", "0.64512473", "0.61154866", "0.5981059", "0.5910356", "0.5888225", "0.58870286", "0.5841088", "0.5841088", "0.5793564", "0.57613933", "0.5706791", "0.5694199", "0.5658731", "0.55998075", "0.55557865", "0.551402", "0.5506323", "0.5488549", "0.54250747", "0.53806984", "0.5335918", "0.53185266", "0.5318278", "0.5317155", "0.53095984", "0.528688", "0.528271", "0.5280909", "0.5263467", "0.5252221", "0.52474105", "0.52416915", "0.51966965", "0.5187096", "0.5186081", "0.51675946", "0.51497036", "0.51082313", "0.5100057", "0.5088681", "0.50877106", "0.50845605", "0.5081608", "0.5076489", "0.506499", "0.50526655", "0.5031874", "0.50272894", "0.50253564", "0.5021021", "0.50163233", "0.50084525", "0.5004999", "0.5002973", "0.5002902", "0.5000042", "0.49942496", "0.49922374", "0.49858537", "0.4975691", "0.49641895", "0.49632528", "0.4956705", "0.49556372", "0.4954303", "0.49451265", "0.4938247", "0.49335337", "0.4930422", "0.49302474", "0.49266434", "0.49185205", "0.4915827", "0.49132913", "0.49001893", "0.4899488", "0.4899379", "0.4896724", "0.4888524", "0.488535", "0.4883001", "0.48780453", "0.48762676", "0.4875408", "0.4875318", "0.48734662", "0.4872513", "0.48705792", "0.48646024", "0.48623458", "0.48583072", "0.4856679", "0.4852727", "0.48509622", "0.4848772", "0.48468357" ]
0.8103135
0
LoadHomePage Render home page
func LoadHomePage(w http.ResponseWriter, r *http.Request) { url := fmt.Sprintf("%s/publications", config.APIURL) response, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil) if err != nil { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()}) return } defer response.Body.Close() if response.StatusCode >= 400 { responses.TreatStatusCode(w, response) return } var publications []models.Publication if err := json.NewDecoder(response.Body).Decode(&publications); err != nil { responses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()}) return } cookie, _ := cookies.Read(r) userID, _ := strconv.ParseUint(cookie["id"], 10, 64) utils.RunTemplate(w, "home.html", struct { Publications []models.Publication UserID uint64 }{ Publications: publications, UserID: userID, }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func homeHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(\"Home\")\n\tif err != nil {\n\t\tlog.Println(\"homeHandler() error: \", err)\n\t\treturn\n\t}\n\trenderTemplate(w, \"home\", p)\n}", "func (hc Home) Home(w http.ResponseWriter, r *http.Request) {\n\tdata := viewModels.NewHome()\n\thc.TemplateManager.Render(\"home\", w, data)\n}", "func (m *Repository) Home(w http.ResponseWriter, r *http.Request) {\n\trender2.RenderTemplate(w, \"home.page.tmpl\", &models2.TemplateData{}, r)\n}", "func (app *App) Home(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\tapp.NotFound(w)\n\t\treturn\n\t}\n\n\tapp.RenderHTML(w, \"home.page.html\")\n}", "func (rp *Repository) Home(w http.ResponseWriter, r *http.Request) {\n\trender.Template(w, \"home.page.tmpl\", &models.TemplateData{})\n}", "func (b *Base) Home(w http.ResponseWriter, r *http.Request) {\n\tb.log.Printf(\"%s %s -> %s\", r.Method, r.URL.Path, r.RemoteAddr)\n\n\tpv := render.PageVars{\n\t\tTitle: \"GoViolin\",\n\t}\n\n\tif err := render.Render(w, \"home.html\", pv); err != nil {\n\t\tb.log.Printf(\"%s %s -> %s : ERROR : %v\", r.Method, r.URL.Path, r.RemoteAddr, err)\n\t\treturn\n\t}\n}", "func (s *Service) HomePage(w http.ResponseWriter, r *http.Request) {\n\tlog.Printf(\"Entry pattern URL: %s\\n\", r.URL.Path)\n\n\ttpl, err := template.ParseFiles(s.Environment[\"TEMPLATE\"] + \"/home.htm\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\terr = tpl.Execute(w, nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func Home(w http.ResponseWriter, req *http.Request) {\n\tgetContextAndRender(\"home\", w, req)\n}", "func Homepage(res render.Render) {\n\tif Settings.Firstrun {\n\t\tres.HTML(200, \"installation/wizard\", nil)\n\t\treturn\n\t}\n\tvar post Post\n\tposts, err := post.GetAll()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tres.JSON(500, map[string]interface{}{\"error\": \"Internal server error\"})\n\t\treturn\n\t}\n\tres.HTML(200, \"home\", posts)\n}", "func HomePage(w http.ResponseWriter, r *http.Request){\n\tdata:= ReadHtmlFile(Dir_Name+\"index.html\")\n\tw.Write(data)\n}", "func RenderHome(response http.ResponseWriter, request *http.Request) {\n\thttp.ServeFile(response, request, \"views/index.html\")\n}", "func (app *application) home(w http.ResponseWriter, r *http.Request) { \n\tif r.URL.Path != \"/\" {\n\t\tapp.notFound(w)\n\t\treturn\n\t}\n\n\ts, err := app.snippets.Latest()\n\tif err != nil {\n\t\tapp.serverError(w, err)\n\t\treturn\n\t}\n\n\t// Use the new render helper\n\tapp.render(w, r, \"home.page.tmpl\", &templateData{\n\t\tSnippets: s,\n\t})\n}", "func HomePage(w http.ResponseWriter, r *http.Request) {\n\ttpl, err := template.ParseFiles(\"html/index.html\")\n\tif err != nil {\n\t\tlog.Fatalln(\"Parse html file error:\", err)\n\t}\n\ttpl.Execute(w, nil)\n}", "func (app *application) home(res http.ResponseWriter, req *http.Request) {\n\tsnippets, err := app.snippets.Lasted()\n\tif err != nil {\n\t\tapp.serverError(res, err)\n\t}\n\n\ttemlsData := &Templates{\n\t\tSnippets: snippets,\n\t}\n\n\tapp.render(res, req, \"home.page.html\", temlsData)\n}", "func showHomePage(c *gin.Context) {\n\tc.JSON(200, gin.H{\n\t\t\"Server\": \"Cool you are ready to start website in goLang\",\n\t})\n}", "func handleHome(w http.ResponseWriter, req *http.Request) {\n\t// render an html page\n\ttmpl, err := template.ParseFiles(\"./templates/home.html\")\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\n\tdata := HomePage{\n\t\tTitle: \"Home\",\n\t}\n\n\ttmpl.Execute(w, data)\n}", "func homePage(w http.ResponseWriter, r *http.Request) {\n\ttemp, err := template.ParseFiles(\"index.html\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\ttemp.Execute(w, nil)\n}", "func (m *Repository) Home(w http.ResponseWriter, r *http.Request) {\n\n\trender.Template(w, r, \"index.page.tmpl\", &models.TemplateData{})\n}", "func L_Home(w http.ResponseWriter, r *http.Request) {\n\tvar link = \"\"\n\tif GetNutzerById(SessionNutzerID).Bild == \"/icons/Mein-Profil_black.svg\" {\n\t\tlink = \"/icons/Mein-Profil.svg\"\n\t} else {\n\t\tlink = GetNutzerById(SessionNutzerID).Bild\n\t}\n\n\tp := tmp_b_home{BildKlein: link, Nutzername: GetNutzerById(SessionNutzerID).Name, Nutzer: strconv.Itoa(GetNutzeranz()), MeineKarteien: strconv.Itoa(GetKarteikastenAnzGespeicherte(SessionNutzerID)), Lernkarten: strconv.Itoa(GetKartenAnz()), Karteien: strconv.Itoa(len(GetAlleKarteikaestenOeffentlich()))}\n\tt, _ := template.ParseFiles(\"./templates/b_home.html\", \"./templates/L_logged_in.html\")\n\tp.BildKlein = link\n\tt.ExecuteTemplate(w, \"layout\", p)\n}", "func handleHomePage(w http.ResponseWriter, r *http.Request) {\n\n\tw.Header().Set(\"Content-type\", \"text/html; charset=utf-8\")\n\tcontext := appengine.NewContext(r)\n\tu := user.Current(context)\n\n\tloginURL, _ := user.LoginURL(context, \"/\")\n\tlogoutURL, _ := user.LogoutURL(context, \"/\")\n\n\td := struct {\n\t\tData interface{}\n\t\tAuthEnabled bool\n\t\tLoginURL string\n\t\tLogoutURL string\n\t}{\n\t\tData: nil,\n\t\tAuthEnabled: u != nil,\n\t\tLoginURL: loginURL,\n\t\tLogoutURL: logoutURL,\n\t}\n\n\tif err := tpl.ExecuteTemplate(w, \"homepage.html\", d); err != nil {\n\t\tlog.Errorf(context, \"%v\", err)\n\t}\n\n\t/*\n\t\tif u == nil {\n\t\t\turl, _ := user.LoginURL(context, \"/\")\n\t\t\tfmt.Fprintf(w, `<a href=\"%s\">Sign in or register</a>`, url)\n\t\t\treturn\n\t\t}\n\t\turl, _ := user.LogoutURL(context, \"/\")\n\t*/\n\t//\tfmt.Fprintf(w, `Welcome, %s! (<a href=\"%s\">sign out</a>)`, u, url)\n}", "func LoadHome(w http.ResponseWriter, req *http.Request) {\n\tw.Write([]byte(\"Try /hello/:name\"))\n}", "func (s *Service) Home(w http.ResponseWriter, r *http.Request) {\n\tlevel.Info(s.logger).Log(\"msg\", \"Home page loaded\")\n\n\tw.WriteHeader(200)\n}", "func (app *App) Home(w http.ResponseWriter, r *http.Request) {\n\t// Fetch a slice of the latest snippets from the database.\n\tsnippets, err := app.Database.LatestSnippets()\n\tif err != nil {\n\t\tapp.ServerError(w, err)\n\t\treturn\n\t}\n\t// Pass the slice of snippets to the \"home.page.html\" templates.\n\tapp.RenderHTML(w, r, \"home.page.html\", &HTMLData{\n\t\tSnippets: snippets,\n\t})\n\n}", "func PageHome() *Renderer {\n\treturn &Renderer{\n\t\tfilenames: []string{\n\t\t\t\"templates/layout.html\",\n\t\t\t\"templates/logo.html\",\n\t\t\t\"templates/pages/home.html\",\n\t\t},\n\t\tcontext: nil,\n\t}\n}", "func Html_home_page(w http.ResponseWriter, r *http.Request) {\n\t\n\t//context := &TemplateContext{Name: \"Foobar\", Addr: \"localhost:9999\"}\n\tfmt.Println(\"HOMe_handler()\")\n\n page := &Page{Title: \"Welcome\", Foo: \"Bar\", SiteInfo: GSiteInfo}\n if err := HomeTemplates.Execute(w, page); err != nil {\n http.Error(w, err.Error(), http.StatusInternalServerError)\n }\n\n}", "func homePage(w http.ResponseWriter, r *http.Request) {\n\thttp.ServeFile(w, r, \"index.html\")\n}", "func (server *Server) ShowHome(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Show Home\")\n\tdata := IndexPageData{\n\t\tTitle: \"Hunt\",\n\t\tSubTitle: \"Welcome to the new Hunt App (made with Go!)\",\n\t}\n\ttempl.ExecuteTemplate(w, \"main\", data)\n}", "func (s Server) HomePage(w http.ResponseWriter, r *http.Request) {\n\n\tif r.URL.Path != \"/\" {\n\t\t// default/included mux is pretty dumb. just gonna throw this in here,\n\t\t// rather than upgrade to a better mux.\n\t\t// https://github.com/golang/go/issues/4799\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\ts.WritePage(w, \"home.html\", nil)\n}", "func displayHome(w http.ResponseWriter, r *http.Request) {\n\tlog.Printf(\"displayHome: url %s\", r.URL.Path)\n\n\t// Tell health check probes that we are alive\n\tif !httphandling.AcceptHTML(r) {\n\t\tfmt.Fprintln(w, \"OK\")\n\t\treturn\n\t}\n\n\ttitle := b.webConfig.GetVarWithDefault(\"Title\", defTitle)\n\tcontent := htmlContent{\n\t\tTitle: title,\n\t}\n\tif config.PasswordProtected() {\n\t\tctx := context.Background()\n\t\tif b.authenticator == nil {\n\t\t\tvar err error\n\t\t\tb.authenticator, err = initAuth(ctx)\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(\"displayHome authenticator could not be initialized\")\n\t\t\t\thttp.Error(w, \"Server error\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tsessionInfo := identity.InvalidSession()\n\t\tcookie, err := r.Cookie(\"session\")\n\t\tif err == nil {\n\t\t\tsessionInfo = b.authenticator.CheckSession(ctx, cookie.Value)\n\t\t} else {\n\t\t\tlog.Printf(\"displayHome error getting cookie: %v\", err)\n\t\t\tb.pageDisplayer.DisplayPage(w, \"login_form.html\", content)\n\t\t\treturn\n\t\t}\n\t\tif !sessionInfo.Valid {\n\t\t\tb.pageDisplayer.DisplayPage(w, \"login_form.html\", content)\n\t\t\treturn\n\t\t} else {\n\t\t\tlog.Printf(\"displayHome: using index_auth_template.html for url %s\", r.URL.Path)\n\t\t\tb.pageDisplayer.DisplayPage(w, \"index_auth_template.html\", content)\n\t\t\treturn\n\t\t}\n\t}\n\tlog.Printf(\"displayHome: template index.html for url %s\", r.URL.Path)\n\tb.pageDisplayer.DisplayPage(w, \"index.html\", content)\n}", "func (h *Handlers) Home(res http.ResponseWriter, req *http.Request) {\n\ttmpl, err := template.ParseFiles(path.Join(\"templates\", \"index.html\"))\n\tif err != nil {\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\n\t}\n\n\tdata, err := NewViewData(h.buildPath)\n\n\tif err != nil {\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\n\t}\n\n\tif err := tmpl.Execute(res, data); err != nil {\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (hCtl HomeCtl) HomePage(c *gin.Context) {\n\t// c.String(200, \"Hello, welcome the from go gin web framework v1.6.3\")\n\n\tc.HTML(http.StatusOK, \"index.tmpl\", gin.H{\n\t\t\"title\": \"Go Gin Home Page\",\n\t})\n}", "func HomePage(w http.ResponseWriter, r *http.Request) {\n\thtml, fileErr := ioutil.ReadFile(\"./checkbpfnet/checkbpfnet.html\")\n\tif fileErr != nil {\n\t logger.Error.Println(\"Unable to open local html file, checkbpfnet.html\", fileErr.Error())\n\t}\n\tfmt.Fprintf(w, string(html))\n}", "func (app *application) home(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\tapp.notFound(w) // use the notFound() helper\n\t\treturn\n\t}\n\n\tfiles := []string{\n\t\t\"./ui/html/home.page.tmpl\",\n\t\t\"./ui/html/base.layout.tmpl\",\n\t\t\"./ui/html/footer.partial.tmpl\",\n\t}\n\n\tts, err := template.ParseFiles(files...)\n\tif err != nil {\n\t\tapp.serverError(w, err) // use the serverError() helper\n\t\treturn\n\t}\n\n\terr = ts.Execute(w, nil)\n\tif err != nil {\n\t\tapp.serverError(w, err) // use the serverError() helper\n\t}\n}", "func HomePage(w http.ResponseWriter, req *http.Request) {\n\tswitch req.Method {\n\tcase \"GET\":\n\t\t// Serve the resource.\n\t\tfmt.Fprintf(w, \"Hello, %q\", html.EscapeString(req.URL.Path))\n\tdefault:\n\t\tfmt.Fprintf(w, \"Error: Invalid request\")\n\t}\n\n}", "func HomeGET(w http.ResponseWriter, r *http.Request) handler.HTML {\n\t// Create an HTML response.\n\tresp := app.HTMLResponse(w, r)\n\t// Prepare home page data.\n\tpageData := &HomePageData{Time: time.Now().String()}\n\t// Generate page HTML.\n\tpageHTML := homeView.MustExecuteToString(resp.Lang(), pageData)\n\t// Create main page data, which is a core template shared by all your website pages.\n\td := app.MainPageData(resp.LocalizedDictionary().Home, pageHTML)\n\t// Complete the response.\n\treturn resp.MustComplete(d)\n}", "func homeHandler(w http.ResponseWriter, r *http.Request) {\n\tp := Profile{}\n\trenderTemplate(w, \"login\", &p)\n}", "func Home(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tH := H(c)\n\tH[\"Title\"] = \"Вечная память приветствует Вас\"\n\tH[\"Active\"] = \"/\"\n\tsession.Save()\n\tc.HTML(200, \"home/show\", H)\n}", "func HomepageHandler(c *gin.Context) {\n\tc.HTML(http.StatusOK, \"index.html\", gin.H{\n\t\t\"Title\": \"Home\",\n\t\t\"Accounts\": &accounts,\n\t\t\"Shares\": &shares,\n\t\t\"NetWorth\": netWorth,\n\t})\n}", "func homeHandler(w http.ResponseWriter, req *http.Request) {\n\tvar tmp = template.Must(\n\t\ttemplate.New(\"\").ParseFiles(\"public/templates/home/index.html\", \"public/templates/layouts/base.html\"),\n\t)\n\tif err := tmp.ExecuteTemplate(w, \"base\", &Page{Title: \"Home\", Body: \"body\"}); err != nil {\n\t\tlog.Printf(\"Error executing template: %v\", err)\n\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t}\n}", "func homeHandler(w http.ResponseWriter, r *http.Request) {\n\terr := templates.ExecuteTemplate(w, \"home\", nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"INFO: Rendering of Template home worked fine\")\n}", "func (app *application) home(w http.ResponseWriter, r *http.Request) {\n\t// write board data\n\tfiles := []string{\n\t\t\"./ui/html/home.page.tmpl\",\n\t\t\"./ui/html/base.layout.tmpl\",\n\t\t\"./ui/html/footer.partial.tmpl\",\n\t}\n\t// render template\n\tts, err := template.ParseFiles(files...)\n\tif err != nil {\n\t\tapp.serverError(w, err)\n\t\treturn\n\t}\n\t// to catch template errors, write to buffer first\n\tbuf := new(bytes.Buffer)\n\terr = ts.Execute(buf, nil)\n\tif err != nil {\n\t\tapp.serverError(w, err)\n\t\treturn\n\t}\n\tbuf.WriteTo(w)\n}", "func Home(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"This is the home page\")\n}", "func (h home) handleHome(w http.ResponseWriter, r *http.Request) {\n\tvm := viewmodel.NewBase()\n\th.homeTemplate.Execute(w, vm)\n}", "func homeHandler(w http.ResponseWriter, r *http.Request) {\n\tp := &Page{}\n\tt, _ := template.ParseFiles(\"./dist/index.html\")\n\tt.Execute(w, p)\n}", "func ServeHomepage(w http.ResponseWriter, _ *http.Request) {\n\thomepage.Data.Mu.Lock()\n\n\terr := webTemplate.ExecuteTemplate(w, \"home\", homepage.Data)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\thomepage.Data.Mu.Unlock()\n}", "func home(w http.ResponseWriter, req *http.Request) {\n\trootPath := \"views/\"\n\tfile := \"home.html\"\n\tfilePath := rootPath + file\n\tif (len(filePath) != 0) && (req.RequestURI == \"/\") {\n\t\tf, err := http.Dir(rootPath).Open(file)\n\t\tif err == nil {\n\t\t\tcontent := io.ReadSeeker(f)\n\t\t\thttp.ServeContent(w, req, filePath, time.Now(), content)\n\t\t\treturn\n\t\t}\n\t}\n\thttp.NotFound(w, req)\n}", "func Home(resp http.ResponseWriter, req *http.Request) {\n\tgo logRequest(req)\n\tbuf := bytes.NewBufferString(homePage)\n\tio.Copy(resp, buf)\n}", "func HomeHandler(response http.ResponseWriter, request *http.Request){\n\tresponse.Header().Set(\"Content-type\", \"text/html\")\n\twebpage, err := ioutil.ReadFile(\"home.html\")\n\tif err != nil { \n\t\thttp.Error(response, fmt.Sprintf(\"home.html file error %v\", err), 500)\n\t}\n\tfmt.Fprint(response, string(webpage));\n}", "func (m *Repository) Home(w http.ResponseWriter, r *http.Request) {\n\n\t// Every time somebody hits that home page for that user session\n\tremoteIP := r.RemoteAddr\n\n\t//Storing the remote IP Address as a string in the session\n\tm.App.Session.Put(r.Context(), \"remote_ip\", remoteIP)\n\n\t//TemplateData passing a empty Template, else it would be error\n\trender.RenderTemplate(w, \"home.page.tmpl.html\", &models.TemplateData{})\n}", "func HomeUIHandler(w http.ResponseWriter, r *http.Request) {\n\tvar ui WREISUISupport\n\tvar err error\n\tfuncname := \"HomeUIHandler\"\n\tappPage := \"home.html\"\n\tlang := \"en-us\"\n\ttmpl := \"default\"\n\n\tui.Language = lang\n\tui.Template = tmpl\n\n\tt, err := template.New(appPage).ParseFiles(\"./static/html/\" + appPage)\n\tif nil != err {\n\t\ts := fmt.Sprintf(\"%s: error loading template: %v\\n\", funcname, err)\n\t\tui.ErrMsg += s\n\t\tfmt.Println(s)\n\t}\n\n\terr = t.Execute(w, &ui)\n\n\tif nil != err {\n\t\tutil.LogAndPrintError(funcname, err)\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func homePage(w http.ResponseWriter, r *http.Request, _ httprouter.Params){\n\tfmt.Fprintf(w, \"<h1>Welcome to the HomePage!<h1>\")\n\tlines, err := File2lines(config_readmepath)\n\tif err != nil {\n\t\tfmt.Println(\"Problem with Readme\")\n\t} else {\n\t\tfor _, line := range lines{\n\t\t\tfmt.Fprintf(w, \"<div style=\\\"font-size: 14px\\\"><p>\"+line+\"<p></div>\")\n\t\t}\n\t\tfmt.Println(\"Endpoint Hit: homePage\")\n\t}\n\t//requestChannel <- \"Home\"\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Home page\")\n}", "func home(w http.ResponseWriter, r *http.Request){\n\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tfiles := []string{\n\t\t\"./ui/html/home.page.tmpl\",\n\t\t\"./ui/html/base.layout.tmpl\",\n\t\t\"./ui/html/footer.partial.tmpl\",\n\t}\n\n\t// Read the files and store the templates in a set. Use a variadic parameter that consists of a slice of file paths.\n\tts, err := template.ParseFiles(files...)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(w, \"Internal Server Error\", 500)\n\t\treturn\n\t}\n\n\t// Write the template content as the response body.\n\terr = ts.Execute(w, nil)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(w, \"Internal Server Error\", 500)\n\t\treturn\n\t}\n}", "func (MainController) Homepage(c *gin.Context) {\n\tc.JSON(200, gin.H{\n\t\t\"message\": \"Welcome to talksy roshan\",\n\t})\n}", "func (m *Repository) Home(w http.ResponseWriter, r *http.Request) {\n\n\tremoteIP := r.RemoteAddr\n\tm.App.Session.Put(r.Context(), \"remote_ip\", remoteIP)\n\n\trender.RenderTemplate(w, \"home.page.tmpl\", &models.TemplateData{})\n}", "func HomeViewHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\tNotFoundHandler(w, r)\n\t\treturn\n\t}\n\n\tt := &templates.Page{Title: \"Home\"}\n\ttemplates.RenderTemplate(w, \"templates/home\", t)\n}", "func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tcontent := GetAllContent()\n\n\t// Prepare data structure for data passed to template.\n\ttype TemplateData struct {\n\t\tContent []Content\n\t\tEnv string\n\t}\n\n\ttemplateData := TemplateData{Content: content, Env: os.Getenv(\"IGO_ENV\")}\n\n\t// Parse templates.\n\tvar templates = template.Must(template.New(\"\").ParseFiles(\"web/templates/_base.html\", \"web/templates/index.html\"))\n\n\t// Execute template.\n\ttemplates.ExecuteTemplate(w, \"_base.html\", templateData)\n}", "func homeHandler(env *Env, w http.ResponseWriter, r *http.Request) error {\n return renderTemplate(w, \"index\", \"base\", nil)\n}", "func HomeHandler(c buffalo.Context) error {\n\treturn c.Render(http.StatusOK, r.HTML(\"index.html\"))\n}", "func HomeHandler(c buffalo.Context) error {\n\ttemplateData := templatedata.Index{PageTitle: \"IsoBuffalo\"}\n\tc.Set(\"page\", templateData)\n\tp := &isokit.RenderParams{Writer: c.Response()}\n\treturn c.Render(200, wraprender.HTML(ts, \"index_page\", p))\n}", "func home(c *gin.Context) {\n\tc.HTML(200, \"home/home\", gin.H{\n\t\t\"Title\": config.Settings.ProjectName + \" welcomes you!\",\n\t})\n}", "func home(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tpu, _ := GetUserFromSession(res, req)\n\tServeTemplateWithParams(res, \"index.html\", pu)\n}", "func (s Site) HomeHandler(w http.ResponseWriter, r *http.Request) {\n\t// The \"/\" pattern matches everything, so we need to check\n\t// that we're at the root here.\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tdata := map[string]interface{}{\n\t\t\"topics\": s.topics,\n\t}\n\ts.render(w, \"home\", data)\n}", "func homePage(w http.ResponseWriter, r *http.Request){\n\tfmt.Fprintf(w, \"Welcome to the default page!\")\n\tfmt.Println(\"Endpoint Hit: root\")\n}", "func home(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"text/html\") // sets page as text/html\n\tfmt.Fprint(w, \"<h1>This is my home page</h1>\")\n}", "func genHomePage() []byte {\n\treturn []byte(\"Welcome to the HomePage!\")\n}", "func HomeGET(w http.ResponseWriter, r *http.Request) {\n\t// Get session\n\tsession := session.Instance(r)\n\n\t// Display the view\n\tv := view.New(r)\n\tv.Name = \"home\"\n\tv.Vars[\"Languages\"] = languages\n\tv.Vars[\"Language\"] = \"eng\"\n\tv.Vars[\"token\"] = csrfbanana.Token(w, r, session)\n\tv.Render(w)\n\tview.Repopulate([]string{\"ImgURL\"}, r.Form, v.Vars)\n\treturn\n}", "func (app *App) HomeHandler(c echo.Context) (err error) {\n\treturn c.Render(http.StatusOK, \"home\", \"\")\n}", "func (c *CommonController) Home() {\n\tc.Ctx.Template = \"index\"\n\tc.HTML(http.StatusOK)\n}", "func HomeHandler(w http.ResponseWriter, req *http.Request) {\n\thomeTemplate, _ := template.ParseFiles(\"static/index.html\")\n\terr := homeTemplate.Execute(w, nil)\n\n\tif err != nil {\n\t\tlog.Println(\"runtime error: exec home template \", err)\n\t\treturn\n\t}\n}", "func HomeHandler(c buffalo.Context) error {\n\tc.Set(\"page-title\", \"Jaburu Home\")\n\tc.Set(\"page-description\", \"Jaburu Home\")\n\treturn c.Render(http.StatusOK, r.HTML(\"index.html\"))\n}", "func Home(response http.ResponseWriter, request *http.Request) {\n\tpage := `\n<html>\n <head></head>\n <body>\n <h1>Index of examples</h1>\n <h2>Notes</h2>\n <div>\n %s\n </div>\n <h3>Example Pages</h3>\n <ul>\n <li><a href=\"/pages/simple-page\">Simple Page Load</a> -- this is a demonstration of simply loading html pages and sending them out. No templating involved.</li>\n <li><a href=\"/compositePages/page1\">Composite Page Load</a> -- This is just like the page load, but it uses a common template to wrap the pages. In other words, content only with a common wrapper.</li>\n <li><a href=\"/simpleImportedTemplate\">Simple Imported Template</a> -- a template imported from an HTML file.</li>\n <li><a href=\"/complexImportedTemplate\">Complex Imported Template</a> -- a template imported from an HTML file with lots of variables.</li>\n <li><a href=\"/fullyTemplatedTemplate\">Fully Templated Template</a> -- a template that incorporates loops, other template files, variables, and loops. Also includes css, images, and js files.</li>\n </ul>\n <h3>Utility Functions</h3>\n <ul>\n <li><a href=\"/images/modemConvo.jpg\">Image load example</a> -- Example of loading an images.</li>\n <li><a href=\"/js/alert.js\">Javascript load example</a> -- Example of loading javascipt.</li>\n <li><a href=\"/css/css1.css\">CSS load example</a> -- Example of loading css.</li>\n </ul>\n </body>\n</html>`\n\n\tf, err := os.Open(\".\")\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer f.Close()\n\n\tfileInfo, _ := f.Stat()\n\n\ttestString := fileInfo.IsDir()\n\n\tfmt.Fprintf(response, page, testString)\n}", "func homePage(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello World\")\n}", "func (c *RBController) Home(w http.ResponseWriter, r *http.Request) (err error) {\n\tstats := map[string]string{\n\t\t\"nRecipes\": \"891\",\n\t\t\"nVolunteers\": \"200,000\",\n\t\t\"nCountries\": \"100+\",\n\t\t\"nYears\": \"54\",\n\t}\n\tc.HTML(w, http.StatusOK, \"home\", stats)\n\treturn nil\n}", "func HomeHandler(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\tstylesheet, err := ioutil.ReadFile(\"./public/index.html\")\n\tif err != nil {\n\t\tfmt.Fprintln(rw, err)\n\t}\n\trw.Header().Add(\"Content-Type\", \"text/html\")\n\tfmt.Fprintln(rw, string(stylesheet))\n}", "func HomeHandler(c buffalo.Context) error {\n\tuid := c.Session().Get(\"current_user_id\")\n\n\tvar content models.Contents\n\terr := models.DB.Select(`tag, type, SUM(time)::INT \"time\"`).\n\t\tWhere(\"user_id = ? AND TO_CHAR(created_at, 'iyyy-iw') = TO_CHAR(NOW(), 'iyyy-iw')\", uid).\n\t\tGroupBy(\"tag\", \"type\").\n\t\tAll(&content)\n\tif err != nil {\n\t\tc.Logger().Errorf(\"get home page: %s\", err)\n\t}\n\n\tcurrentWeekTime, avgWeekTime := &models.Content{}, &models.Content{}\n\terr = models.DB.Select(`SUM(time) AS time`).\n\t\tWhere(`TO_CHAR(created_at, 'iyyy-iw') = TO_CHAR(NOW(), 'iyyy-iw')`).\n\t\tFirst(currentWeekTime)\n\tif err != nil {\n\t\tc.Logger().Errorf(\"get home page: %s\", err)\n\t}\n\n\terr = models.DB.RawQuery(`\n\t\tSELECT ROUND(AVG(t)) as time FROM (\n\t\t\tSELECT SUM(time) t, TO_CHAR(created_at, 'iyyy-iw') w\n\t\t\t\tFROM contents\n\t\t\t\tGROUP BY w\n\t\t) _ WHERE w != TO_CHAR(NOW(), 'iyyy-iw')\n\t\t`).First(avgWeekTime)\n\tif err != nil {\n\t\tc.Logger().Errorf(\"get home page: %s\", err)\n\t}\n\n\tc.Set(\"contents\", content)\n\tc.Set(\"types\", content.GetUniqueTypes())\n\tc.Set(\"progress\", asPercents(currentWeekTime, avgWeekTime))\n\treturn c.Render(http.StatusOK, r.HTML(\"index.html\"))\n}", "func Home(w http.ResponseWriter, r *http.Request) {\n\thttp.ServeFile(w, r, \"static/index.html\")\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\tfp := mp(\"static/templates/index.html\")\n\tindexTemplate, err := ioutil.ReadFile(fp)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to open %v\", fp)\n\t}\n\tt := template.New(\"index-template\")\n\tt, _ = t.Parse(string(indexTemplate))\n\tt.Execute(w, indexTemplate)\n}", "func homePage(response http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(response, \"Welcome to the RESTAPI!\")\n}", "func HomeHandler(c buffalo.Context) error {\n\tif commitID == \"\" {\n\t\tc.Data()[\"commitID\"] = \"Unknown Revision\"\n\t} else {\n\t\tc.Data()[\"commitID\"] = commitID[:6]\n\t}\n\treturn c.Render(200, r.HTML(\"index.html\"))\n}", "func HomeHandler(c buffalo.Context) error {\n\tc.Set(\"blogPosts\", blog.LastPosts())\n\treturn c.Render(200, r.HTML(\"home.html\", \"home-layout.html\"))\n}", "func Homepage(app inter.App, title string, description string) *HomepageView {\n\treturn &HomepageView{\n\t\tTitle: title,\n\t\tDescription: description,\n\t\tLocale: Locale(app),\n\t}\n}", "func Homepage(app inter.App, title string, description string) *HomepageView {\n\treturn &HomepageView{\n\t\tTitle: title,\n\t\tDescription: description,\n\t\tLocale: Locale(app),\n\t}\n}", "func (s *Server) HandleHome() http.HandlerFunc {\n\tvar (\n\t\tinit sync.Once\n\t\ttpl *template.Template\n\t\terr error\n\t)\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tinit.Do(func() {\n\t\t\ttpl, err = template.New(\"\").ParseGlob(\"web/templates/*.tpl\")\n\t\t})\n\t\tif err != nil {\n\t\t\ts.Logger.Printf(\"%s\\n\", err)\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n m, err := s.TaskGetAll()\n if err != nil {\n s.Logger.Printf(\"TasksGetAll: %s\\n\", err)\n }\n tasks := mapToXTask(m)\n\n\t\terr = tpl.ExecuteTemplate(w, \"main\", tasks)\n\t\tif err != nil {\n\t\t\ts.Logger.Fatalf(\"%s\\n\", err)\n\t\t}\n\t}\n\n}", "func HomePage(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"You have reached simple-service, try /ingress or /egress\")\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\ttext, err := template.ParseFiles(views[\"index\"])\n\tif err == nil {\n\t\ttext.Execute(w, nil)\n\t}\n}", "func home(w http.ResponseWriter, r *http.Request) {\n\t//meng-chek ketersedian session\n\tsession := sessions.Start(w, r)\n\tif len(session.GetString(\"username\")) == 0 {\n\t\thttp.Redirect(w, r, \"/login\", 301)\n\t}\n\n\t//properti untuk di set di html\n\tvar data = map[string]string{\n\t\t\"username\": session.GetString(\"username\"),\n\t\t\"message\": \"Selamat datang di menu utama\",\n\t}\n\n\tvar t, err = template.ParseFiles(\"views/home.html\")\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\n\tt.Execute(w, data)\n\treturn\n\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\twelcome := Welcome{\"to Cycling Blog\", time.Now().Format(time.Stamp)}\n\tt := template.Must(template.ParseFiles(\"templates/home.html\"))\n\n\tif err := t.ExecuteTemplate(w, \"home.html\", welcome); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func homepage(w http.ResponseWriter, r *http.Request) {\n\tio.WriteString(w, homepageHTML)\n}", "func (app *application) home(w http.ResponseWriter, r *http.Request) {\n\tif app.authenticatedCustomer(r) != 0 {\n\t\thttp.Redirect(w, r, \"/customer/home\", http.StatusFound)\n\t\treturn\n\t} else if app.authenticatedVendor(r) != 0 {\n\t\thttp.Redirect(w, r, \"/vendor/home\", http.StatusFound)\n\t\treturn\n\t}\n\tapp.render(w, r, \"home.page.tmpl\", nil)\n}", "func (app *application) home(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\t// Initialize a slice containing the paths to the two files. Note that the\n\t// home.page.tmpl file must be the *first* file in the slice.\n\tfiles := []string{\n\t\t\"./ui/html/home.page.tmpl\",\n\t\t\"./ui/html/base.layout.tmpl\",\n\t\t\"./ui/html/footer.partial.tmpl\",\n\t}\n\n\t// Use the template.ParseFiles() function to read the files and store the\n\t// templates in a template set. Notice that we can pass the slice of file paths\n\t// as a variadic parameter?\n\tts, err := template.ParseFiles(files...)\n\tif err != nil {\n\t\t// Because the home handler function is now a method against application\n\t\t// it can access its fields, including the error logger. We'll write the log\n\t\t// message to this instead of the standard logger.\n\t\tapp.errorLog.Println(err.Error())\n\t\thttp.Error(w, \"Internal Server Error\", 500)\n\t\treturn\n\t}\n\t// We then use the Execute() method on the template set to write the template\n\t// content as the response body. The last parameter to Execute() represents any\n\t// dynamic data that we want to pass in, which for now we'll leave as nil.\n\terr = ts.Execute(w, nil)\n\tif err != nil {\n\t\tapp.errorLog.Println(err.Error())\n\t\thttp.Error(w, \"Internal Server Error\", 500)\n\t}\n\n}", "func homeHandler(c http.ResponseWriter, req *http.Request) {\n\thomeTempl.Execute(c, req.Host)\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\thttp.ServeFile(w, r, \"/home/jordan/convo/static/html/home.html\")\n}", "func LoadPage() {\n\tb, _ := ioutil.ReadFile(\"./web/index.html\")\n\tPage = string(b)\n}", "func HomeHandler(w http.ResponseWriter, r *http.Request) {\n\thttp.ServeFile(w, r, \"views/index.html\")\n}", "func (td *WebUI) RootPage(w http.ResponseWriter, r *http.Request) {\n\ttd.templateDataMtx.RLock()\n\t// Execute template to a string instead of directly to the\n\t// http.ResponseWriter so that execute errors can be handled first. This can\n\t// avoid partial writes of the page to the client.\n\tchainHeight := td.ExplorerSource.GetHeight()\n\tpageSize := 6\n\tif chainHeight < pageSize {\n\t\tpageSize = chainHeight\n\t}\n\tinitialBlocks := make([]*hcjson.GetBlockVerboseResult, 0, pageSize)\n\tfor i := chainHeight; i > chainHeight-pageSize; i-- {\n\t\tdata := td.ExplorerSource.GetBlockVerbose(i, false)\n\t\tinitialBlocks = append(initialBlocks, data)\n\t}\n\t// hashrate_h_s := initialBlocks[1].Difficulty * (math.Pow(2, 32)) / 150 // h/s\n\thashrate_th_s := td.ExplorerSource.GetNetWorkHashRate()/math.Pow(10,12) // Th/s\n\tstr, err := TemplateExecToString(td.templ, \"home\", struct {\n\t\tInitialData []*hcjson.GetBlockVerboseResult\n\t\tData WebTemplateData\n\t\tStakeDiffWindowSize int64\n\t\tHashRate float64\n\t}{\n\t\tinitialBlocks,\n\t\ttd.TemplateData,\n\t\ttd.params.StakeDiffWindowSize,\n\t\thashrate_th_s,\n\t})\n\ttd.templateDataMtx.RUnlock()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to execute template: %v\", err)\n\t\thttp.Error(w, \"template execute failure\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\tw.WriteHeader(http.StatusOK)\n\tio.WriteString(w, str)\n}", "func HomeGet(c *gin.Context) {\n\tH := DefaultH(c)\n\tH[\"Title\"] = fmt.Sprintf(\"Shop special offers and deals on %s\", config.SiteTitle)\n\tH[\"MetaKeywords\"] = \"Special offers, International shipping deals, Discounts, Discount centre\"\n\tH[\"MetaDescription\"] = \"Buy popular products via gateway shopping centre with international shipping. Low prices on brand items!\"\n\tH[\"Nodes\"] = cache.GetHomeNodes()\n\tH[\"MenuNodes\"] = models.MenuNodes()\n\tH[\"HomeTopProducts\"] = cache.GetHomeTopProducts()\n\tc.HTML(200, \"home/show\", H)\n}", "func HomeHandler(c buffalo.Context) error {\n\ttx, ok := c.Value(\"tx\").(*pop.Connection)\n\tif !ok {\n\t\treturn fmt.Errorf(\"no transaction found\")\n\t}\n\n\tscreencasts := &models.Screencasts{}\n\n\t// Paginate results. Params \"page\" and \"per_page\" control pagination.\n\t// Default values are \"page=1\" and \"per_page=20\".\n\tq := tx.PaginateFromParams(c.Params())\n\n\t// Retrieve all Screencasts from the DB\n\tif err := q.All(screencasts); err != nil {\n\t\treturn err\n\t}\n\tc.Set(\"screencasts\", screencasts)\n\thomeView, err := views.Home(c, parsedManifest)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn c.Render(200, render.EltToRenderer(homeView))\n}", "func homeHandler(w http.ResponseWriter, r *http.Request) {\n\tif r.URL.Path != \"/\" {\n\t\terrorHandler(w, r, http.StatusNotFound)\n\t\treturn\n\t} else {\n\t\tuserEmail := components.GetEmailFromCookie(r)\n\n\t\tif userEmail == \"\" {\n\t\t\ttpl.ExecuteTemplate(w, \"home.template\", map[string]string{\n\t\t\t\t\"isLoggedIn\": \"false\",\n\t\t\t})\n\t\t} else {\n\t\t\ttpl.ExecuteTemplate(w, \"home.template\", map[string]string{\n\t\t\t\t\"isLoggedIn\": \"true\",\n\t\t\t})\n\t\t}\n\t}\n}", "func Home(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tfmt.Fprint(w, homeMessage)\n}" ]
[ "0.75011134", "0.7305672", "0.73013526", "0.7266723", "0.72194743", "0.7141759", "0.7124269", "0.7121118", "0.71153516", "0.71008635", "0.7035879", "0.7006161", "0.7001379", "0.69949424", "0.69775707", "0.6968816", "0.6948308", "0.69211024", "0.69147867", "0.6909854", "0.6907767", "0.6892586", "0.68863386", "0.68826705", "0.68775403", "0.68378997", "0.6817548", "0.68048006", "0.6761522", "0.67535996", "0.6749493", "0.6736543", "0.6715878", "0.6694304", "0.6691941", "0.66533613", "0.6653353", "0.66392124", "0.6635013", "0.6617921", "0.6607441", "0.6603286", "0.6583632", "0.65417665", "0.6493795", "0.6490873", "0.6489068", "0.6468932", "0.64484924", "0.64415777", "0.6429454", "0.6426494", "0.6424941", "0.6406521", "0.6402635", "0.64021647", "0.63969666", "0.6387217", "0.63868487", "0.63846546", "0.6375056", "0.6362741", "0.63565654", "0.6354416", "0.6348104", "0.63476515", "0.6329408", "0.63197666", "0.63177603", "0.63130593", "0.63065666", "0.6304368", "0.62997437", "0.62963563", "0.62508947", "0.62405914", "0.62400484", "0.6240002", "0.6230029", "0.6210616", "0.6198532", "0.61961764", "0.61961764", "0.6173156", "0.61598456", "0.6153151", "0.61511326", "0.6149267", "0.6144811", "0.614233", "0.6126048", "0.6110843", "0.6103167", "0.6101929", "0.6085792", "0.6060342", "0.60579425", "0.60499257", "0.6003839", "0.5957982" ]
0.74064004
1
LoadEditPage Load edit page
func LoadEditPage(w http.ResponseWriter, r *http.Request) { parameters := mux.Vars(r) publicationID, err := strconv.ParseUint(parameters["publicationId"], 10, 64) if err != nil { responses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()}) return } url := fmt.Sprintf("%s/publications/%d", config.APIURL, publicationID) response, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil) if err != nil { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()}) return } defer response.Body.Close() if response.StatusCode >= 400 { responses.TreatStatusCode(w, response) return } var publication models.Publication if err = json.NewDecoder(response.Body).Decode(&publication); err != nil { responses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()}) return } utils.RunTemplate(w, "edit-publication.html", publication) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func editHandler(w http.ResponseWriter, r *http.Request) {\r\n title := r.URL.Path[len(\"/edit/\"):]\r\n p, err := loadPage(title)\r\n if err != nil {\r\n p = &Page{Title: title}\r\n }\r\n renderTemplate(w, \"edit\", p)\r\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/edit/\"):]\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func handlerEdit(w http.ResponseWriter, r *http.Request, title string) {\r\n\tpage, err := loadPage(title)\r\n\tif err != nil {\r\n\t\tpage = &Page{Title: title}\r\n\t}\r\n\t//to use a html file we have to use the template.ParseFile\r\n\tfetchHTML(w, \"edit\", page)\r\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\t/* The renderTemplate function replaces the following code for better code re-use:\n\t * t, _ := template.ParseFiles(\"edit.html\")\t\n\t * t.Execute(w,p)\n\t */ \n\trenderTemplate(w, \"edit\", p)\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title, Filename: title}\n\t}\n\trenderTemplate(w, \"edit\", p)\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tlog.Println(\"editHandler() error: \", err)\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"edit\", p)\n}", "func (env *Env) Edit(res http.ResponseWriter, req *http.Request, title string) {\n\tenv.Log.V(1, \"beginning handling of Edit.\")\n\tenv.Log.V(1, \"loading requested page from cache.\")\n\tp, err := env.Cache.LoadPageFromCache(title)\n\tif err != nil {\n\t\tenv.Log.V(1, \"if file from cache not found, then retrieve requested page from db.\")\n\t\tp, _ = env.DB.LoadPage(title)\n\t}\n\tif p.Title == \"\" {\n\t\tenv.Log.V(1, \"if page title is blank, then try again.\")\n\t\tp, _ = env.DB.LoadPage(title)\n\t}\n\tif p == nil {\n\t\tenv.Log.V(1, \"notifying client that the request page was not found.\")\n\t\thttp.NotFound(res, req)\n\t\treturn\n\t}\n\tif strings.Contains(p.Title, \"_\") {\n\t\tp.Title = strings.Replace(p.Title, \"_\", \" \", -1)\n\t}\n\tenv.Log.V(1, \"requested page found, rendering the edit template.\")\n\tenv.Render(res, \"edit\", p)\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"edit\", p) // Passes: ResponseWriter, templatename, template page fill\n\t//t.Execute(w, p) Executes template, writes HTML to http.ResponseWriter (w)\n}", "func (h *Handler) EditPage(c echo.Context) error {\n\tm := echo.Map{}\n\tif err := c.Bind(&m); err != nil {\n\t\treturn err\n\t}\n\tnr, nt, route := m[\"newRoute\"].(string), m[\"newTitle\"].(string), m[\"route\"].(string)\n\n\tuserDataMap := utils.GetUserDataFromContext(&c)\n\temail := (*userDataMap)[\"email\"].(string)\n\n\tpage, err := h.pageStore.EditPage(email, route, nr, nt)\n\tif err != nil {\n\t\tutils.Logger.Error(err)\n\t\treturn c.JSON(http.StatusInternalServerError, createRes(false, nil, nil, http.StatusText(http.StatusInternalServerError)))\n\t}\n\treturn c.JSON(http.StatusOK, createRes(true, page, nil, \"\"))\n}", "func EditPage(c *fiber.Ctx) error {\n\t// Firstly checks if given table exists\n\tname := c.Params(\"name\")\n\tT := databasepack.FindTable(name)\n\tif T < 0 {\n\t\treturn c.Send([]byte(\"No table with such name!\"))\n\t}\n\t// Next checks if the user can actually perform this action\n\tif !databasepack.Allowed(querypack.INFO.Roles, \"editor_\"+name) {\n\t\treturn c.Send([]byte(\"Permission declined!\"))\n\t}\n\t// Lastly posts given post\n\tdatabasepack.CreatePosts(c.Body(), name, T)\n\treturn c.Send([]byte(\"Successfully edited!\"))\n}", "func handleEdit(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := page.Load(title)\n\tif err != nil {\n\t\tp = &page.Page{Title: title}\n\t}\n\trender(w, \"edit\", p)\n\tlogInfo(p.Title, \"file opened in edit mode\")\n}", "func EditPage(ctx *sweetygo.Context) error {\n\tctx.Set(\"title\", \"Edit\")\n\tctx.Set(\"editor\", true)\n\ttitle := ctx.Param(\"title\")\n\ttitle = strings.Replace(title, \"-\", \" \", -1)\n\tpost, err := model.GetPostByTitle(title)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx.Set(\"post\", post)\n\treturn ctx.Render(200, \"posts/edit\")\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n p := selectRow(title, w, r)\n renderTemplate(w, \"edit\", p)\n}", "func (controller *UserController) GetEditPage(ctx *fasthttp.RequestCtx) {\n\tcontroller.getProfile(ctx, true)\n}", "func Edit(w http.ResponseWriter, r *http.Request){\n\tidDoProduto := r.URL.Query().Get(\"id\")\n\tproduto := models.EditaProduto(idDoProduto)\n\ttemp.ExecuteTemplate(w, \"Edit\", produto)\n}", "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func LoadUserEditPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tchannel := make(chan models.User)\n\n\tgo models.GetUserData(channel, userID, r)\n\n\tuser := <-channel\n\tif user.ID == 0 {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: \"Erro ao buscar o usuário\"})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-profile.html\", user)\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\tarticle, _, err := article.ByID(c.DB, c.Param(\"id\"), c.UserID)\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tc.Redirect(uri)\n\t\treturn\n\t}\n\n\tv := c.View.New(\"article/edit\")\n\tc.Repopulate(v.Vars, \"tittle\")\n\tv.Vars[\"article\"] = article\n\tv.Render(w, r)\n}", "func AdminEdit(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminEdit, w, data)\n}", "func AdminEdit(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminEdit, w, data)\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\r\n\tdb := Database.Dbconn()\r\n\t\r\n\tnId := r.URL.Query().Get(\"id\")\r\n\ttsql := fmt.Sprintf(\"SELECT * FROM employee.dbo.employee where Id='%s';\", nId)\r\n\tselDB, err := db.Query(tsql)\r\n\tif err != nil {\r\n panic(err.Error())\r\n\t}\r\n\r\n\tper :=persona{}\r\n\tfor selDB.Next(){\r\n\t\tvar (\r\n\t\t\tId string\r\n\t\t\tName string\r\n\t\t\tLocation string\r\n\t\t)\r\n\r\n\t\terr =selDB.Scan(&Id, &Name, &Location)\r\n\t\tif err != nil {\r\n\t\t\tpanic(err.Error())\r\n\t\t}\r\n\t\tper.Id=Id\r\n\t\tper.Name = Name\r\n\t\tper.Location = Location\r\n\t}\r\n\r\n\tlog.Println(per)\r\n\ttmpl.ExecuteTemplate(w, \"Show\", per)\r\n\r\n}", "func InitEditPageHandler(db yoradb.PostRepository, templatesPath string) *EditPageHandler {\n\n\tpathes := make([]string, 3)\n\tpathes[0] = filepath.Join(templatesPath, \"layout.gohtml\")\n\tpathes[1] = filepath.Join(templatesPath, \"edit.gohtml\")\n\tpathes[2] = filepath.Join(templatesPath, \"empty_og.gohtml\")\n\n\ttempl, err := yotemplate.InitTemplate(pathes...)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tlog.Println(\"Edit page template is initialized.\")\n\n\treturn &EditPageHandler{template: templ, db: db}\n}", "func EditPageHandler(db *sql.DB, tmpl ExecuteTemplateFunc) http.HandlerFunc {\n\treturn handleErrors(func(w http.ResponseWriter, r *http.Request) error {\n\t\tblogslug := mux.Vars(r)[\"blogslug\"]\n\t\tpageslug := mux.Vars(r)[\"pageslug\"]\n\t\tdto, err := EditPageQuery(db, blogslug, pageslug)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn tmpl(w, \"editpage.html\", dto)\n\t})\n}", "func (ac *ArticleController) Edit(w http.ResponseWriter, r *http.Request) {\n\t// u := userContext(r.Context())\n\t// debug: dummy user\n\tctx := r.Context()\n\tu := models.UserContext(ctx)\n\tif u.IsAdmin {\n\t\tp := httptreemux.ContextParams(ctx)\n\n\t\tidParam, _ := strconv.Atoi(p[\"id\"])\n\t\tif idParam <= 0 { // conversion failed or bad input\n\t\t\tsendJSON(\"Input not valid\", http.StatusBadRequest, w)\n\t\t\treturn\n\t\t}\n\n\t\tid := uint(idParam)\n\t\ttitle := r.FormValue(\"title\")\n\t\ttext := r.FormValue(\"text\")\n\n\t\ta := models.ArticleUpdate(id, title, text)\n\t\tif a.ID == 0 { // Something went wrong\n\t\t\tsendJSON(\"Error: impossible to edit article\", http.StatusInternalServerError, w)\n\t\t\treturn\n\t\t}\n\n\t\turl := r.URL.EscapedPath()\n\t\tcache.RemoveURL(url)\n\n\t\tw.Header().Set(\"Content-Location\", url)\n\t\tsendJSON(a, http.StatusOK, w)\n\t} else {\n\t\tsendJSON(\"You are not admin\", http.StatusForbidden, w)\n\t}\n}", "func handlerView(w http.ResponseWriter, r *http.Request, title string) {\r\n\tp2, err := loadPage(title)\r\n\tif err != nil {\r\n\t\t//thiswill redirect the cliebt to the edit page so the content may be created\r\n\t\t//the http.redirect fucntion adds an HTTP status code\r\n\t\t//of fttp.statusFound(302) and a location header to the http response\r\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\r\n\t\tfmt.Println(err.Error())\r\n\t\tos.Exit(1)\r\n\t}\r\n\tfetchHTML(w, \"view\", p2)\r\n}", "func (h *MovieHandler) edit(w http.ResponseWriter, r *http.Request) {\n\t// Parse the id param from the URL and convert it into an int64.\n\tid, err := strconv.ParseInt(chi.URLParam(r, \"id\"), 10, 64)\n\tif err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Not Found\", http.StatusNotFound)\n\t\tlog.Println(\"Error:\", err)\n\t\treturn\n\t}\n\n\t// Call GetMovie to get the movie from the database.\n\tif movie, err := h.MovieService.GetMovie(id); err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Not Found\", http.StatusNotFound)\n\t\tlog.Println(\"Error:\", err)\n\t} else {\n\t\t// Render a HTML response and set status code.\n\t\trender.HTML(w, http.StatusOK, \"movie/edit.html\", movie)\n\t}\n}", "func (v FaturasResource) Edit(c buffalo.Context) error {\n\treturn c.Error(404, errors.New(\"not available\"))\n}", "func (repo *Repository) EditWikiPage(doer *User, oldWikiName, newWikiName, content, message string) error {\n\treturn repo.updateWikiPage(doer, oldWikiName, newWikiName, content, message, false)\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tdb := dbConn()\n\tnId := r.URL.Query().Get(\"id\")\n\tselDB, err := db.Query(\"SELECT * FROM Employee WHERE id=?\", nId)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\temp := Employee{}\n\tfor selDB.Next() {\n\t\tvar id int\n\t\tvar name, city string\n\t\terr = selDB.Scan(&id, &name, &city)\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\temp.Id = id\n\t\temp.Name = name\n\t\temp.City = city\n\t}\n\tgetTemplates().ExecuteTemplate(w, \"Edit\", emp)\n\tdefer db.Close()\n}", "func Edit(writer http.ResponseWriter, request *http.Request, p httprouter.Params) {\n\n\tvar TP m.Thread\n\n\t//find the thread by id and assign it to TP\n\terr := m.Threads.Find(\"_id\", p.ByName(\"id\"), &TP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the thread by ID!!\")\n\t\thttp.Redirect(writer, request, \"/home\", 302)\n\t\treturn\n\t}\n\n\tvar UP m.User\n\n\t//get the User and assign to User UP struct\n\terr = m.Users.Find(\"_id\", TP.User, &UP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the user by ID!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\t// get the list of mongo collections\n\tcoll, err := m.ShowCollectionNames(m.DB)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Get the list of Collection!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\tdashlist := m.FindDetails{\n\t\tCollectionNames: coll,\n\t\tContentDetails: &TP,\n\t\tUser: &UP,\n\t}\n\n\tvar LIP m.LogInUser\n\n\terr = m.GetLogInUser(\"User\", &LIP, request)\n\tif err != nil {\n\t\tdashlist.LogInUser = nil\n\t\tLogger.Printf(\"Failed to get the login details %v\\n\", err)\n\t} else {\n\t\tdashlist.LogInUser = &LIP\n\t}\n\n\tgenerateHTML(writer, &dashlist, \"Layout\", \"ThreadLeftSideBar\", \"ThreadTopSideBar\", \"ThreadModal\", \"ThreadEdit\")\n}", "func (t *Item) Edit(c *gin.Context) {\n\tid := c.Param(\"id\")\n\taid, err := strconv.ParseInt(id, 10, 64)\n\tif err != nil {\n\t\tc.String(500, \"%s\", err)\n\t\treturn\n\t}\n\titem, err := model.ItemOne(t.DB, aid)\n\tif err != nil {\n\t\tc.String(500, \"%s\", err)\n\t\treturn\n\t}\n\tc.HTML(http.StatusOK, \"edit.tmpl\", gin.H{\n\t\t\"item\": item,\n\t\t\"context\": c,\n\t\t\"csrf\": csrf.GetToken(c),\n\t})\n}", "func (q *QuestionnaireT) EditPage(idx int) *pageT {\n\tif idx < 0 || idx > len(q.Pages)-1 {\n\t\tlog.Panicf(\"EditPage(): %v pages - valid indexes are 0...%v\", len(q.Pages), len(q.Pages)-1)\n\t}\n\treturn q.Pages[idx]\n}", "func EditHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Edit post\")\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/view\"):]\n\tp, _ := loadPage(title)\n\trenderTemplate(w, \"edit\", p)\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\t\t// path component of the requested URL\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\t// If the page is not found, redirects the client to the EDIT page so that the content may be created.\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\t// Adds an HTTP status code of http.StatusFound (302) and a Location header to the HTTP response.\n\t\treturn\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func (ctl *SaleCounterProductController) Edit() {\n\tid := ctl.Ctx.Input.Param(\":id\")\n\tif id != \"\" {\n\t\tif idInt64, e := strconv.ParseInt(id, 10, 64); e == nil {\n\t\t\tif counterProduct, err := md.GetSaleCounterProductByID(idInt64); err == nil {\n\t\t\t\tctl.Data[\"SaleCounterProduct\"] = counterProduct\n\t\t\t\tctl.PageAction = counterProduct.SaleCounter.Name\n\t\t\t}\n\t\t}\n\t}\n\tctl.Data[\"FormField\"] = \"form-edit\"\n\tctl.Data[\"RecordID\"] = id\n\tctl.Data[\"Action\"] = \"edit\"\n\tctl.Layout = \"base/base.html\"\n\tctl.TplName = \"sale/sale_counter_product_form.html\"\n}", "func JournalEdit(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tdb, err := sql.Open(\"mysql\", connectionString)\n\tcheckErr(err)\n\n\t// query\n\trows, err := db.Query(\"SELECT title, content FROM chengshair.journal_entry WHERE idjournal_entry=?;\", vars[\"Id\"])\n\tcheckErr(err)\n\n\trows.Next()\n\tvar title string\n\tvar content string\n\terr = rows.Scan(&title, &content)\n\tcheckErr(err)\n\n\ti, err := strconv.Atoi(vars[\"Id\"])\n\ttemplates.ExecuteTemplate(w, \"edit.html\", &Entry{\n\t\tTitle: template.HTML(title),\n\t\tBody: content,\n\t\tId: i,\n\t\tContent: template.HTML(title + content)})\n\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\titem, _, err := code.ByID(c.DB, c.Param(\"id\"))\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tc.Redirect(uri)\n\t\treturn\n\t}\n\n\tv := c.View.New(\"code/edit\")\n\tc.Repopulate(v.Vars, \"amount\")\n\tv.Vars[\"item\"] = item\n\tv.Vars[\"setdate\"] = item.Trans_Datetime.Time.Format(\"2006-01-02\")\n\tv.Render(w, r)\n}", "func (r *PoolNAPTRResource) Edit(id string, item Pool) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+PoolNAPTREndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\r\n title := r.URL.Path[len(\"/view/\"):]\r\n p, err := loadPage(title)\r\n if err != nil {\r\n http.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\r\n return\r\n }\r\n renderTemplate(w, \"view\", p)\r\n}", "func EditPost(req *http.Request, params martini.Params, res render.Render) {\n\tvar post Post\n\tpost.Slug = params[\"slug\"]\n\tpost, err := post.Get()\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tres.JSON(500, map[string]interface{}{\"error\": \"Internal server error\"})\n\t\treturn\n\t}\n\tres.HTML(200, \"post/edit\", post)\n}", "func handleView(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := page.Load(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, pathEdit+title, http.StatusFound)\n\t\tlogInfo(r.URL.Path, \"redirected to edit page\")\n\t\treturn\n\t}\n\n\tp.ParseBody()\n\trender(w, \"view\", p)\n\tlogInfo(p.Title, \"file displayed\")\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\titem, _, err := summary.ByID(c.DB, c.Param(\"id\"))\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tc.Redirect(uri)\n\t\treturn\n\t}\n\n\tv := c.View.New(\"summary/edit\")\n\tc.Repopulate(v.Vars, \"name\")\n\tv.Vars[\"item\"] = item\n\tv.Render(w, r)\n}", "func (p Database) Edit(d interface{}) (string, error) {\n\tjsonBuf, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tidRev := idAndRev{}\n\tmust(json.Unmarshal(jsonBuf, &idRev))\n\tif idRev.ID == \"\" {\n\t\treturn \"\", errNoID\n\t}\n\tif idRev.Rev == \"\" {\n\t\treturn \"\", errNoRev\n\t}\n\tu := fmt.Sprintf(\"%s/%s\", p.DBURL(), url.QueryEscape(idRev.ID))\n\tir := Response{}\n\tif _, err = interact(\"PUT\", u, p.defaultHdrs, jsonBuf, &ir); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn ir.Rev, nil\n}", "func (s *Service) CmsEdit(ctx context.Context, req *model.ReqUpEdit) (err error) {\n\tvar (\n\t\tokMids map[int64]*model.UpMC\n\t\tupInfo *model.UpMC\n\t\tok bool\n\t)\n\tif okMids, err = s.dao.VerifyIds([]int64{req.MID}); err != nil {\n\t\treturn\n\t}\n\tif len(okMids) == 0 {\n\t\treturn ecode.TvUpperNotInList\n\t}\n\tif upInfo, ok = okMids[req.MID]; !ok {\n\t\tlog.Error(\"okMids %v, Mid %d, not found\", okMids, req.MID)\n\t\treturn ecode.NothingFound\n\t}\n\tif err = s.dao.SetUpper(req); err != nil { // update upper cms info in DB\n\t\treturn\n\t}\n\tupInfo.CMSFace = req.Face\n\tupInfo.CMSName = req.Name\n\terr = s.dao.SetUpMetaCache(ctx, upInfo) // update Cache\n\treturn\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\n\t\treturn\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func (s *Server) handleDashboardTestimonialEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepDel string\n\t\tStepUpd string\n\t}{\n\t\tStepDel: \"stepDel\",\n\t\tStepUpd: \"stepUpd\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"testimonial-edit.html\")\n\t\t})\n\t\tctx, provider, data, errs, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Testimonials\", provider.GetURLTestimonials()},\n\t\t\t{\"Edit Testimonial\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLTestimonials()\n\t\tdata[TplParamFormAction] = provider.GetURLTestimonialEdit()\n\t\tdata[TplParamSteps] = steps\n\t\tdata[TplParamClientView] = r.FormValue(URLParams.Client)\n\n\t\t//validate the id\n\t\tidStr := r.FormValue(URLParams.ID)\n\t\ttestimonialID := uuid.FromStringOrNil(idStr)\n\t\tif testimonialID == uuid.Nil {\n\t\t\tlogger.Warnw(\"invalid uuid\", \"id\", idStr)\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLTestimonials(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\t\t//load the testimonial\n\t\tctx, testimonial, err := LoadTestimonialByProviderIDAndID(ctx, s.getDB(), provider.Provider, &testimonialID)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"load testimonial\", \"error\", err, \"id\", testimonialID)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamTestimonial] = s.createTestimonialUI(testimonial)\n\n\t\t//prepare the confirmation modal\n\t\tdata[TplParamConfirmMsg] = GetMsgText(MsgTestimonialDelConfirm)\n\t\tdata[TplParamConfirmSubmitName] = URLParams.Step\n\t\tdata[TplParamConfirmSubmitValue] = steps.StepDel\n\n\t\t//check the method\n\t\tif r.Method == http.MethodGet {\n\t\t\tdata[TplParamCity] = testimonial.City\n\t\t\tdata[TplParamName] = testimonial.Name\n\t\t\tdata[TplParamText] = testimonial.Text\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//handle the input\n\t\tcity := r.FormValue(URLParams.City)\n\t\timgDel := r.FormValue(URLParams.ImgDel) == \"true\"\n\t\tname := r.FormValue(URLParams.Name)\n\t\ttext := r.FormValue(URLParams.Text)\n\t\tstep := r.FormValue(URLParams.Step)\n\n\t\t//prepare the data\n\t\tdata[TplParamCity] = city\n\t\tdata[TplParamName] = name\n\t\tdata[TplParamText] = text\n\n\t\t//validate the data\n\t\tform := TestimonialForm{\n\t\t\tNameForm: NameForm{\n\t\t\t\tName: name,\n\t\t\t},\n\t\t\tCity: city,\n\t\t\tText: text,\n\t\t}\n\t\tok = s.validateForm(w, r.WithContext(ctx), tpl, data, errs, form, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tvar msgKey MsgKey\n\t\tswitch step {\n\t\tcase steps.StepDel:\n\t\t\t//delete the testimonial\n\t\t\tctx, err := DeleteTestimonial(ctx, s.getDB(), provider.ID, testimonial.ID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"delete testimonial\", \"error\", err, \"id\", testimonial.ID)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgTestimonialDel\n\t\tcase steps.StepUpd:\n\t\t\t//populate from the form\n\t\t\ttestimonial.Name = form.Name\n\t\t\ttestimonial.City = form.City\n\t\t\ttestimonial.Text = form.Text\n\n\t\t\t//handle the uploaded files\n\t\t\tctx, uploadImg, err := s.processFileUploadBase64(r.WithContext(ctx), URLParams.Img, provider.FormatUserID())\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"upload file\", \"error\", err)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t//check if delete or explicitly set\n\t\t\tif uploadImg != nil {\n\t\t\t\ttestimonial.SetImg(uploadImg.GetFile())\n\t\t\t} else if imgDel {\n\t\t\t\ttestimonial.DeleteImg()\n\t\t\t}\n\n\t\t\t//update the testimonial\n\t\t\tctx, err = SaveTestimonial(ctx, s.getDB(), testimonial)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"save testimonial\", \"error\", err, \"testimonial\", testimonial)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgTestimonialEdit\n\t\tdefault:\n\t\t\tlogger.Errorw(\"invalid step\", \"id\", testimonial.ID, \"step\", step)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//success\n\t\ts.SetCookieMsg(w, msgKey, testimonial.Name)\n\t\turl := s.checkClientView(data, provider, provider.GetURLTestimonials())\n\t\thttp.Redirect(w, r.WithContext(ctx), url, http.StatusSeeOther)\n\t}\n}", "func EditArticleHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Infof(\"EditArticleHandler: %s\", r.URL.Path)\n\tid, err := getID(w, r)\n\tif err != nil {\n\t\thttp.Error(w, \"Invalid Title Name\", http.StatusNotFound)\n\t\treturn\n\t}\n\tif id == 0 {\n\t\treturn\n\t}\n\tarticle, err := GetArticle(id)\n\tif err != nil {\n\t\tarticle = &db.Article{ID: id, Title: \"Untitle\"}\n\t}\n\tRenderArticle(w, \"edit\", article)\n}", "func viewHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tlog.Println(\"viewHandler() error: \", err)\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\n\t\treturn\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func (_Content *ContentTransactor) RunEdit(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _Content.contract.Transact(opts, \"runEdit\")\n}", "func Edit(defval, prompt string, refresh func(int, int)) string {\n\treturn EditDynamicWithCallback(defval, prompt, refresh, nil)\n}", "func (t *ThreadController) Edit(c *gin.Context) {\n\n\tif err := model.ValidateParams(c, \"tid\"); err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"errors\": err,\n\t\t})\n\t\treturn\n\t}\n\n\tthread := ts.FindByID(c.Param(\"tid\"))\n\n\tc.HTML(http.StatusOK, \"thread/edit.html\", gin.H{\n\t\t\"thread\": thread,\n\t\t\"ginContext\": c,\n\t})\n}", "func (c *FwRouter) Edit(vsys string, e Entry) error {\n\tvar err error\n\n\t_, fn := c.versioning()\n\tpath := c.xpath([]string{e.Name})\n\tdata := fn(e)\n\n\tif err = c.ns.Edit(e.Name, path, data); err != nil {\n\t\treturn err\n\t}\n\n\t// Remove the virtual routers from any vsys they're currently in.\n\tif err = c.con.VsysUnimport(util.VirtualRouterImport, \"\", \"\", []string{e.Name}); err != nil {\n\t\treturn err\n\t}\n\n\t// Perform vsys import next.\n\treturn c.con.VsysImport(util.VirtualRouterImport, \"\", \"\", vsys, []string{e.Name})\n}", "func (h EditPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\n\tres := EditURLPattern.FindStringSubmatch(r.URL.Path)\n\tif res == nil {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tpostID, err := strconv.ParseInt(res[1], 10, 64)\n\tif err != nil {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tep := &EditPage{}\n\n\tuser, ok := UserFromContext(r.Context())\n\tif ok {\n\t\tep.UserName = user.Name\n\t}\n\n\tif !user.EditPostPermit {\n\t\tw.WriteHeader(http.StatusForbidden)\n\t\tep.ErrorMessage = \"Недостаточно прав для редактирования статьи\"\n\t\tErrorTemplate.Execute(w, ep)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodGet {\n\n\t\tep.Post, err = h.db.GetPostByID(postID)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error during db query for edit page: %v\\n\", err)\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(http.StatusOK)\n\n\t\th.template.Execute(w, ep)\n\t} else if r.Method == http.MethodPost {\n\t\terr = r.ParseForm()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error during edit form parse: %v\\n\", err)\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tpost := &yoradb.Post{ID: postID}\n\n\t\tpost.Title = template.HTML(r.FormValue(\"title\"))\n\t\tpost.Description = template.HTML(r.FormValue(\"description\"))\n\t\tpost.ImageURL = r.FormValue(\"imageurl\")\n\t\tpost.Annotation = template.HTML(r.FormValue(\"annotation\"))\n\t\tpost.Text = template.HTML(r.FormValue(\"posttext\"))\n\n\t\terr = h.db.UpdatePost(post)\n\t\tif err != nil {\n\t\t\tep.Post = post\n\t\t\tep.ErrorMessage = err.Error()\n\n\t\t\tlog.Printf(\"Error during update post in DB: %v\\n\", err)\n\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\th.template.Execute(w, ep)\n\n\t\t\treturn\n\t\t}\n\n\t\tredirectURL := fmt.Sprintf(\"/post/%v\", post.ID)\n\t\thttp.Redirect(w, r, redirectURL, http.StatusSeeOther)\n\t}\n}", "func UserEdit(w http.ResponseWriter, r *http.Request, u *User) error {\n\treturn RenderTemplate(w, \"user_profile.html\", struct{ User *User }{u})\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\tmv.editQuery(v, key, ch, mod)\n\treturn\n}", "func (r *VCMPResource) Edit(id string, item VCMPConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+VCMPEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (v CustomersResource) Edit(c buffalo.Context) error {\n\tcustomer := &models.Customer{}\n\n\terr := v.scope(c).Find(customer, c.Param(\"customer_id\"))\n\tif err != nil {\n\t\treturn c.Error(404, err)\n\t}\n\t// Make customer available inside the html template\n\tc.Set(\"customer\", customer)\n\n\treturn c.Render(200, r.HTML(\"customers/edit.html\"))\n}", "func (r *FeatureModuleResource) Edit(id string, item FeatureModuleConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+FeatureModuleEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *HealthResource) Edit(id string, item HealthConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+HealthEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/view/\"):]\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)// if there does not exist page:title, make a new page.\n\t\treturn\t\t\n\t}\n\trenderTemplate(w, \"view\", p)\n\t// t, _ := template.ParseFiles(\"view.html\")// return *template.Template, error\n\t// t.Execute(w,p)\n\t// fmt.Fprintf(w, \"<h1>%s</h1><div>%s</div>\", p.Title, p.Body)\n}", "func (dal *DalNavElement) Edit(ctx context.Context, tx *sql.Tx,\n\trec *coremodel.NavElement,\n) error {\n\tnow := time.Now()\n\trecord := goqu.Record{\n\t\tCoreNavElement.NaeName: rec.Name,\n\t\tCoreNavElement.NaeDescription: rec.Description,\n\t\tCoreNavElement.NaeIcon: rec.Icon,\n\t\tCoreNavElement.NaeOrder: rec.Order,\n\t\tCoreNavElement.NaeURL: rec.URL,\n\t\tCoreNavElement.NaeParentID: ZeroString(rec.ParentID),\n\t\tCoreNavElement.NaeUpdatedAt: now,\n\t\tCoreNavElement.NaeStatus: rec.Status,\n\t}\n\n\tquery := NewUpdate(T.CoreNavElement).\n\t\tSet(record).\n\t\tWhere(\n\t\t\tgoqu.C(CoreNavElement.NaeID).Eq(rec.ID),\n\n\t\t\tgoqu.C(CoreNavElement.NaeUpdatedAt).Eq(rec.UpdatedAt),\n\t\t)\n\tres, err := DoUpdate(ctx, tx, query)\n\tif err != nil {\n\t\tDebugErr(ctx, err)\n\t\treturn err\n\t}\n\trec.UpdatedAt = now\n\treturn CheckOneRowUpdated(ctx, T.CoreNavElement, res)\n}", "func (stdnt *Student) Edit(ctx context.Context) error {\n\tkey, err := datastore.DecodeKey(stdnt.ID)\n\tif err != nil {\n\t\treturn errors.New(err.Error())\n\t}\n\t_, err = datastore.Put(ctx, key, stdnt)\n\tif err != nil {\n\t\treturn errors.New(err.Error())\n\t}\n\treturn nil\n}", "func (r *DatasyncLocalProfileResource) Edit(id string, item DatasyncLocalProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+DatasyncLocalProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *OAuthProfileResource) Edit(id string, item OAuthProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+OAuthProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *Service) Edit(id alarmquote.ArticleID, a alarmquote.Article) error {\n\tif err := validate(a); err != nil {\n\t\treturn err\n\t}\n\n\tif id != a.ID {\n\t\treturn alarmquote.ErrChangeIDForbidden\n\t}\n\n\tif _, err := s.Article(id); err != nil {\n\t\treturn errors.Wrap(err, \"error retrieving when editing an article\")\n\t}\n\n\tif err := s.repo.Modify(id, a); err != nil {\n\t\treturn errors.Wrap(err, \"error editing an article\")\n\t}\n\n\treturn nil\n}", "func EditHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Received a content request. Preparing response\")\n\tresp := response{\n\t\tSuccessful: false,\n\t\tErrMsg: errors.New(\"Unknown failure\"),\n\t}\n\twriter := json.NewEncoder(w)\n\tdefer writer.Encode(resp)\n\n\t// Parse the request.\n\tfmt.Println(\"Parsing request\")\n\tdata := form{}\n\tresp.ErrMsg = json.NewDecoder(r.Body).Decode(&data)\n\n\tfmt.Println(\"Obtained following data: \")\n\tfmt.Printf(\"%+v\\n\", data)\n\n\t// Validate requestor token\n\tvalid := true\n\tvalid, resp.ErrMsg = session.Validate(data.User, data.Token)\n\n\tfilepath = path + data.ID + data.ContentType\n\n\tmodErr = update.ModifyContentFilePath(filepath)\n\twriteErr = write(filepath, data.Content)\n\tif modErr != nil {\n\t\tresp.ErrMsg = modErr\n\t} else {\n\t\tresp.ErrMsg = writeErr\n\t}\n\n}", "func (r *FPGAInfoResource) Edit(id string, item FPGAInfoConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+FPGAInfoEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (r *SSHProfileResource) Edit(id string, item SSHProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+SSHProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func EditPageQuery(db *sql.DB, blogslug string, pageslug string) (*EditPageDto, error) {\n\tsql := `\n\t\tselect Date, Show, Title, Body \n\t\tfrom pages\n\t\twhere BlogSlug = ? and PageSlug = ?\n\t`\n\trow := db.QueryRow(sql, blogslug, pageslug)\n\n\tvar date time.Time\n\tvar show bool\n\tvar title string\n\tvar body []byte\n\terr := row.Scan(&date, &show, &title, &body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &EditPageDto{\n\t\tFormattedDate: date.Format(dateFormat),\n\t\tTitle: title,\n\t\tShow: show,\n\t\tBody: body,\n\t\tBlogSlug: blogslug,\n\t\tPageSlug: pageslug,\n\t}, nil\n}", "func (t *TaskService) Edit(w http.ResponseWriter, r *http.Request) {\n\tvar (\n\t\temptyUUID gocql.UUID\n\t\ttaskIDStr = mux.Vars(r)[\"taskID\"]\n\t\tpartnerID = mux.Vars(r)[partnerIDKey]\n\t\tctx = r.Context()\n\t\tcurrentUser = t.userService.GetUser(r, t.httpClient)\n\t\tmodifiedAt = time.Now().Truncate(time.Millisecond).UTC()\n\t)\n\n\ttaskID, err := gocql.ParseUUID(taskIDStr)\n\tif err != nil || taskID == emptyUUID {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorTaskIDHasBadFormat, \"TaskService.Edit: task ID(UUID=%s) has bad format or empty. err=%v\", taskIDStr, err)\n\t\tcommon.SendBadRequest(w, r, errorcode.ErrorTaskIDHasBadFormat)\n\t\treturn\n\t}\n\n\tinputTask, err := t.extractPostTaskPayload(r, w)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tinputTask.PartnerID = partnerID\n\tinternalTasks, err := t.taskPersistence.GetByIDs(ctx, nil, inputTask.PartnerID, false, taskID)\n\tif err != nil && err != gocql.ErrNotFound {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetTaskByTaskID, \"TaskService.Edit: can not get internal tasks by Task ID %v. err=%v\", taskID, err)\n\t\tcommon.SendInternalServerError(w, r, errorcode.ErrorCantGetTaskByTaskID)\n\t\treturn\n\t}\n\n\tif len(internalTasks) == 0 {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetTaskByTaskID, \"TaskService.Edit: can not get internal tasks by Task ID %v. err=%v\", taskID, err)\n\t\tcommon.SendNotFound(w, r, errorcode.ErrorCantGetTaskByTaskID)\n\t\treturn\n\t}\n\n\ttask := internalTasks[0]\n\ttask.Schedule = inputTask.Schedule\n\ttask.Schedule.StartRunTime = task.Schedule.StartRunTime.Truncate(time.Minute)\n\ttask.Schedule.EndRunTime = task.Schedule.EndRunTime.Truncate(time.Minute)\n\ttask.ModifiedBy = currentUser.UID()\n\ttask.ModifiedAt = modifiedAt\n\ttask.DefinitionID = inputTask.DefinitionID\n\ttask.OriginID = inputTask.OriginID\n\ttask.PartnerID = partnerID\n\n\ttask.TargetsByType = inputTask.TargetsByType\n\tif task.TargetsByType == nil {\n\t\ttask.TargetsByType = make(models.TargetsByType)\n\t}\n\n\tif inputTask.Targets.Type != 0 {\n\t\ttask.TargetsByType[inputTask.Targets.Type] = inputTask.Targets.IDs\n\t}\n\n\tfor targetType, targets := range task.TargetsByType {\n\t\ttask.Targets.Type = targetType\n\t\ttask.Targets.IDs = targets\n\t}\n\n\tif len(inputTask.Parameters) > 0 {\n\t\ttask.Parameters = inputTask.Parameters\n\t}\n\n\tfor i := range internalTasks {\n\t\tinternalTasks[i].OriginalNextRunTime = time.Time{}\n\t\tif internalTasks[i].State != statuses.TaskStateDisabled {\n\t\t\tinternalTasks[i].State = statuses.TaskStateInactive\n\t\t}\n\t\tinternalTasks[i].ModifiedBy = currentUser.UID()\n\t}\n\n\tt.processEditReq(ctx, internalTasks, r, w, currentUser, task)\n}", "func (c *FwGeneral) Edit(e Config) error {\n var err error\n _, fn := c.versioning()\n c.con.LogAction(\"(edit) general settings\")\n\n path := c.xpath()\n\n _, err = c.con.Edit(path, fn(e), nil, nil)\n return err\n}", "func (a ClustersAPI) Edit(editReq httpmodels.EditReq) error {\n\t_, err := a.Client.performQuery(http.MethodPost, \"/clusters/edit\", editReq, nil)\n\treturn err\n}", "func (s *Server) handleDashboardUserEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepDel string\n\t}{\n\t\tStepDel: \"stepDel\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"user-edit.html\")\n\t\t})\n\t\tctx, provider, data, _, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Users\", provider.GetURLUsers()},\n\t\t\t{\"Edit Team Member\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLUsers()\n\t\tdata[TplParamFormAction] = provider.GetURLUserEdit()\n\t\tdata[TplParamSteps] = steps\n\n\t\t//handle the input\n\t\tidStr := r.FormValue(URLParams.UserID)\n\t\tstep := r.FormValue(URLParams.Step)\n\n\t\t//prepare the data\n\t\tdata[TplParamUserID] = idStr\n\n\t\t//load the provider user\n\t\tid := uuid.FromStringOrNil(idStr)\n\t\tif id == uuid.Nil {\n\t\t\tlogger.Warnw(\"invalid uuid\", \"id\", idStr)\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\t\tctx, providerUser, err := LoadProviderUserByProviderIDAndID(ctx, s.getDB(), provider.ID, &id)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"load provider user\", \"error\", err, \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tif providerUser == nil {\n\t\t\tlogger.Errorw(\"no provider user\", \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamUser] = providerUser\n\n\t\t//prepare the confirmation modal\n\t\tdata[TplParamConfirmMsg] = GetMsgText(MsgUserDelConfirm)\n\t\tdata[TplParamConfirmSubmitName] = URLParams.Step\n\t\tdata[TplParamConfirmSubmitValue] = steps.StepDel\n\n\t\t//check the method\n\t\tif r.Method == http.MethodGet {\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tvar msgKey MsgKey\n\t\tswitch step {\n\t\tcase steps.StepDel:\n\t\t\t//delete the provider user\n\t\t\tctx, err := DeleteUserProvider(ctx, s.getDB(), provider.ID, providerUser.ID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"delete provider user\", \"error\", err, \"id\", providerUser.ID)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgUserDel\n\t\tdefault:\n\t\t\tlogger.Errorw(\"invalid step\", \"id\", providerUser.ID, \"step\", step)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//success\n\t\ts.SetCookieMsg(w, msgKey, providerUser.Login)\n\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t}\n}", "func (r *ECMResource) Edit(id string, item ECMConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+ECMEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Edit(ctx *aero.Context) string {\n\tid := ctx.Get(\"id\")\n\tmaterial, err := mui.GetMaterial(id)\n\n\tif err != nil {\n\t\treturn ctx.Error(http.StatusNotFound, \"Material not found\")\n\t}\n\n\treturn ctx.HTML(components.EditMaterial(material))\n}", "func PageEditToBytes(edit PageEdit) ([]byte, error) {\n // Turn the edit into JSON\n editJsonBytes, err := json.Marshal(edit)\n if err != nil {\n return nil, err\n }\n\n editJson := string(editJsonBytes)\n\n // Urlencode the JSON onto one line\n escaped := url.QueryEscape(editJson)\n\n return []byte(escaped + \"\\n\"), nil\n}", "func (_LvRecording *LvRecordingTransactor) RunEdit(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _LvRecording.contract.Transact(opts, \"runEdit\")\n}", "func TasksEdit(c buffalo.Context) error {\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\n\ttask := &models.Task{}\n\terr := tx.Eager().Find(task, c.Param(\"task_id\"))\n\tif err != nil {\n\t\tc.Flash().Add(\"warning\", \"Cannot find that task.\")\n\t\treturn c.Redirect(307, \"/\")\n\t}\n\tc.Set(\"task\", task)\n\treturn c.Render(http.StatusOK, r.HTML(\"tasks/edit.html\"))\n}", "func (c *Firewall) Edit(vsys string, e Entry) error {\n\treturn c.ns.Edit(\"\", \"\", vsys, c.pather(), e)\n}", "func Alter(writer http.ResponseWriter, request *http.Request) {\n\tvar sp SanPham\n\tsp.TenSanPham = request.FormValue(\"TenSanPham\")\n\tvar Gia int\n\tfmt.Sscanf(request.FormValue(\"Gia\"), \"%d\", &Gia)\n\tsp.Gia = Gia\n\tedit(sp)\n\n\tvar listSP []SanPham\n\tlistSP = getAll()\n\ttemplate_html.ExecuteTemplate(writer, \"Home\", listSP)\n}", "func EditWebsite(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\tuser := sessions.LoggedInUser(r)\n\t\tid := strings.Split(r.RequestURI, \"/\")[2] // grab website id\n\n\t\twebsite, err := model.GetWebsiteDetail(id, user.ID)\n\t\tif err != nil {\n\t\t\t// if there are no rows in database user is not the owner\n\t\t\tif err == sql.ErrNoRows {\n\t\t\t\thttp.Redirect(w, r, \"/403\", http.StatusSeeOther)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Println(\"EditWebsite: GetWebsiteDetail:\", err)\n\t\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tmsg := addWebsiteMsg{Name: website.Name, URL: website.URL,\n\t\t\tType: \"Edit\", ShortURL: website.ShortURL}\n\t\trenderAddWebsite(w, r, msg)\n\n\t// for post request on /website/id/edit page\n\tcase \"POST\":\n\t\tuser := sessions.LoggedInUser(r)\n\t\tid := strings.Split(r.RequestURI, \"/\")[2] // grab website id\n\n\t\terr := r.ParseForm()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\twebsite, err := model.GetWebsiteDetail(id, user.ID)\n\t\tif err != nil {\n\t\t\tif err == sql.ErrNoRows {\n\t\t\t\thttp.Redirect(w, r, \"/403\", http.StatusForbidden)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Println(err)\n\t\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tname := r.Form[\"name\"][0]\n\t\turl := r.Form[\"url\"][0]\n\t\tnewShortURL := r.Form[\"shortURL\"][0]\n\t\tnewData := model.Website{Name: name, URL: url, ShortURL: newShortURL}\n\t\tmsg := addWebsiteMsg{Name: name, URL: url, ShortURL: newShortURL, Type: \"Edit\"}\n\n\t\tif len(newShortURL) > 8 {\n\t\t\tmsg.ErrorShortURL = \"Short URL should be max 8 characters long\"\n\t\t\trenderAddWebsite(w, r, msg)\n\t\t\treturn\n\t\t}\n\n\t\terr = model.EditWebsite(user.ID, website, newData)\n\t\tif err != nil {\n\t\t\tif err == model.ErrorShortURLExist {\n\t\t\t\tmsg.ErrorShortURL = \"This short url already exist in db, please pick another one\"\n\t\t\t\trenderAddWebsite(w, r, msg)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfmt.Println(\"Edit Website:\", err)\n\t\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\t// successfully updated, redirect to dashboard\n\t\thttp.Redirect(w, r, \"/dashboard\", http.StatusSeeOther)\n\t}\n}", "func (vr *VirtualResource) Edit(id string, item VirtualServerConfig) error {\n\tresp, err := vr.doRequest(\"PUT\", id, item)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif err := vr.readError(resp); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\treturn\n}", "func (mv *MainView) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {\n\treturn\n}", "func (s *Server) handleDashboardFaqEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepDel string\n\t\tStepUpd string\n\t}{\n\t\tStepDel: \"stepDel\",\n\t\tStepUpd: \"stepUpd\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"faq-edit.html\")\n\t\t})\n\t\tctx, provider, data, errs, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"FAQs\", provider.GetURLFaqs()},\n\t\t\t{\"Edit FAQ\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLFaqs()\n\t\tdata[TplParamFormAction] = provider.GetURLFaqEdit(nil)\n\t\tdata[TplParamSteps] = steps\n\t\tdata[TplParamClientView] = r.FormValue(URLParams.Client)\n\n\t\t//validate the id\n\t\tidStr := r.FormValue(URLParams.ID)\n\t\tfaqID := uuid.FromStringOrNil(idStr)\n\t\tif faqID == uuid.Nil {\n\t\t\tlogger.Warnw(\"invalid uuid\", \"id\", idStr)\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLFaqs(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\t\t//load the faq\n\t\tctx, faq, err := LoadFaqByProviderIDAndID(ctx, s.getDB(), provider.Provider, &faqID)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"load faq\", \"error\", err, \"id\", faqID)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamFaq] = s.createFaqUI(faq)\n\n\t\t//prepare the confirmation modal\n\t\tdata[TplParamConfirmMsg] = GetMsgText(MsgFaqDelConfirm)\n\t\tdata[TplParamConfirmSubmitName] = URLParams.Step\n\t\tdata[TplParamConfirmSubmitValue] = steps.StepDel\n\n\t\t//check the method\n\t\tif r.Method == http.MethodGet {\n\t\t\tdata[TplParamName] = faq.Question\n\t\t\tdata[TplParamText] = faq.Answer\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//handle the input\n\t\tname := r.FormValue(URLParams.Name)\n\t\tstep := r.FormValue(URLParams.Step)\n\t\ttext := r.FormValue(URLParams.Text)\n\n\t\t//prepare the data\n\t\tdata[TplParamName] = name\n\t\tdata[TplParamText] = text\n\n\t\t//validate the data\n\t\tform := FaqForm{\n\t\t\tQuestion: name,\n\t\t\tAnswer: text,\n\t\t}\n\t\tok = s.validateForm(w, r.WithContext(ctx), tpl, data, errs, form, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tvar msgKey MsgKey\n\t\tswitch step {\n\t\tcase steps.StepDel:\n\t\t\t//delete the faq\n\t\t\tctx, err := DeleteFaq(ctx, s.getDB(), provider.ID, faq.ID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"delete faq\", \"error\", err, \"id\", faq.ID)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgFaqDel\n\t\tcase steps.StepUpd:\n\t\t\t//populate from the form\n\t\t\tfaq.Question = form.Question\n\t\t\tfaq.Answer = form.Answer\n\n\t\t\t//update the faq\n\t\t\tctx, err = SaveFaq(ctx, s.getDB(), faq)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"save testimonial\", \"error\", err, \"faq\", faq)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgFaqEdit\n\t\tdefault:\n\t\t\tlogger.Errorw(\"invalid step\", \"id\", faq.ID, \"step\", step)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//success\n\t\ts.SetCookieMsg(w, msgKey)\n\t\turl := s.checkClientView(data, provider, provider.GetURLFaqs())\n\t\thttp.Redirect(w, r.WithContext(ctx), url, http.StatusSeeOther)\n\t}\n}", "func EditViewByID(rootView View, id string) EditView {\n\tif view := ViewByID(rootView, id); view != nil {\n\t\tif buttons, ok := view.(EditView); ok {\n\t\t\treturn buttons\n\t\t}\n\t\tErrorLog(`EditViewByID(_, \"` + id + `\"): The found View is not EditView`)\n\t}\n\treturn nil\n}", "func editFormHandler(w http.ResponseWriter, r *http.Request) *appError {\n\tvideo, err := videoFromRequest(r)\n\tif err != nil {\n\t\treturn appErrorf(err, \"%v\", err)\n\t}\n\n\treturn editTmpl.Execute(w, r, video)\n}", "func (r *MonitorNoneResource) Edit(id string, item MonitorNone) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+MonitorNoneEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func test(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\t//title := \"edit\"\n\ttype data struct {\n\t\tTitle string\n\t\tBody string\n\t}\n\t//dataVal := data{\"hello\",\"test\"}\n\tt, _ := template.ParseFiles(\"edit.html\")\n\tt.Execute(w, nil)\n}", "func (c HTTPClient) Edit(id, title, message string, duration time.Duration) ([]byte, error) {\n\tres := []byte(`response for Edit reminder`)\n\treturn res, nil\n}", "func NewEdit(idd uintptr) *Edit {\n\treturn &Edit{WindowBase: WindowBase{idd: idd}}\n}", "func EditBlogHandler(db *sql.DB, tmpl ExecuteTemplateFunc) http.HandlerFunc {\n\treturn handleErrors(func(w http.ResponseWriter, r *http.Request) error {\n\t\tblogslug := mux.Vars(r)[\"blogslug\"]\n\t\tblog, err := EditBlogQuery(db, blogslug)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn tmpl(w, \"editblog.html\", blog)\n\t})\n}", "func (s *Server) handleDashboardBookingEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepConfirm string\n\t\tStepUpd string\n\t\tStepUpdAll string\n\t}{\n\t\tStepConfirm: \"stepConfirm\",\n\t\tStepUpd: \"stepUpd\",\n\t\tStepUpdAll: \"stepUpdAll\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"order-edit.html\")\n\t\t})\n\t\tctx, provider, data, errs, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, false)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamActiveNav] = provider.GetURLBookings()\n\t\tdata[TplParamFormAction] = provider.GetURLBookingEdit()\n\t\tdata[TplParamSteps] = steps\n\n\t\t//handle the input\n\t\tcode := r.FormValue(URLParams.Code)\n\t\tdateStr := r.FormValue(URLParams.Date)\n\t\tdesc := r.FormValue(URLParams.Desc)\n\t\tidStr := r.FormValue(URLParams.BookID)\n\t\tlocation := r.FormValue(URLParams.Location)\n\t\tsvcIDStr := r.FormValue(URLParams.SvcID)\n\t\tstep := r.FormValue(URLParams.Step)\n\t\ttimeStr := r.FormValue(URLParams.Time)\n\t\ttimeZone := provider.User.TimeZone\n\n\t\t//load the booking\n\t\tctx, book, ok := s.loadTemplateBook(w, r.WithContext(ctx), tpl, data, errs, idStr, true, false)\n\t\tif !ok {\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLBookings(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\t\t//check permissions\n\t\tok = s.checkOwner(w, r.WithContext(ctx), provider, book)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//default if not set or if client-created\n\t\tif svcIDStr == \"\" || book.ClientCreated {\n\t\t\tsvcIDStr = book.Service.ID.String()\n\t\t}\n\t\tif dateStr == \"\" || book.ClientCreated {\n\t\t\tdateStr = FormatDateLocal(book.TimeFrom, timeZone)\n\t\t}\n\t\tif timeStr == \"\" || book.ClientCreated {\n\t\t\ttimeStr = strconv.FormatInt(book.TimeFrom.Unix(), 10)\n\t\t}\n\n\t\t//prepare the data\n\t\tdata[TplParamCode] = code\n\t\tdata[TplParamDate] = dateStr\n\t\tdata[TplParamDesc] = desc\n\t\tdata[TplParamLocation] = location\n\t\tdata[TplParamRecurrenceFreq] = book.FormatRecurrenceFreq()\n\t\tdata[TplParamSvcID] = svcIDStr\n\t\tdata[TplParamTime] = timeStr\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Orders\", provider.GetURLBookings()},\n\t\t\t{\"Edit Order\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\n\t\t//load the services\n\t\tctx, svcs, ok := s.loadTemplateServices(w, r.WithContext(ctx), tpl, data, provider)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//find the service in the list\n\t\tvar svc *serviceUI\n\t\tfor _, s := range svcs {\n\t\t\tif s.ID.String() == svcIDStr {\n\t\t\t\tsvc = s\n\t\t\t}\n\t\t}\n\t\tif svc == nil {\n\t\t\tlogger.Errorw(\"invalid service id\", \"id\", book.Service.ID)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamSvc] = svc\n\n\t\t//check the method\n\t\tnow := data[TplParamCurrentTime].(time.Time)\n\t\tif r.Method == http.MethodGet {\n\t\t\t//load the service times\n\t\t\tctx, svcStartDate, _, svcTimes, ok := s.loadTemplateServiceTimes(w, r.WithContext(ctx), tpl, data, errs, provider, svc, dateStr, now, false)\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsvcStartDateStr := FormatDateLocal(svcStartDate, timeZone)\n\t\t\tdata[TplParamSvcStartDate] = svcStartDateStr\n\t\t\tdata[TplParamSvcBusyTimes] = svcTimes\n\n\t\t\t//default the date if necessary\n\t\t\tif dateStr == \"\" {\n\t\t\t\tdateStr = svcStartDateStr\n\t\t\t\tdata[TplParamDate] = dateStr\n\t\t\t}\n\t\t\tdata[TplParamCode] = book.CouponCode\n\t\t\tdata[TplParamDesc] = book.ProviderNote\n\t\t\tdata[TplParamLocation] = book.Location\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tchangeAllFollowing := false\n\t\tswitch step {\n\t\tcase steps.StepUpdAll:\n\t\t\tchangeAllFollowing = true\n\t\t\tfallthrough\n\t\tcase steps.StepUpd:\n\t\t\t//no edits allowed for captured bookings\n\t\t\tif !book.IsEditable(now) {\n\t\t\t\thttp.Redirect(w, r.WithContext(ctx), book.GetURLView(), http.StatusSeeOther)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t//validate the booking\n\t\t\tform := &ClientBookingForm{\n\t\t\t\tServiceID: svcIDStr,\n\t\t\t\tClientID: book.Client.ID.String(),\n\t\t\t\tEmail: book.Client.Email,\n\t\t\t\tName: book.Client.Name,\n\t\t\t\tPhone: book.Client.Phone,\n\t\t\t\tProviderNote: desc,\n\t\t\t\tProviderNoteSet: true,\n\t\t\t\tClientCreated: book.ClientCreated,\n\t\t\t\tConfirmed: true,\n\t\t\t\tLocation: location,\n\t\t\t\tClientBookingDateTimeForm: ClientBookingDateTimeForm{\n\t\t\t\t\tTimeUnixForm: TimeUnixForm{\n\t\t\t\t\t\tTime: timeStr,\n\t\t\t\t\t},\n\t\t\t\t\tTimeZoneForm: TimeZoneForm{\n\t\t\t\t\t\tTimeZone: timeZone,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tCode: code,\n\t\t\t}\n\t\t\tok = s.validateForm(w, r.WithContext(ctx), tpl, data, errs, form, true)\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t//update the booking\n\t\t\tbook, ok = s.saveBooking(w, r.WithContext(ctx), tpl, data, errs, provider, book.ProviderUser, svc, book, now, changeAllFollowing, form, false)\n\t\t\tif !ok {\n\t\t\t\treturn\n\t\t\t}\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLBookingEditSuccess(book.ID), http.StatusSeeOther)\n\t\t\treturn\n\t\tcase steps.StepConfirm:\n\t\t\tif !book.Confirmed {\n\t\t\t\t//validate the note\n\t\t\t\tform := &ClientConfirmForm{\n\t\t\t\t\tText: desc,\n\t\t\t\t\tCode: code,\n\t\t\t\t}\n\t\t\t\tok = s.validateForm(w, r.WithContext(ctx), tpl, data, errs, form, true)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t//mark the booking confirmed\n\t\t\t\tbook.SetCouponCode(form.Code)\n\t\t\t\tbook.SetProviderNote(form.Text)\n\t\t\t\tctx, err := MarkBookingConfirmed(ctx, s.getDB(), svc.Service, book.Booking, now)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogger.Errorw(\"confirm booking\", \"error\", err)\n\t\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t//queue the emails\n\t\t\t\tctx, err = s.queueEmailsBookingConfirm(ctx, book)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogger.Errorw(\"queue email booking confirm\", \"error\", err)\n\t\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLBookingEditSuccess(book.ID), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\t\tlogger.Errorw(\"invalid step\", \"id\", book.ID, \"step\", step)\n\t\tdata[TplParamErr] = GetErrText(Err)\n\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\treturn\n\t}\n}", "func (r *DOSProfileDOSNetworkResource) Edit(id string, item DOSProfileDOSNetworkConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+DOSProfileDOSNetworkEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (wh *Webhook) Edit(webhookId string, accountId string, data map[string]interface{}, extraHeaders map[string]string) (map[string]interface{}, error) {\n\tif accountId != \"\" {\n\t\turl := fmt.Sprintf(\"/%s%s/%s%s/%s\", constants.VERSION_V2, constants.ACCOUNT_URL, url.PathEscape(accountId), constants.WEBHOOK, url.PathEscape(webhookId))\n\t\treturn wh.Request.Patch(url, data, extraHeaders)\n\t}\n\turl := fmt.Sprintf(\"/%s%s/%s\", constants.VERSION_V1, constants.WEBHOOK, url.PathEscape(accountId))\n\treturn wh.Request.Put(url, data, extraHeaders)\n}", "func FAQEditViewRender(w http.ResponseWriter, r *http.Request) {\n\tsID := r.FormValue(\"id\")\n\tif sID == \"\" {\n\t\tlog.Error(\"Form value not have id\")\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tid, err := strconv.Atoi(sID)\n\tif err != nil {\n\t\tlog.Error(\"Error convert Id from string to int \" + err.Error())\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfaq, err := db.GetFAQByID(id)\n\tif err == NotFound {\n\t\tlog.Error(\"Get FAQ error \" + err.Error())\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t} else if err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t//log.Error(faq)\n\n\tfaqs := []db.FAQ{faq}\n\n\tvar result = make(map[string]interface{})\n\n\tresult[\"faq\"] = faqs\n\n\ttplHelper.Render(w, \"edit\", result)\n}", "func (s *Action) Edit(c *cli.Context) error {\n\tctx := ctxutil.WithGlobalFlags(c)\n\tname := c.Args().First()\n\tif name == \"\" {\n\t\treturn exit.Error(exit.Usage, nil, \"Usage: %s edit secret\", s.Name)\n\t}\n\n\tif err := hook.Invoke(ctx, \"edit.pre-hook\", name); err != nil {\n\t\treturn exit.Error(exit.Hook, err, \"edit.pre-hook failed: %s\", err)\n\t}\n\n\tif err := s.Store.CheckRecipients(ctx, name); err != nil {\n\t\treturn exit.Error(exit.Recipients, err, \"Invalid recipients detected: %s\", err)\n\t}\n\n\tif err := s.edit(ctx, c, name); err != nil {\n\t\treturn err\n\t}\n\n\treturn hook.InvokeRoot(ctx, \"edit.post-hook\", name, s.Store)\n}", "func (c *client) Edit(filename string, update bool, filter Filter) error {\n\tif filename == \"-\" {\n\t\treturn EditStream(c.o.InStream, c.o.OutStream, filename, filter)\n\t}\n\n\tif update {\n\t\treturn UpdateFile(filename, filter)\n\t}\n\n\treturn ReadFile(filename, c.o.OutStream, filter)\n}", "func Edit(c *gin.Context) {\n\tid, err := strconv.Atoi(c.Param(\"id\"))\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\tvar json utils.WishlistItem\n\tif err := c.ShouldBindJSON(&json); err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\terr = utils.EditItem(id, json)\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t\treturn\n\t}\n\tc.JSON(200, gin.H{\"status\": \"Item updated\"})\n}" ]
[ "0.75582063", "0.75402147", "0.7427725", "0.7361682", "0.7335997", "0.7325859", "0.71529", "0.7121132", "0.7109892", "0.70804507", "0.7028085", "0.6797492", "0.6783623", "0.66810155", "0.6630552", "0.659135", "0.6569401", "0.6555289", "0.65096617", "0.65096617", "0.63843006", "0.636572", "0.6292612", "0.62445873", "0.62425935", "0.6202101", "0.6135293", "0.6125715", "0.6094047", "0.60835177", "0.6070545", "0.60392994", "0.5980671", "0.5954642", "0.5897711", "0.5872089", "0.58622044", "0.5844349", "0.58104426", "0.5694995", "0.5678423", "0.56740403", "0.56549966", "0.56193423", "0.55657625", "0.5561059", "0.54937476", "0.54923195", "0.5477035", "0.546933", "0.546494", "0.5438388", "0.539575", "0.5386216", "0.5379896", "0.5347772", "0.5345229", "0.53344923", "0.532921", "0.53234607", "0.53202593", "0.53058326", "0.53026795", "0.5283051", "0.52808845", "0.5271234", "0.5260219", "0.5238054", "0.5236788", "0.5217712", "0.52145094", "0.52111375", "0.52002233", "0.5199201", "0.5189521", "0.5187777", "0.51789236", "0.5165967", "0.5155458", "0.5146517", "0.5141183", "0.5140785", "0.51333654", "0.51305705", "0.51305705", "0.5129738", "0.5112847", "0.5110651", "0.5105611", "0.50854725", "0.50821733", "0.50694686", "0.5069101", "0.505022", "0.5050007", "0.5047969", "0.50436467", "0.5038259", "0.5022406", "0.50150627" ]
0.7584963
0
LoadUsersPage Load users page
func LoadUsersPage(w http.ResponseWriter, r *http.Request) { nameOrNick := strings.ToLower(r.URL.Query().Get("user")) url := fmt.Sprintf("%s/users?usuario=%s", config.APIURL, nameOrNick) response, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil) if err != nil { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()}) return } defer response.Body.Close() if response.StatusCode >= 400 { responses.TreatStatusCode(w, response) return } var users []models.User if err := json.NewDecoder(response.Body).Decode(&users); err != nil { responses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()}) return } utils.RunTemplate(w, "users.html", users) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func LoadUserPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"userId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserIDLogged, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tif userID == userIDLogged {\n\t\thttp.Redirect(w, r, \"/profile\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"user.html\", struct {\n\t\tUser models.User\n\t\tUserLoggedID uint64\n\t}{\n\t\tUser: user,\n\t\tUserLoggedID: userIDLogged,\n\t})\n}", "func (d *webData) showUsersWeb(w http.ResponseWriter, r *http.Request) {\n\tp := storage.QueryAllUserInfo(d.PDB)\n\terr := d.tpl.ExecuteTemplate(w, \"showUserCompletePage\", p)\n\tif err != nil {\n\t\tlog.Println(\"showUsersWeb: template execution error = \", err)\n\t}\n\tfmt.Fprint(w, err)\n}", "func LoadUserEditPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tchannel := make(chan models.User)\n\n\tgo models.GetUserData(channel, userID, r)\n\n\tuser := <-channel\n\tif user.ID == 0 {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: \"Erro ao buscar o usuário\"})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-profile.html\", user)\n}", "func GetUsersPage(resp http.ResponseWriter, req *http.Request) {\n\tpage := request.MapPage(mux.Vars(req))\n\tstart := page.GetPage() * page.GetSize()\n\tend := start + page.GetSize()\n\n\tif end > len(users) {\n\t\tend = len(users)\n\t}\n\n\tvar content []interface{}\n\tif page.GetSize() > 0 && start < len(users) {\n\t\tcontent = append(content, users[start:end])\n\t}\n\n\tresult := response.BuildPage(&content, page, int64(len(users)))\n\n\tresponse.WriteJSON(http.StatusOK, result, resp)\n}", "func (s *peerRESTServer) LoadUsersHandler(w http.ResponseWriter, r *http.Request) {\n\tif !s.IsValid(w, r) {\n\t\ts.writeErrorResponse(w, errors.New(\"Invalid request\"))\n\t\treturn\n\t}\n\n\terr := globalIAMSys.Load()\n\tif err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tw.(http.Flusher).Flush()\n}", "func (h *handler) Users(w http.ResponseWriter, r *http.Request) {\n\tapiReq, err := http.NewRequest(\"GET\", h.serverAddress+\"/users\", nil)\n\tif err != nil {\n\t\tserverError(w, err)\n\t\treturn\n\t}\n\n\tclient := &http.Client{}\n\tres, err := client.Do(apiReq)\n\tif err != nil {\n\t\tserverError(w, err)\n\t\treturn\n\t}\n\tdefer res.Body.Close()\n\n\tvar uis []socialnet.UserItem\n\terr = json.NewDecoder(res.Body).Decode(&uis)\n\tif err != nil {\n\t\tserverError(w, err)\n\t\treturn\n\t}\n\n\terr = h.template.ExecuteTemplate(w, \"users.html\", uis)\n\tif err != nil {\n\t\tserverError(w, fmt.Errorf(\"failed to execute template users.html: %s\", err))\n\t\treturn\n\t}\n}", "func userPage(w http.ResponseWriter, r *http.Request){\n\tisLogged, name := CheckLoginStatus(w,r)\n\n\tif isLogged {\n\t\terr := templ.ExecuteTemplate(w, \"userHome\", name)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t} else {\n\t\thttp.Redirect(w,r,\"/unauthorized\",http.StatusSeeOther)\n\t}\n}", "func ViewUsers(w http.ResponseWriter, r *http.Request) { \n AuthorizePages(w,r) \n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewUsers.html\")\n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n userId := UserIds{\n UserId: r.FormValue(\"userId\"),\n }\n\n var successMessage string\n var isShow bool \n\n if (userId.UserId != \"\" ) {\n if (dbquery.DeleteManagerUser(\"User\",userId.UserId)){\n isShow = true\n successMessage = \"User Deleted Successfully\"\n }\n }\n\n var userList []helpers.User \n userList = dbquery.GetUserByRole(\"\",\"'User'\")\n t.Execute(w, AllUsersResponse{Users: userList, SuccessMessage: successMessage, IsShow: isShow}) \n}", "func ShowUsers(baseURL string) int {\n\tif utils.LoginCheck() {\n\t\t// HTTP\n\t\tt := utils.GetToken()\n\t\tclient := &http.Client{}\n\t\treq, _ := http.NewRequest(\"GET\", baseURL+\"/v1/users?token=\"+t, nil)\n\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\tutils.PrintError(err.Error())\n\t\t}\n\n\t\tdefer resp.Body.Close()\n\t\tbody, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tutils.PrintError(err.Error())\n\t\t}\n\n\t\tr := &UserList{}\n\t\terr = json.Unmarshal([]byte(string(body)), &r)\n\t\tif err != nil {\n\t\t\tutils.PrintError(err.Error())\n\t\t}\n\n\t\tif resp.StatusCode == 200 {\n\t\t\tfor i := 0; i < len(r.Data); i++ {\n\t\t\t\tprintUser(r.Data[i])\n\t\t\t}\n\t\t\treturn 0\n\t\t}\n\n\t\tif resp.StatusCode == 401 {\n\t\t\tfmt.Println(r.Message)\n\t\t\treturn 1\n\t\t}\n\n\t\treturn 1\n\t} else {\n\t\tfmt.Println(\"Please Login First\")\n\t\treturn 1\n\t}\n}", "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func (h *userHandler) showUsers(ctx context.Context, rw http.ResponseWriter) {\n\n\tusers, err := h.serv.DB.UserCol.FindAll(ctx)\n\n\tif err != nil {\n\n\t\th.serv.writeResponse(ctx, rw, err.Error(), http.StatusBadRequest, nil)\n\n\t\treturn\n\t}\n\n\th.serv.writeResponsePlus(ctx, rw, \"users\", http.StatusOK, nil, users)\n}", "func LitUsersUnderHim(w http.ResponseWriter, r *http.Request) { \n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/listUsersUnderHim.html\")\n\n userDetails := getSession(r)\n\n AuthorizePages(w,r)\n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n if err != nil {\n fmt.Println(err)\n }\n var userList []helpers.User\n var listLen int\n var failedMessage string\n var isShow bool = false\n\n userList = dbquery.GetUserByMngrList(userDetails.UserId)\n listLen = len(userList);\n\n if listLen == 0 {\n isShow = true\n failedMessage = \"Currently you are not assigned for any User\"\n } \n\n t.Execute(w, AllUsersResponse{Users: userList, ListLen: listLen, FailedMessage: failedMessage, IsShow: isShow}) \n}", "func UsersShow(c buffalo.Context) error {\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\n\tuser := &models.User{}\n\terr := tx.Eager(\"Contracts.Boss\").Find(user, c.Param(\"user_id\"))\n\tif err != nil {\n\t\tc.Flash().Add(\"warning\", \"Cannot find that user.\")\n\t\treturn c.Redirect(307, \"/\")\n\t}\n\n\tc.Set(\"user\", user)\n\treturn c.Render(http.StatusOK, r.HTML(\"users/show.html\"))\n}", "func LoadDemoUsers(s storage.Store) {\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Fake Mike\", \"NaN\"))\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Test Mike\", \"123-456-7890\"))\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Test User\", \"555-555-5555\"))\n}", "func LoadPage(c *fiber.Ctx, login string, roles []int) error {\n\tquerypack.INFO.Roles = roles\n\tquerypack.INFO.Login = login\n\tquerypack.INFO.LoggedIn = true\n\tc.Method(\"GET\")\n\tc.Path(querypack.INFO.URL)\n\tquerypack.AddCookie(c)\n\treturn c.Next()\n}", "func ViewUsers(w http.ResponseWriter, r *http.Request) error {\n if r.Method == \"GET\" {\n myUid, err0 := GetMyUserId(r)\n if err0 != nil {\n return err0\n }\n ctx1, _ := context.WithTimeout(context.Background(), constant.ContextTimeoutDuration)\n response, err := BackendClientIns.FindAllUsers(ctx1, &FindAllUsersRequest{})\n if err != nil {\n return err\n }\n allUsers := response.Users\n newUserList := make([]user, 0)\n for _, value := range allUsers {\n if value.UserId == myUid { // Exclude myself\n continue\n }\n ctx, _ := context.WithTimeout(context.Background(), constant.ContextTimeoutDuration)\n responseFromWhetherFollowing, _ := BackendClientIns.UserCheckWhetherFollowing(ctx,\n &UserCheckWhetherFollowingRequest{\n SourceUserId: myUid,\n TargetUserId: value.UserId,\n })\n newUserList = append(newUserList, user{Name: value.UserName,\n Followed: responseFromWhetherFollowing.Ok,\n Id: strconv.Itoa(int(value.UserId))})\n }\n view := viewUserView{\n UserList: newUserList,\n }\n log.Println(view.UserList)\n t, _ := template.ParseFiles(constant.RelativePathForTemplate + \"users.html\")\n w.Header().Set(\"Content-Type\", \"text/html\")\n t.Execute(w, view)\n }\n return nil\n}", "func showUsers(ctx context.Context, client *api.Client, path string, ifModifiedSince *string, ifNoneMatch *string) (*http.Response, error) {\n\treq, err := newShowUsersRequest(ctx, client, path, ifModifiedSince, ifNoneMatch)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client.Do(ctx, req)\n}", "func LoadUserLoggedProfile(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"profile.html\", user)\n\n}", "func (d *webData) addUsersWeb(w http.ResponseWriter, r *http.Request) {\n\terr := d.tpl.ExecuteTemplate(w, \"addUserCompletePage\", \"some data\")\n\tif err != nil {\n\t\tlog.Println(\"addUsersWeb: template execution error = \", err)\n\t}\n\n\tr.ParseForm()\n\tu := storage.User{}\n\tgetFormValuesUserInfo(&u, r)\n\n\tif u.FirstName != \"\" {\n\t\tpid, _ := storage.QueryForLastUID(d.PDB)\n\t\t//increment the user index nr by one for the new used to add\n\t\tpid++\n\t\tfmt.Println(\"------pid ---------- = \", pid)\n\t\tprintln(\"addUsersWeb: UID = \", pid)\n\t\tu.Number = pid\n\t\tstorage.AddUser(d.PDB, u)\n\t}\n}", "func UsersShow(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tid := params[\"id\"]\n\tuserID, _ := strconv.Atoi(id)\n\n\tuser, err := models.UserFindByID(userID)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusNotFound, err.Error())\n\n\t\treturn\n\t}\n\n\tresponse := Response{\n\t\t\"user\": user,\n\t}\n\trespondWithJSON(w, http.StatusOK, response)\n}", "func LoadUserData(id int) error{\n\n\tuserPos, err := findUser(id)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Errorf(\"Error: \",err.Error())\n\t\treturn err\n\t}\n\n\tloadUserDataAt(userPos)\n\n\treturn nil\n}", "func loadPage(pn string, r *http.Request) (*Page, error) {\n\tdata := &Page{\n\t\tPageName: pn,\n\t}\n\n\t/* Get user name for filling in template too */\n\tsesh, _ := store.Get(r, \"loginSession\")\n\tuname, ok := sesh.Values[\"username\"].(string)\n\tif !ok {\n\t\treturn nil, &ClientSafeError{Msg: \"invalid username\"}\n\t}\n\tdata.Username = uname\n\t/* get user's role */\n\trole, err := getRoleNum(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch role {\n\tcase FACILITATOR:\n\t\tdata.Role = \"Facilitator\"\n\t\tdata.Messages, err = getNotifications(data.Username)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase TEACHER:\n\t\tdata.Role = \"Teacher\"\n\tcase ADMIN:\n\t\tdata.Role = \"Admin\"\n\tdefault:\n\t\treturn nil, &ClientSafeError{Msg: \"insufficient access rights\"}\n\t}\n\n\treturn data, nil\n}", "func ShowUser(w http.ResponseWriter, r *http.Request) {\n\tAddCors(&w)\n\n\tfmt.Printf(\"IN SHOW USER\")\n\t//pass in user ID from somewhere, try to get from url, maybe in a form when the link is hit\n\tuserInfo := pg.ReturnUser(1)\n\tfmt.Printf(\"IN SHOW USER2\")\n\t//Encode writes the JSON encoding of userInfo to the stream\n\tjson.NewEncoder(w).Encode(userInfo)\n\tfmt.Printf(\"IN SHOW USER3\")\n\t//returns json encoding of the data\n\tpagesJson, err := json.Marshal(userInfo)\n\tfmt.Printf(\"IN SHOW USER4\")\n\tif err != nil {\n\t\tlog.Fatal(\"Cannot encode to JSON \", err)\n\t}\n\n\tfmt.Printf(\"%s\", pagesJson)\n}", "func UsersGet(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tlog.Println(\"starting retrieval\")\n\tstart := 0\n\tlimit := 10\n\n\tnext := start + limit\n\n\tw.Header().Set(\"Pragma\", \"no-cache\")\n\tw.Header().Set(\"Link\", \"<http://localhost:8080/api/users?start=\"+string(next)+\"; rel=\\\"next\\\"\")\n\n\trows, _ := database.Query(\"SELECT * FROM users LIMIT 10\")\n\n\tusers := Users{}\n\n\tfor rows.Next() {\n\t\tuser := User{}\n\t\trows.Scan(&user.ID, &user.Username, &user.First, &user.Last, &user.Email)\n\t\tusers.Users = append(users.Users, user)\n\t}\n\n\toutput, err := json.Marshal(users)\n\tif err != nil {\n\t\tfmt.Fprintln(w, \"Something went wrong while processing your request: \", err)\n\t}\n\n\tfmt.Fprintln(w, string(output))\n}", "func FetchUsers(page int) ([]User, error) {\n\tclient := &http.Client{}\n\tURL := fmt.Sprintf(\"%s?page=%d\", baseURL, page)\n\treq, _ := http.NewRequest(\"GET\", URL, nil)\n\tres, err := client.Do(req)\n\t//res, err := client.Get(URL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tusdata := &CollectionData{}\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = json.Unmarshal(body, usdata)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn usdata.Users, nil\n}", "func ajaxUsers(r *http.Request) ([]byte, error) {\n\tm := bson.M{}\n\tif n, e := webutil.String(r, \"name\"); e == nil {\n\t\tm[db.ID] = n\n\t}\n\tu, e := db.Users(m)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\treturn util.JSON(map[string]interface{}{\"users\": u})\n}", "func userShow(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tvars := mux.Vars(r)\n\tmember := cleanInput(vars[\"member\"])\n\tdb := co.DbConnection(dbc)\n\tstmtQryNm, err := db.Prepare(\"SELECT user_name, email, display_name FROM members where user_name = ? ;\")\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n\tresults, err := stmtQryNm.Query(member)\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n var users []userInfo\n\tfor results.Next() {\n\t\tvar user userInfo\n\t\terr = results.Scan(&user.Name, &user.Email, &user.Display)\n\t\tif err != nil {\n\t\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t\t}\n \tusers = append(users, user)\n\t}\n\tresults.Close()\n stmtQryNm.Close()\n\tdb.Close()\n\tjsonPrintUser(w, users)\n return\n}", "func LoadViewCreateUser(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"register.html\", nil)\n}", "func userRolesShowPage(httpresponsewriter http.ResponseWriter, httprequest *http.Request) {\n\n\tsecurity.UserRolesShowPage(httpresponsewriter, httprequest, redisclient)\n}", "func GetUsers(write http.ResponseWriter, request *http.Request) {\n\n\ttypeUser := request.URL.Query().Get(\"type\")\n\tpage := request.URL.Query().Get(\"page\")\n\tsearch := request.URL.Query().Get(\"search\")\n\n\tpagTemp, err := strconv.Atoi(page)\n\tif err != nil {\n\t\thttp.Error(write, \"Page value should be greater than 0\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tpag := int64(pagTemp)\n\n\tresult, status := bd.GetUsers(IDUser, pag, search, typeUser)\n\tif status == false {\n\t\thttp.Error(write, \"Error GetUsers\", http.StatusBadRequest)\n\t\treturn\n\t}\n\twrite.Header().Set(\"Content-Type\", \"application/json\")\n\twrite.WriteHeader(http.StatusCreated)\n\tjson.NewEncoder(write).Encode(result)\n}", "func (a *Server) ListUsers(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"lists all users\")\n}", "func GetUsers(req *http.Request, render render.Render, account services.Account) {\n qs := req.URL.Query()\n userIDs := qs[\"userId\"]\n var users []models.User\n for _, userID := range userIDs {\n if user, err := account.GetUser(userID); err != nil {\n render.JSON(err.HttpCode, err)\n return\n } else {\n users = append(users, *user)\n }\n }\n render.JSON(http.StatusOK, users)\n}", "func ListAllUsers(w http.ResponseWriter, r *http.Request) {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusBadRequest, \"Mohomaaf ...dsb\", nil, nil)\n\t\t}\n\t}()\n\n\tfLog := userMgmtLogger.WithField(\"func\", \"ListAllUsers\").WithField(\"RequestID\", r.Context().Value(constants.RequestID)).WithField(\"path\", r.URL.Path).WithField(\"method\", r.Method)\n\n\tiauthctx := r.Context().Value(constants.HansipAuthentication)\n\tif iauthctx == nil {\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusUnauthorized, \"You are not authorized to access this resource\", nil, nil)\n\t\treturn\n\t}\n\n\tfLog.Trace(\"Listing Users\")\n\tpageRequest, err := helper.NewPageRequestFromRequest(r)\n\tif err != nil {\n\t\tfLog.Errorf(\"helper.NewPageRequestFromRequest got %s\", err.Error())\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusBadRequest, err.Error(), nil, nil)\n\t\treturn\n\t}\n\tusers, page, err := UserRepo.ListUser(r.Context(), pageRequest)\n\tif err != nil {\n\t\tfLog.Errorf(\"UserRepo.ListUser got %s\", err.Error())\n\t\thelper.WriteHTTPResponse(r.Context(), w, http.StatusInternalServerError, err.Error(), nil, nil)\n\t\treturn\n\t}\n\tsusers := make([]*SimpleUser, len(users))\n\tfor i, v := range users {\n\t\tsusers[i] = &SimpleUser{\n\t\t\tRecID: v.RecID,\n\t\t\tEmail: v.Email,\n\t\t\tEnabled: v.Enabled,\n\t\t\tSuspended: v.Suspended,\n\t\t}\n\t}\n\tret := make(map[string]interface{})\n\tret[\"users\"] = susers\n\tret[\"page\"] = page\n\thelper.WriteHTTPResponse(r.Context(), w, http.StatusOK, \"List of all user paginated\", nil, ret)\n}", "func LoadHomePage(w http.ResponseWriter, r *http.Request) {\n\turl := fmt.Sprintf(\"%s/publications\", config.APIURL)\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tvar publications []models.Publication\n\tif err := json.NewDecoder(response.Body).Decode(&publications); err != nil {\n\t\tresponses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tutils.RunTemplate(w, \"home.html\", struct {\n\t\tPublications []models.Publication\n\t\tUserID uint64\n\t}{\n\t\tPublications: publications,\n\t\tUserID: userID,\n\t})\n}", "func GetUsers(c *gin.Context) {\n\tvar user []Models.User\n\tvar u Models.User\n\terr := Models.GetAllUsers(&user)\n\tif err != nil {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"error\" : gin.H { \n\t\t\t\"status\": http.StatusNotFound,\n\t\t\t\"message\": err.Error(),\n\t\t}})\n\t\tc.AbortWithStatus(http.StatusNotFound)\n\t} else {\n\t\tlog.Println(\"====== Bind By Query String ======\")\n\t\tlog.Println(u.Nombre)\n\t\t//var rubro []Models.RubroUsuario\n\t \n\t\tfmt.Println(c.Request.URL.Query())\n\t\t page, _ := strconv.Atoi(c.DefaultQuery(\"page\", \"1\"))\n\t\t limit, _ := strconv.Atoi(c.DefaultQuery(\"limit\", \"50\"))\n\t\n\t\t paginator := pagination.Paging(&pagination.Param{\n\t\t\tDB: Config.DB.Preload(\"Rubros\").Preload(\"Unidades\"),\n\t\t\tPage: page,\n\t\t\tLimit: limit,\n\t\t\tOrderBy: []string{\"id\"},\n\t\t\tShowSQL: true,\n\t\t}, &user)\n \n\t\tc.JSON(200, paginator)\n\n\t}\n}", "func userList(w http.ResponseWriter, r *http.Request) {}", "func GetUsers(w http.ResponseWriter, r *http.Request) {\n\tvar users []UsersData\n\terr := model.FindAll(nil, &users)\n\tif err != nil {\n\t\tfmt.Println(\"err\", err)\n\t\tw.Write([]byte(\"Something wen't wrong!!\"))\n\t} else {\n\t\trender.JSON(w, 200, &users)\n\t}\n}", "func UserListAll(w http.ResponseWriter, r *http.Request) {\n\n\tvar err error\n\tvar pageSize int\n\tvar paginatedUsers auth.PaginatedUsers\n\n\t// Init output\n\toutput := []byte(\"\")\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\trefRoles := gorillaContext.Get(r, \"auth_roles\").([]string)\n\n\t// Grab url path variables\n\turlValues := r.URL.Query()\n\tpageToken := urlValues.Get(\"pageToken\")\n\tstrPageSize := urlValues.Get(\"pageSize\")\n\tprojectName := urlValues.Get(\"project\")\n\tprojectUUID := \"\"\n\n\tif projectName != \"\" {\n\t\tprojectUUID = projects.GetUUIDByName(projectName, refStr)\n\t\tif projectUUID == \"\" {\n\t\t\terr := APIErrorNotFound(\"ProjectUUID\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tif strPageSize != \"\" {\n\t\tif pageSize, err = strconv.Atoi(strPageSize); err != nil {\n\t\t\tlog.Errorf(\"Pagesize %v produced an error while being converted to int: %v\", strPageSize, err.Error())\n\t\t\terr := APIErrorInvalidData(\"Invalid page size\")\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// check that user is indeed a service admin in order to be priviledged to see full user info\n\tpriviledged := auth.IsServiceAdmin(refRoles)\n\n\t// Get Results Object - call is always priviledged because this handler is only accessible by service admins\n\tif paginatedUsers, err = auth.PaginatedFindUsers(pageToken, int32(pageSize), projectUUID, priviledged, refStr); err != nil {\n\t\terr := APIErrorInvalidData(\"Invalid page token\")\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := paginatedUsers.ExportJSON()\n\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\toutput = []byte(resJSON)\n\trespondOK(w, output)\n\n}", "func (s *Server) handleDashboardUsers() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"users.html\")\n\t\t})\n\t\tctx, provider, data, _, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Users\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLUsers()\n\t\tdata[TplParamFormAction] = provider.GetURLUserEdit()\n\n\t\t//load the users\n\t\tctx, users, err := ListProviderUsersByProviderID(ctx, s.getDB(), provider.ID, false)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"list users\", \"error\", err, \"id\", provider.ID)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamUsers] = users\n\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t}\n}", "func ViewManagerAndUsers(w http.ResponseWriter, r *http.Request) {\n AuthorizePages(w,r) // Restrict Unauthorized User \n tmpl, err := template.ParseFiles(\"templates/viewManagersAndUsers.html\")\n if err != nil {\n fmt.Println(err)\n }\n\n var managerList []helpers.User\n var userList []helpers.User\n\n managerList = dbquery.GetManagerList()\n\n userId := UserIds{\n ManagerId: r.FormValue(\"managerId\"),\n }\n \n var isShow bool = false\n var noDataMessage string\n var listLen int\n \n if userId.ManagerId != \"Select\" && userId.ManagerId != \"\" {\n userList = dbquery.GetUserByMngrList(userId.ManagerId)\n listLen = len(userList);\n } else {\n isShow = true\n noDataMessage = \"Please select Manager\"\n }\n\n if (listLen == 0 && (userId.ManagerId != \"Select\" && userId.ManagerId != \"\")) {\n isShow = true\n noDataMessage = \"There are no users for this Manager\"\n }\n\n AuthorizePages(w,r) // Restrict Unauthorized User\n \n tmpl.Execute(w, AllUsersResponse{ListLen: listLen, Managers: managerList, Users: userList, IsShow: isShow, FailedMessage: noDataMessage})\n}", "func (ctl UserController) Users(c *gin.Context) {\n\tusers, err := microsoft.NewUser().Users(c.Param(\"id\"), c.Query(\"next\"))\n\tif err != nil {\n\t\tc.JSON(rootCtl.wrap(http.StatusInternalServerError, err.Error()))\n\t}\n\n\tc.JSON(rootCtl.wrap(http.StatusOK, users))\n}", "func (ctl UserController) Users(c *gin.Context) {\n\tusers, err := microsoft.NewUser().Users(c.Param(\"id\"), c.Query(\"next\"))\n\tif err != nil {\n\t\tc.JSON(rootCtl.wrap(http.StatusInternalServerError, err.Error()))\n\t}\n\n\tc.JSON(rootCtl.wrap(http.StatusOK, users))\n}", "func USERS_GET_ProfileView(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tctx := appengine.NewContext(req)\n\tu, _ := GetUserFromSession(req)\n\tid, convErr := strconv.ParseInt(params.ByName(\"ID\"), 10, 64)\n\tif ErrorPage(ctx, res, nil, \"Invalid ID\", convErr, http.StatusBadRequest) {\n\t\treturn\n\t}\n\tci, getErr := GetUserFromID(ctx, id)\n\tif ErrorPage(ctx, res, u, \"Not a valid user ID\", getErr, http.StatusNotFound) {\n\t\treturn\n\t}\n\tlog.Infof(ctx, \"error ID: \", id)\n\tnotes, err := GetAllNotes(ctx, id)\n\tlog.Infof(ctx, \"error: \", len(notes))\n\tif ErrorPage(ctx, res, nil, \"Internal Server Error\", err, http.StatusSeeOther) {\n\t\treturn\n\t}\n\tscreen := struct {\n\t\tHeaderData\n\t\tData *User\n\t\tAllNotes []NoteOutput\n\t}{\n\t\t*MakeHeader(res, req, true, true),\n\t\tci,\n\t\tnotes,\n\t}\n\tServeTemplateWithParams(res, \"user-profile\", screen)\n}", "func getUsersHandler(c *gin.Context) {\n\tuser, _ := c.Get(JwtIdentityKey)\n\n\t// Role check.\n\tif !isAdmin(user) {\n\t\tc.JSON(http.StatusUnauthorized, gin.H{\"message\": \"unauthorized\"})\n\t\treturn\n\t}\n\n\tpage := c.DefaultQuery(\"page\", \"1\")\n\tcount := c.DefaultQuery(\"count\", \"10\")\n\tpageInt, _ := strconv.Atoi(page)\n\tcountInt, _ := strconv.Atoi(count)\n\n\tif page == \"0\" {\n\t\tpageInt = 1\n\t}\n\n\tvar wg sync.WaitGroup\n\tvar users *[]types.User\n\tvar usersCount int\n\n\tdb := data.New()\n\twg.Add(1)\n\tgo func() {\n\t\tusers = db.Users.GetUsers((pageInt-1)*countInt, countInt)\n\t\twg.Done()\n\t}()\n\n\twg.Add(1)\n\tgo func() {\n\t\tusersCount = db.Users.GetUsersCount()\n\t\twg.Done()\n\t}()\n\twg.Wait()\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"code\": http.StatusOK,\n\t\t\"users\": users,\n\t\t\"count\": usersCount,\n\t})\n}", "func allUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tvar users []User\n\tdb.Scopes(Paginate(r)).Find(&users)\n\terr := json.NewEncoder(w).Encode(users)\n\tlog.ErrorHandler(err)\n\tlog.AccessHandler(r, 200)\n\treturn\n}", "func GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Getting all users\"))\n}", "func LoadUsers(db *database.DB, userMap map[string]*User, currentUserID string) error {\n\tif len(userMap) <= 0 {\n\t\treturn nil\n\t}\n\tuserIDs := make([]interface{}, 0, len(userMap))\n\tfor id := range userMap {\n\t\tuserIDs = append(userIDs, id)\n\t}\n\n\trows := database.NewQuery(`\n\t\tSELECT u.id,u.firstName,u.lastName,u.lastWebsiteVisit,!ISNULL(s.userId)\n\t\tFROM (\n\t\t\tSELECT *\n\t\t\tFROM users\n\t\t\tWHERE id IN `).AddArgsGroup(userIDs).Add(`\n\t\t) AS u\n\t\tLEFT JOIN (\n\t\t\tSELECT *\n\t\t\tFROM userSubscriptions\n\t\t\tWHERE userId=?`, currentUserID).Add(`\n\t\t) AS s\n\t\tON (u.id=s.toUserId)`).ToStatement(db).Query()\n\terr := rows.Process(func(db *database.DB, rows *database.Rows) error {\n\t\tvar u coreUserData\n\t\terr := rows.Scan(&u.ID, &u.FirstName, &u.LastName, &u.LastWebsiteVisit, &u.IsSubscribed)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to scan for user: %v\", err)\n\t\t}\n\t\tuserMap[u.ID].coreUserData = u\n\t\treturn nil\n\t})\n\treturn err\n}", "func (config *AppConfig) getUserByPage(pageID int) (users AppUsers, err error) {\n\t// get json bytes from the panel.\n\tuserBytes, err := config.queryApplicationAPI(fmt.Sprintf(\"users/%d\", pageID), \"get\", nil)\n\tif err != nil {\n\t\treturn users, err\n\t}\n\n\t// Unmarshal the bytes to a usable struct.\n\terr = json.Unmarshal(userBytes, &users)\n\tif err != nil {\n\t\treturn users, err\n\t}\n\n\treturn users, nil\n}", "func TestLoadPage(t *testing.T) {\n\tmembers := member.GetMembers()\n\tbooks := book.GetBook()\n\n\tpage := loadPage(members, books)\n\n\tif len(page.Members) < 1 || len(page.Books) < 1 {\n\t\tt.Errorf(\"Page did not load based on data.\")\n\t} else {\n\t\tfmt.Println(\"index.go Func loadPage PASS\")\n\t}\n}", "func FetchUsers(w http.ResponseWriter, r *http.Request) {\n\titems, err := AllUsers()\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(500), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tjson.NewEncoder(w).Encode(items)\n}", "func LoadRegisterPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"register.html\", nil)\n}", "func (s *Server) ViewUsers(ctx context.Context, req *pbApi.ViewUsersRequest) (*pbApi.ViewUsersResponse, error) {\n\tif s.dbHandler == nil {\n\t\treturn nil, status.Error(codes.Internal, \"No database connection\")\n\t}\n\t// number of users to get\n\tconst Q = 10\n\tvar (\n\t\tuserId = req.UserId\n\t\tfollowCtx = req.Context\n\t\toffset = int(req.Offset)\n\t\tpbUsersData = make([]*pbDataFormat.BasicUserData, Q)\n\t\tcount = 0\n\t)\n\tpbUser, err := s.dbHandler.User(userId)\n\tif err != nil {\n\t\tif errors.Is(err, dbmodel.ErrUserNotFound) {\n\t\t\treturn nil, status.Error(codes.NotFound, err.Error())\n\t\t}\n\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t}\n\tvar (\n\t\tdone = make(chan error)\n\t\tquit = make(chan error)\n\t)\n\t// Get data of users concurrently.\n\tswitch followCtx {\n\tcase \"following\":\n\t\tif offset >= len(pbUser.FollowingIds) {\n\t\t\treturn nil, status.Error(codes.OutOfRange, \"Offset out of range\")\n\t\t}\n\t\tuserIds := pbUser.FollowingIds[offset:]\n\t\tfor i := 0; (i < len(userIds)) && (count < Q); i++ {\n\t\t\tcount++\n\t\t\tuserId := userIds[i]\n\t\t\tgo func(userId string, idx int) {\n\t\t\t\tvar (\n\t\t\t\t\tpbUser *pbDataFormat.User\n\t\t\t\t\terr error\n\t\t\t\t)\n\t\t\t\tpbUser, err = s.dbHandler.User(userId)\n\t\t\t\tif err == nil {\n\t\t\t\t\tpbUsersData[idx] = pbUser.BasicUserData\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase done <- err:\n\t\t\t\tcase <-quit:\n\t\t\t\t}\n\t\t\t}(userId, i)\n\t\t}\n\tcase \"followers\":\n\t\tif offset >= len(pbUser.FollowersIds) {\n\t\t\treturn nil, status.Error(codes.OutOfRange, \"Offset out of range\")\n\t\t}\n\t\tuserIds := pbUser.FollowersIds[offset:]\n\t\tfor i := 0; (i < len(userIds)) && (count < Q); i++ {\n\t\t\tcount++\n\t\t\tuserId := userIds[i]\n\t\t\tgo func(userId string, idx int) {\n\t\t\t\tvar (\n\t\t\t\t\tpbUser *pbDataFormat.User\n\t\t\t\t\terr error\n\t\t\t\t)\n\t\t\t\tpbUser, err = s.dbHandler.User(userId)\n\t\t\t\tif err == nil {\n\t\t\t\t\tpbUsersData[idx] = pbUser.BasicUserData\n\t\t\t\t}\n\t\t\t\tselect {\n\t\t\t\tcase done <- err:\n\t\t\t\tcase <-quit:\n\t\t\t\t}\n\t\t\t}(userId, i)\n\t\t}\n\tdefault:\n\t\treturn nil, status.Error(codes.InvalidArgument, \"Context should be either following or followers\")\n\t}\n\t// Check for errors. It terminates every go-routine hung on the statement\n\t// \"case done<- err\" by closing the channel quit and returns the first err\n\t// read.\n\tfor i := 0; i < count; i++ {\n\t\terr = <-done\n\t\tif err != nil {\n\t\t\tclose(quit)\n\t\t\treturn nil, status.Error(codes.Internal, err.Error())\n\t\t}\n\t}\n\tif count < Q {\n\t\t// It got data of less than Q users; re-slice pbUsersData to get rid\n\t\t// of the last Q - count (empty) data of users.\n\t\tpbUsersData = pbUsersData[:count]\n\t}\n\treturn &pbApi.ViewUsersResponse{\n\t\tBasicUserData: pbUsersData,\n\t}, nil\n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func (h *User) List(w http.ResponseWriter, r *http.Request) {\n\tlimit, offset := utils.GetPaginationParams(r.URL.Query())\n\tresp, err := h.Storage.GetUserList(limit, offset)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tR.JSON500(w)\n\t\treturn\n\t}\n\n\tif len(resp) < 1 {\n\t\tR.JSON404(w)\n\t\treturn\n\t}\n\n\tR.JSON200(w, resp)\n}", "func LoadLoginPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\n\tif cookie[\"token\"] != \"\" {\n\t\thttp.Redirect(w, r, \"/feed\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"login.html\", nil)\n}", "func FetchUserUI(usrName string) {\n\tif checkIfRequiredFilesExist(db) {\n\t\tif queryString(usrName, \"db/usernames.txt\") == false {\n\t\t\tfmt.Println(\"The following user does not exist: \", usrName)\n\t\t} else {\n\t\t\tuser := FetchUser(usrName)\n\t\t\tuser.printInfo()\n\t\t}\n\t}\n}", "func (h *HTTPClientHandler) getAllUsersHandler(w http.ResponseWriter, r *http.Request) {\n\n\tuserid, _ := r.URL.Query()[\"q\"]\n\t// looking for specific user\n\tif len(userid) > 0 {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"userid\": userid[0],\n\t\t}).Info(\"Looking for user..\")\n\n\t\tuser, err := h.db.getUser(userid[0])\n\n\t\tif err == nil {\n\t\t\t// Marshal provided interface into JSON structure\n\t\t\tresponse := UserResource{Data: user}\n\t\t\tuj, _ := json.Marshal(response)\n\n\t\t\t// Write content-type, statuscode, payload\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(200)\n\t\t\tfmt.Fprintf(w, \"%s\", uj)\n\t\t\treturn\n\t\t} else {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"error\": err.Error(),\n\t\t\t}).Warn(\"Failed to insert..\")\n\n\t\t\tcontent, code := responseDetailsFromMongoError(err)\n\n\t\t\t// Marshal provided interface into JSON structure\n\t\t\tuj, _ := json.Marshal(content)\n\n\t\t\t// Write content-type, statuscode, payload\n\t\t\twriteJsonResponse(w, &uj, code)\n\t\t\treturn\n\n\t\t}\n\t}\n\n\tlog.Warn(len(userid))\n\t// displaying all users\n\tresults, err := h.db.getUsers()\n\tif err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Error(\"Got error when tried to get all users\")\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"count\": len(results),\n\t}).Info(\"number of users\")\n\n\t// Marshal provided interface into JSON structure\n\tresponse := UsersResource{Data: results}\n\tuj, _ := json.Marshal(response)\n\n\t// Write content-type, statuscode, payload\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(200)\n\tfmt.Fprintf(w, \"%s\", uj)\n}", "func ViewListOtherManagers(w http.ResponseWriter, r *http.Request) { \n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewListOtherManagers.html\")\n\n userDetails := getSession(r)\n\n AuthorizePages(w,r)\n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n if err != nil {\n fmt.Println(err)\n }\n var managerList []helpers.User\n var listLen int\n var failedMessage string\n var isShow bool = false\n\n managerList = dbquery.GetManagerList()\n listLen = len(managerList);\n\n var managerList1 []helpers.User\n\n for i := 0; i < listLen; i++ {\n if managerList[i].UserId != userDetails.UserId {\n managerList1 = append(managerList1, helpers.User{\n FirstName: managerList[i].FirstName,\n LastName: managerList[i].LastName,\n UserId: managerList[i].UserId,\n })\n }\n }\n if listLen == 0 {\n isShow = true\n failedMessage = \"Currently you are not assigned for any User\"\n } \n\n t.Execute(w, AllUsersResponse{Users: managerList1, ListLen: listLen, FailedMessage: failedMessage, IsShow: isShow}) \n}", "func (uh UserHandler) GetAllUsers(w http.ResponseWriter, r *http.Request) {\n\tlog.Print(utils.InfoLog + \"UserHandler:GetAllUsers called\")\n\n\tvar results *[]models.User\n\tresults, err := uh.UserManager.GetUsers(); if err != nil {\n\t\tutils.ReturnWithErrorLong(w, *err)\n\t\tlog.Println(utils.ErrorLog + \"Insert body here\") // TODO ??\n\t\treturn\n\t}\n\tjson.NewEncoder(w).Encode(results)\n\tw.WriteHeader(http.StatusOK)\n}", "func users() {\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader([]string{\"#\", \"UID\", \"姓名\", \"头像\"})\n\ttable.SetAutoFormatHeaders(true)\n\ttable.SetAutoWrapText(false)\n\tfor i, user := range config.Instance.Users {\n\t\ttable.Append([]string{strconv.Itoa(i), user.UIDHazy, user.Name, user.Avatar})\n\t}\n\ttable.Render()\n\n}", "func (s *Shell) ListUsers(_ *cli.Context) (err error) {\n\tresp, err := s.HTTP.Get(\"/v2/users/\", nil)\n\tif err != nil {\n\t\treturn s.errorOut(err)\n\t}\n\tdefer func() {\n\t\tif cerr := resp.Body.Close(); cerr != nil {\n\t\t\terr = multierr.Append(err, cerr)\n\t\t}\n\t}()\n\n\treturn s.renderAPIResponse(resp, &AdminUsersPresenters{})\n}", "func UserIndexHandler(w http.ResponseWriter, req *http.Request) {\n\n\t// Get session values or redirect to Login\n\tsession, err := sessions.Store.Get(req, \"session\")\n\n\tif err != nil {\n\t\tlog.Println(\"error identifying session\")\n\t\thttp.Redirect(w, req, \"/login/\", 302)\n\t\treturn\n\t\t// in case of error\n\t}\n\n\t// Prep for user authentication\n\tsessionMap := getUserSessionValues(session)\n\n\tusername := sessionMap[\"username\"]\n\tloggedIn := sessionMap[\"loggedin\"]\n\tisAdmin := sessionMap[\"isAdmin\"]\n\n\tfmt.Println(session)\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t\treturn\n\t}\n\n\tusers, err := database.ListUsers(db)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\twv := WebView{\n\t\tSessionUser: username,\n\t\tIsLoggedIn: loggedIn,\n\t\tIsAdmin: isAdmin,\n\t\tUsers: users,\n\t\tUserFrame: true,\n\t\tArchitecture: baseArchitecture,\n\t}\n\n\tRender(w, \"templates/user_index.html\", wv)\n}", "func LoadUsers(userCsv string) {\n\t// read users\n\tif file, err := os.Open(userCsv); err == nil {\n\t\treader := csv.NewReader(file)\n\t\tdefer file.Close()\n\t\tfor strs, err := reader.Read(); err == nil; strs, err = reader.Read() {\n\t\t\tuserId, _ := strconv.Atoi(strs[0])\n\t\t\tif userId != 0 {\n\t\t\t\tuserName := strs[1]\n\t\t\t\tpassword := strs[2]\n\t\t\t\tusers = append(users, User{Id: userId, Username: userName, Password: password})\n\t\t\t}\n\t\t}\n\t} else {\n\t\tpanic(err.Error())\n\t}\n\n\t// root user\n\t// ss.rootToken = userId2Token(ss.UserMap[\"root\"].Id)\n}", "func ViewManagers(w http.ResponseWriter, r *http.Request) { \n AuthorizePages(w,r)\n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewManagers.html\")\n \n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n userId := UserIds{\n ManagerId: r.FormValue(\"managerId\"),\n }\n\n var successMessage string\n var isShow bool \n\n if (userId.ManagerId != \"\" ) {\n if (dbquery.DeleteManagerUser(\"Manager\",userId.ManagerId)){\n isShow = true\n successMessage = \"Manager Deleted Successfully\"\n }\n }\n\n var managerList []helpers.User\n managerList = dbquery.GetUserByRole(\"\",\"'Manager'\")\n t.Execute(w, AllUsersResponse{Users: managerList, SuccessMessage: successMessage, IsShow: isShow}) \n}", "func userIndex(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tdb := co.DbConnection(dbc)\n\t// DB query to get all the users\n\tresults, err := db.Query(\"SELECT user_name FROM members\")\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n\tvar members []string\n\tfor results.Next() {\n\t\tvar name string\n\t\terr = results.Scan(&name)\n\t\tif err != nil {\n\t\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t\t}\n\t\tmembers = append(members, name)\n\t}\n\tresults.Close()\n\tdb.Close()\n\tjsonPrint(w, members)\n return\n}", "func ShowUserData(c *gin.Context) {\r\n\tvar info []models.Userinfo\r\n\tmodels.DB.Find(&info)\r\n\r\n\tc.JSON(200, gin.H{\"data\": info})\r\n}", "func UserInfo(data UserInfoData) http.Handler {\n\treturn httputil.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {\n\t\treturn ui.ServePage(w, r, \"UserInfo\", data.ToJSON())\n\t})\n}", "func ShowUserHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\n\tclustername := vars[\"name\"]\n\tselector := r.URL.Query().Get(\"selector\")\n\tnamespace := r.URL.Query().Get(\"namespace\")\n\texpired := r.URL.Query().Get(\"expired\")\n\tclientVersion := r.URL.Query().Get(\"version\")\n\tlog.Debugf(\"ShowUserHandler parameters expired [%s] selector [%s] namespace [%s] expired [%s] version [%s]\", expired, selector, namespace, clientVersion, clustername)\n\n\tusername, err := apiserver.Authn(apiserver.SHOW_SECRETS_PERM, w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tw.Header().Set(\"WWW-Authenticate\", `Basic realm=\"Restricted\"`)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(http.StatusOK)\n\n\tresp := msgs.ShowUserResponse{}\n\tif clientVersion != msgs.PGO_VERSION {\n\t\tresp.Status = msgs.Status{Code: msgs.Error, Msg: apiserver.VERSION_MISMATCH_ERROR}\n\t\tresp.Results = make([]msgs.ShowUserDetail, 0)\n\t\tjson.NewEncoder(w).Encode(resp)\n\t\treturn\n\t}\n\n\tvar ns string\n\tns, err = apiserver.GetNamespace(apiserver.Clientset, username, namespace)\n\tif err != nil {\n\t\tresp.Status = msgs.Status{Code: msgs.Error, Msg: err.Error()}\n\t\tresp.Results = make([]msgs.ShowUserDetail, 0)\n\t\tjson.NewEncoder(w).Encode(resp)\n\t\treturn\n\t}\n\n\tresp = ShowUser(clustername, selector, expired, ns)\n\tjson.NewEncoder(w).Encode(resp)\n\n}", "func ListUsers(w http.ResponseWriter, r *http.Request) {\n\tusers, err := dal.GetUsers(\"\")\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\tcommon.WriteResponse(w, users)\n}", "func ShowUsersPath(id int64) string {\n\treturn fmt.Sprintf(\"/api/v1/users/%v\", id)\n}", "func mypage(w http.ResponseWriter, req *http.Request) {\n\n\t// var b []Board\n\n\t// if !alreadyLoggedIn(w, req) {\n\t// \thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t// \treturn\n\t// }\n\tif !alreadyLoggedIn(w, req) {\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\tu := getUser(w, req)\n\ttpl.ExecuteTemplate(w, \"mypage.gohtml\", u) //! html로 바꾸는법~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n}", "func (h *UserRepos) View(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tdata := make(map[string]interface{})\n\tf := func() error {\n\n\t\tclaims, err := auth.ClaimsFromContext(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tusr, err := h.UserRepo.ReadByID(ctx, claims, claims.Subject)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdata[\"user\"] = usr.Response(ctx)\n\n\t\tusrAccs, err := h.UserAccountRepo.FindByUserID(ctx, claims, claims.Subject, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, usrAcc := range usrAccs {\n\t\t\tif usrAcc.AccountID == claims.Audience {\n\t\t\t\tdata[\"userAccount\"] = usrAcc.Response(ctx)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tif err := f(); err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-view.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func UsersLoginGet(c buffalo.Context) error {\n\treturn c.Render(200, r.HTML(\"users/login\"))\n}", "func GetUsers(w http.ResponseWriter, r *http.Request) {\n\tloginOrName := strings.ToLower(r.URL.Query().Get(\"user\"))\n\n\tdb, err := database.Connect()\n\tif err != nil {\n\t\tresponses.Error(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tdefer db.Close()\n\n\trepository := repository.NewRepositoryUser(db)\n\n\tusers, err := repository.SearchByLoginOrName(loginOrName)\n\tif err != nil {\n\t\tresponses.Error(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tresponses.JSON(w, http.StatusOK, users)\n\n}", "func load_user_list() {\n\tcreate_and_lock(USERLIST_FILENAME) // lock userlist file\n\tdefer lock_for_files_map[USERLIST_FILENAME].Unlock()\n\n\tfile, err := os.OpenFile(USERLIST_FILENAME, os.O_CREATE|os.O_RDONLY, 0600)\n\tdefer file.Close()\n\tcheck_err(err)\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tsplitted_string := strings.Split(line, \":\")\n\t\tuname := strings.TrimSpace(splitted_string[0])\n\t\tpsw := strings.TrimSpace(splitted_string[1])\n\t\t// store user in server memory\n\t\tuser_map_lock.Lock()\n\t\tuser_map[uname] = psw\n\t\tuser_map_lock.Unlock()\n\t}\n\n}", "func ListAllUsers(w http.ResponseWriter, r *http.Request){\n\n\trows, err:= db.Query(\"SELECT * FROM users LIMIT 20\")\n\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\tpanic(\"failed to connect database\")\n\t}\n\n\tlistUsers := Users{}\n\tfor rows.Next() {\n\t\tp := User{}\n\t\tif err := rows.Scan(&p.ID, &p.Name, &p.Score); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tlistUsers = append(listUsers, p)\n\n\t}\n\tdefer rows.Close()\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(200)\n\tjson.NewEncoder(w).Encode(listUsers)\n}", "func showUser(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"cache-control\", \"no-store, no-cache, must-revalidate\")\n\tsession := sessions.Start(w, r)\n\n\tif len(session.GetString(\"username\")) == 0 {\n\t\thttp.Redirect(w, r, \"/login\", 301)\n\t}\n\n\tvars := mux.Vars(r)\n\tusername := vars[\"username\"]\n\tcurrentUser := QueryUser(session.GetString(\"username\"))\n\tuser := QueryUser(username)\n\tpjax := r.Header.Get(\"X-PJAX\") == \"\"\n\tprofile := QueryProfile(user.ID)\n\tvar following bool\n\n\tdb.QueryRow(\"SELECT 1 FROM follows WHERE follow_to = ? AND follow_by = ?\", user.ID, currentUser.ID).Scan(&following)\n\n\tdb.QueryRow(\"SELECT COUNT(*) FROM follows WHERE follow_by = ?\", user.ID).Scan(&profile.FollowingCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM follows WHERE follow_to = ?\", user.ID).Scan(&profile.FollowerCount)\n\n\tdb.QueryRow(\"SELECT COUNT(*) FROM posts WHERE created_by = ?\", user.ID).Scan(&profile.PostCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM comments WHERE created_by = ?\", user.ID).Scan(&profile.CommentCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM yeahs WHERE yeah_by = ?\", user.ID).Scan(&profile.YeahCount)\n\n\tpost_rows, _ := db.Query(\"SELECT posts.id, community_id, created_at, body, image, title, icon FROM posts LEFT JOIN communities ON communities.id = community_id WHERE created_by = ? ORDER BY created_at DESC LIMIT 3\", user.ID)\n\tvar posts []post\n\n\tfor post_rows.Next() {\n\n\t\tvar row = post{}\n\t\tvar timestamp time.Time\n\t\tvar yeahed string\n\n\t\terr = post_rows.Scan(&row.ID, &row.CommunityID, &timestamp, &row.Body, &row.Image, &row.CommunityName, &row.CommunityIcon)\n\t\trow.CreatedAt = humanTiming(timestamp)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\t// Check if the post has been yeahed.\n\t\tdb.QueryRow(\"SELECT id FROM yeahs WHERE yeah_post = ? AND yeah_by = ? AND on_comment=0\", row.ID, currentUser.ID).Scan(&yeahed)\n\t\tif yeahed != \"\" {\n\t\t\trow.Yeahed = true\n\t\t}\n\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM yeahs WHERE yeah_post = ? AND on_comment=0\", row.ID).Scan(&row.YeahCount)\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM comments WHERE post = ?\", row.ID).Scan(&row.CommentCount)\n\n\t\tposts = append(posts, row)\n\t}\n\tpost_rows.Close()\n\n\tyeah_rows, _ := db.Query(\"SELECT posts.id, created_by, community_id, created_at, body, image, username, nickname, avatar, online, title, icon FROM yeahs INNER JOIN posts ON posts.id = yeah_post INNER JOIN users ON users.id = posts.created_by INNER JOIN communities ON communities.id = community_id WHERE yeah_by = ? AND on_comment = 0 ORDER BY created_at DESC LIMIT 3\", user.ID)\n\tvar yeahs []post\n\n\tfor yeah_rows.Next() {\n\n\t\tvar row = post{}\n\t\tvar timestamp time.Time\n\t\tvar yeahed string\n\n\t\terr = yeah_rows.Scan(&row.ID, &row.CreatedBy, &row.CommunityID, &timestamp, &row.Body, &row.Image, &row.PosterUsername, &row.PosterNickname, &row.PosterIcon, &row.PosterOnline, &row.CommunityName, &row.CommunityIcon)\n\t\trow.CreatedAt = humanTiming(timestamp)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\t// Check if the post has been yeahed.\n\t\tdb.QueryRow(\"SELECT id FROM yeahs WHERE yeah_post = ? AND yeah_by = ? AND on_comment=0\", row.ID, currentUser.ID).Scan(&yeahed)\n\t\tif yeahed != \"\" {\n\t\t\trow.Yeahed = true\n\t\t}\n\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM yeahs WHERE yeah_post = ? AND on_comment=0\", row.ID).Scan(&row.YeahCount)\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM comments WHERE post = ?\", row.ID).Scan(&row.CommentCount)\n\n\t\tyeahs = append(yeahs, row)\n\t}\n\tyeah_rows.Close()\n\n\tvar data = map[string]interface{}{\n\t\t\"Title\": user.Nickname + \"'s profile\",\n\t\t\"Pjax\": pjax,\n\t\t\"CurrentUser\": currentUser,\n\t\t\"User\": user,\n\t\t\"Profile\": profile,\n\t\t\"Following\": following,\n\t\t\"Posts\": posts,\n\t\t\"Yeahs\": yeahs,\n\t}\n\n\terr := templates.ExecuteTemplate(w, \"user.html\", data)\n\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (api *API) getUsersHandler() service.Handler {\n\treturn func(ctx context.Context, w http.ResponseWriter, r *http.Request) error {\n\t\tusers, err := user.LoadAll(ctx, api.mustDB(), user.LoadOptions.WithOrganization)\n\t\tif err != nil {\n\t\t\treturn sdk.WrapError(err, \"cannot load user from db\")\n\t\t}\n\t\treturn service.WriteJSON(w, users, http.StatusOK)\n\t}\n}", "func (projectL) LoadUsers(ctx context.Context, e boil.ContextExecutor, singular bool, maybeProject interface{}, mods queries.Applicator) error {\n\tvar slice []*Project\n\tvar object *Project\n\n\tif singular {\n\t\tobject = maybeProject.(*Project)\n\t} else {\n\t\tslice = *maybeProject.(*[]*Project)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &projectR{}\n\t\t}\n\t\targs = append(args, object.ID)\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &projectR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.ID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.ID)\n\t\t}\n\t}\n\n\tif len(args) == 0 {\n\t\treturn nil\n\t}\n\n\tquery := NewQuery(\n\t\tqm.Select(\"`users`.*, `a`.`project_id`\"),\n\t\tqm.From(\"`users`\"),\n\t\tqm.InnerJoin(\"`project_user` as `a` on `users`.`id` = `a`.`user_id`\"),\n\t\tqm.WhereIn(\"`a`.`project_id` in ?\", args...),\n\t)\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load users\")\n\t}\n\n\tvar resultSlice []*User\n\n\tvar localJoinCols []uint\n\tfor results.Next() {\n\t\tone := new(User)\n\t\tvar localJoinCol uint\n\n\t\terr = results.Scan(&one.ID, &one.FirstName, &one.LastName, &one.VKLink, &one.TGLink, &one.TGID, &one.TGState, &one.CreatedAt, &one.UpdatedAt, &localJoinCol)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to scan eager loaded results for users\")\n\t\t}\n\t\tif err = results.Err(); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to plebian-bind eager loaded slice users\")\n\t\t}\n\n\t\tresultSlice = append(resultSlice, one)\n\t\tlocalJoinCols = append(localJoinCols, localJoinCol)\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results in eager load on users\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for users\")\n\t}\n\n\tif len(userAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif singular {\n\t\tobject.R.Users = resultSlice\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif foreign.R == nil {\n\t\t\t\tforeign.R = &userR{}\n\t\t\t}\n\t\t\tforeign.R.Projects = append(foreign.R.Projects, object)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor i, foreign := range resultSlice {\n\t\tlocalJoinCol := localJoinCols[i]\n\t\tfor _, local := range slice {\n\t\t\tif local.ID == localJoinCol {\n\t\t\t\tlocal.R.Users = append(local.R.Users, foreign)\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.Projects = append(foreign.R.Projects, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func UserShow(w http.ResponseWriter, r *http.Request, u *User) error {\n\t// list of repositories owned by User\n\trepos, err := database.ListRepos(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// list of user team accounts\n\tteams, err := database.ListTeams(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// list of recent commits\n\tcommits, err := database.ListCommitsUser(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := struct {\n\t\tUser *User\n\t\tRepos []*Repo\n\t\tTeams []*Team\n\t\tCommits []*RepoCommit\n\t}{u, repos, teams, commits}\n\treturn RenderTemplate(w, \"user_dashboard.html\", &data)\n}", "func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {\n\tsanitizedPath := strings.TrimPrefix(r.URL.Path, \"/graph/v1.0/\")\n\todataReq, err := godata.ParseRequest(r.Context(), sanitizedPath, r.URL.Query())\n\tif err != nil {\n\t\tg.logger.Err(err).Interface(\"query\", r.URL.Query()).Msg(\"query error\")\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tusers, err := g.identityBackend.GetUsers(r.Context(), r.URL.Query())\n\tif err != nil {\n\t\tvar errcode errorcode.Error\n\t\tif errors.As(err, &errcode) {\n\t\t\terrcode.Render(w, r)\n\t\t} else {\n\t\t\terrorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())\n\t\t}\n\t\treturn\n\t}\n\n\tusers, err = sortUsers(odataReq, users)\n\tif err != nil {\n\t\tvar errcode errorcode.Error\n\t\tif errors.As(err, &errcode) {\n\t\t\terrcode.Render(w, r)\n\t\t} else {\n\t\t\terrorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())\n\t\t}\n\t\treturn\n\t}\n\trender.Status(r, http.StatusOK)\n\trender.JSON(w, r, &listResponse{Value: users})\n}", "func fetchAllUser(c *gin.Context) {\n\tvar users []user\n\n\tdb.Find(&users)\n\n\tif len(users) <= 0 {\n\t\tc.JSON(http.StatusNotFound, gin.H{\"status\": http.StatusNotFound, \"message\": \"No user found!\"})\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\"status\": http.StatusOK, \"data\": users})\n}", "func (app *App) allUsers(w http.ResponseWriter, r *http.Request) {\n\tusers, err := users.GetUsers(app.Db)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\trespondWithJSON(w, http.StatusOK, users)\n}", "func (handler *UserHandler) GetAllUsers(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tvar users []*User\n\tul, err := handler.UserService.GetAllUsers()\n\n\tfor _, user := range ul {\n\t\tusers = append(users, user.hidePassword())\n\t}\n\n\tif err != nil {\n\t\thandler.Formatter.JSON(w, http.StatusBadRequest, util.NewError(\"1008\", \"Missing user privileges\", err.Error()))\n\t} else {\n\t\thandler.Formatter.JSON(w, http.StatusOK, users)\n\t}\n\n}", "func UserViewHandler(w http.ResponseWriter, req *http.Request) {\n\n\t// Get session values or redirect to Login\n\tsession, err := sessions.Store.Get(req, \"session\")\n\n\tif err != nil {\n\t\tlog.Println(\"error identifying session\")\n\t\thttp.Redirect(w, req, \"/login/\", 302)\n\t\treturn\n\t\t// in case of error\n\t}\n\n\t// Prep for user authentication\n\tsessionMap := getUserSessionValues(session)\n\n\tusername := sessionMap[\"username\"]\n\tloggedIn := sessionMap[\"loggedin\"]\n\tisAdmin := sessionMap[\"isAdmin\"]\n\n\tvars := mux.Vars(req)\n\tidString := vars[\"id\"]\n\n\tpk, err := strconv.Atoi(idString)\n\tif err != nil {\n\t\tpk = 0\n\t\tlog.Println(err)\n\t}\n\n\tfmt.Println(session)\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t\treturn\n\t}\n\n\tuser, err := database.PKLoadUser(db, int64(pk))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\tfmt.Println(\"Unable to load User\")\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t}\n\n\t// Validate that User == Admin\n\tIsAuthor := false\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t}\n\n\texps, err := database.ListUserExperiences(db, user.UserName)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlrs := []*models.LearningResource{}\n\tlrStrings := []string{}\n\n\tfor _, ex := range exps {\n\t\tif !isInString(lrStrings, ex.LearningResource.Path) {\n\t\t\tlrs = append(lrs, ex.LearningResource)\n\t\t\tlrStrings = append(lrStrings, ex.LearningResource.Path)\n\t\t}\n\t}\n\n\t// Determine overall progression\n\n\tvar targetTotal, currentTotal int\n\n\tfor _, s := range user.Streams {\n\t\ttargetTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][0]\n\t\tcurrentTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][1]\n\t}\n\n\tcategories := map[string]int{\n\t\t\"currentTotal\": currentTotal,\n\t\t\"targetTotal\": targetTotal,\n\t}\n\n\tfor _, ex := range exps {\n\t\tcategories[ex.Stream.Name] += ex.Points\n\t\tcategories[\"max\"] += ex.Points\n\t}\n\n\twv := WebView{\n\t\tUser: user,\n\t\tIsAuthor: IsAuthor,\n\t\tIsLoggedIn: loggedIn,\n\t\tSessionUser: username,\n\t\tIsAdmin: isAdmin,\n\t\tLearningResources: lrs,\n\t\tExperiences: exps,\n\t\tCategoryMap: categories,\n\t\tUserFrame: true,\n\t\tNumMap: skillMap,\n\t\tStringMap: fontMap,\n\t\tArchitecture: baseArchitecture,\n\t}\n\n\tRender(w, \"templates/user_view.html\", wv)\n}", "func (srv *UsersService) ListHandler(ctx *gin.Context) {\n\tlogger := srv.logger.New(\"action\", \"ListHandler\")\n\n\tcurrentUser := GetCurrentUser(ctx)\n\n\tlimitQuery := ctx.DefaultQuery(\"limit\", \"10\")\n\tpageQuery := ctx.DefaultQuery(\"page\", \"1\")\n\tparams := ctx.Request.URL.Query()\n\n\tvar adminsRoleIncluded = false\n\n\troles := params[\"filter[role_name]\"]\n\tif len(roles) > 0 {\n\t\tfor key, role := range roles {\n\t\t\t// remove root from role names if user is not root\n\t\t\t// only root can see root users\n\t\t\tif role == models.RoleRoot && currentUser.RoleName != models.RoleRoot {\n\t\t\t\tcopy(roles[key:], roles[key+1:])\n\t\t\t\troles[len(roles)-1] = \"\"\n\t\t\t\troles = roles[:len(roles)-1]\n\t\t\t}\n\t\t\tif role == models.RoleRoot || role == models.RoleAdmin {\n\t\t\t\tadminsRoleIncluded = true\n\t\t\t}\n\t\t}\n\t} else {\n\t\tadminsRoleIncluded = true\n\t}\n\n\tvar hasPerm bool\n\tif adminsRoleIncluded {\n\t\thasPerm = srv.PermissionsService.CanViewAdminProfile(currentUser.UID)\n\t} else {\n\t\thasPerm = srv.PermissionsService.CanViewUserProfile(currentUser.UID)\n\t}\n\n\tif !hasPerm {\n\t\tsrv.ResponseService.Forbidden(ctx)\n\t\treturn\n\t}\n\n\tquery := srv.Repository.GetUsersRepository().Filter(params)\n\n\tpagination, err := srv.Repository.GetUsersRepository().Paginate(query, pageQuery, limitQuery, serializers.NewUsers())\n\tif err != nil {\n\t\tlogger.Error(\"сan't load list of user\", \"error\", err)\n\t\t// Returns a \"400 StatusBadRequest\" response\n\t\tsrv.ResponseService.Error(ctx, responses.CannotRetrieveCollection, \"Can't load list of users\")\n\t\treturn\n\t}\n\n\t// Returns a \"200 OK\" response\n\tsrv.ResponseService.OkResponse(ctx, pagination)\n}", "func GetUsersHandler(w http.ResponseWriter, r *http.Request) {\n\tvar users []User\n\tfor _, v := range Listusers {\n\t\tusers = append(users, v)\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tj, err := json.Marshal(users)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(j)\n}", "func (_obj *WebApiAuth) SysUser_GetPage(pageSize int32, pageIndex int32, req *SysUser, res *SysUser_List, _opt ...map[string]string) (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(pageSize, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = _os.Write_int32(pageIndex, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 4)\n\tif err != nil {\n\t\treturn err\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, \"SysUser_GetPage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 4, true)\n\tif err != nil {\n\t\treturn err\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 nil\n}", "func (authTokenL) LoadUser(e boil.Executor, singular bool, maybeAuthToken interface{}) error {\n\tvar slice []*AuthToken\n\tvar object *AuthToken\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthToken.(*AuthToken)\n\t} else {\n\t\tslice = *maybeAuthToken.(*[]*AuthToken)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authTokenR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authTokenR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from \\\"users\\\" where \\\"id\\\" in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(authTokenAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *peerRESTServer) LoadUserHandler(w http.ResponseWriter, r *http.Request) {\n\tif !s.IsValid(w, r) {\n\t\ts.writeErrorResponse(w, errors.New(\"Invalid request\"))\n\t\treturn\n\t}\n\n\tobjAPI := newObjectLayerFn()\n\tif objAPI == nil {\n\t\ts.writeErrorResponse(w, errServerNotInitialized)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\taccessKey := vars[peerRESTUser]\n\tif accessKey == \"\" {\n\t\ts.writeErrorResponse(w, errors.New(\"username is missing\"))\n\t\treturn\n\t}\n\n\ttemp, err := strconv.ParseBool(vars[peerRESTUserTemp])\n\tif err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tif err = globalIAMSys.LoadUser(objAPI, accessKey, temp); err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tw.(http.Flusher).Flush()\n}", "func (c *UsersController) Show(ctx *app.ShowUsersContext) error {\n\treturn proxy.RouteHTTP(ctx, c.config.GetAuthShortServiceHostName())\n}", "func ServeNewUserPage(w http.ResponseWriter, r *http.Request) {\n\tctx := appengine.NewContext(r)\n\n\t// Get the invitation UID\n\tuid := mux.Vars(r)[\"uid\"]\n\n\tinvite, key, err := bhap.InvitationByUID(ctx, uid)\n\tif err != nil {\n\t\thttp.Error(w,\n\t\t\t\"Error while getting invitation information\",\n\t\t\thttp.StatusInternalServerError)\n\t\tlog.Errorf(ctx, \"could not get invitation information: %v\", err)\n\t\treturn\n\t}\n\n\tif key == nil {\n\t\thttp.Error(w,\n\t\t\t\"Invalid invitation ID. Are you trying to pull a fast one?\",\n\t\t\thttp.StatusBadRequest)\n\t\tlog.Warningf(ctx, \"new user request made with invalid invitation ID\")\n\t\treturn\n\t}\n\n\tbackgroundURL, err := randomBackgroundURL()\n\tif err != nil {\n\t\thttp.Error(w, \"Error while looking for backgrounds\",\n\t\t\thttp.StatusInternalServerError)\n\t\tlog.Errorf(ctx, \"looking for backgrounds: %v\", err)\n\t\treturn\n\t}\n\n\tfiller := newUserFiller{\n\t\tInvitationUID: uid,\n\t\tEmail: invite.Email,\n\t\tBackgroundURL: backgroundURL,\n\t}\n\tshowTemplate(ctx, w, newUserTemplate, filler)\n}", "func (c *Client) ListUsers() (*http.Response, error) {\n\treturn c.get(\"/user/listusers\", nil)\n}", "func listUsersPartial(client *Client) ([]interface{}, error) {\n\treturn client.GetItemListInterfaceArray(\"/access/users\")\n}", "func (h *Handler) GetUsers(w http.ResponseWriter, r *http.Request) {\n\tvar users []User\n\tcur, err := h.Collection.Find(context.TODO(), bson.D{{}}, options.Find())\n\tif err != nil {\n\t\th.Logger.Errorf(\"err retrieving cursor item: %s\", err)\n\t\thttp.Error(w, http.StatusText(500), 500)\n\t\treturn\n\t}\n\tfor cur.Next(context.TODO()) {\n\t\tuser := &User{}\n\t\terr := cur.Decode(&user)\n\t\tif err != nil {\n\t\t\th.Logger.Errorf(\"err decoding item: %s\", err)\n\t\t\thttp.Error(w, http.StatusText(500), 500)\n\t\t\treturn\n\t\t}\n\t\tuser.Password = \"\" // Never return password hashes\n\t\tusers = append(users, *user)\n\t}\n\trender.JSON(w, r, users) // A chi router helper for serializing and returning json\n}", "func getUsers(types int) {\n\treq, _ := http.NewRequest(\"GET\", cfg.Main.Server+\"users\", nil)\n\treq.Header.Set(\"Content-Type\", \"application/xml\")\n\treq.Header.Set(\"Authorization\", cfg.Main.Key)\n\tclient := &http.Client{}\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\tp(\"Couldn't connect to Openfire server: %s\", err.Error())\n\t\treturn\n\t}\n\tdefer res.Body.Close()\n\tif res.StatusCode != 200 {\n\t\tp(\"Error requesting userlist from the server.\")\n\t\treturn\n\t}\n\tbody, _ := ioutil.ReadAll(res.Body)\n\tvar users XMLUsers\n\txml.Unmarshal(body, &users)\n\tfor _, e := range users.User {\n\t\tn := e.Username + \",\"\n\t\tif e.Name != \"\" {\n\t\t\tn = e.Username + \",\" + e.Name\n\t\t}\n\t\tswitch types {\n\t\tcase 0:\n\t\t\tm := \"<missing e-mail>\"\n\t\t\tif e.Email != \"\" {\n\t\t\t\tm = e.Email\n\t\t\t}\n\t\t\tp(\"%s,%s\", n, m)\n\t\tcase 1:\n\t\t\tif e.Email != \"\" {\n\t\t\t\tp(\"%s,%s\", n, e.Email)\n\t\t\t}\n\t\tcase 2:\n\t\t\tif e.Email == \"\" {\n\t\t\t\tp(\"%s\", n)\n\t\t\t}\n\t\t}\n\t}\n}", "func ShowCurrentUserList() {\n\tul := &define.UserList\n\tShowUserList(ul)\n}", "func ReadAllUsers(ID string, page int64, search string, stype string) ([]*models.Users, bool) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\n\tdefer cancel()\n\t//Aqui apunto a la base de datos y la collection\n\tbd := MongoCN.Database(\"twittgo\")\n\tcol := bd.Collection(\"users\")\n\n\tvar results []*models.Users\n\n\tfindOptions := options.Find()\n\tfindOptions.SetLimit(20)\n\tfindOptions.SetSkip((page - 1) * 20)\n\n\tquery := bson.M{\n\t\t\"nombre\": bson.M{\"$regex\": `(?i)` + search},\n\t}\n\n\tcur, err := col.Find(ctx, query, findOptions)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn results, false\n\t}\n\n\tvar find, include bool\n\n\tfor cur.Next(ctx) {\n\t\tvar s models.Users\n\t\terr := cur.Decode(&s)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t\treturn results, false\n\t\t}\n\n\t\tvar r models.Relation\n\t\tr.UserID = ID\n\t\tr.UserRelationID = s.ID.Hex()\n\n\t\tinclude = false\n\n\t\tfind, err = CheckRelation(r)\n\t\tif stype == \"new\" && find == false {\n\t\t\tinclude = true\n\t\t}\n\t\tif stype == \"follow\" && find == true {\n\t\t\tinclude = true\n\t\t}\n\n\t\tif r.UserRelationID == ID {\n\t\t\tinclude = false\n\t\t}\n\t\tif include == true {\n\t\t\ts.Password = \"\"\n\t\t\ts.Biografia = \"\"\n\t\t\ts.Banner = \"\"\n\t\t\ts.Email = \"\"\n\t\t\ts.SitioWeb = \"\"\n\t\t\ts.Ubicacion = \"\"\n\n\t\t\tresults = append(results, &s)\n\t\t}\n\n\t}\n\n\terr = cur.Err()\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn results, false\n\t}\n\n\tcur.Close(ctx)\n\treturn results, true\n}", "func GetUsersSearch(baseURL string) {\n\ttargetURL := baseURL + \"?username=\" + usrSearch.Username +\n\t\t\"&email=\" + usrSearch.Email +\n\t\t\"&page=\" + strconv.Itoa(usrSearch.Page) +\n\t\t\"&page_size=\" + strconv.Itoa(usrSearch.PageSize)\n\n\tfmt.Println(\"==> GET\", targetURL)\n\n\t// Read beegosessionID from .cookie.yaml\n\tc, err := utils.CookieLoad()\n\tif err != nil {\n\t\tfmt.Println(\"error:\", err)\n\t\treturn\n\t}\n\n\tutils.Request.Get(targetURL).\n\t\tSet(\"Cookie\", \"harbor-lang=zh-cn; beegosessionID=\"+c.BeegosessionID).\n\t\tEnd(utils.PrintStatus)\n}", "func renderUser(w http.ResponseWriter, r *http.Request) {\n\tuser, err := r.Cookie(\"user_id\")\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/signin\", http.StatusMovedPermanently)\n\t\treturn\n\t}\n\t//Cookie Value\n\tcv := user.Value\n\n\tuserFile := \"user/\" + cv + \".gojson\"\n\n\t//Read User File\n\n\tbs := helpers.Reader(userFile)\n\n\t//Convert data that has been read in GOJSON to a map-interface\n\thelpers.Unmarshal(bs, &passer)\n\tfname := passer[\"person\"].(map[string]interface{})[\"firstname\"]\n\tlname := passer[\"person\"].(map[string]interface{})[\"lastname\"]\n\tuname := passer[\"person\"].(map[string]interface{})[\"username\"]\n\n\t//Converting values to string to store in a struct\n\tfirstname := fmt.Sprintf(\"%v\", fname)\n\tlastname := fmt.Sprintf(\"%v\", lname)\n\tusername := fmt.Sprintf(\"%v\", uname)\n\n\t//Storing Read values in struct to pass into template\n\tuser_details := person{\n\t\tuserInfo{\n\t\t\tFirstname: firstname,\n\t\t\tLastname: lastname,\n\t\t\tUsername: username,\n\t\t},\n\t}\n\t//fmt.Println(firstname)\n\ttpl, err := template.ParseFiles(\"app/index.gohtml\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\ttpl.Execute(w, user_details.Person)\n\n}" ]
[ "0.7564145", "0.70554775", "0.7006458", "0.6990626", "0.65036213", "0.64619017", "0.63973314", "0.6349167", "0.63369733", "0.61949444", "0.61718976", "0.6163519", "0.613001", "0.6098995", "0.60652465", "0.60556334", "0.5992087", "0.59665483", "0.5942233", "0.59002393", "0.5899755", "0.5893706", "0.5863902", "0.5863057", "0.58432984", "0.58167833", "0.5805886", "0.5771059", "0.5759956", "0.57315695", "0.57190186", "0.56691843", "0.565869", "0.5645575", "0.5626288", "0.5609968", "0.5603389", "0.55964774", "0.5583402", "0.55780923", "0.5572381", "0.5572381", "0.5568346", "0.55541176", "0.55502784", "0.553357", "0.55205035", "0.55165493", "0.5508194", "0.55051666", "0.5488397", "0.54770947", "0.54735094", "0.54536617", "0.5447352", "0.5433026", "0.541965", "0.5412234", "0.5401773", "0.53892094", "0.53869915", "0.5364355", "0.53574795", "0.5346811", "0.5341508", "0.5330877", "0.5329053", "0.5327146", "0.5325189", "0.5324943", "0.5322185", "0.53206956", "0.5313839", "0.5304275", "0.5298311", "0.52836084", "0.52750295", "0.52738833", "0.5265986", "0.5253235", "0.52498853", "0.52441216", "0.5232503", "0.52275443", "0.5225128", "0.52154434", "0.52108556", "0.5206971", "0.52019775", "0.51996404", "0.5198529", "0.519748", "0.5187643", "0.5183504", "0.5180345", "0.51760983", "0.5172781", "0.5167812", "0.5166709", "0.5165526" ]
0.8562869
0
LoadUserPage Load user profile
func LoadUserPage(w http.ResponseWriter, r *http.Request) { parameters := mux.Vars(r) userID, err := strconv.ParseUint(parameters["userId"], 10, 64) if err != nil { responses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()}) return } cookie, _ := cookies.Read(r) userIDLogged, _ := strconv.ParseUint(cookie["id"], 10, 64) user, err := models.SearchCompleteUser(userID, r) if err != nil { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()}) return } if userID == userIDLogged { http.Redirect(w, r, "/profile", 302) return } utils.RunTemplate(w, "user.html", struct { User models.User UserLoggedID uint64 }{ User: user, UserLoggedID: userIDLogged, }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func LoadUserEditPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tchannel := make(chan models.User)\n\n\tgo models.GetUserData(channel, userID, r)\n\n\tuser := <-channel\n\tif user.ID == 0 {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: \"Erro ao buscar o usuário\"})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-profile.html\", user)\n}", "func LoadUserLoggedProfile(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"profile.html\", user)\n\n}", "func LoadUsersPage(w http.ResponseWriter, r *http.Request) {\n\tnameOrNick := strings.ToLower(r.URL.Query().Get(\"user\"))\n\n\turl := fmt.Sprintf(\"%s/users?usuario=%s\", config.APIURL, nameOrNick)\n\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tvar users []models.User\n\tif err := json.NewDecoder(response.Body).Decode(&users); err != nil {\n\t\tresponses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"users.html\", users)\n}", "func LoadUserData(id int) error{\n\n\tuserPos, err := findUser(id)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Errorf(\"Error: \",err.Error())\n\t\treturn err\n\t}\n\n\tloadUserDataAt(userPos)\n\n\treturn nil\n}", "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func (t *OpetCode) loadUser(APIstub shim.ChaincodeStubInterface, userKey string) (User, error) {\n user_json, _ := APIstub.GetState(userKey)\n var user User\n\n if user_json == nil {\n return user, errors.New(\"There is no user exist\")\n } \n _ = json.Unmarshal([]byte(user_json), &user) \n return user, nil\n}", "func (a *Ctl) Profile(res http.ResponseWriter, req *http.Request) {\n\ttype pageData struct {\n\t\tUser User\n\t}\n\td := pageData{\n\t\tUser: a.getUser(res, req),\n\t}\n\tif !a.alreadyLoggedIn(req) {\n\t\ta.Logging.Warning.Println(\"Unauthorised access to Profile from \", req.UserAgent())\n\t\thttp.Redirect(res, req, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\ta.Template.ExecuteTemplate(res, \"profile.html\", d)\n}", "func (wc WebClient) Profile(user *User) error {\n\n\tconst (\n\t\tselLocation = \"html body table.pagew tbody tr td.pagew table.t tbody tr td div img[src='https://img.zhivem.ru/pic_location.png']\"\n\t\tselUsername = \"html body table.pagew tbody tr td.pagew table.t tbody tr td div.header2\"\n\t\tselTable = \"html body table.pagew tbody tr td.pagew table.t tbody tr td table.t tbody tr\"\n\t)\n\n\tprofileURL := NewEndpointBuilder(wc.Config.BaseURL).\n\t\tWithPath(fmt.Sprintf(\"/web/%s\", user.Profile)).\n\t\tString()\n\n\tresponse, err := wc.client.Get(profileURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\n\tdoc, err := goquery.NewDocumentFromReader(response.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuser.Location = newLocation(doc.Find(selLocation).First().Parent().Contents().Text()) // We need parent contents\n\tuser.Name = strip(doc.Find(selUsername).First().Contents().Text())\n\n\ttable := make(map[string]string)\n\tdoc.Find(selTable).Each(func(i int, sel *goquery.Selection) {\n\t\tcaption := sel.Find(\"td.grey\")\n\t\tif key := caption.Contents().Text(); len(key) > 0 {\n\t\t\ttable[key] = caption.Siblings().Contents().Text()\n\t\t}\n\t})\n\n\tif langs := table[\"Владею языками:\"]; len(langs) > 0 {\n\t\tlangs := Map(strings.Split(strings.Split(langs, \"·\")[0], \",\"), strip)\n\t\tuser.Languages = &langs\n\t}\n\n\tuser.Motto = strip(table[\"Мой девиз:\"])\n\n\tuser.Instagram = strip(table[\"Instagram:\"])\n\n\treturn nil\n}", "func (authUserL) LoadUserCommonUserprofile(e boil.Executor, singular bool, maybeAuthUser interface{}) error {\n\tvar slice []*AuthUser\n\tvar object *AuthUser\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthUser.(*AuthUser)\n\t} else {\n\t\tslice = *maybeAuthUser.(*AuthUserSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authUserR{}\n\t\t}\n\t\targs[0] = object.ID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authUserR{}\n\t\t\t}\n\t\t\targs[i] = obj.ID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `common_userprofile` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load CommonUserprofile\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*CommonUserprofile\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice CommonUserprofile\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.UserCommonUserprofile = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.ID == foreign.UserID {\n\t\t\t\tlocal.R.UserCommonUserprofile = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *webData) showUsersWeb(w http.ResponseWriter, r *http.Request) {\n\tp := storage.QueryAllUserInfo(d.PDB)\n\terr := d.tpl.ExecuteTemplate(w, \"showUserCompletePage\", p)\n\tif err != nil {\n\t\tlog.Println(\"showUsersWeb: template execution error = \", err)\n\t}\n\tfmt.Fprint(w, err)\n}", "func Profile(response http.ResponseWriter, request *http.Request) {\n\tswitch request.Method {\n\tcase \"GET\":\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\ttype detail struct {\n\t\t\tProfile model.User\n\t\t}\n\n\t\tdetails := detail{\n\t\t\tProfile: user,\n\t\t}\n\n\t\tif user.LoginState {\n\t\t\ttmp, err := template.ParseFiles(\n\t\t\t\t\"admin/template/template.gohtml\",\n\t\t\t\t\"admin/template/sidebar.gohtml\",\n\t\t\t\t\"admin/template/header.gohtml\",\n\t\t\t\t\"admin/template/footer.gohtml\",\n\t\t\t\t\"admin/profile.gohtml\",\n\t\t\t)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(err)\n\t\t\t\thttp.Error(response, \"internal server error\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ttmp.ExecuteTemplate(response, \"layout\", details)\n\t\t\treturn\n\n\t\t} else {\n\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\tcase \"POST\":\n\t\t//get current user from session the nfind in db.\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\t//handle err\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\t//check if current user is loggedin.\n\t\tif user.LoginState {\n\t\t\trequest.ParseMultipartForm(100000)\n\n\t\t\tuserName := request.FormValue(\"userName\")\n\t\t\tfirstname := request.FormValue(\"firstName\")\n\t\t\tlastName := request.FormValue(\"lastName\")\n\t\t\tPassWord := request.FormValue(\"password\")\n\t\t\tEmail := request.FormValue(\"email\")\n\t\t\tID, _ := primitive.ObjectIDFromHex(request.FormValue(\"ID\"))\n\t\t\taddress := request.FormValue(\"address\")\n\t\t\tCity := request.FormValue(\"city\")\n\t\t\tState := request.FormValue(\"state\")\n\t\t\tZip := request.FormValue(\"zip\")\n\t\t\tpics, header, err := request.FormFile(\"pics\")\n\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(response, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t//save profile image to upload folder.\n\t\t\t//refer \"github.com/ukane-philemon/RudigoNews/utils/saveimage\"\n\t\t\tsaveimage.SaveImage(pics, header)\n\n\t\t\t//Hash new password.\n\t\t\tPassWord = model.PasswordHash(PassWord)\n\n\t\t\tnewUser := model.User{\n\t\t\t\tID: ID,\n\t\t\t\tUserName: userName,\n\t\t\t\tEmail: Email,\n\t\t\t\tFirst: firstname,\n\t\t\t\tLast: lastName,\n\t\t\t\tPassword: PassWord,\n\t\t\t\tAddress: address,\n\t\t\t\tAvatar: header.Filename,\n\t\t\t\tCity: City,\n\t\t\t\tState: State,\n\t\t\t\tZip: Zip,\n\t\t\t}\n\n\t\t\tif model.UpdateUser(newUser, ID) == nil {\n\t\t\t\thttp.Redirect(response, request, \"/admin/profile\", http.StatusSeeOther)\n\t\t\t\tfmt.Print(\"user updated\")\n\n\t\t\t} else {\n\t\t\t\tmodel.CreateUser(newUser)\n\t\t\t}\n\n\t\t} else {\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusFound)\n\t\t}\n\tdefault:\n\t\thttp.Redirect(response, request, \"/login\", http.StatusForbidden)\n\t}\n\n}", "func USERS_GET_ProfileView(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tctx := appengine.NewContext(req)\n\tu, _ := GetUserFromSession(req)\n\tid, convErr := strconv.ParseInt(params.ByName(\"ID\"), 10, 64)\n\tif ErrorPage(ctx, res, nil, \"Invalid ID\", convErr, http.StatusBadRequest) {\n\t\treturn\n\t}\n\tci, getErr := GetUserFromID(ctx, id)\n\tif ErrorPage(ctx, res, u, \"Not a valid user ID\", getErr, http.StatusNotFound) {\n\t\treturn\n\t}\n\tlog.Infof(ctx, \"error ID: \", id)\n\tnotes, err := GetAllNotes(ctx, id)\n\tlog.Infof(ctx, \"error: \", len(notes))\n\tif ErrorPage(ctx, res, nil, \"Internal Server Error\", err, http.StatusSeeOther) {\n\t\treturn\n\t}\n\tscreen := struct {\n\t\tHeaderData\n\t\tData *User\n\t\tAllNotes []NoteOutput\n\t}{\n\t\t*MakeHeader(res, req, true, true),\n\t\tci,\n\t\tnotes,\n\t}\n\tServeTemplateWithParams(res, \"user-profile\", screen)\n}", "func userPage(w http.ResponseWriter, r *http.Request){\n\tisLogged, name := CheckLoginStatus(w,r)\n\n\tif isLogged {\n\t\terr := templ.ExecuteTemplate(w, \"userHome\", name)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t} else {\n\t\thttp.Redirect(w,r,\"/unauthorized\",http.StatusSeeOther)\n\t}\n}", "func (braceletPhotoL) LoadUser(e boil.Executor, singular bool, maybeBraceletPhoto interface{}) error {\n\tvar slice []*BraceletPhoto\n\tvar object *BraceletPhoto\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeBraceletPhoto.(*BraceletPhoto)\n\t} else {\n\t\tslice = *maybeBraceletPhoto.(*BraceletPhotoSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &braceletPhotoR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &braceletPhotoR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (c *Context) LoadUser(key string) error {\n\tif c.User != nil {\n\t\treturn nil\n\t}\n\n\tvar user interface{}\n\tvar err error\n\n\tif index := strings.IndexByte(key, ';'); index > 0 {\n\t\tuser, err = c.OAuth2Storer.GetOAuth(key[:index], key[index+1:])\n\t} else {\n\t\tuser, err = c.Storer.Get(key)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.User = Unbind(user)\n\treturn nil\n}", "func Profile() echo.HandlerFunc {\n\treturn func(context echo.Context) error {\n\t\tuser, err := FindByID(context.Param(\"userID\"))\n\t\tif err != nil || user == nil {\n\t\t\treturn context.JSON(http.StatusInternalServerError, errors.New(\"Cannot load user with ID %s\"))\n\t\t}\n\n\t\tsession := context.Get(\"session\").(*session.Session)\n\n\t\tif session != nil && (session.IsAdmin || session.UserID == user.ID) {\n\t\t\tuser.Hash = \"\" // don't leak user Hash, for security\n\t\t\treturn context.JSON(http.StatusOK, user)\n\t\t}\n\n\t\treturn context.JSON(http.StatusOK, formatUser(user))\n\t}\n}", "func loadPage(pn string, r *http.Request) (*Page, error) {\n\tdata := &Page{\n\t\tPageName: pn,\n\t}\n\n\t/* Get user name for filling in template too */\n\tsesh, _ := store.Get(r, \"loginSession\")\n\tuname, ok := sesh.Values[\"username\"].(string)\n\tif !ok {\n\t\treturn nil, &ClientSafeError{Msg: \"invalid username\"}\n\t}\n\tdata.Username = uname\n\t/* get user's role */\n\trole, err := getRoleNum(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch role {\n\tcase FACILITATOR:\n\t\tdata.Role = \"Facilitator\"\n\t\tdata.Messages, err = getNotifications(data.Username)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase TEACHER:\n\t\tdata.Role = \"Teacher\"\n\tcase ADMIN:\n\t\tdata.Role = \"Admin\"\n\tdefault:\n\t\treturn nil, &ClientSafeError{Msg: \"insufficient access rights\"}\n\t}\n\n\treturn data, nil\n}", "func ProfileHandler(c buffalo.Context) error {\n\tuser := models.User{}\n\tdb := c.Value(\"tx\").(*pop.Connection)\n\tdb.Find(&user, c.Param(\"uid\"))\n\treturn c.Render(200, r.JSON(user))\n}", "func (s *VaultUserStore) Load(id msp.IdentityIdentifier) (*msp.UserData, error) {\n\tsecret, err := s.client.Logical().Read(\"fabric/kv/users/\" + strings.ToLower(id.ID) + \"@\" + strings.ToLower(id.MSPID))\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif secret == nil {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tvalue, ok := secret.Data[\"value\"]\n\n\tif !ok {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tcertString, ok := value.(string)\n\n\tif !ok {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tcertBytes := []byte(certString)\n\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to hex decode cert bytes\")\n\t}\n\n\tuserData := msp.UserData{\n\t\tID: id.ID,\n\t\tMSPID: id.MSPID,\n\t\tEnrollmentCertificate: certBytes,\n\t}\n\n\treturn &userData, nil\n}", "func ShowUser(w http.ResponseWriter, r *http.Request) {\n\tAddCors(&w)\n\n\tfmt.Printf(\"IN SHOW USER\")\n\t//pass in user ID from somewhere, try to get from url, maybe in a form when the link is hit\n\tuserInfo := pg.ReturnUser(1)\n\tfmt.Printf(\"IN SHOW USER2\")\n\t//Encode writes the JSON encoding of userInfo to the stream\n\tjson.NewEncoder(w).Encode(userInfo)\n\tfmt.Printf(\"IN SHOW USER3\")\n\t//returns json encoding of the data\n\tpagesJson, err := json.Marshal(userInfo)\n\tfmt.Printf(\"IN SHOW USER4\")\n\tif err != nil {\n\t\tlog.Fatal(\"Cannot encode to JSON \", err)\n\t}\n\n\tfmt.Printf(\"%s\", pagesJson)\n}", "func (context *authenticationContext) LoadUser(login, salt, hash string) error {\n\tif _, found := context.registeredUsers[login]; found {\n\t\treturn errors.New(\"user already exists\")\n\t}\n\tcontext.registeredUsers[login] = PasswordInformation{salt, hash}\n\treturn nil\n}", "func LoadUser(db *pg.DB, username string) (*models.User, error) {\n\tuser := new(models.User)\n\n\tfmt.Println(\"Loading User \" + username)\n\terr := db.Model(user).\n\t\tWhere(\"user_name = ?\", username).\n\t\tLimit(1).\n\t\tSelect()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn new(models.User), err\n\t}\n\treturn user, nil\n}", "func LoadUserByID(ID int) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE id=$1\"\n\terr := dbConn.QueryRow(q, ID).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func renderUser(w http.ResponseWriter, r *http.Request) {\n\tuser, err := r.Cookie(\"user_id\")\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/signin\", http.StatusMovedPermanently)\n\t\treturn\n\t}\n\t//Cookie Value\n\tcv := user.Value\n\n\tuserFile := \"user/\" + cv + \".gojson\"\n\n\t//Read User File\n\n\tbs := helpers.Reader(userFile)\n\n\t//Convert data that has been read in GOJSON to a map-interface\n\thelpers.Unmarshal(bs, &passer)\n\tfname := passer[\"person\"].(map[string]interface{})[\"firstname\"]\n\tlname := passer[\"person\"].(map[string]interface{})[\"lastname\"]\n\tuname := passer[\"person\"].(map[string]interface{})[\"username\"]\n\n\t//Converting values to string to store in a struct\n\tfirstname := fmt.Sprintf(\"%v\", fname)\n\tlastname := fmt.Sprintf(\"%v\", lname)\n\tusername := fmt.Sprintf(\"%v\", uname)\n\n\t//Storing Read values in struct to pass into template\n\tuser_details := person{\n\t\tuserInfo{\n\t\t\tFirstname: firstname,\n\t\t\tLastname: lastname,\n\t\t\tUsername: username,\n\t\t},\n\t}\n\t//fmt.Println(firstname)\n\ttpl, err := template.ParseFiles(\"app/index.gohtml\")\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\ttpl.Execute(w, user_details.Person)\n\n}", "func GetProfile(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tuname, found := vars[\"uname\"]\n\tif !found {\n\t\tw.WriteHeader(http.StatusUnprocessableEntity)\n\t\tfmt.Fprintf(w, \"%s\", \"invalid username\")\n\t\treturn\n\t} // NOT NEEDED\n\n\t// get the username\n\ttokk := r.Header.Get(\"Token\")\n\tvar payload *token.Payload\n\tif tokk != \"\" {\n\t\tmaker, err := token.NewPasetoMaker(\"abcd1234abcd1234abcd1234abcd1234\")\n\t\tif err != nil {\n\t\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\t\tpayload, err = maker.VerifyToken(tokk)\n\t\tif err != nil {\n\t\t\tpayload = &token.Payload{}\n\t\t}\n\t} else {\n\t\tresponses.ERROR(w, http.StatusUnauthorized, errors.New(\"user not logged in\"))\n\t\treturn\n\t}\n\n\t// form the dto\n\tvar dto *dtos.ProfileDTO = dtos.NewProfileDTO()\n\tif payload.Username != \"\" {\n\t\tdto.LoggedIn = true // some one is there\n\t}\n\tif payload.Username == uname {\n\t\tdto.Editable = true // same user is there\n\t}\n\n\t// start the database\n\tdatabase, err := db.Connect()\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tdefer database.Close()\n\n\t// search the database\n\tvar user schema.User\n\terr = database.Model(&schema.User{}).Where(\"username = ?\", uname).Find(&user).Error\n\tswitch err {\n\tcase nil:\n\tcase gorm.ErrRecordNotFound:\n\t\tresponses.ERROR(w, http.StatusNotFound, gorm.ErrRecordNotFound)\n\t\treturn\n\tdefault:\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\t// form the dto now\n\tdto.FromSchema(&user)\n\n\t// more db calls to populate drafts, cards, bookmarks\n\tif dto.Editable {\n\t\tdto.Drafts, err = crud.GetDraftsFromDB(database, dto.Username)\n\t\tif err != nil {\n\t\t\tlog.Println(\"coudnot fetch drafts, cards or bookmarks from db\")\n\t\t}\n\t}\n\tdto.Cards, err = crud.GetCardsFromDB(database, dto.Username)\n\tif dto.Editable {\n\t\tdto.Bookmarks, err = crud.GetBookMarkCardsFromDB(database, dto.Username)\n\t\tif err != nil {\n\t\t\tlog.Println(\"coudnot fetch drafts, cards or bookmarks from db\")\n\t\t}\n\t}\n\n\t// return the response\n\tresponses.JSON(w, http.StatusAccepted, *dto)\n\treturn\n\n}", "func (s *peerRESTServer) LoadUserHandler(w http.ResponseWriter, r *http.Request) {\n\tif !s.IsValid(w, r) {\n\t\ts.writeErrorResponse(w, errors.New(\"Invalid request\"))\n\t\treturn\n\t}\n\n\tobjAPI := newObjectLayerFn()\n\tif objAPI == nil {\n\t\ts.writeErrorResponse(w, errServerNotInitialized)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\taccessKey := vars[peerRESTUser]\n\tif accessKey == \"\" {\n\t\ts.writeErrorResponse(w, errors.New(\"username is missing\"))\n\t\treturn\n\t}\n\n\ttemp, err := strconv.ParseBool(vars[peerRESTUserTemp])\n\tif err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tif err = globalIAMSys.LoadUser(objAPI, accessKey, temp); err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tw.(http.Flusher).Flush()\n}", "func (controller *UserController) GetProfilePage(ctx *fasthttp.RequestCtx) {\n\tcontroller.getProfile(ctx, false)\n}", "func (u *User) Load() error {\n\treturn DB.LoadUser(u)\n}", "func LoadViewCreateUser(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"register.html\", nil)\n}", "func (us *userService) ShowProfile(ctx *atreugo.RequestCtx) error {\n\tstringUserID := string(ctx.Request.Header.Cookie(state.HandlerUserKeyCookie))\n\tuserID, err := strconv.ParseInt(stringUserID, 10, 64)\n\tif err != nil || userID < 1 {\n\t\tctx.SetStatusCode(http.StatusBadRequest)\n\t\treturn errors.New(http.StatusText(http.StatusBadRequest))\n\t}\n\n\tuser, err := us.usecase.Profile(ctx, userID)\n\tif err != nil {\n\t\tctx.SetStatusCode(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\treturn ctx.JSONResponse(user)\n}", "func SeeUser(w http.ResponseWriter, r *http.Request) {\n\t//Check if we have and ID\n\tID := r.URL.Query().Get(\"id\")\n\tif len(ID) < 1 {\n\t\thttp.Error(w, \"Must send the parameter ID\", http.StatusBadRequest)\n\t\treturn\n\t}\n\t//Profile not find\n\tprofile, err := db.SeeUser(ID)\n\tif err != nil {\n\t\thttp.Error(w, \"An error occurred when we try to find the register\"+err.Error(), 400)\n\t\treturn\n\t}\n\tw.Header().Set(\"context-type\", \"application/json\")\n\tw.WriteHeader(http.StatusCreated)\n\tjson.NewEncoder(w).Encode(profile)\n\n}", "func (sys *IAMSys) LoadUser(objAPI ObjectLayer, accessKey string, isSTS bool) error {\n\tif objAPI == nil {\n\t\treturn errInvalidArgument\n\t}\n\n\tsys.Lock()\n\tdefer sys.Unlock()\n\n\tif globalEtcdClient == nil {\n\t\terr := loadUser(objAPI, accessKey, isSTS, sys.iamUsersMap)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = loadMappedPolicy(objAPI, accessKey, isSTS, sys.iamUserPolicyMap)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t// When etcd is set, we use watch APIs so this code is not needed.\n\treturn nil\n}", "func (notificationL) LoadUser(e boil.Executor, singular bool, maybeNotification interface{}, mods queries.Applicator) error {\n\tvar slice []*Notification\n\tvar object *Notification\n\n\tif singular {\n\t\tobject = maybeNotification.(*Notification)\n\t} else {\n\t\tslice = *maybeNotification.(*[]*Notification)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &notificationR{}\n\t\t}\n\t\targs = append(args, object.UserID)\n\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &notificationR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.UserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.UserID)\n\n\t\t}\n\t}\n\n\tquery := NewQuery(qm.From(`user_profile`), qm.WhereIn(`id in ?`, args...))\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.Query(e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load UserProfile\")\n\t}\n\n\tvar resultSlice []*UserProfile\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice UserProfile\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for user_profile\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for user_profile\")\n\t}\n\n\tif len(notificationAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.User = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userProfileR{}\n\t\t}\n\t\tforeign.R.UserNotifications = append(foreign.R.UserNotifications, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userProfileR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.UserNotifications = append(foreign.R.UserNotifications, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (config *CrocConfig) GetUserByPage(pageID int) (User, error) {\n\tvar user User\n\tendpoint := fmt.Sprintf(\"users/%d\", pageID)\n\n\t// get json bytes from the panel.\n\tubytes, err := config.queryPanelAPI(endpoint, \"get\", nil)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\t// Unmarshal the bytes to a usable struct.\n\terr = json.Unmarshal(ubytes, &user)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\treturn user, nil\n}", "func LoadPage(c *fiber.Ctx, login string, roles []int) error {\n\tquerypack.INFO.Roles = roles\n\tquerypack.INFO.Login = login\n\tquerypack.INFO.LoggedIn = true\n\tc.Method(\"GET\")\n\tc.Path(querypack.INFO.URL)\n\tquerypack.AddCookie(c)\n\treturn c.Next()\n}", "func UserProfile(w http.ResponseWriter, r *http.Request) {\n\n\t// Add content type header to the response\n\tcontentType := \"application/json\"\n\tcharset := \"utf-8\"\n\tw.Header().Add(\"Content-Type\", fmt.Sprintf(\"%s; charset=%s\", contentType, charset))\n\n\t// Grab context references\n\trefStr := gorillaContext.Get(r, \"str\").(stores.Store)\n\n\turlValues := r.URL.Query()\n\n\t// if the url parameter 'key' is empty or absent, end the request with an unauthorized response\n\tif urlValues.Get(\"key\") == \"\" {\n\t\terr := APIErrorUnauthorized()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\tresult, err := auth.GetUserByToken(urlValues.Get(\"key\"), refStr)\n\n\tif err != nil {\n\t\tif err.Error() == \"not found\" {\n\t\t\terr := APIErrorUnauthorized()\n\t\t\trespondErr(w, err)\n\t\t\treturn\n\t\t}\n\t\terr := APIErrQueryDatastore()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Output result to JSON\n\tresJSON, err := result.ExportJSON()\n\n\tif err != nil {\n\t\terr := APIErrExportJSON()\n\t\trespondErr(w, err)\n\t\treturn\n\t}\n\n\t// Write response\n\trespondOK(w, []byte(resJSON))\n\n}", "func MemberProfile(w http.ResponseWriter,r *http.Request){\n\t// get tableid\n\tvars := mux.Vars(r)\n\tid := vars[\"userid\"]\n\tid = Between(id,\"ObjectID(\\\"\",\"\\\")\")\n\tuserid,err := primitive.ObjectIDFromHex(id)\n\tCheck(err)\n\n\tvar user Member\n\n\t// create connection\n\tclient, err := CreateConnection()\n\tCheck(err)\n\n\t// select db and collection\n cl := client.Database(database).Collection(collection)\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\n\tdefer cancel() /* USER DOC */\n\t// find table document\n\terr = cl.FindOne(ctx, bson.M{\"_id\": userid}).Decode(&user)\n\tCheck(err)\n\n\t// set headers\n\tw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tw.Header().Set(\"Access-Control-Allow-Method\", \"GET\")\n\tw.WriteHeader(http.StatusOK)\n\n\t//render template\n\tRenderTemp(w,\"profilePage\",\"base\",user)\n}", "func userShow(w http.ResponseWriter, r *http.Request) {\n w.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tvars := mux.Vars(r)\n\tmember := cleanInput(vars[\"member\"])\n\tdb := co.DbConnection(dbc)\n\tstmtQryNm, err := db.Prepare(\"SELECT user_name, email, display_name FROM members where user_name = ? ;\")\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n\tresults, err := stmtQryNm.Query(member)\n\tif err != nil {\n\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t}\n var users []userInfo\n\tfor results.Next() {\n\t\tvar user userInfo\n\t\terr = results.Scan(&user.Name, &user.Email, &user.Display)\n\t\tif err != nil {\n\t\t\tpanic(err.Error()) // proper error handling instead of panic in your app\n\t\t}\n \tusers = append(users, user)\n\t}\n\tresults.Close()\n stmtQryNm.Close()\n\tdb.Close()\n\tjsonPrintUser(w, users)\n return\n}", "func (authTokenL) LoadUser(e boil.Executor, singular bool, maybeAuthToken interface{}) error {\n\tvar slice []*AuthToken\n\tvar object *AuthToken\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthToken.(*AuthToken)\n\t} else {\n\t\tslice = *maybeAuthToken.(*[]*AuthToken)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authTokenR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authTokenR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from \\\"users\\\" where \\\"id\\\" in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(authTokenAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func ShowUserData(c *gin.Context) {\r\n\tvar info []models.Userinfo\r\n\tmodels.DB.Find(&info)\r\n\r\n\tc.JSON(200, gin.H{\"data\": info})\r\n}", "func (authUserUserPermissionL) LoadUser(e boil.Executor, singular bool, maybeAuthUserUserPermission interface{}) error {\n\tvar slice []*AuthUserUserPermission\n\tvar object *AuthUserUserPermission\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthUserUserPermission.(*AuthUserUserPermission)\n\t} else {\n\t\tslice = *maybeAuthUserUserPermission.(*AuthUserUserPermissionSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authUserUserPermissionR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authUserUserPermissionR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func LoadDemoUsers(s storage.Store) {\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Fake Mike\", \"NaN\"))\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Test Mike\", \"123-456-7890\"))\n\ts.AddItem(NewUser(s.NextID(), \"[email protected]\", \"Test User\", \"555-555-5555\"))\n}", "func LoadUserByTGID(tgID int) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE tg_id=$1\"\n\terr := dbConn.QueryRow(q, tgID).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func (h *UserHandler) Show(c *gin.Context) {\n\tvar preloadData = map[string]interface{}{\n\t\t\"Informations\": nil,\n\t\t\"Cards\": nil,\n\t}\n\n\tvar filterUser = map[string]interface{}{\n\t\t\"id\": c.MustGet(\"user_id\"),\n\t}\n\n\tvar currentUser models.User\n\terr := h.userSrv.FindOneWithScopes(&currentUser, filterUser, preloadData)\n\tif err != nil {\n\t\trespondError(c, http.StatusUnauthorized, err.Error())\n\t\treturn\n\t}\n\n\tvar resUser serializers.UserResponse\n\tif err := serializers.ConvertSerializer(currentUser, &resUser); err != nil {\n\t\trespondError(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, serializers.Resp{Result: resUser, Error: nil})\n}", "func (user *UserObject) Load(database *sqlx.DB) error {\n\tquery := fmt.Sprintf(specificItemLoad, userTableName, user.ID)\n\tresults, err := database.Queryx(query)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = user.Populate(results)\n\tif err != nil {\n\t\tlogrus.Warnf(\"failed populating data: %v\", err)\n\t}\n\n\terr = results.Close()\n\tif err != nil {\n\t\tlogrus.Warnf(\"failed closing results: %v\", err)\n\t}\n\treturn nil\n}", "func loadUser(user string) User {\n\tsession := getSession()\n\tdefer session.Close()\n\n\tusers := session.DB(\"pitsch_test\").C(\"users\")\n\n\tuserresult := User{}\n\terr := users.Find(bson.M{\"name\": user}).One(&userresult)\n\tif err != nil {\n\t\tfmt.Println(\"No such user: \")\n\t}\n\n\treturn userresult\n}", "func (u *User) Load(tx *sql.Tx, id string) error {\n\tlog.Printf(\"db.User.Load %s\", id)\n\n\tstmt := bytes.Buffer{}\n\tstmt.WriteString(`SELECT `)\n\tstmt.WriteString(userSelectColumns)\n\tstmt.WriteString(` FROM `)\n\tstmt.WriteString(userTable)\n\tstmt.WriteString(` WHERE id = ?`)\n\n\tlog.Printf(\"SQL QUERY: %s: with values %s\", stmt.String(), id)\n\n\trow := tx.QueryRow(stmt.String(), id)\n\n\tif err := u.Scan(row); err != nil {\n\t\treturn errors.Wrap(err, \"scanning row\")\n\t}\n\treturn nil\n}", "func (u *User) Load(userID string) (*models.User, error) {\n\tuser := models.User{\n\t\tUserID: models.UserID(userID),\n\t\tContact: &models.Contact{},\n\t\tReputation: &models.Reputation{},\n\t\tLocation: &models.Location{},\n\t}\n\n\tdb := u.conn.Get()\n\n\trow := db.QueryRow(fmt.Sprintf(selectUser, ` WHERE UserID = $1 `), userID)\n\n\tvar tags []string\n\n\terr := row.Scan(\n\t\t&userID,\n\t\t&user.Name,\n\t\t&user.Description,\n\t\t&user.DeviceID,\n\t\t&user.AllowShareData,\n\t\tpq.Array(&tags),\n\t\tpq.Array(&user.Images),\n\t\t&user.CreatedAt,\n\t\t&user.LastUpdate,\n\t\t&user.Reputation.Giver,\n\t\t&user.Reputation.Taker,\n\t\t&user.Contact.URL,\n\t\t&user.Contact.Email,\n\t\t&user.Contact.Facebook,\n\t\t&user.Contact.Instagram,\n\t\t&user.Contact.Twitter,\n\t\t&user.Contact.AdditionalData,\n\t\t&user.Location.Address,\n\t\t&user.Location.City,\n\t\t&user.Location.State,\n\t\t&user.Location.ZipCode,\n\t\t&user.Location.Country,\n\t\t&user.Location.Lat,\n\t\t&user.Location.Lon,\n\t\t&user.RegisterFrom,\n\t)\n\n\tuser.Tags = models.Tags(tags)\n\n\tif err != nil {\n\t\tlog.Printf(\"fail to try load user from database: id=%s, error = %s\", userID, err.Error())\n\t\treturn &user, u.conn.CheckError(err)\n\t}\n\n\tuser.Contact.Phones, err = u.loadPhones(userID)\n\n\treturn &user, u.conn.CheckError(err)\n}", "func (r *RouteHandler) getUserProfileInfo(c echo.Context) (*LoggedInUserData, error) {\n\tloggedIn := c.Get(custommiddleware.UserLoggedIn)\n\n\tloggedInBool, ok := loggedIn.(bool)\n\tif !ok || !loggedInBool {\n\t\treturn nil, errors.New(\"User is not logged in\")\n\t}\n\n\tl := LoggedInUserData{}\n\n\tid := c.Get(custommiddleware.UserIDKey)\n\n\tidInt, ok := id.(int64)\n\tif !ok {\n\t\tlog.Error(\"Could not assert id to int64\")\n\t\treturn nil, errors.New(\"could not assert id to int64\")\n\t}\n\n\tgetUserReq := userproto.GetUserFromIDRequest{\n\t\tUserID: idInt,\n\t}\n\n\tuserResp, err := r.u.GetUserFromID(context.TODO(), &getUserReq)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tl.Username = userResp.Username\n\t// l.ProfilePictureURL = userResp. // TODO\n\tl.Rank = int32(userResp.Rank)\n\tl.Email = userResp.Email\n\tl.UserID = idInt\n\treturn &l, nil\n}", "func GetUserProfile(w http.ResponseWriter, r *http.Request) {\n\n\tif utils.URLChecker(w, r, \"/profile\") {\n\n\t\tif r.Method == \"GET\" {\n\t\t\t//if userId now, createdPost uid equal -> show\n\t\t\tu := models.User{\n\t\t\t\tSession : session,\n\t\t\t}\n\t\t\tdislikedPost, likedPost, posts, comments, user := u.GetUserProfile(r, w)\n\t\t\t//check if current cookie equal - cookie\n\t\t\tutils.RenderTemplate(w, \"header\", utils.IsAuth(r))\n\t\t\tutils.RenderTemplate(w, \"profile\", user)\n\t\t\tutils.RenderTemplate(w, \"created_post\", posts)\n\t\t\tutils.RenderTemplate(w, \"favorited_post\", likedPost)\n\t\t\tutils.RenderTemplate(w, \"disliked_post\", dislikedPost)\n\t\t\tutils.RenderTemplate(w, \"comment_user\", comments)\n\t\t}\n\t}\n}", "func (repository *Datastore)GetProfile(username string)(*user.Person,error){\n\tperson := newUser() //initialize user.Person and will used to store profile info\n\tquery := `SELECT * FROM userRepository WHERE username = ?`\n\terr := repository.Db.Get(&person, query, username) //get person profile details\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &person, nil\n}", "func getUserProfileHandler(c *gin.Context) {\n\tuser, _ := c.Get(JwtIdentityKey)\n\tusername := user.(*types.User).Username\n\n\tdb := data.New()\n\tu, _ := db.Users.GetUserByUsername(username)\n\n\tc.JSON(200, gin.H{\n\t\t\"status\": http.StatusOK,\n\t\t\"username\": u.Username,\n\t\t\"role\": u.Role,\n\t})\n}", "func loadUser(col *mgo.Collection, userID string) *User {\n\tvar user User\n\terr := col.Find(bson.M{\"id\": userID}).One(&user)\n\n\tif err != nil && err != mgo.ErrNotFound {\n\t\tlog.Println(\"Failed: *************************** load user\", err)\n\t\treturn nil\n\t}\n\tif user.ID == \"\" {\n\t\tuser.ID = userID\n\t\tfmt.Println(\"Loaded user\")\n\t\tcol.Insert(user)\n\t}\n\t//spew.Dump(user)\n\treturn &user\n}", "func (mdb MongoDBConnection) LoadUser(Email string) (result structs.User, err error) {\n\tmdb.session = mdb.GetSession()\n\tdefer mdb.session.Close()\n\tc := mdb.session.DB(\"webadventure\").C(\"users\")\n\terr = c.Find(bson.M{\"email\": Email}).One(&result)\n\treturn result, err\n}", "func FetchUserUI(usrName string) {\n\tif checkIfRequiredFilesExist(db) {\n\t\tif queryString(usrName, \"db/usernames.txt\") == false {\n\t\t\tfmt.Println(\"The following user does not exist: \", usrName)\n\t\t} else {\n\t\t\tuser := FetchUser(usrName)\n\t\t\tuser.printInfo()\n\t\t}\n\t}\n}", "func (this *UserAuthController) Profile() {\n\tsesid := this.GetSession(\"sesid\")\n if(sesid == nil){\n this.Redirect(\"/\",302)\n return\n }\n this.TplName = \"userAuth/profile.tpl\"\n\n url := \"172.17.0.2:27017\"\n database := \"testDB\"\n collection := \"users\"\n session, err := mgo.Dial(url)\n\n if(err != nil){\n log.Fatal(err)\n }\n defer session.Close()\n\n session.SetMode(mgo.Monotonic, true)\n\n c := session.DB(database).C(collection)\n\n result := User{}\n err = c.Find(bson.M{\"email\" : sesid}).One(&result)\n\n if(err != nil){\n this.Redirect(\"/login\",302)\n return\n }else{\n this.Data[\"firstName\"] = result.FirstName\n this.Data[\"lastName\"] = result.LastName\n this.Data[\"company\"] = result.Company\n this.Data[\"categories\"] = result.Categories\n this.Data[\"address1\"] = result.Address1\n this.Data[\"address2\"] = result.Address2\n this.Data[\"phone\"] = result.Phone\n }\n}", "func (authMessageL) LoadUser(e boil.Executor, singular bool, maybeAuthMessage interface{}) error {\n\tvar slice []*AuthMessage\n\tvar object *AuthMessage\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthMessage.(*AuthMessage)\n\t} else {\n\t\tslice = *maybeAuthMessage.(*AuthMessageSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authMessageR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authMessageR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func getUserProfile(w http.ResponseWriter, r *http.Request) {\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tvar body user\n\te := json.NewDecoder(r.Body).Decode(&body)\n\tif e != nil {\n\n\t\tfmt.Print(e)\n\t}\n\tvar result primitive.M // an unordered representation of a BSON document which is a Map\n\terr := userCollection.FindOne(context.TODO(), bson.D{{\"name\", body.Name}}).Decode(&result)\n\tif err != nil {\n\n\t\tfmt.Println(err)\n\n\t}\n\tjson.NewEncoder(w).Encode(result) // returns a Map containing document\n\n}", "func (core *Plugin) viewUser(c cmd.Context) (string, slack.PostMessageParameters) {\n\tparams := slack.PostMessageParameters{}\n\tusername := c.Options[\"user\"].Value\n\tuser := model.Member{\n\t\tSlackID: cmd.ParseMention(username),\n\t}\n\tif err := core.Bot.DAL.GetMemberBySlackID(&user); err != nil {\n\t\tlog.WithError(err).Error(\"Failed to get member \" + username)\n\t\treturn \"Failed to get member \" + username, params\n\t}\n\tparams.Attachments = user.SlackAttachments()\n\treturn username + \"'s profile\", params\n}", "func (o *AuthUser) Reload(exec boil.Executor) error {\n\tret, err := FindAuthUser(exec, o.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func GetUsersPage(resp http.ResponseWriter, req *http.Request) {\n\tpage := request.MapPage(mux.Vars(req))\n\tstart := page.GetPage() * page.GetSize()\n\tend := start + page.GetSize()\n\n\tif end > len(users) {\n\t\tend = len(users)\n\t}\n\n\tvar content []interface{}\n\tif page.GetSize() > 0 && start < len(users) {\n\t\tcontent = append(content, users[start:end])\n\t}\n\n\tresult := response.BuildPage(&content, page, int64(len(users)))\n\n\tresponse.WriteJSON(http.StatusOK, result, resp)\n}", "func UserDetailsHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\tcurrentUser := GetUser(r)\n\tuserProfile, _, errorUser := userService.RetrieveUserForAdmin(id)\n\tif errorUser == nil && userPermission.CurrentOrAdmin(currentUser, userProfile.ID) {\n\t\tif userPermission.CurrentOrAdmin(currentUser, userProfile.ID) {\n\t\t\tb := form.UserForm{}\n\t\t\tmodelHelper.BindValueForm(&b, r)\n\t\t\tlanguages.SetTranslationFromRequest(viewProfileEditTemplate, r, \"en-us\")\n\t\t\tavailableLanguages := languages.GetAvailableLanguages()\n\t\t\thtv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), availableLanguages, NewSearchForm(), Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)}\n\t\t\terr := viewProfileEditTemplate.ExecuteTemplate(w, \"index.html\", htv)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlanguages.SetTranslationFromRequest(notFoundTemplate, r, \"en-us\")\n\t\terr := notFoundTemplate.ExecuteTemplate(w, \"index.html\", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)})\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n }\n}", "func (s *peerRESTServer) LoadUsersHandler(w http.ResponseWriter, r *http.Request) {\n\tif !s.IsValid(w, r) {\n\t\ts.writeErrorResponse(w, errors.New(\"Invalid request\"))\n\t\treturn\n\t}\n\n\terr := globalIAMSys.Load()\n\tif err != nil {\n\t\ts.writeErrorResponse(w, err)\n\t\treturn\n\t}\n\n\tw.(http.Flusher).Flush()\n}", "func (s *Store) User(name string) (ui *UserInfo, err error) {\n\terr = s.read(func(data *Data) error {\n\t\tui = data.User(name)\n\t\tif ui == nil {\n\t\t\treturn errInvalidate\n\t\t}\n\t\treturn nil\n\t})\n\treturn\n}", "func (stockL) LoadUser(e boil.Executor, singular bool, maybeStock interface{}) error {\n\tvar slice []*Stock\n\tvar object *Stock\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeStock.(*Stock)\n\t} else {\n\t\tslice = *maybeStock.(*[]*Stock)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &stockR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &stockR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `users` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.UserID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (controller *UserController) GetEditPage(ctx *fasthttp.RequestCtx) {\n\tcontroller.getProfile(ctx, true)\n}", "func (c *Client) Profile(username string) (UserModel, ContentModel, error) {\n\tuserId, err := getUserId(username)\n\tif err != nil {\n\t\treturn UserModel{}, ContentModel{}, err\n\t}\n\turl := fmt.Sprintf(USER_PATH, API, userId, APP_VERSION)\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn UserModel{}, ContentModel{}, err\n\t}\n\tvar data UserResponse\n\tjson.NewDecoder(res.Body).Decode(&data)\n\tif !data.Success && data.Error != \"\" {\n\t\treturn UserModel{}, ContentModel{}, errors.New(data.Error)\n\t}\n\treturn data.Profile, data.Profile.Content.Content, nil\n}", "func UserInfo(data UserInfoData) http.Handler {\n\treturn httputil.HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {\n\t\treturn ui.ServePage(w, r, \"UserInfo\", data.ToJSON())\n\t})\n}", "func (projectL) LoadUser(ctx context.Context, e boil.ContextExecutor, singular bool, maybeProject interface{}, mods queries.Applicator) error {\n\tvar slice []*Project\n\tvar object *Project\n\n\tif singular {\n\t\tobject = maybeProject.(*Project)\n\t} else {\n\t\tslice = *maybeProject.(*[]*Project)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &projectR{}\n\t\t}\n\t\targs = append(args, object.UserID)\n\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &projectR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.UserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.UserID)\n\n\t\t}\n\t}\n\n\tif len(args) == 0 {\n\t\treturn nil\n\t}\n\n\tquery := NewQuery(\n\t\tqm.From(`user`),\n\t\tqm.WhereIn(`user.ID in ?`, args...),\n\t)\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for user\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for user\")\n\t}\n\n\tif len(projectAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.User = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userR{}\n\t\t}\n\t\tforeign.R.Projects = append(foreign.R.Projects, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.Projects = append(foreign.R.Projects, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func User(store *projector.SlideStore) {\n\tstore.RegisterSliderFunc(\"user\", func(ctx context.Context, fetch *datastore.Fetcher, p7on *projector.Projection) (responseValue []byte, err error) {\n\t\tid, err := strconv.Atoi(strings.Split(p7on.ContentObjectID, \"/\")[1])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting user id: %w\", err)\n\t\t}\n\n\t\tuser, err := NewUser(ctx, fetch, id, p7on.MeetingID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting new user id: %w\", err)\n\t\t}\n\t\tif err := fetch.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tout := struct {\n\t\t\tUser string `json:\"user\"`\n\t\t}{\n\t\t\tuser.UserRepresentation(p7on.MeetingID),\n\t\t}\n\t\tresponseValue, err = json.Marshal(out)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"encoding response slide user: %w\", err)\n\t\t}\n\t\treturn responseValue, err\n\t})\n\n\tstore.RegisterGetTitleInformationFunc(\"user\", func(ctx context.Context, fetch *datastore.Fetcher, fqid string, itemNumber string, meetingID int) (json.RawMessage, error) {\n\t\tid, err := strconv.Atoi(strings.Split(fqid, \"/\")[1])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting user id: %w\", err)\n\t\t}\n\n\t\tuser, err := NewUser(ctx, fetch, id, meetingID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"loading user: %w\", err)\n\t\t}\n\t\tif err := fetch.Err(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tout := struct {\n\t\t\tCollection string `json:\"collection\"`\n\t\t\tContentObjectID string `json:\"content_object_id\"`\n\t\t\tUsername string `json:\"username\"`\n\t\t}{\n\t\t\t\"user\",\n\t\t\tfqid,\n\t\t\tuser.UserRepresentation(meetingID),\n\t\t}\n\t\tresponseValue, err := json.Marshal(out)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"encoding title: %w\", err)\n\t\t}\n\t\treturn responseValue, err\n\t})\n}", "func ShowUserDetails() error {\n\tspinner.Start()\n\tuser, err := getCurrentUser()\n\tspinner.Stop()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(`NAME: %s\nEMAIL: %s\nAPPS:\n`, user.Details.Name, user.Email)\n\n\ttable := tablewriter.NewWriter(os.Stdout)\n\ttable.SetHeader([]string{\"Id\", \"Name\"})\n\tfor name, id := range user.Apps {\n\t\ttable.Append([]string{id, name})\n\t}\n\ttable.Render()\n\n\treturn nil\n}", "func (c users) LoadUserToToken(tk *Token, l *log.Entry) error {\n\tu, err := c.getWithTeams(*tk.Email, l)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttk.User = u\n\treturn nil\n}", "func (postL) LoadEditorUser(ctx context.Context, e boil.ContextExecutor, singular bool, maybePost interface{}, mods queries.Applicator) error {\n\tvar slice []*Post\n\tvar object *Post\n\n\tif singular {\n\t\tobject = maybePost.(*Post)\n\t} else {\n\t\tslice = *maybePost.(*[]*Post)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &postR{}\n\t\t}\n\t\targs = append(args, object.EditorUserID)\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &postR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.EditorUserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.EditorUserID)\n\t\t}\n\t}\n\n\tquery := NewQuery(qm.From(`users`), qm.WhereIn(`id in ?`, args...))\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for users\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for users\")\n\t}\n\n\tif len(postAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.EditorUser = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userR{}\n\t\t}\n\t\tforeign.R.EditorUserPosts = append(foreign.R.EditorUserPosts, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.EditorUserID == foreign.ID {\n\t\t\t\tlocal.R.EditorUser = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.EditorUserPosts = append(foreign.R.EditorUserPosts, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (d *webData) addUsersWeb(w http.ResponseWriter, r *http.Request) {\n\terr := d.tpl.ExecuteTemplate(w, \"addUserCompletePage\", \"some data\")\n\tif err != nil {\n\t\tlog.Println(\"addUsersWeb: template execution error = \", err)\n\t}\n\n\tr.ParseForm()\n\tu := storage.User{}\n\tgetFormValuesUserInfo(&u, r)\n\n\tif u.FirstName != \"\" {\n\t\tpid, _ := storage.QueryForLastUID(d.PDB)\n\t\t//increment the user index nr by one for the new used to add\n\t\tpid++\n\t\tfmt.Println(\"------pid ---------- = \", pid)\n\t\tprintln(\"addUsersWeb: UID = \", pid)\n\t\tu.Number = pid\n\t\tstorage.AddUser(d.PDB, u)\n\t}\n}", "func loadUserDataAt(pos int) error{\n\n\tif pos > len(userList.UserList){\n\t\treturn errors.New(\"Out of range\")\n\t}\n\tUser = userList.UserList[pos]\n\n\tAccessToken = User.AccessToken\n\tcode = User.RefreshToken\n\treturn nil\n}", "func (r *UserRead) show(q *msg.Request, mr *msg.Result) {\n\tvar (\n\t\tuserID, userName string\n\t\tfirstName, lastName string\n\t\tmailAddr, team string\n\t\tdictID, dictName, createdBy string\n\t\tcreatedAt time.Time\n\t\temployeeNr int\n\t\tisActive, isSystem, isDeleted bool\n\t\terr error\n\t)\n\n\tif err = r.stmtShow.QueryRow(\n\t\tq.User.ID,\n\t).Scan(\n\t\t&userID,\n\t\t&userName,\n\t\t&firstName,\n\t\t&lastName,\n\t\t&employeeNr,\n\t\t&mailAddr,\n\t\t&isActive,\n\t\t&isSystem,\n\t\t&isDeleted,\n\t\t&team,\n\t\t&dictID,\n\t\t&dictName,\n\t\t&createdBy,\n\t\t&createdAt,\n\t); err == sql.ErrNoRows {\n\t\tmr.NotFound(err, q.Section)\n\t\treturn\n\t} else if err != nil {\n\t\tmr.ServerError(err, q.Section)\n\t\treturn\n\t}\n\n\tmr.User = append(mr.User, proto.User{\n\t\tID: userID,\n\t\tUserName: userName,\n\t\tFirstName: firstName,\n\t\tLastName: lastName,\n\t\tEmployeeNumber: strconv.Itoa(employeeNr),\n\t\tMailAddress: mailAddr,\n\t\tIsActive: isActive,\n\t\tIsSystem: isSystem,\n\t\tIsDeleted: isDeleted,\n\t\tTeamID: team,\n\t\tDetails: &proto.UserDetails{\n\t\t\tCreation: &proto.DetailsCreation{\n\t\t\t\tCreatedAt: createdAt.Format(msg.RFC3339Milli),\n\t\t\t\tCreatedBy: createdBy,\n\t\t\t},\n\t\t\tDictionaryID: dictID,\n\t\t\tDictionaryName: dictName,\n\t\t},\n\t})\n\tmr.OK()\n}", "func (h *UserRepos) View(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tdata := make(map[string]interface{})\n\tf := func() error {\n\n\t\tclaims, err := auth.ClaimsFromContext(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tusr, err := h.UserRepo.ReadByID(ctx, claims, claims.Subject)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdata[\"user\"] = usr.Response(ctx)\n\n\t\tusrAccs, err := h.UserAccountRepo.FindByUserID(ctx, claims, claims.Subject, false)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, usrAcc := range usrAccs {\n\t\t\tif usrAcc.AccountID == claims.Audience {\n\t\t\t\tdata[\"userAccount\"] = usrAcc.Response(ctx)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tif err := f(); err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-view.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func showUser(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"cache-control\", \"no-store, no-cache, must-revalidate\")\n\tsession := sessions.Start(w, r)\n\n\tif len(session.GetString(\"username\")) == 0 {\n\t\thttp.Redirect(w, r, \"/login\", 301)\n\t}\n\n\tvars := mux.Vars(r)\n\tusername := vars[\"username\"]\n\tcurrentUser := QueryUser(session.GetString(\"username\"))\n\tuser := QueryUser(username)\n\tpjax := r.Header.Get(\"X-PJAX\") == \"\"\n\tprofile := QueryProfile(user.ID)\n\tvar following bool\n\n\tdb.QueryRow(\"SELECT 1 FROM follows WHERE follow_to = ? AND follow_by = ?\", user.ID, currentUser.ID).Scan(&following)\n\n\tdb.QueryRow(\"SELECT COUNT(*) FROM follows WHERE follow_by = ?\", user.ID).Scan(&profile.FollowingCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM follows WHERE follow_to = ?\", user.ID).Scan(&profile.FollowerCount)\n\n\tdb.QueryRow(\"SELECT COUNT(*) FROM posts WHERE created_by = ?\", user.ID).Scan(&profile.PostCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM comments WHERE created_by = ?\", user.ID).Scan(&profile.CommentCount)\n\tdb.QueryRow(\"SELECT COUNT(*) FROM yeahs WHERE yeah_by = ?\", user.ID).Scan(&profile.YeahCount)\n\n\tpost_rows, _ := db.Query(\"SELECT posts.id, community_id, created_at, body, image, title, icon FROM posts LEFT JOIN communities ON communities.id = community_id WHERE created_by = ? ORDER BY created_at DESC LIMIT 3\", user.ID)\n\tvar posts []post\n\n\tfor post_rows.Next() {\n\n\t\tvar row = post{}\n\t\tvar timestamp time.Time\n\t\tvar yeahed string\n\n\t\terr = post_rows.Scan(&row.ID, &row.CommunityID, &timestamp, &row.Body, &row.Image, &row.CommunityName, &row.CommunityIcon)\n\t\trow.CreatedAt = humanTiming(timestamp)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\t// Check if the post has been yeahed.\n\t\tdb.QueryRow(\"SELECT id FROM yeahs WHERE yeah_post = ? AND yeah_by = ? AND on_comment=0\", row.ID, currentUser.ID).Scan(&yeahed)\n\t\tif yeahed != \"\" {\n\t\t\trow.Yeahed = true\n\t\t}\n\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM yeahs WHERE yeah_post = ? AND on_comment=0\", row.ID).Scan(&row.YeahCount)\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM comments WHERE post = ?\", row.ID).Scan(&row.CommentCount)\n\n\t\tposts = append(posts, row)\n\t}\n\tpost_rows.Close()\n\n\tyeah_rows, _ := db.Query(\"SELECT posts.id, created_by, community_id, created_at, body, image, username, nickname, avatar, online, title, icon FROM yeahs INNER JOIN posts ON posts.id = yeah_post INNER JOIN users ON users.id = posts.created_by INNER JOIN communities ON communities.id = community_id WHERE yeah_by = ? AND on_comment = 0 ORDER BY created_at DESC LIMIT 3\", user.ID)\n\tvar yeahs []post\n\n\tfor yeah_rows.Next() {\n\n\t\tvar row = post{}\n\t\tvar timestamp time.Time\n\t\tvar yeahed string\n\n\t\terr = yeah_rows.Scan(&row.ID, &row.CreatedBy, &row.CommunityID, &timestamp, &row.Body, &row.Image, &row.PosterUsername, &row.PosterNickname, &row.PosterIcon, &row.PosterOnline, &row.CommunityName, &row.CommunityIcon)\n\t\trow.CreatedAt = humanTiming(timestamp)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\t// Check if the post has been yeahed.\n\t\tdb.QueryRow(\"SELECT id FROM yeahs WHERE yeah_post = ? AND yeah_by = ? AND on_comment=0\", row.ID, currentUser.ID).Scan(&yeahed)\n\t\tif yeahed != \"\" {\n\t\t\trow.Yeahed = true\n\t\t}\n\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM yeahs WHERE yeah_post = ? AND on_comment=0\", row.ID).Scan(&row.YeahCount)\n\t\tdb.QueryRow(\"SELECT COUNT(id) FROM comments WHERE post = ?\", row.ID).Scan(&row.CommentCount)\n\n\t\tyeahs = append(yeahs, row)\n\t}\n\tyeah_rows.Close()\n\n\tvar data = map[string]interface{}{\n\t\t\"Title\": user.Nickname + \"'s profile\",\n\t\t\"Pjax\": pjax,\n\t\t\"CurrentUser\": currentUser,\n\t\t\"User\": user,\n\t\t\"Profile\": profile,\n\t\t\"Following\": following,\n\t\t\"Posts\": posts,\n\t\t\"Yeahs\": yeahs,\n\t}\n\n\terr := templates.ExecuteTemplate(w, \"user.html\", data)\n\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t}\n}", "func (pc UserController) Show(c *gin.Context) {\n\tid := c.Params.ByName(\"id\")\n\tvar u repository.UserRepository\n\tidInt, _ := strconv.Atoi(id)\n\tuser, err := u.GetByID(idInt)\n\n\tif err != nil {\n\t\tc.AbortWithStatus(400)\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"error\": err.Error()})\n\t} else {\n\t\tc.JSON(200, user)\n\t}\n}", "func readProfile(cookieValue string) (*Profile, error) {\n\tapiURL := \"http://localhost:8080/v1/accounts/@me\"\n\tclient := &http.Client{}\n\trequest, err := http.NewRequest(\"GET\", apiURL, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trequest.Header.Add(\"Cookie\", cookieValue)\n\tresp, err := client.Do(request)\n\tif err != nil {\n\t\tlog.Println(\"Cookie may expire \", err)\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t// Extract data from response and turn to pageInfo type\n\tvar pageInfo Profile\n\terr = json.Unmarshal(bodyBytes, &pageInfo)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\treturn &pageInfo, err\n}", "func UserEdit(w http.ResponseWriter, r *http.Request, u *User) error {\n\treturn RenderTemplate(w, \"user_profile.html\", struct{ User *User }{u})\n}", "func ViewUsers(w http.ResponseWriter, r *http.Request) { \n AuthorizePages(w,r) \n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewUsers.html\")\n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n userId := UserIds{\n UserId: r.FormValue(\"userId\"),\n }\n\n var successMessage string\n var isShow bool \n\n if (userId.UserId != \"\" ) {\n if (dbquery.DeleteManagerUser(\"User\",userId.UserId)){\n isShow = true\n successMessage = \"User Deleted Successfully\"\n }\n }\n\n var userList []helpers.User \n userList = dbquery.GetUserByRole(\"\",\"'User'\")\n t.Execute(w, AllUsersResponse{Users: userList, SuccessMessage: successMessage, IsShow: isShow}) \n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func GetUserProfileHandler(w http.ResponseWriter, r *http.Request) {\n\n}", "func (m *MockDatabase) LoadUserID(ID string) (general.User, error) {\n\targs := m.Called(ID)\n\treturn args.Get(0).(general.User), args.Error(1)\n}", "func PKLoadUser(db *pg.DB, pk int64) (*models.User, error) {\n\t// Select user by Primary Key\n\tuser := &models.User{ID: pk}\n\terr := db.Select(user)\n\n\tif err != nil {\n\t\treturn &models.User{UserName: \"New\"}, err\n\t}\n\n\tfmt.Println(\"User loaded From DB\")\n\treturn user, nil\n}", "func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {\n\ts := session.(*Session)\n\tuser := goth.User{\n\t\tAccessToken: s.AccessToken,\n\t\tProvider: p.Name(),\n\t}\n\n\treq, err := http.NewRequest(\"GET\", \"\", nil)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\t//add url as opaque to avoid escaping of \"(\"\n\treq.URL = &url.URL{\n\t\tScheme: \"https\",\n\t\tHost: \"api.linkedin.com\",\n\t\tOpaque: userEndpoint,\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer \"+s.AccessToken)\n\treq.Header.Add(\"x-li-format\", \"json\") //request json response\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn user, err\n\t}\n\tdefer resp.Body.Close()\n\t//err = userFromReader(io.TeeReader(resp.Body, os.Stdout), &user)\n\terr = userFromReader(resp.Body, &user)\n\treturn user, err\n}", "func UserShow(w http.ResponseWriter, r *http.Request, u *User) error {\n\t// list of repositories owned by User\n\trepos, err := database.ListRepos(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// list of user team accounts\n\tteams, err := database.ListTeams(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// list of recent commits\n\tcommits, err := database.ListCommitsUser(u.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdata := struct {\n\t\tUser *User\n\t\tRepos []*Repo\n\t\tTeams []*Team\n\t\tCommits []*RepoCommit\n\t}{u, repos, teams, commits}\n\treturn RenderTemplate(w, \"user_dashboard.html\", &data)\n}", "func (m *MockDatabase) LoadUserSessionID(SessionID string) (general.User, error) {\n\targs := m.Called(SessionID)\n\treturn args.Get(0).(general.User), args.Error(1)\n}", "func (transactionL) LoadUser(e boil.Executor, singular bool, maybeTransaction interface{}) error {\n\tvar slice []*Transaction\n\tvar object *Transaction\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeTransaction.(*Transaction)\n\t} else {\n\t\tslice = *maybeTransaction.(*[]*Transaction)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &transactionR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &transactionR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `users` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.UserID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func LoadUserByUsername(username string) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE username=$1\"\n\terr := dbConn.QueryRow(q, username).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func GetUser(c *context.Context) {\n\ta, _ := auth.GetCurrentTokenData(c)\n\n\turl := fmt.Sprintf(\"%s/users/show.json?source=%s&uid=%s&access_token=%s\",\n\t\tWEIBOSERVER, auth.APPKEY, a.UID, a.AccessToken)\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tc.WriteJson(500, \"无法联系新浪服务器\")\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\tbody, _ := ioutil.ReadAll(resp.Body)\n\tc.WriteBody(resp.StatusCode, body)\n}", "func UserViewHandler(w http.ResponseWriter, req *http.Request) {\n\n\t// Get session values or redirect to Login\n\tsession, err := sessions.Store.Get(req, \"session\")\n\n\tif err != nil {\n\t\tlog.Println(\"error identifying session\")\n\t\thttp.Redirect(w, req, \"/login/\", 302)\n\t\treturn\n\t\t// in case of error\n\t}\n\n\t// Prep for user authentication\n\tsessionMap := getUserSessionValues(session)\n\n\tusername := sessionMap[\"username\"]\n\tloggedIn := sessionMap[\"loggedin\"]\n\tisAdmin := sessionMap[\"isAdmin\"]\n\n\tvars := mux.Vars(req)\n\tidString := vars[\"id\"]\n\n\tpk, err := strconv.Atoi(idString)\n\tif err != nil {\n\t\tpk = 0\n\t\tlog.Println(err)\n\t}\n\n\tfmt.Println(session)\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t\treturn\n\t}\n\n\tuser, err := database.PKLoadUser(db, int64(pk))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\tfmt.Println(\"Unable to load User\")\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t}\n\n\t// Validate that User == Admin\n\tIsAuthor := false\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t}\n\n\texps, err := database.ListUserExperiences(db, user.UserName)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlrs := []*models.LearningResource{}\n\tlrStrings := []string{}\n\n\tfor _, ex := range exps {\n\t\tif !isInString(lrStrings, ex.LearningResource.Path) {\n\t\t\tlrs = append(lrs, ex.LearningResource)\n\t\t\tlrStrings = append(lrStrings, ex.LearningResource.Path)\n\t\t}\n\t}\n\n\t// Determine overall progression\n\n\tvar targetTotal, currentTotal int\n\n\tfor _, s := range user.Streams {\n\t\ttargetTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][0]\n\t\tcurrentTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][1]\n\t}\n\n\tcategories := map[string]int{\n\t\t\"currentTotal\": currentTotal,\n\t\t\"targetTotal\": targetTotal,\n\t}\n\n\tfor _, ex := range exps {\n\t\tcategories[ex.Stream.Name] += ex.Points\n\t\tcategories[\"max\"] += ex.Points\n\t}\n\n\twv := WebView{\n\t\tUser: user,\n\t\tIsAuthor: IsAuthor,\n\t\tIsLoggedIn: loggedIn,\n\t\tSessionUser: username,\n\t\tIsAdmin: isAdmin,\n\t\tLearningResources: lrs,\n\t\tExperiences: exps,\n\t\tCategoryMap: categories,\n\t\tUserFrame: true,\n\t\tNumMap: skillMap,\n\t\tStringMap: fontMap,\n\t\tArchitecture: baseArchitecture,\n\t}\n\n\tRender(w, \"templates/user_view.html\", wv)\n}", "func (o *UserGoogle) Reload(ctx context.Context, exec boil.ContextExecutor) error {\n\tret, err := FindUserGoogle(ctx, exec, o.GoogleID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func (app *appDB) updateProfile(w http.ResponseWriter, r *http.Request) {\r\n\t//redirect to main page if there's no cookie found\r\n\tif !session.Check(w, r) {\r\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\r\n\t\treturn\r\n\t}\r\n\tup := updatePage{}\r\n\tuserID, _ := session.Get(r)\r\n\r\n\tup.UserID = userID\r\n\tapp.render(w, profileTemplate, up)\r\n\treturn\r\n}", "func (up *UserPermissions) Load() (err error) {\n\tup.file.Open(READ_ONLY)\n\tdefer up.file.Close()\n\tif up.file.size == 0 {return}\n\tup.Lock()\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tkey, upr := rec.ToUserPermissionRecord(up.debug)\n\t\t\tup.index[key] = upr // Don't need to use gateway because up is fresh\n\t\t}\n\t\treturn nil\n\t}\n\terr = up.file.Process(f, PERMISSION_RECORD, false)\n\tup.Unlock()\n\treturn\n}", "func (r *Reaction) LoadUser() (*user_model.User, error) {\n\tif r.User != nil {\n\t\treturn r.User, nil\n\t}\n\tuser, err := user_model.GetUserByID(db.DefaultContext, r.UserID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr.User = user\n\treturn user, nil\n}", "func (bot *BotAPI) PreloadUserInfo(update *Update) {\n\tif update.Message == nil || update.Message.IsAnonymous() {\n\t\treturn\n\t}\n\tvar user User\n\tvar err error\n\tif update.Message.Chat.Type == \"group\" {\n\t\tuser, err = bot.GetGroupMemberInfo(update.GroupID, update.UserID, false)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tuser, err = bot.GetStrangerInfo(update.UserID)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\n\tupdate.Message.From = &user\n}", "func LoadLoginPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\n\tif cookie[\"token\"] != \"\" {\n\t\thttp.Redirect(w, r, \"/feed\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"login.html\", nil)\n}", "func (u *User) Profile() (p *UserProfile, err error) {\n\treturn p, getjson(u.client, p, nil, \"/users/%d/profile\", u.ID)\n}" ]
[ "0.76636285", "0.74508435", "0.6977827", "0.64868104", "0.6387404", "0.6350716", "0.63026816", "0.61875933", "0.61619353", "0.61365813", "0.607116", "0.6012404", "0.60118514", "0.6001068", "0.5987921", "0.5973989", "0.589364", "0.58862895", "0.58212346", "0.5812843", "0.57916725", "0.5785279", "0.57517165", "0.57513976", "0.57280236", "0.5713175", "0.5711923", "0.5699365", "0.5692095", "0.56788397", "0.56770945", "0.5676382", "0.56542814", "0.56189907", "0.5613788", "0.56100625", "0.56097585", "0.56070197", "0.5591884", "0.5588588", "0.5575741", "0.5575521", "0.55661136", "0.55656916", "0.5559133", "0.555858", "0.55458796", "0.55274326", "0.5521505", "0.55010355", "0.54886806", "0.5477434", "0.54620934", "0.54601204", "0.5459539", "0.545497", "0.5452987", "0.54345834", "0.5420843", "0.5407896", "0.5405057", "0.5397233", "0.5394043", "0.5375969", "0.5373443", "0.53581923", "0.5350315", "0.5349249", "0.5322106", "0.53211755", "0.5320505", "0.531353", "0.52942395", "0.5290838", "0.5289668", "0.52856064", "0.5276004", "0.5266414", "0.5262815", "0.5261016", "0.5254666", "0.5253232", "0.52463305", "0.5239986", "0.52349", "0.52275705", "0.5226159", "0.5216934", "0.5204644", "0.5193168", "0.5184148", "0.51778775", "0.5167478", "0.51672864", "0.51672566", "0.51653755", "0.51633674", "0.5159313", "0.51535714", "0.5151795" ]
0.761864
1
LoadUserLoggedProfile Load the user profile
func LoadUserLoggedProfile(w http.ResponseWriter, r *http.Request) { cookie, _ := cookies.Read(r) userID, _ := strconv.ParseUint(cookie["id"], 10, 64) user, err := models.SearchCompleteUser(userID, r) if err != nil { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()}) return } utils.RunTemplate(w, "profile.html", user) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (authUserL) LoadUserCommonUserprofile(e boil.Executor, singular bool, maybeAuthUser interface{}) error {\n\tvar slice []*AuthUser\n\tvar object *AuthUser\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthUser.(*AuthUser)\n\t} else {\n\t\tslice = *maybeAuthUser.(*AuthUserSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authUserR{}\n\t\t}\n\t\targs[0] = object.ID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authUserR{}\n\t\t\t}\n\t\t\targs[i] = obj.ID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `common_userprofile` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load CommonUserprofile\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*CommonUserprofile\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice CommonUserprofile\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.UserCommonUserprofile = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.ID == foreign.UserID {\n\t\t\t\tlocal.R.UserCommonUserprofile = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func LoadUserData(id int) error{\n\n\tuserPos, err := findUser(id)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Errorf(\"Error: \",err.Error())\n\t\treturn err\n\t}\n\n\tloadUserDataAt(userPos)\n\n\treturn nil\n}", "func (context *authenticationContext) LoadUser(login, salt, hash string) error {\n\tif _, found := context.registeredUsers[login]; found {\n\t\treturn errors.New(\"user already exists\")\n\t}\n\tcontext.registeredUsers[login] = PasswordInformation{salt, hash}\n\treturn nil\n}", "func (m *MockDatabase) LoadUserSessionID(SessionID string) (general.User, error) {\n\targs := m.Called(SessionID)\n\treturn args.Get(0).(general.User), args.Error(1)\n}", "func LoadUserPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"userId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserIDLogged, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tif userID == userIDLogged {\n\t\thttp.Redirect(w, r, \"/profile\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"user.html\", struct {\n\t\tUser models.User\n\t\tUserLoggedID uint64\n\t}{\n\t\tUser: user,\n\t\tUserLoggedID: userIDLogged,\n\t})\n}", "func (c *Context) LoadUser(key string) error {\n\tif c.User != nil {\n\t\treturn nil\n\t}\n\n\tvar user interface{}\n\tvar err error\n\n\tif index := strings.IndexByte(key, ';'); index > 0 {\n\t\tuser, err = c.OAuth2Storer.GetOAuth(key[:index], key[index+1:])\n\t} else {\n\t\tuser, err = c.Storer.Get(key)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tc.User = Unbind(user)\n\treturn nil\n}", "func (s *VaultUserStore) Load(id msp.IdentityIdentifier) (*msp.UserData, error) {\n\tsecret, err := s.client.Logical().Read(\"fabric/kv/users/\" + strings.ToLower(id.ID) + \"@\" + strings.ToLower(id.MSPID))\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif secret == nil {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tvalue, ok := secret.Data[\"value\"]\n\n\tif !ok {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tcertString, ok := value.(string)\n\n\tif !ok {\n\t\treturn nil, msp.ErrUserNotFound\n\t}\n\n\tcertBytes := []byte(certString)\n\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to hex decode cert bytes\")\n\t}\n\n\tuserData := msp.UserData{\n\t\tID: id.ID,\n\t\tMSPID: id.MSPID,\n\t\tEnrollmentCertificate: certBytes,\n\t}\n\n\treturn &userData, nil\n}", "func (t *OpetCode) loadUser(APIstub shim.ChaincodeStubInterface, userKey string) (User, error) {\n user_json, _ := APIstub.GetState(userKey)\n var user User\n\n if user_json == nil {\n return user, errors.New(\"There is no user exist\")\n } \n _ = json.Unmarshal([]byte(user_json), &user) \n return user, nil\n}", "func (c *Context) LoadSessionUser() error {\n\tif c.User != nil {\n\t\treturn nil\n\t}\n\n\tkey, ok := c.SessionStorer.Get(SessionKey)\n\tif !ok {\n\t\treturn ErrUserNotFound\n\t}\n\n\treturn c.LoadUser(key)\n}", "func (sys *IAMSys) LoadUser(objAPI ObjectLayer, accessKey string, isSTS bool) error {\n\tif objAPI == nil {\n\t\treturn errInvalidArgument\n\t}\n\n\tsys.Lock()\n\tdefer sys.Unlock()\n\n\tif globalEtcdClient == nil {\n\t\terr := loadUser(objAPI, accessKey, isSTS, sys.iamUsersMap)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = loadMappedPolicy(objAPI, accessKey, isSTS, sys.iamUserPolicyMap)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t// When etcd is set, we use watch APIs so this code is not needed.\n\treturn nil\n}", "func LoadProfile() (*ini.File, error) {\n\thome, err := homedir.Dir()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsharedCredentialsPath, err := envOrDefault(envSharedCredentialsFile, func() (string, error) {\n\t\treturn filepath.Join(home, \".aws\", \"credentials\"), nil\n\t})\n\tconfigFilePath, err := envOrDefault(envAWSConfigFile, func() (string, error) {\n\t\treturn filepath.Join(home, \".aws\", \"config\"), nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ini.Load(sharedCredentialsPath, configFilePath)\n}", "func (u *User) Load() error {\n\treturn DB.LoadUser(u)\n}", "func Profile() echo.HandlerFunc {\n\treturn func(context echo.Context) error {\n\t\tuser, err := FindByID(context.Param(\"userID\"))\n\t\tif err != nil || user == nil {\n\t\t\treturn context.JSON(http.StatusInternalServerError, errors.New(\"Cannot load user with ID %s\"))\n\t\t}\n\n\t\tsession := context.Get(\"session\").(*session.Session)\n\n\t\tif session != nil && (session.IsAdmin || session.UserID == user.ID) {\n\t\t\tuser.Hash = \"\" // don't leak user Hash, for security\n\t\t\treturn context.JSON(http.StatusOK, user)\n\t\t}\n\n\t\treturn context.JSON(http.StatusOK, formatUser(user))\n\t}\n}", "func qemuImgProfileLoad(sysOS *sys.OS, imgPath string, dstPath string, allowedCmdPaths []string) error {\n\tprofile := filepath.Join(aaPath, \"profiles\", qemuImgProfileFilename(imgPath))\n\tcontent, err := ioutil.ReadFile(profile)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\tupdated, err := qemuImgProfile(imgPath, dstPath, allowedCmdPaths)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif string(content) != string(updated) {\n\t\terr = ioutil.WriteFile(profile, []byte(updated), 0600)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\terr = loadProfile(sysOS, qemuImgProfileFilename(imgPath))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (braceletPhotoL) LoadUser(e boil.Executor, singular bool, maybeBraceletPhoto interface{}) error {\n\tvar slice []*BraceletPhoto\n\tvar object *BraceletPhoto\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeBraceletPhoto.(*BraceletPhoto)\n\t} else {\n\t\tslice = *maybeBraceletPhoto.(*BraceletPhotoSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &braceletPhotoR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &braceletPhotoR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func LoadProfileFromFile(profile string, generator *generate.Generator) error {\n\treturn nil\n}", "func LoadProfile() *Profile {\n\tonce.Do(func() {\n\t\tprofileName := strings.ToLower(config.NodeConfig.GetString(config.CfgProfileUseProfile))\n\t\tif profileName == config.AutoProfileName {\n\t\t\tv, err := mem.VirtualMemory()\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\n\t\t\tif v.Total >= 8000000000*0.95 {\n\t\t\t\tprofileName = \"8gb\"\n\t\t\t} else if v.Total >= 4000000000*0.95 {\n\t\t\t\tprofileName = \"4gb\"\n\t\t\t} else if v.Total >= 2000000000*0.95 {\n\t\t\t\tprofileName = \"2gb\"\n\t\t\t} else if v.Total >= 1000000000*0.95 {\n\t\t\t\tprofileName = \"1gb\"\n\t\t\t} else {\n\t\t\t\tpanic(ErrNotEnoughMemory)\n\t\t\t}\n\t\t}\n\n\t\tswitch profileName {\n\t\tcase \"8gb\":\n\t\t\tprofile = Profile8GB\n\t\t\tprofile.Name = \"8gb\"\n\t\tcase \"4gb\":\n\t\t\tprofile = Profile4GB\n\t\t\tprofile.Name = \"4gb\"\n\t\tcase \"2gb\":\n\t\t\tprofile = Profile2GB\n\t\t\tprofile.Name = \"2gb\"\n\t\tcase \"1gb\", \"light\":\n\t\t\tprofile = Profile1GB\n\t\t\tprofile.Name = \"1gb\"\n\t\tdefault:\n\t\t\tp := &Profile{}\n\t\t\tif !config.ProfilesConfig.IsSet(profileName) {\n\t\t\t\tpanic(fmt.Sprintf(\"profile '%s' is not defined in the config\", profileName))\n\t\t\t}\n\t\t\tif err := config.ProfilesConfig.UnmarshalKey(profileName, p); err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tp.Name = profileName\n\t\t\tprofile = p\n\t\t}\n\t})\n\treturn profile\n}", "func (r *RouteHandler) getUserProfileInfo(c echo.Context) (*LoggedInUserData, error) {\n\tloggedIn := c.Get(custommiddleware.UserLoggedIn)\n\n\tloggedInBool, ok := loggedIn.(bool)\n\tif !ok || !loggedInBool {\n\t\treturn nil, errors.New(\"User is not logged in\")\n\t}\n\n\tl := LoggedInUserData{}\n\n\tid := c.Get(custommiddleware.UserIDKey)\n\n\tidInt, ok := id.(int64)\n\tif !ok {\n\t\tlog.Error(\"Could not assert id to int64\")\n\t\treturn nil, errors.New(\"could not assert id to int64\")\n\t}\n\n\tgetUserReq := userproto.GetUserFromIDRequest{\n\t\tUserID: idInt,\n\t}\n\n\tuserResp, err := r.u.GetUserFromID(context.TODO(), &getUserReq)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tl.Username = userResp.Username\n\t// l.ProfilePictureURL = userResp. // TODO\n\tl.Rank = int32(userResp.Rank)\n\tl.Email = userResp.Email\n\tl.UserID = idInt\n\treturn &l, nil\n}", "func LoadUserEditPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tchannel := make(chan models.User)\n\n\tgo models.GetUserData(channel, userID, r)\n\n\tuser := <-channel\n\tif user.ID == 0 {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: \"Erro ao buscar o usuário\"})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-profile.html\", user)\n}", "func qemuImgProfileLoad(sysOS *sys.OS, imgPath string, dstPath string, allowedCmdPaths []string) (string, error) {\n\tname := fmt.Sprintf(\"<%s>_<%s>\", strings.ReplaceAll(strings.Trim(imgPath, \"/\"), \"/\", \"-\"), strings.ReplaceAll(strings.Trim(dstPath, \"/\"), \"/\", \"-\"))\n\tprofileName := profileName(\"qemu-img\", name)\n\tprofilePath := filepath.Join(aaPath, \"profiles\", profileName)\n\tcontent, err := os.ReadFile(profilePath)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn \"\", err\n\t}\n\n\tupdated, err := qemuImgProfile(profileName, imgPath, dstPath, allowedCmdPaths)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif string(content) != string(updated) {\n\t\terr = os.WriteFile(profilePath, []byte(updated), 0600)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\terr = loadProfile(sysOS, profileName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn profileName, nil\n}", "func (repository *Datastore)GetProfile(username string)(*user.Person,error){\n\tperson := newUser() //initialize user.Person and will used to store profile info\n\tquery := `SELECT * FROM userRepository WHERE username = ?`\n\terr := repository.Db.Get(&person, query, username) //get person profile details\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &person, nil\n}", "func LoadUser(db *pg.DB, username string) (*models.User, error) {\n\tuser := new(models.User)\n\n\tfmt.Println(\"Loading User \" + username)\n\terr := db.Model(user).\n\t\tWhere(\"user_name = ?\", username).\n\t\tLimit(1).\n\t\tSelect()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn new(models.User), err\n\t}\n\treturn user, nil\n}", "func loadIdentity(userName, identity string) ([]byte, error) {\n\tif filepath.Dir(identity) == \".\" {\n\t\tu, err := user.Current()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tidentity = filepath.Join(u.HomeDir, \".ssh\", identity)\n\t}\n\n\treturn ioutil.ReadFile(identity)\n}", "func (s *UserSession) Load(session map[string]string) bool {\n s.AesKey = session[app.STR_KEY]\n s.UserName = session[app.STR_NAME]\n s.Password = session[app.STR_PASSWORD]\n s.Expire = session[app.STR_EXPIRE]\n s.Encrypted = true\n\n return s.Decrypt()\n}", "func (m *SecurityProfileManager) loadProfile(profile *SecurityProfile) error {\n\tprofile.loadedInKernel = true\n\tprofile.loadedNano = uint64(m.resolvers.TimeResolver.ComputeMonotonicTimestamp(time.Now()))\n\n\t// push kernel space filters\n\tif err := m.securityProfileSyscallsMap.Put(profile.profileCookie, profile.generateSyscallsFilters()); err != nil {\n\t\treturn fmt.Errorf(\"couldn't push syscalls filter: %w\", err)\n\t}\n\n\t// TODO: load generated programs\n\tseclog.Debugf(\"security profile %s (version:%s status:%s) loaded in kernel space\", profile.Metadata.Name, profile.Version, profile.Status.String())\n\treturn nil\n}", "func (p Profiles) LoadProfileByName(name, key string) (string, error) {\n\tprofile, found := p.NamedProfiles[name]\n\tif !found {\n\t\treturn \"\", errors.Wrap(ProfileNotExistError, name)\n\t}\n\n\td, err := readProfileFile(profile.Path, key)\n\treturn d, err\n}", "func LoadUserByID(ID int) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE id=$1\"\n\terr := dbConn.QueryRow(q, ID).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func loadProfile(file string) (*profiler.Profile, error) {\n\tif !strings.HasSuffix(file, \".json\") {\n\t\treturn nil, fmt.Errorf(\n\t\t\t\"unrecognized profile extension %q for %q; only json profiles are currently supported\",\n\t\t\tfilepath.Ext(file),\n\t\t\tfile,\n\t\t)\n\t}\n\n\tf, err := os.Open(file)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer f.Close()\n\n\tdata, err := ioutil.ReadAll(f)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar profile *profiler.Profile\n\terr = json.Unmarshal(data, &profile)\n\treturn profile, err\n}", "func LoadUsers(db *database.DB, userMap map[string]*User, currentUserID string) error {\n\tif len(userMap) <= 0 {\n\t\treturn nil\n\t}\n\tuserIDs := make([]interface{}, 0, len(userMap))\n\tfor id := range userMap {\n\t\tuserIDs = append(userIDs, id)\n\t}\n\n\trows := database.NewQuery(`\n\t\tSELECT u.id,u.firstName,u.lastName,u.lastWebsiteVisit,!ISNULL(s.userId)\n\t\tFROM (\n\t\t\tSELECT *\n\t\t\tFROM users\n\t\t\tWHERE id IN `).AddArgsGroup(userIDs).Add(`\n\t\t) AS u\n\t\tLEFT JOIN (\n\t\t\tSELECT *\n\t\t\tFROM userSubscriptions\n\t\t\tWHERE userId=?`, currentUserID).Add(`\n\t\t) AS s\n\t\tON (u.id=s.toUserId)`).ToStatement(db).Query()\n\terr := rows.Process(func(db *database.DB, rows *database.Rows) error {\n\t\tvar u coreUserData\n\t\terr := rows.Scan(&u.ID, &u.FirstName, &u.LastName, &u.LastWebsiteVisit, &u.IsSubscribed)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to scan for user: %v\", err)\n\t\t}\n\t\tuserMap[u.ID].coreUserData = u\n\t\treturn nil\n\t})\n\treturn err\n}", "func (notificationL) LoadUser(e boil.Executor, singular bool, maybeNotification interface{}, mods queries.Applicator) error {\n\tvar slice []*Notification\n\tvar object *Notification\n\n\tif singular {\n\t\tobject = maybeNotification.(*Notification)\n\t} else {\n\t\tslice = *maybeNotification.(*[]*Notification)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &notificationR{}\n\t\t}\n\t\targs = append(args, object.UserID)\n\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &notificationR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.UserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.UserID)\n\n\t\t}\n\t}\n\n\tquery := NewQuery(qm.From(`user_profile`), qm.WhereIn(`id in ?`, args...))\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.Query(e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load UserProfile\")\n\t}\n\n\tvar resultSlice []*UserProfile\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice UserProfile\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for user_profile\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for user_profile\")\n\t}\n\n\tif len(notificationAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.User = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userProfileR{}\n\t\t}\n\t\tforeign.R.UserNotifications = append(foreign.R.UserNotifications, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userProfileR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.UserNotifications = append(foreign.R.UserNotifications, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *MockDatabase) LoadUserID(ID string) (general.User, error) {\n\targs := m.Called(ID)\n\treturn args.Get(0).(general.User), args.Error(1)\n}", "func LoadUserByTGID(tgID int) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE tg_id=$1\"\n\terr := dbConn.QueryRow(q, tgID).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func (m *FileUserDatabase) Load() (err error) {\n\tyml := &FileDatabaseModel{Users: map[string]FileDatabaseUserDetailsModel{}}\n\n\tif err = yml.Read(m.Path); err != nil {\n\t\treturn fmt.Errorf(\"error reading the authentication database: %w\", err)\n\t}\n\n\tm.Lock()\n\n\tdefer m.Unlock()\n\n\tif err = yml.ReadToFileUserDatabase(m); err != nil {\n\t\treturn fmt.Errorf(\"error decoding the authentication database: %w\", err)\n\t}\n\n\treturn m.LoadAliases()\n}", "func GetProfile(c *gin.Context, auth *oauth2.Config, apiToken *oauth2.Token) (profile Profile, err error) {\n\tclient := auth.Client(c, apiToken)\n\turi := \"\"\n\tswitch auth.Endpoint {\n\tcase facebook.Endpoint:\n\t\turi = \"https://graph.facebook.com/v2.2/me?fields=id,name,email,picture,first_name,last_name\"\n\tcase google.Endpoint:\n\t\turi = \"https://www.googleapis.com/oauth2/v1/userinfo?alt=json\"\n\tdefault:\n\t\turi = \"\"\n\t}\n\n\tresp, err := client.Get(uri)\n\tif err != nil {\n\t\tc.AbortWithError(http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tdefer resp.Body.Close()\n\tcontents, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\tc.AbortWithError(http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tswitch auth.Endpoint {\n\tcase facebook.Endpoint:\n\t\tvar p ProfileFacebook\n\t\terr = json.Unmarshal(contents, &p)\n\t\tif err != nil {\n\t\t\tprofile = Profile{}\n\t\t} else {\n\t\t\tprofile = Profile{\n\t\t\t\tID: p.ID,\n\t\t\t\tEmail: p.Email,\n\t\t\t\tFirstName: p.FirstName,\n\t\t\t\tLastName: p.LastName,\n\t\t\t\tHd: p.Hd,\n\t\t\t\tLocale: p.Locale,\n\t\t\t\tName: p.Name,\n\t\t\t\tSource: \"facebook\",\n\t\t\t}\n\t\t}\n\tcase google.Endpoint:\n\t\tvar p ProfileGoogle\n\t\terr = json.Unmarshal(contents, &p)\n\t\tif err != nil {\n\t\t\tprofile = Profile{}\n\t\t} else {\n\t\t\tprofile = Profile{\n\t\t\t\tID: p.ID,\n\t\t\t\tEmail: p.Email,\n\t\t\t\tFirstName: p.GivenName,\n\t\t\t\tLastName: p.FamilyName,\n\t\t\t\tHd: p.Hd,\n\t\t\t\tLocale: p.Locale,\n\t\t\t\tName: p.Name,\n\t\t\t\tSource: \"google\",\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tprofile = Profile{}\n\t}\n\n\tif len(profile.Email) == 0 {\n\t\terr = errors.New(\"Empty Email\")\n\t}\n\n\treturn\n}", "func loadUser(user string) User {\n\tsession := getSession()\n\tdefer session.Close()\n\n\tusers := session.DB(\"pitsch_test\").C(\"users\")\n\n\tuserresult := User{}\n\terr := users.Find(bson.M{\"name\": user}).One(&userresult)\n\tif err != nil {\n\t\tfmt.Println(\"No such user: \")\n\t}\n\n\treturn userresult\n}", "func (a *Ctl) Profile(res http.ResponseWriter, req *http.Request) {\n\ttype pageData struct {\n\t\tUser User\n\t}\n\td := pageData{\n\t\tUser: a.getUser(res, req),\n\t}\n\tif !a.alreadyLoggedIn(req) {\n\t\ta.Logging.Warning.Println(\"Unauthorised access to Profile from \", req.UserAgent())\n\t\thttp.Redirect(res, req, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\ta.Template.ExecuteTemplate(res, \"profile.html\", d)\n}", "func (c *claimExtractor) loadProfileClaims() (*simplejson.Json, error) {\n\tif c.profileURL == nil || c.profileURL.String() == \"\" || c.requestHeaders == nil {\n\t\t// When no profileURL is set, we return a non-empty map so that\n\t\t// we don't attempt to populate the profile claims again.\n\t\t// If there are no headers, the request would be unauthorized so we also skip\n\t\t// in this case too.\n\t\treturn simplejson.New(), nil\n\t}\n\n\tclaims, err := requests.New(c.profileURL.String()).\n\t\tWithContext(c.ctx).\n\t\tWithHeaders(c.requestHeaders).\n\t\tDo().\n\t\tUnmarshalSimpleJSON()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error making request to profile URL: %v\", err)\n\t}\n\n\treturn claims, nil\n}", "func (mdb MongoDBConnection) LoadUser(Email string) (result structs.User, err error) {\n\tmdb.session = mdb.GetSession()\n\tdefer mdb.session.Close()\n\tc := mdb.session.DB(\"webadventure\").C(\"users\")\n\terr = c.Find(bson.M{\"email\": Email}).One(&result)\n\treturn result, err\n}", "func (u *User) Load(tx *sql.Tx, id string) error {\n\tlog.Printf(\"db.User.Load %s\", id)\n\n\tstmt := bytes.Buffer{}\n\tstmt.WriteString(`SELECT `)\n\tstmt.WriteString(userSelectColumns)\n\tstmt.WriteString(` FROM `)\n\tstmt.WriteString(userTable)\n\tstmt.WriteString(` WHERE id = ?`)\n\n\tlog.Printf(\"SQL QUERY: %s: with values %s\", stmt.String(), id)\n\n\trow := tx.QueryRow(stmt.String(), id)\n\n\tif err := u.Scan(row); err != nil {\n\t\treturn errors.Wrap(err, \"scanning row\")\n\t}\n\treturn nil\n}", "func GetLoggedUser(c *gin.Context) data.User {\n\tif c.Keys == nil {\n\t\treturn data.User{}\n\t}\n\n\tu, ok := c.Keys[\"user\"].(data.User)\n\n\tif !ok {\n\t\treturn data.User{}\n\t}\n\n\treturn u\n}", "func (o *CMFFamilyUserPoliciesTake) Reload(ctx context.Context, exec boil.ContextExecutor) error {\n\tret, err := FindCMFFamilyUserPoliciesTake(ctx, exec, o.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func (authMessageL) LoadUser(e boil.Executor, singular bool, maybeAuthMessage interface{}) error {\n\tvar slice []*AuthMessage\n\tvar object *AuthMessage\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthMessage.(*AuthMessage)\n\t} else {\n\t\tslice = *maybeAuthMessage.(*AuthMessageSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authMessageR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authMessageR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func LoadUserConfig() (*Config, error) {\n\treturn LoadConfigFromFilepath(strings.Replace(DefaultConfigFile, \"~/\", getHome()+\"/\", 1))\n}", "func (stockL) LoadUser(e boil.Executor, singular bool, maybeStock interface{}) error {\n\tvar slice []*Stock\n\tvar object *Stock\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeStock.(*Stock)\n\t} else {\n\t\tslice = *maybeStock.(*[]*Stock)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &stockR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &stockR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `users` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.UserID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o *AuthUser) Reload(exec boil.Executor) error {\n\tret, err := FindAuthUser(exec, o.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func goFetchFacebookProfile(sessId string) {\n\tif bo, err := sessionDao.Get(sessId); err != nil {\n\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile(%s) - error loading session data: %e\", sessId, err))\n\t} else if bo == nil {\n\t\tlog.Println(fmt.Sprintf(\"[WARN] goFetchFacebookProfile(%s) - session does not exist\", sessId))\n\t} else if bo.IsExpired() {\n\t\tlog.Println(fmt.Sprintf(\"[WARN] goFetchFacebookProfile(%s) - session expired\", sessId))\n\t} else if claims, err := parseLoginToken(bo.GetSessionData()); err != nil {\n\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile(%s) - cannot parse JWT token: %e\", sessId, err))\n\t} else if claims.Type != sessionTypePreLogin || claims.isExpired() {\n\t\tlog.Println(fmt.Sprintf(\"[WARN] goFetchFacebookProfile(%s) - invalid claims type of JWT expired\", sessId))\n\t} else {\n\t\tsess := &Session{}\n\t\tif err := json.Unmarshal(claims.Data, &sess); err != nil {\n\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile(%s) - error decoding session: %e\", sessId, err))\n\t\t\treturn\n\t\t}\n\t\tif sess.Channel != loginChannelFacebook {\n\t\t\tlog.Println(fmt.Sprintf(\"[WARN] goFetchFacebookProfile(%s) - invalid login channel: %s\", sessId, sess.Channel))\n\t\t\treturn\n\t\t}\n\t\toauth2Token := &oauth2.Token{}\n\t\tif err := json.Unmarshal(sess.Data, &oauth2Token); err != nil {\n\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile - error unmarshalling oauth2.Token: %e\", err))\n\t\t} else {\n\t\t\tctx, _ := context.WithTimeout(context.Background(), 10*time.Second)\n\t\t\tif profile, err := fbGetProfile(ctx, oauth2Token.AccessToken); err != nil {\n\t\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile - error fetching Facebook userinfo: %e\", err))\n\t\t\t} else {\n\t\t\t\tif u, err := createUserAccountFromFacebookProfile(profile); err != nil {\n\t\t\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile - error creating user account from Facebook userinfo: %e\", err))\n\t\t\t\t} else {\n\t\t\t\t\tjs, _ := json.Marshal(oauth2Token)\n\t\t\t\t\tsess.UserId = u.GetId()\n\t\t\t\t\tsess.DisplayName = u.GetDisplayName()\n\t\t\t\t\tsess.ExpiredAt = oauth2Token.Expiry\n\t\t\t\t\tsess.Data = js // JSON-serialization of oauth2.Token\n\t\t\t\t\tclaims, err := genLoginClaims(sessId, sess)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile(%s) - error generating login token: %e\", sessId, err))\n\t\t\t\t\t}\n\t\t\t\t\t_, _, err = saveSession(claims)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(fmt.Sprintf(\"[ERROR] goFetchFacebookProfile(%s) - error saving login token: %e\", sessId, err))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func LoadUserConfig(filePath string, dbConfig *db.SparrowConfig) {\n\tpath := filepath.Join(filePath, defaultUserFile)\n\n\txmlFile, err := os.Open(path)\n\tif err != nil {\n\t\tslog.Fatalf(\"Could not load users definition file\")\n\t}\n\n\tdefer xmlFile.Close()\n\n\tuserExpire = time.Duration(dbConfig.UserExpire)\n\n\tdata, _ := ioutil.ReadAll(xmlFile)\n\n\tusers := UsersConfig{}\n\txml.Unmarshal(data, &users)\n\n\tfor _, u := range users.Users {\n\t\tuserList[u.Username] = &u\n\t}\n}", "func (authTokenL) LoadUser(e boil.Executor, singular bool, maybeAuthToken interface{}) error {\n\tvar slice []*AuthToken\n\tvar object *AuthToken\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthToken.(*AuthToken)\n\t} else {\n\t\tslice = *maybeAuthToken.(*[]*AuthToken)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authTokenR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authTokenR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from \\\"users\\\" where \\\"id\\\" in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(authTokenAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func GetProfile(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tuname, found := vars[\"uname\"]\n\tif !found {\n\t\tw.WriteHeader(http.StatusUnprocessableEntity)\n\t\tfmt.Fprintf(w, \"%s\", \"invalid username\")\n\t\treturn\n\t} // NOT NEEDED\n\n\t// get the username\n\ttokk := r.Header.Get(\"Token\")\n\tvar payload *token.Payload\n\tif tokk != \"\" {\n\t\tmaker, err := token.NewPasetoMaker(\"abcd1234abcd1234abcd1234abcd1234\")\n\t\tif err != nil {\n\t\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\t\tpayload, err = maker.VerifyToken(tokk)\n\t\tif err != nil {\n\t\t\tpayload = &token.Payload{}\n\t\t}\n\t} else {\n\t\tresponses.ERROR(w, http.StatusUnauthorized, errors.New(\"user not logged in\"))\n\t\treturn\n\t}\n\n\t// form the dto\n\tvar dto *dtos.ProfileDTO = dtos.NewProfileDTO()\n\tif payload.Username != \"\" {\n\t\tdto.LoggedIn = true // some one is there\n\t}\n\tif payload.Username == uname {\n\t\tdto.Editable = true // same user is there\n\t}\n\n\t// start the database\n\tdatabase, err := db.Connect()\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tdefer database.Close()\n\n\t// search the database\n\tvar user schema.User\n\terr = database.Model(&schema.User{}).Where(\"username = ?\", uname).Find(&user).Error\n\tswitch err {\n\tcase nil:\n\tcase gorm.ErrRecordNotFound:\n\t\tresponses.ERROR(w, http.StatusNotFound, gorm.ErrRecordNotFound)\n\t\treturn\n\tdefault:\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\t// form the dto now\n\tdto.FromSchema(&user)\n\n\t// more db calls to populate drafts, cards, bookmarks\n\tif dto.Editable {\n\t\tdto.Drafts, err = crud.GetDraftsFromDB(database, dto.Username)\n\t\tif err != nil {\n\t\t\tlog.Println(\"coudnot fetch drafts, cards or bookmarks from db\")\n\t\t}\n\t}\n\tdto.Cards, err = crud.GetCardsFromDB(database, dto.Username)\n\tif dto.Editable {\n\t\tdto.Bookmarks, err = crud.GetBookMarkCardsFromDB(database, dto.Username)\n\t\tif err != nil {\n\t\t\tlog.Println(\"coudnot fetch drafts, cards or bookmarks from db\")\n\t\t}\n\t}\n\n\t// return the response\n\tresponses.JSON(w, http.StatusAccepted, *dto)\n\treturn\n\n}", "func DefaultReadProfile(ctx context.Context, in *Profile, db *gorm1.DB) (*Profile, error) {\n\tif in == nil {\n\t\treturn nil, errors1.NilArgumentError\n\t}\n\tormObj, err := in.ToORM(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif ormObj.Id == \"\" {\n\t\treturn nil, errors1.EmptyIdError\n\t}\n\tif hook, ok := interface{}(&ormObj).(ProfileORMWithBeforeReadApplyQuery); ok {\n\t\tif db, err = hook.BeforeReadApplyQuery(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif db, err = gorm2.ApplyFieldSelection(ctx, db, nil, &ProfileORM{}); err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormObj).(ProfileORMWithBeforeReadFind); ok {\n\t\tif db, err = hook.BeforeReadFind(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tormResponse := ProfileORM{}\n\tif err = db.Where(&ormObj).First(&ormResponse).Error; err != nil {\n\t\treturn nil, err\n\t}\n\tif hook, ok := interface{}(&ormResponse).(ProfileORMWithAfterReadFind); ok {\n\t\tif err = hook.AfterReadFind(ctx, db); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tpbResponse, err := ormResponse.ToPB(ctx)\n\treturn &pbResponse, err\n}", "func (u *User) Load(userID string) (*models.User, error) {\n\tuser := models.User{\n\t\tUserID: models.UserID(userID),\n\t\tContact: &models.Contact{},\n\t\tReputation: &models.Reputation{},\n\t\tLocation: &models.Location{},\n\t}\n\n\tdb := u.conn.Get()\n\n\trow := db.QueryRow(fmt.Sprintf(selectUser, ` WHERE UserID = $1 `), userID)\n\n\tvar tags []string\n\n\terr := row.Scan(\n\t\t&userID,\n\t\t&user.Name,\n\t\t&user.Description,\n\t\t&user.DeviceID,\n\t\t&user.AllowShareData,\n\t\tpq.Array(&tags),\n\t\tpq.Array(&user.Images),\n\t\t&user.CreatedAt,\n\t\t&user.LastUpdate,\n\t\t&user.Reputation.Giver,\n\t\t&user.Reputation.Taker,\n\t\t&user.Contact.URL,\n\t\t&user.Contact.Email,\n\t\t&user.Contact.Facebook,\n\t\t&user.Contact.Instagram,\n\t\t&user.Contact.Twitter,\n\t\t&user.Contact.AdditionalData,\n\t\t&user.Location.Address,\n\t\t&user.Location.City,\n\t\t&user.Location.State,\n\t\t&user.Location.ZipCode,\n\t\t&user.Location.Country,\n\t\t&user.Location.Lat,\n\t\t&user.Location.Lon,\n\t\t&user.RegisterFrom,\n\t)\n\n\tuser.Tags = models.Tags(tags)\n\n\tif err != nil {\n\t\tlog.Printf(\"fail to try load user from database: id=%s, error = %s\", userID, err.Error())\n\t\treturn &user, u.conn.CheckError(err)\n\t}\n\n\tuser.Contact.Phones, err = u.loadPhones(userID)\n\n\treturn &user, u.conn.CheckError(err)\n}", "func (authUserUserPermissionL) LoadUser(e boil.Executor, singular bool, maybeAuthUserUserPermission interface{}) error {\n\tvar slice []*AuthUserUserPermission\n\tvar object *AuthUserUserPermission\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeAuthUserUserPermission.(*AuthUserUserPermission)\n\t} else {\n\t\tslice = *maybeAuthUserUserPermission.(*AuthUserUserPermissionSlice)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &authUserUserPermissionR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &authUserUserPermissionR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `auth_user` where `id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load AuthUser\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*AuthUser\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice AuthUser\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func ProfileHandler(c buffalo.Context) error {\n\tuser := models.User{}\n\tdb := c.Value(\"tx\").(*pop.Connection)\n\tdb.Find(&user, c.Param(\"uid\"))\n\treturn c.Render(200, r.JSON(user))\n}", "func (p *plugin) Load(prof irc.Profile) error {\n\tp.m.Lock()\n\tdefer p.m.Unlock()\n\n\tp.quit = make(chan struct{})\n\tp.file = filepath.Join(prof.Root(), \"stats.dat\")\n\tp.cmd = cmd.New(prof.CommandPrefix(), nil)\n\n\t//p.cmd.Bind(TextWhoisName, false, p.cmdWhois).\n\t//\tAdd(TextNick, true, cmd.RegAny)\n\n\t//p.cmd.Bind(TextFirstOn, false, p.cmdFirstOn).\n\t//\tAdd(TextNick, true, cmd.RegAny)\n\n\t//p.cmd.Bind(TextLastOn, false, p.cmdLastOn).\n\t//\tAdd(TextNick, true, cmd.RegAny)\n\n\tgo p.periodicSave()\n\treturn util.ReadFile(p.file, &p.users, true)\n}", "func (s *Store) Load(fileName string) error {\n\tf, err := os.Open(fileName)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\ts.pwFile = fileName\n\n\tnewUsers := make(map[string]*authUser)\n\n\tscan := bufio.NewScanner(f)\n\tfor scan.Scan() {\n\t\tline := scan.Text()\n\t\tparsedLine := strings.Split(line, \":\")\n\t\tif len(parsedLine) < 2 && line != \"\" {\n\t\t\treturn errors.New(\"Invalid line in password file\")\n\t\t}\n\t\tnewUsers[parsedLine[0]] = &authUser{\n\t\t\tencoded: parsedLine[1],\n\t\t}\n\t}\n\terr = scan.Err()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.latch.Lock()\n\ts.users = newUsers\n\ts.latch.Unlock()\n\n\treturn nil\n}", "func LoadTestUser() *User {\n\t// Just for demonstration purpose, we create a user with the encrypted \"test\" password.\n\t// In real-world applications, you might load the user from the database by specific parameters (email, username, etc.)\n\thashedPassword, _ := bcrypt.GenerateFromPassword([]byte(\"test\"), 8)\n\treturn &User{Password: string(hashedPassword), Name: \"Test user\"}\n}", "func loadUser(col *mgo.Collection, userID string) *User {\n\tvar user User\n\terr := col.Find(bson.M{\"id\": userID}).One(&user)\n\n\tif err != nil && err != mgo.ErrNotFound {\n\t\tlog.Println(\"Failed: *************************** load user\", err)\n\t\treturn nil\n\t}\n\tif user.ID == \"\" {\n\t\tuser.ID = userID\n\t\tfmt.Println(\"Loaded user\")\n\t\tcol.Insert(user)\n\t}\n\t//spew.Dump(user)\n\treturn &user\n}", "func Profile(response http.ResponseWriter, request *http.Request) {\n\tswitch request.Method {\n\tcase \"GET\":\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\ttype detail struct {\n\t\t\tProfile model.User\n\t\t}\n\n\t\tdetails := detail{\n\t\t\tProfile: user,\n\t\t}\n\n\t\tif user.LoginState {\n\t\t\ttmp, err := template.ParseFiles(\n\t\t\t\t\"admin/template/template.gohtml\",\n\t\t\t\t\"admin/template/sidebar.gohtml\",\n\t\t\t\t\"admin/template/header.gohtml\",\n\t\t\t\t\"admin/template/footer.gohtml\",\n\t\t\t\t\"admin/profile.gohtml\",\n\t\t\t)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(err)\n\t\t\t\thttp.Error(response, \"internal server error\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ttmp.ExecuteTemplate(response, \"layout\", details)\n\t\t\treturn\n\n\t\t} else {\n\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\tcase \"POST\":\n\t\t//get current user from session the nfind in db.\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\t//handle err\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\t//check if current user is loggedin.\n\t\tif user.LoginState {\n\t\t\trequest.ParseMultipartForm(100000)\n\n\t\t\tuserName := request.FormValue(\"userName\")\n\t\t\tfirstname := request.FormValue(\"firstName\")\n\t\t\tlastName := request.FormValue(\"lastName\")\n\t\t\tPassWord := request.FormValue(\"password\")\n\t\t\tEmail := request.FormValue(\"email\")\n\t\t\tID, _ := primitive.ObjectIDFromHex(request.FormValue(\"ID\"))\n\t\t\taddress := request.FormValue(\"address\")\n\t\t\tCity := request.FormValue(\"city\")\n\t\t\tState := request.FormValue(\"state\")\n\t\t\tZip := request.FormValue(\"zip\")\n\t\t\tpics, header, err := request.FormFile(\"pics\")\n\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(response, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t//save profile image to upload folder.\n\t\t\t//refer \"github.com/ukane-philemon/RudigoNews/utils/saveimage\"\n\t\t\tsaveimage.SaveImage(pics, header)\n\n\t\t\t//Hash new password.\n\t\t\tPassWord = model.PasswordHash(PassWord)\n\n\t\t\tnewUser := model.User{\n\t\t\t\tID: ID,\n\t\t\t\tUserName: userName,\n\t\t\t\tEmail: Email,\n\t\t\t\tFirst: firstname,\n\t\t\t\tLast: lastName,\n\t\t\t\tPassword: PassWord,\n\t\t\t\tAddress: address,\n\t\t\t\tAvatar: header.Filename,\n\t\t\t\tCity: City,\n\t\t\t\tState: State,\n\t\t\t\tZip: Zip,\n\t\t\t}\n\n\t\t\tif model.UpdateUser(newUser, ID) == nil {\n\t\t\t\thttp.Redirect(response, request, \"/admin/profile\", http.StatusSeeOther)\n\t\t\t\tfmt.Print(\"user updated\")\n\n\t\t\t} else {\n\t\t\t\tmodel.CreateUser(newUser)\n\t\t\t}\n\n\t\t} else {\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusFound)\n\t\t}\n\tdefault:\n\t\thttp.Redirect(response, request, \"/login\", http.StatusForbidden)\n\t}\n\n}", "func load_user_list() {\n\tcreate_and_lock(USERLIST_FILENAME) // lock userlist file\n\tdefer lock_for_files_map[USERLIST_FILENAME].Unlock()\n\n\tfile, err := os.OpenFile(USERLIST_FILENAME, os.O_CREATE|os.O_RDONLY, 0600)\n\tdefer file.Close()\n\tcheck_err(err)\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tsplitted_string := strings.Split(line, \":\")\n\t\tuname := strings.TrimSpace(splitted_string[0])\n\t\tpsw := strings.TrimSpace(splitted_string[1])\n\t\t// store user in server memory\n\t\tuser_map_lock.Lock()\n\t\tuser_map[uname] = psw\n\t\tuser_map_lock.Unlock()\n\t}\n\n}", "func GetUserProfile(w http.ResponseWriter, r *http.Request) {\n\n\tif utils.URLChecker(w, r, \"/profile\") {\n\n\t\tif r.Method == \"GET\" {\n\t\t\t//if userId now, createdPost uid equal -> show\n\t\t\tu := models.User{\n\t\t\t\tSession : session,\n\t\t\t}\n\t\t\tdislikedPost, likedPost, posts, comments, user := u.GetUserProfile(r, w)\n\t\t\t//check if current cookie equal - cookie\n\t\t\tutils.RenderTemplate(w, \"header\", utils.IsAuth(r))\n\t\t\tutils.RenderTemplate(w, \"profile\", user)\n\t\t\tutils.RenderTemplate(w, \"created_post\", posts)\n\t\t\tutils.RenderTemplate(w, \"favorited_post\", likedPost)\n\t\t\tutils.RenderTemplate(w, \"disliked_post\", dislikedPost)\n\t\t\tutils.RenderTemplate(w, \"comment_user\", comments)\n\t\t}\n\t}\n}", "func (user *UserObject) Load(database *sqlx.DB) error {\n\tquery := fmt.Sprintf(specificItemLoad, userTableName, user.ID)\n\tresults, err := database.Queryx(query)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = user.Populate(results)\n\tif err != nil {\n\t\tlogrus.Warnf(\"failed populating data: %v\", err)\n\t}\n\n\terr = results.Close()\n\tif err != nil {\n\t\tlogrus.Warnf(\"failed closing results: %v\", err)\n\t}\n\treturn nil\n}", "func (wc WebClient) Profile(user *User) error {\n\n\tconst (\n\t\tselLocation = \"html body table.pagew tbody tr td.pagew table.t tbody tr td div img[src='https://img.zhivem.ru/pic_location.png']\"\n\t\tselUsername = \"html body table.pagew tbody tr td.pagew table.t tbody tr td div.header2\"\n\t\tselTable = \"html body table.pagew tbody tr td.pagew table.t tbody tr td table.t tbody tr\"\n\t)\n\n\tprofileURL := NewEndpointBuilder(wc.Config.BaseURL).\n\t\tWithPath(fmt.Sprintf(\"/web/%s\", user.Profile)).\n\t\tString()\n\n\tresponse, err := wc.client.Get(profileURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\n\tdoc, err := goquery.NewDocumentFromReader(response.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuser.Location = newLocation(doc.Find(selLocation).First().Parent().Contents().Text()) // We need parent contents\n\tuser.Name = strip(doc.Find(selUsername).First().Contents().Text())\n\n\ttable := make(map[string]string)\n\tdoc.Find(selTable).Each(func(i int, sel *goquery.Selection) {\n\t\tcaption := sel.Find(\"td.grey\")\n\t\tif key := caption.Contents().Text(); len(key) > 0 {\n\t\t\ttable[key] = caption.Siblings().Contents().Text()\n\t\t}\n\t})\n\n\tif langs := table[\"Владею языками:\"]; len(langs) > 0 {\n\t\tlangs := Map(strings.Split(strings.Split(langs, \"·\")[0], \",\"), strip)\n\t\tuser.Languages = &langs\n\t}\n\n\tuser.Motto = strip(table[\"Мой девиз:\"])\n\n\tuser.Instagram = strip(table[\"Instagram:\"])\n\n\treturn nil\n}", "func (ms *MySQL) GetUser(username string) (int, string, string, error) { // get acc data by profile\n\tvar u entities.User\n\tresult, err := db.Db.Query(\"SELECT id,username, hash FROM nf_stn.users WHERE username = ?;\", username)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t\treturn u.ID, u.Username, u.Hash, err\n\t}\n\tfor result.Next() {\n\t\terr = result.Scan(&u.ID, &u.Username, &u.Hash)\n\t\tif err != nil {\n\t\t\tlog.Error(err.Error())\n\t\t}\n\t}\n\tlog.Info(\"successfully got user!\")\n\treturn u.ID, u.Username, u.Hash, err\n}", "func (up *UserPermissions) Load() (err error) {\n\tup.file.Open(READ_ONLY)\n\tdefer up.file.Close()\n\tif up.file.size == 0 {return}\n\tup.Lock()\n\tf := func(rec *GenericRecord) error {\n\t\tif rec.ksz > 0 {\n\t\t\tkey, upr := rec.ToUserPermissionRecord(up.debug)\n\t\t\tup.index[key] = upr // Don't need to use gateway because up is fresh\n\t\t}\n\t\treturn nil\n\t}\n\terr = up.file.Process(f, PERMISSION_RECORD, false)\n\tup.Unlock()\n\treturn\n}", "func (s *Scim) LoadAccount(name, realm string, anyState bool, tx storage.Tx) (*cpb.Account, int, error) {\n\tacct := &cpb.Account{}\n\tstatus, err := s.readTx(storage.AccountDatatype, realm, storage.DefaultUser, name, storage.LatestRev, acct, tx)\n\tif err != nil {\n\t\treturn nil, status, err\n\t}\n\t// TODO: move state checks to storage package.\n\tif acct.State != storage.StateActive && !anyState {\n\t\treturn nil, http.StatusNotFound, fmt.Errorf(\"not found\")\n\t}\n\treturn acct, http.StatusOK, nil\n}", "func (svc *inmemService) GetProfile(ctx context.Context, id string) (Profile, error) {\n\t// Get the Read lock from the inmemService struct\n\tsvc.mtx.RLock()\n\n\t// Immediately set up a lock release to occur when the function finishes\n\tdefer svc.mtx.RUnlock()\n\n\t// Look for the profile by the `id` function param\n\tprofile, ok := svc.profiles[id]\n\n\t// Check if the profile id was not found in the datastore\n\tif !ok {\n\n\t\t// Return an empty profile and an error informing the caller that the profile was not found\n\t\treturn Profile{}, ErrNotFound\n\n\t}\n\n\t// Return the profile to the caller and a nil error\n\treturn profile, nil\n\n}", "func (a *Account) Load() error {\n\tvalue, err := a.get()\n\tif err != nil {\n\t\treturn err\n\t}\n\tunmarshal(value, &a)\n\treturn nil\n}", "func LoadUserByUsername(username string) (*User, error) {\n\tu := &User{}\n\tq := \"SELECT id, role, tg_id, username, name, fb, vk, picture_id, bdate FROM users WHERE username=$1\"\n\terr := dbConn.QueryRow(q, username).Scan(&u.ID, &u.Role, &u.TGUserID, &u.Username, &u.Name, &u.FB, &u.VK, &u.PictureID, &u.BDate)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, ErrNoUser\n\t}\n\treturn u, err\n}", "func (ps *MemProfiles) Load(key string) (value *Profile, ok bool) {\n\tps.RLock()\n\tresult, ok := ps.internal[key]\n\tps.RUnlock()\n\treturn result, ok\n}", "func loadConfig(cfgName string, profileName string) (profile, error) {\n\tif cfgName == \"\" {\n\t\tcfgName = getConfigFile()\n\t}\n\tif cfgName == \"\" {\n\t\treturn profile{}, errors.New(\"please specify the path to the config file\")\n\t}\n\n\tb, err := ioutil.ReadFile(cfgName)\n\tif err != nil {\n\t\treturn profile{}, fmt.Errorf(\"unable to read config: %v\", err)\n\t}\n\n\tvar cfg config\n\tif _, err := toml.Decode(string(b), &cfg); err != nil {\n\t\treturn profile{}, fmt.Errorf(\"unable to parse config file %s: %v\", cfgName, err)\n\t}\n\n\tfor _, p := range cfg.Profile {\n\t\tif p.Name == profileName {\n\t\t\treturn p, nil\n\t\t}\n\t}\n\treturn profile{}, fmt.Errorf(\"profile %q not found in %s\", profileName, cfgName)\n}", "func loadProfileObjects(obj interface{}, opts *ebpf.CollectionOptions) error {\n\tspec, err := loadProfile()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn spec.LoadAndAssign(obj, opts)\n}", "func (c *IRacing) GetProfile(ctx context.Context) (*UserProfile, error) {\n\n\tprofile := &UserProfile{}\n\n\terr := c.json(ctx, http.MethodGet, \"/membersite/member/GetMember\", nil, profile)\n\n\treturn profile, err\n}", "func (u *Users) Get(ctx context.Context, username string) (user model.UserInfo, err error) {\n\tif user, err = u.database.GetUserProfile(ctx, username); err != nil {\n\t\terr = errors.Wrap(err, \"GetUserProfile\")\n\t}\n\treturn\n}", "func SessionLoad(next http.Handler) http.Handler {\n\tlog.Println(\"Loading session...\")\n\treturn session.LoadAndSave(next)\n}", "func (projectL) LoadUser(ctx context.Context, e boil.ContextExecutor, singular bool, maybeProject interface{}, mods queries.Applicator) error {\n\tvar slice []*Project\n\tvar object *Project\n\n\tif singular {\n\t\tobject = maybeProject.(*Project)\n\t} else {\n\t\tslice = *maybeProject.(*[]*Project)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &projectR{}\n\t\t}\n\t\targs = append(args, object.UserID)\n\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &projectR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.UserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.UserID)\n\n\t\t}\n\t}\n\n\tif len(args) == 0 {\n\t\treturn nil\n\t}\n\n\tquery := NewQuery(\n\t\tqm.From(`user`),\n\t\tqm.WhereIn(`user.ID in ?`, args...),\n\t)\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for user\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for user\")\n\t}\n\n\tif len(projectAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.User = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userR{}\n\t\t}\n\t\tforeign.R.Projects = append(foreign.R.Projects, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID == foreign.ID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.Projects = append(foreign.R.Projects, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (db *LocalDb) load() error {\n\n\tdb.mutex.Lock()\n\tdefer db.mutex.Unlock()\n\n\t// read file\n\tdata, err := ioutil.ReadFile(constLocalDbFn)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn err\n\t}\n\n\t// decode json\n\tdb.users = make(map[string]*UserInfo)\n\tif err := json.Unmarshal(data, &db.users); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (self *RegisObjManager) LoadPersonalChatLogObj(id string) *RedisPersonalChatLogObj {\n\tvalue, ok := self.Load(id)\n\tif ok {\n\t\treturn value.(*RedisPersonalChatLogObj)\n\t}\n\treturn nil\n}", "func (c users) LoadUserToToken(tk *Token, l *log.Entry) error {\n\tu, err := c.getWithTeams(*tk.Email, l)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttk.User = u\n\treturn nil\n}", "func (service *Service) LoadProfile(email account.Email) <-chan LoadResult {\n\tresult := make(chan LoadResult, 1)\n\tservice.jobQueue <- loadProfile{email: email, channel: result}\n\treturn result\n}", "func LoadUserConfig() *Config {\n\n\tconfigFilePath := getEnv(\"CONFIG_PATH\", \"./config.yaml\")\n\tuserConfig := loadConfigurationFile(configFilePath)\n\n\terr := mergo.Merge(&userConfig, defaultConfig)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tyamlConfig, err := yaml.Marshal(userConfig)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"Using the following config:\\n\\n=======\\n\\n%s\\n\\n========\\n\\n\", string(yamlConfig))\n\n\treturn &userConfig\n}", "func getUserProfileHandler(c *gin.Context) {\n\tuser, _ := c.Get(JwtIdentityKey)\n\tusername := user.(*types.User).Username\n\n\tdb := data.New()\n\tu, _ := db.Users.GetUserByUsername(username)\n\n\tc.JSON(200, gin.H{\n\t\t\"status\": http.StatusOK,\n\t\t\"username\": u.Username,\n\t\t\"role\": u.Role,\n\t})\n}", "func (r *Reaction) LoadUser() (*user_model.User, error) {\n\tif r.User != nil {\n\t\treturn r.User, nil\n\t}\n\tuser, err := user_model.GetUserByID(db.DefaultContext, r.UserID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr.User = user\n\treturn user, nil\n}", "func (s *RestServer) getProfileFromSessionAndDb(r *http.Request) (*domainuser.Profile, string, error) {\n\tuserId, err := s.getUserIdFromSessionAndDb(r)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"getUserIdFromSessionAndDb() failed: %v\", err)\n\t}\n\n\tif len(userId) == 0 {\n\t\t// Not an error.\n\t\t// It's just not in the session cookie.\n\t\treturn nil, \"\", nil\n\t}\n\n\tc := r.Context()\n\tprofile, err := s.userDataClient.GetUserProfileById(c, userId)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"GetUserProfileById() failed: %v\", err)\n\t}\n\n\treturn profile, userId, nil\n}", "func (s *userServiceImpl) LoadContextIdentityAndUser(ctx context.Context) (*repository.Identity, error) {\n\tidentityID, err := manager.ContextIdentity(ctx)\n\tif err != nil {\n\t\treturn nil, errors.NewUnauthorizedError(err.Error())\n\t}\n\t// Check if the identity exists\n\tidentity, err := s.Repositories().Identities().LoadWithUser(ctx, *identityID)\n\tif err != nil {\n\t\treturn nil, errors.NewUnauthorizedError(err.Error())\n\t}\n\n\treturn identity, err\n}", "func FindProfile(ID string) (models.User, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second*15)\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"socialnetwork\")\n\tcollection := db.Collection(\"Users\")\n\n\tvar result models.User\n\tobjID, _ := primitive.ObjectIDFromHex(ID)\n\n\tobject := bson.M{\n\t\t\"_id\": objID,\n\t}\n\n\terr := collection.FindOne(ctx, object).Decode(&result)\n\tresult.Password = \"\"\n\tif err != nil {\n\t\treturn result, err\n\t}\n\treturn result, nil\n}", "func GetUser(c *gin.Context) {\n\tnID := c.Param(\"user_id\")\n\tdb := dbConn()\n\tselDB, err := db.Query(\"CALL read_user(?)\", nID)\n\tif err != nil {\n\t\tpanic(err.Error)\n\t}\n\n\tuser := User{}\n\tusers := []User{}\n\tfor selDB.Next() {\n\t\tvar id, username, useremail, fname, lname, password, passwordchange, passwordexpired, lastlogon, accountlocked string\n\t\terr = selDB.Scan(&id, &username, &useremail, &fname, &lname, &password, &passwordchange, &passwordexpired, &lastlogon, &accountlocked)\n\t\tif err != nil {\n\t\t\tlog.Println(err)\n\t\t\tc.JSON(500, gin.H{\n\t\t\t\t\"error\": err.Error(),\n\t\t\t})\n\t\t}\n\t\tuser.ID = id\n\t\tuser.UserName = username\n\t\tuser.UserEmail = useremail\n\t\tuser.FName = fname\n\t\tuser.LName = lname\n\t\tuser.Password = password\n\t\tuser.PasswordChange = passwordchange\n\t\tuser.PasswordExpired = passwordexpired\n\t\tuser.LastLogon = lastlogon\n\t\tuser.AccountLocked = accountlocked\n\t\tiid, err := strconv.Atoi(id)\n\t\tif err != nil {\n\t\t\tpanic(err.Error)\n\t\t}\n\t\tselDB02, err := db.Query(\"CALL read_access_userid(?)\", iid)\n\t\tif err != nil {\n\t\t\tpanic(err.Error)\n\t\t}\n\t\taccess := Access{}\n\t\taccessList := []Access{}\n\t\tfor selDB02.Next() {\n\t\t\tvar accessid, userid, courtid, caseaccess, personaccess, accountingaccess, juryaccess, attorneyaccess, configaccess, securitylevel, sealedcase string\n\t\t\terr := selDB02.Scan(&accessid, &userid, &courtid, &caseaccess, &personaccess, &accountingaccess, &juryaccess, &attorneyaccess, &configaccess, &securitylevel, &sealedcase)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t\tc.JSON(500, gin.H{\n\t\t\t\t\t\"error\": err.Error(),\n\t\t\t\t})\n\t\t\t}\n\t\t\taccess.AccessID = accessid\n\t\t\taccess.IDUser = userid\n\t\t\taccess.IDCourt = courtid\n\t\t\taccess.CaseAccess = caseaccess\n\t\t\taccess.PersonAccess = personaccess\n\t\t\taccess.AccountingAccess = accountingaccess\n\t\t\taccess.JuryAccess = juryaccess\n\t\t\taccess.AttorneyAccess = attorneyaccess\n\t\t\taccess.ConfigAccess = configaccess\n\t\t\taccess.SecurityLevel = securitylevel\n\t\t\taccess.SealedCase = sealedcase\n\t\t\taccessList = append(accessList, access)\n\t\t}\n\t\tuser.AccessList = accessList\n\t\tusers = append(users, user)\n\t}\n\n\tc.JSON(200, gin.H{\n\t\t\"result\": users,\n\t})\n\n\tdefer db.Close()\n}", "func LoadUsers(userCsv string) {\n\t// read users\n\tif file, err := os.Open(userCsv); err == nil {\n\t\treader := csv.NewReader(file)\n\t\tdefer file.Close()\n\t\tfor strs, err := reader.Read(); err == nil; strs, err = reader.Read() {\n\t\t\tuserId, _ := strconv.Atoi(strs[0])\n\t\t\tif userId != 0 {\n\t\t\t\tuserName := strs[1]\n\t\t\t\tpassword := strs[2]\n\t\t\t\tusers = append(users, User{Id: userId, Username: userName, Password: password})\n\t\t\t}\n\t\t}\n\t} else {\n\t\tpanic(err.Error())\n\t}\n\n\t// root user\n\t// ss.rootToken = userId2Token(ss.UserMap[\"root\"].Id)\n}", "func GetProfile(_db Queryable, uid int64) (*Profile, error) {\n\tp := &Profile{}\n\terr := _db.QueryRow(`SELECT first_name, last_name, high_score, gender, \n img, birth_date, signup_date\n FROM profile WHERE uid = $1`, uid).Scan(\n\t\tp.FirstName, p.LastName, p.HighScore, p.Gender, p.Img, p.BirthDate, p.SignupDate)\n\tif err != nil {\n\t\treturn nil, err\n\t} else {\n\t\treturn p, err\n\t}\n}", "func LoadIdentity() {\n\tC.glowLoadIdentity(gpLoadIdentity)\n}", "func GetUserProfile(ctx *pulumi.Context,\n\tname string, id pulumi.ID, state *UserProfileState, opts ...pulumi.ResourceOpt) (*UserProfile, error) {\n\tinputs := make(map[string]interface{})\n\tif state != nil {\n\t\tinputs[\"allowSelfManagement\"] = state.AllowSelfManagement\n\t\tinputs[\"sshPublicKey\"] = state.SshPublicKey\n\t\tinputs[\"sshUsername\"] = state.SshUsername\n\t\tinputs[\"userArn\"] = state.UserArn\n\t}\n\ts, err := ctx.ReadResource(\"aws:opsworks/userProfile:UserProfile\", name, id, inputs, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &UserProfile{s: s}, nil\n}", "func (transactionL) LoadUser(e boil.Executor, singular bool, maybeTransaction interface{}) error {\n\tvar slice []*Transaction\n\tvar object *Transaction\n\n\tcount := 1\n\tif singular {\n\t\tobject = maybeTransaction.(*Transaction)\n\t} else {\n\t\tslice = *maybeTransaction.(*[]*Transaction)\n\t\tcount = len(slice)\n\t}\n\n\targs := make([]interface{}, count)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &transactionR{}\n\t\t}\n\t\targs[0] = object.UserID\n\t} else {\n\t\tfor i, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &transactionR{}\n\t\t\t}\n\t\t\targs[i] = obj.UserID\n\t\t}\n\t}\n\n\tquery := fmt.Sprintf(\n\t\t\"select * from `users` where `user_id` in (%s)\",\n\t\tstrmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),\n\t)\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintf(boil.DebugWriter, \"%s\\n%v\\n\", query, args)\n\t}\n\n\tresults, err := e.Query(query, args...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\tdefer results.Close()\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tobject.R.User = resultSlice[0]\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.UserID.Int == foreign.UserID {\n\t\t\t\tlocal.R.User = foreign\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (u *User) GetProfile() string {\n\treturn \"\"\n}", "func (d *DecodeService) Load(w http.ResponseWriter, r *http.Request) {\n\tvar req request.UserNameAudioToken\n\terr := json.NewDecoder(r.Body).Decode(&req)\n\tif err != nil {\n\t\tservice.ProcessBadFormat(w, service.ErrWrongFormat)\n\t\treturn\n\t}\n\n\tdb, err := d.adb.Get(req.Username)\n\tif err != nil {\n\t\tservice.ProcessServerError(w, service.ErrFindUser)\n\t\treturn\n\t}\n\n\tas, err := storage.NewAudioPostgres(db)\n\tif err != nil {\n\t\tservice.ProcessServerError(w, service.ErrFindUser)\n\t\treturn\n\t}\n\n\taudio, err := as.GetByToken(req.Token)\n\tif err != nil {\n\t\tservice.ProcessServerError(w, service.ErrFindUserAudio)\n\t\treturn\n\t}\n\n\tf, err := os.OpenFile(getLocation(req.Username, audio.Name), os.O_RDONLY, 0666)\n\tif err != nil {\n\t\tservice.ProcessServerError(w, service.ErrFindUserAudio)\n\t}\n\tdefer f.Close()\n\n\tio.Copy(w, f)\n}", "func (us *userService) ShowProfile(ctx *atreugo.RequestCtx) error {\n\tstringUserID := string(ctx.Request.Header.Cookie(state.HandlerUserKeyCookie))\n\tuserID, err := strconv.ParseInt(stringUserID, 10, 64)\n\tif err != nil || userID < 1 {\n\t\tctx.SetStatusCode(http.StatusBadRequest)\n\t\treturn errors.New(http.StatusText(http.StatusBadRequest))\n\t}\n\n\tuser, err := us.usecase.Profile(ctx, userID)\n\tif err != nil {\n\t\tctx.SetStatusCode(http.StatusInternalServerError)\n\t\treturn err\n\t}\n\n\treturn ctx.JSONResponse(user)\n}", "func getFullProfile(client *http.Client, optional ...string) (FacebookPublicProfile, error) {\n\turl := getAPIUrl(\"/me?fields=name,locale,age_range,gender\")\n\tif len(optional) == 1 {\n\t\turl = optional[0]\n\t}\n\tresp, err := client.Get(url)\n\tdefer resp.Body.Close()\n\tdecoder := json.NewDecoder(resp.Body)\n\tvar profile FacebookPublicProfile\n\terr = decoder.Decode(&profile)\n\tif err != nil {\n\t\treturn FacebookPublicProfile{}, err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn FacebookPublicProfile{}, errors.New(\"Unathorized. Check token.\")\n\t}\n\treturn profile, nil\n}", "func GetStoredUser() (User, error) {\n\tvar user User\n\thomeDir, err := homedir.Dir()\n\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\tfilePath := filepath.Join(\".recime\", \"netrc\")\n\n\tlocation := filepath.Join(homeDir, filePath)\n\n\tfile, err := os.OpenFile(location, os.O_RDONLY|os.O_CREATE, 0600)\n\n\tif err != nil {\n\t\treturn user, err\n\t}\n\n\tdat, err := ioutil.ReadAll(file)\n\n\tif len(dat) > 0 {\n\t\tjson.Unmarshal(dat, &user)\n\t}\n\n\treturn user, err\n}", "func readProfile(cookieValue string) (*Profile, error) {\n\tapiURL := \"http://localhost:8080/v1/accounts/@me\"\n\tclient := &http.Client{}\n\trequest, err := http.NewRequest(\"GET\", apiURL, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trequest.Header.Add(\"Cookie\", cookieValue)\n\tresp, err := client.Do(request)\n\tif err != nil {\n\t\tlog.Println(\"Cookie may expire \", err)\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t// Extract data from response and turn to pageInfo type\n\tvar pageInfo Profile\n\terr = json.Unmarshal(bodyBytes, &pageInfo)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\treturn &pageInfo, err\n}", "func LoadUserDomainMembership(db *database.DB, u *User, domainMap map[string]*Domain) error {\n\tu.DomainMembershipMap = make(map[string]*DomainMember)\n\trows := db.NewStatement(`\n\t\tSELECT dm.domainId,dm.userId,dm.createdAt,dm.role,d.pageId\n\t\tFROM domainMembers AS dm\n\t\tJOIN domains AS d\n\t\tON (dm.domainId=d.id)\n\t\tWHERE dm.userId=?`).Query(u.ID)\n\terr := rows.Process(func(db *database.DB, rows *database.Rows) error {\n\t\tvar dm DomainMember\n\t\terr := rows.Scan(&dm.DomainID, &dm.UserID, &dm.CreatedAt, &dm.Role, &dm.DomainPageID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to scan for a member: %v\", err)\n\t\t}\n\t\tdm.CanApproveComments = RoleAtLeast(dm.Role, ReviewerDomainRole)\n\t\tdm.CanSubmitLinks = RoleAtLeast(dm.Role, ReviewerDomainRole)\n\t\tu.DomainMembershipMap[dm.DomainID] = &dm\n\t\tif domainMap != nil {\n\t\t\tdomainMap[dm.DomainID] = NewDomainWithID(dm.DomainID)\n\t\t}\n\t\treturn nil\n\t})\n\treturn err\n}", "func (o *CMFUserSuper) Reload(ctx context.Context, exec boil.ContextExecutor) error {\n\tret, err := FindCMFUserSuper(ctx, exec, o.UID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func (userdata *User) LoadFile(filename string) (dataBytes []byte, err error) {\r\n\r\n\t//TODO: This is a toy implementation.\r\n\t/*\r\n\t\tstorageKey, _ := uuid.FromBytes([]byte(filename + userdata.Username)[:16])\r\n\t\tdataJSON, ok := userlib.DatastoreGet(storageKey)\r\n\t\tif !ok {\r\n\t\t\treturn nil, errors.New(strings.ToTitle(\"File not found!\"))\r\n\t\t}\r\n\t\tjson.Unmarshal(dataJSON, &dataBytes)\r\n\t*/\r\n\t//if file DNE, return error. retrieve fileKey from Datastore\r\n\tupdatedUser, err := GetLatestUser(userdata.UUID_, userdata.PasswordHash, userdata.HMACKey, userdata.EncKey)\r\n\tif err != nil {\r\n\t\treturn nil, errors.New(\"Failed to retrieve latest user info.\")\r\n\t}\r\n\tfileKey, found := updatedUser.Filespace[filename]\r\n\r\n\tif !found {\r\n\t\treturn nil, errors.New(\"File not found in user's filespace.\")\r\n\t}\r\n\r\n\t//again, check if ur loading shared file, if so retrieve through access token\r\n\tvar latestFileKey FileKey\r\n\t_, own := updatedUser.FilesOwned[filename]\r\n\tif !own { //this is just in case a revocation has happened and the fileKey data has changed\r\n\t\tat := userdata.AccessTokens[filename]\r\n\t\tlatestFileKey, err = updatedUser.RetrieveAccessToken(at)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, errors.New(\"Failed to retrieve access token.\")\r\n\t\t}\r\n\t} else {\r\n\t\tfileKeyDS, found2 := userlib.DatastoreGet(fileKey.KeyId)\r\n\t\tif !found2 {\r\n\t\t\treturn nil, errors.New(\"File not found in DataStore.\")\r\n\t\t}\r\n\r\n\t\tlen_data := len(fileKeyDS) - userlib.HashSizeBytes\r\n\t\t//fix ag panic\r\n\t\tif len_data < 0 || len_data > len(fileKeyDS) || len(fileKeyDS[:len_data]) < userlib.HashSizeBytes {\r\n\t\t\t//automatically return error, file has been changed\r\n\t\t\treturn nil, errors.New(\"FileKey data length has changed.\")\r\n\t\t}\r\n\r\n\t\t//verify integrity of both fileKey struct and the file itself\r\n\t\tcomputedMac, _ := userlib.HMACEval(fileKey.HMAC_key, fileKeyDS[:len_data])\r\n\t\tif !userlib.HMACEqual(computedMac, fileKeyDS[len_data:]) {\r\n\t\t\treturn nil, errors.New(\"File key struct has been tampered with in Datastore.\")\r\n\t\t}\r\n\r\n\t\t//decrypt fileKey in datastore to get latest version\r\n\t\t//decrypt > depad > unmarshal\r\n\t\tfileKey_pad := userlib.SymDec(fileKey.Enc_key, fileKeyDS[:len_data])\r\n\t\tfileKey_decrypt := PKCS(fileKey_pad, \"remove\")\r\n\t\terr = json.Unmarshal(fileKey_decrypt, &latestFileKey) //set current fileKey to latest\r\n\t}\r\n\r\n\t//now that we know fileKey is ok and we have the latest version,\r\n\t//check integrity of each file in file append\r\n\tvar filePart []byte //this is the retrieved file elements DATA field\r\n\r\n\tfor i := 1; i <= latestFileKey.NumFiles; i++ {\r\n\t\t//retrieve appropriate fileElem from Datastore, generate correct file ID\r\n\t\tkeyMsg := latestFileKey.KeyId.String() + \"_\" + strconv.Itoa(i) //i is index of file\r\n\t\tkey_bytes, _ := userlib.HMACEval(latestFileKey.HMAC_key, []byte(keyMsg))\r\n\t\tfileID, _ := uuid.FromBytes(key_bytes[:16])\r\n\r\n\t\tfile_enc, err := userlib.DatastoreGet(fileID)\r\n\t\tlen_file := len(file_enc) - userlib.HashSizeBytes\r\n\r\n\t\tif !err {\r\n\t\t\terror_msg := \"File part not found: \" + keyMsg\r\n\t\t\treturn nil, errors.New(error_msg)\r\n\t\t}\r\n\r\n\t\t//fix ag out of bounds error\r\n\t\tif len_file < 0 || len_file > len(file_enc) || len(file_enc[:len_file]) < userlib.HashSizeBytes {\r\n\t\t\t//automatically return error, file has been changed\r\n\t\t\treturn nil, errors.New(\"File data length has changed.\")\r\n\t\t}\r\n\r\n\t\t//check integrity through HMAC\r\n\t\tfileMAC, _ := userlib.HMACEval(latestFileKey.HMAC_key, file_enc[:len_file])\r\n\t\tif !userlib.HMACEqual(fileMAC, file_enc[len_file:]) {\r\n\t\t\terror_msg := \"File part has been compromised: \" + keyMsg\r\n\t\t\treturn nil, errors.New(error_msg)\r\n\t\t}\r\n\r\n\t\t//decrypt, depad, demarshal, and extract data field\r\n\t\tfile_dec := userlib.SymDec(latestFileKey.Enc_key, file_enc[:len_file])\r\n\t\tfile_dec = PKCS(file_dec, \"remove\")\r\n\t\tvar file_demarsh FileElem\r\n\t\terr2 := json.Unmarshal(file_dec, &file_demarsh)\r\n\r\n\t\tif err2 != nil {\r\n\t\t\terror_msg := \"Error unmarshaling this file part: \" + keyMsg\r\n\t\t\treturn nil, errors.New(error_msg)\r\n\t\t}\r\n\r\n\t\t//finally we have the unmarshaled file struct, set filePart to the data\r\n\t\tfilePart = file_demarsh.Filedata\r\n\t\tdataBytes = append(dataBytes, filePart...)\r\n\t}\r\n\r\n\treturn dataBytes, nil\r\n}" ]
[ "0.63070524", "0.62410325", "0.61597294", "0.6100095", "0.59883857", "0.59538347", "0.5951708", "0.59262055", "0.58728063", "0.58575684", "0.58039385", "0.5759732", "0.57335424", "0.5730588", "0.56361836", "0.56168014", "0.5613954", "0.56097436", "0.55798995", "0.55492866", "0.5518828", "0.5511424", "0.54994893", "0.5485624", "0.54240155", "0.54216564", "0.53972274", "0.5389252", "0.5385502", "0.5384821", "0.5352765", "0.53518593", "0.5338988", "0.5320961", "0.5318381", "0.53146654", "0.5291711", "0.5284056", "0.52751124", "0.5241964", "0.5218105", "0.52109414", "0.52090377", "0.52016616", "0.5199231", "0.517838", "0.5168789", "0.5148328", "0.5134564", "0.5111167", "0.510942", "0.5090984", "0.5078338", "0.5065672", "0.50619763", "0.5040944", "0.50400734", "0.5039843", "0.5023733", "0.5011685", "0.49993047", "0.4998931", "0.49987832", "0.4991493", "0.4990348", "0.49882957", "0.49699983", "0.49670562", "0.49640447", "0.49612075", "0.49550062", "0.4953291", "0.4950493", "0.49377084", "0.49369037", "0.49368495", "0.4928824", "0.492809", "0.49242088", "0.49169016", "0.49085918", "0.49046806", "0.49004605", "0.48977107", "0.4895891", "0.48933402", "0.48848438", "0.48592374", "0.4859001", "0.48577568", "0.48507372", "0.48483023", "0.48437643", "0.48366985", "0.48346087", "0.48299244", "0.4823778", "0.4820164", "0.48013508", "0.47974467" ]
0.8122793
0
LoadUserEditPage Load page to edit user
func LoadUserEditPage(w http.ResponseWriter, r *http.Request) { cookie, _ := cookies.Read(r) userID, _ := strconv.ParseUint(cookie["id"], 10, 64) channel := make(chan models.User) go models.GetUserData(channel, userID, r) user := <-channel if user.ID == 0 { responses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: "Erro ao buscar o usuário"}) return } utils.RunTemplate(w, "edit-profile.html", user) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"update-password.html\", nil)\n}", "func UserEdit(w http.ResponseWriter, r *http.Request, u *User) error {\n\treturn RenderTemplate(w, \"user_profile.html\", struct{ User *User }{u})\n}", "func (controller *UserController) GetEditPage(ctx *fasthttp.RequestCtx) {\n\tcontroller.getProfile(ctx, true)\n}", "func (s *Server) handleDashboardUserEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepDel string\n\t}{\n\t\tStepDel: \"stepDel\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"user-edit.html\")\n\t\t})\n\t\tctx, provider, data, _, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Users\", provider.GetURLUsers()},\n\t\t\t{\"Edit Team Member\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLUsers()\n\t\tdata[TplParamFormAction] = provider.GetURLUserEdit()\n\t\tdata[TplParamSteps] = steps\n\n\t\t//handle the input\n\t\tidStr := r.FormValue(URLParams.UserID)\n\t\tstep := r.FormValue(URLParams.Step)\n\n\t\t//prepare the data\n\t\tdata[TplParamUserID] = idStr\n\n\t\t//load the provider user\n\t\tid := uuid.FromStringOrNil(idStr)\n\t\tif id == uuid.Nil {\n\t\t\tlogger.Warnw(\"invalid uuid\", \"id\", idStr)\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\t\tctx, providerUser, err := LoadProviderUserByProviderIDAndID(ctx, s.getDB(), provider.ID, &id)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"load provider user\", \"error\", err, \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tif providerUser == nil {\n\t\t\tlogger.Errorw(\"no provider user\", \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamUser] = providerUser\n\n\t\t//prepare the confirmation modal\n\t\tdata[TplParamConfirmMsg] = GetMsgText(MsgUserDelConfirm)\n\t\tdata[TplParamConfirmSubmitName] = URLParams.Step\n\t\tdata[TplParamConfirmSubmitValue] = steps.StepDel\n\n\t\t//check the method\n\t\tif r.Method == http.MethodGet {\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tvar msgKey MsgKey\n\t\tswitch step {\n\t\tcase steps.StepDel:\n\t\t\t//delete the provider user\n\t\t\tctx, err := DeleteUserProvider(ctx, s.getDB(), provider.ID, providerUser.ID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"delete provider user\", \"error\", err, \"id\", providerUser.ID)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgUserDel\n\t\tdefault:\n\t\t\tlogger.Errorw(\"invalid step\", \"id\", providerUser.ID, \"step\", step)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//success\n\t\ts.SetCookieMsg(w, msgKey, providerUser.Login)\n\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t}\n}", "func (h *Handler) EditUser(c *fiber.Ctx) error {\n\tservice := services.NewUserService()\n\tid, err := strconv.ParseInt(c.Params(\"id\"), 10, 32)\n\n\tif err != nil {\n\t\treturn c.Status(400).JSON(fiber.Map{\"status\": \"error\", \"message\": err.Error()})\n\t}\n\n\tvar usr user.User\n\tif err := c.BodyParser(&usr); err != nil {\n\t\treturn c.Status(422).JSON(fiber.Map{\"status\": \"error\", \"message\": \"Invalid fields\"})\n\t}\n\n\terr = service.UpdateUser(&usr, int(id))\n\n\tif err != nil {\n\t\treturn c.Status(500).JSON(fiber.Map{\"status\": \"error\", \"message\": err.Error()})\n\t}\n\n\treturn c.JSON(fiber.Map{\"status\": \"success\", \"message\": \"UpdatedUser\", \"data\": usr})\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\r\n title := r.URL.Path[len(\"/edit/\"):]\r\n p, err := loadPage(title)\r\n if err != nil {\r\n p = &Page{Title: title}\r\n }\r\n renderTemplate(w, \"edit\", p)\r\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/edit/\"):]\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func EditPage(c *fiber.Ctx) error {\n\t// Firstly checks if given table exists\n\tname := c.Params(\"name\")\n\tT := databasepack.FindTable(name)\n\tif T < 0 {\n\t\treturn c.Send([]byte(\"No table with such name!\"))\n\t}\n\t// Next checks if the user can actually perform this action\n\tif !databasepack.Allowed(querypack.INFO.Roles, \"editor_\"+name) {\n\t\treturn c.Send([]byte(\"Permission declined!\"))\n\t}\n\t// Lastly posts given post\n\tdatabasepack.CreatePosts(c.Body(), name, T)\n\treturn c.Send([]byte(\"Successfully edited!\"))\n}", "func (h *Handler) EditPage(c echo.Context) error {\n\tm := echo.Map{}\n\tif err := c.Bind(&m); err != nil {\n\t\treturn err\n\t}\n\tnr, nt, route := m[\"newRoute\"].(string), m[\"newTitle\"].(string), m[\"route\"].(string)\n\n\tuserDataMap := utils.GetUserDataFromContext(&c)\n\temail := (*userDataMap)[\"email\"].(string)\n\n\tpage, err := h.pageStore.EditPage(email, route, nr, nt)\n\tif err != nil {\n\t\tutils.Logger.Error(err)\n\t\treturn c.JSON(http.StatusInternalServerError, createRes(false, nil, nil, http.StatusText(http.StatusInternalServerError)))\n\t}\n\treturn c.JSON(http.StatusOK, createRes(true, page, nil, \"\"))\n}", "func LoadEditPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tpublicationID, err := strconv.ParseUint(parameters[\"publicationId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\turl := fmt.Sprintf(\"%s/publications/%d\", config.APIURL, publicationID)\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tvar publication models.Publication\n\tif err = json.NewDecoder(response.Body).Decode(&publication); err != nil {\n\t\tresponses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-publication.html\", publication)\n}", "func handlerEdit(w http.ResponseWriter, r *http.Request, title string) {\r\n\tpage, err := loadPage(title)\r\n\tif err != nil {\r\n\t\tpage = &Page{Title: title}\r\n\t}\r\n\t//to use a html file we have to use the template.ParseFile\r\n\tfetchHTML(w, \"edit\", page)\r\n}", "func (u *Users) Edit(ctx context.Context, user model.UserInfo, actionBy int64) (err error) {\n\tif err = u.database.EditUser(ctx, user, actionBy); err != nil {\n\t\terr = errors.Wrap(err, \"EditUser\")\n\t}\n\treturn\n}", "func (config *AppConfig) EditUser(editUser UserAttributes, userID int) (user User, err error) {\n\teditUserBytes, err := json.Marshal(editUser)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// get json bytes from the panel.\n\tuserBytes, err := config.queryApplicationAPI(fmt.Sprintf(\"users/%d\", userID), \"patch\", editUserBytes)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Get user info from the panel\n\t// Unmarshal the bytes to a usable struct.\n\terr = json.Unmarshal(userBytes, &user)\n\tif err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tlog.Println(\"editHandler() error: \", err)\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"edit\", p)\n}", "func (config *CrocConfig) EditUser(editUser UserAttributes, userID int) (User, error) {\n\tvar userDetails User\n\tendpoint := fmt.Sprintf(\"users/%d\", userID)\n\n\teubytes, err := json.Marshal(editUser)\n\tif err != nil {\n\t\treturn userDetails, err\n\t}\n\n\t// get json bytes from the panel.\n\tubytes, err := config.queryPanelAPI(endpoint, \"patch\", eubytes)\n\tif err != nil {\n\t\treturn userDetails, err\n\t}\n\n\t// Get user info from the panel\n\t// Unmarshal the bytes to a usable struct.\n\terr = json.Unmarshal(ubytes, &userDetails)\n\tif err != nil {\n\t\treturn userDetails, err\n\t}\n\n\treturn userDetails, nil\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\t/* The renderTemplate function replaces the following code for better code re-use:\n\t * t, _ := template.ParseFiles(\"edit.html\")\t\n\t * t.Execute(w,p)\n\t */ \n\trenderTemplate(w, \"edit\", p)\n}", "func LoadUserPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"userId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserIDLogged, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tif userID == userIDLogged {\n\t\thttp.Redirect(w, r, \"/profile\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"user.html\", struct {\n\t\tUser models.User\n\t\tUserLoggedID uint64\n\t}{\n\t\tUser: user,\n\t\tUserLoggedID: userIDLogged,\n\t})\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title, Filename: title}\n\t}\n\trenderTemplate(w, \"edit\", p)\n}", "func editHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\tp = &Page{Title: title}\n\t}\n\trenderTemplate(w, \"edit\", p) // Passes: ResponseWriter, templatename, template page fill\n\t//t.Execute(w, p) Executes template, writes HTML to http.ResponseWriter (w)\n}", "func (app *application) EditUser(w http.ResponseWriter, r *http.Request) {\n\tid := chi.URLParam(r, \"id\")\n\tuserID, _ := strconv.Atoi(id)\n\n\tvar user models.User\n\n\terr := app.readJSON(w, r, &user)\n\tif err != nil {\n\t\tapp.badRequest(w, r, err)\n\t\treturn\n\t}\n\n\tif userID > 0 { // For an existing user, update the user record\n\t\terr = app.DB.EditUser(user)\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\n\t\tif user.Password != \"\" {\n\t\t\tnewHash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 12)\n\t\t\tif err != nil {\n\t\t\t\tapp.badRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terr = app.DB.UpdatePasswordForUser(user, string(newHash))\n\t\t\tif err != nil {\n\t\t\t\tapp.badRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t} else { // For a new user, simply add the user to the users table\n\t\tnewHash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 12)\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\terr = app.DB.AddUser(user, string(newHash))\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tvar resp struct {\n\t\tError bool `json:\"error\"`\n\t\tMessage string `json:\"message\"`\n\t}\n\n\tresp.Error = false\n\tapp.writeJSON(w, http.StatusOK, resp)\n}", "func editUser(userID int, firstName string, MI string, lastName string, privLevel int) error {\n\n\tdb, err := sql.Open(\"mysql\", DB_USER_NAME+\":\"+DB_PASSWORD+\"@unix(/var/run/mysql/mysql.sock)/\"+DB_NAME)\n\tif err != nil {\n\t\treturn errors.New(\"No connection\")\n\t}\n\n\tres, err := db.Exec(\"update Users set FirstName=?, MiddleInitial=?, LastName=?, PrivLevel=? where UserID=?\", firstName, MI, lastName, privLevel, userID)\n\n\tif err != nil {\n\t\treturn errors.New(\"User update failed.\")\n\t}\n\n\trowsAffected, err := res.RowsAffected()\n\n\tif rowsAffected != 1 {\n\t\treturn errors.New(\"Query didn't match any users.\")\n\t}\n\n\treturn nil\n}", "func AdminEdit(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminEdit, w, data)\n}", "func AdminEdit(w http.ResponseWriter, data interface{}) {\n\trender(tpAdminEdit, w, data)\n}", "func (env *Env) Edit(res http.ResponseWriter, req *http.Request, title string) {\n\tenv.Log.V(1, \"beginning handling of Edit.\")\n\tenv.Log.V(1, \"loading requested page from cache.\")\n\tp, err := env.Cache.LoadPageFromCache(title)\n\tif err != nil {\n\t\tenv.Log.V(1, \"if file from cache not found, then retrieve requested page from db.\")\n\t\tp, _ = env.DB.LoadPage(title)\n\t}\n\tif p.Title == \"\" {\n\t\tenv.Log.V(1, \"if page title is blank, then try again.\")\n\t\tp, _ = env.DB.LoadPage(title)\n\t}\n\tif p == nil {\n\t\tenv.Log.V(1, \"notifying client that the request page was not found.\")\n\t\thttp.NotFound(res, req)\n\t\treturn\n\t}\n\tif strings.Contains(p.Title, \"_\") {\n\t\tp.Title = strings.Replace(p.Title, \"_\", \" \", -1)\n\t}\n\tenv.Log.V(1, \"requested page found, rendering the edit template.\")\n\tenv.Render(res, \"edit\", p)\n}", "func (c *Client) EditUser(eu *www.EditUser) (*www.EditUserReply, error) {\n\tresponseBody, err := c.makeRequest(http.MethodPost,\n\t\twww.PoliteiaWWWAPIRoute, www.RouteEditUser, eu)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar eur www.EditUserReply\n\terr = json.Unmarshal(responseBody, &eur)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal EditUserReply: %v\", err)\n\t}\n\n\tif c.cfg.Verbose {\n\t\terr := prettyPrintJSON(eur)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn &eur, nil\n}", "func UsersEdit(w http.ResponseWriter, r *http.Request) {\n\trequest, err := decode(r)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t}\n\n\tif valid, err := helpers.ValidateUser(request, helpers.GetUserEditFields()); !valid {\n\t\trespondFailedValidation(w, err)\n\n\t\treturn\n\t}\n\n\tparams := mux.Vars(r)\n\tid := params[\"id\"]\n\tuserID, _ := strconv.Atoi(id)\n\n\tuser, err := models.UserFindByID(userID)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusNotFound, err.Error())\n\n\t\treturn\n\t}\n\n\tupdatedUser, err := models.UserEdit(user, request)\n\tif err != nil {\n\t\trespondWithError(w, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tresponse := Response{\n\t\t\"user\": updatedUser,\n\t}\n\trespondWithJSON(w, http.StatusOK, response)\n}", "func EditProfile(w http.ResponseWriter, r *http.Request) {\n\tvar t models.User\n\n\terr := json.NewDecoder(r.Body).Decode(&t)\n\tif err != nil {\n\t\thttp.Error(w, \"the data is invalid\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tvar status bool\n\tstatus, err = db.EditRegister(t, IDUser)\n\tif err != nil {\n\t\thttp.Error(w, \"An error occurred when trying to modify the register. Please try again\"+err.Error(), 400)\n\t\treturn\n\t}\n\tif !status {\n\t\thttp.Error(w, \"It was not possible to modify the user's register in the db\"+err.Error(), 400)\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusCreated)\n}", "func (*RegDBService) EditUser(reg *Registration) error {\n\terr := rdb.Model(reg).Update(reg).Error\n\treturn err\n}", "func handleEdit(w http.ResponseWriter, r *http.Request, title string) {\n\tp, err := page.Load(title)\n\tif err != nil {\n\t\tp = &page.Page{Title: title}\n\t}\n\trender(w, \"edit\", p)\n\tlogInfo(p.Title, \"file opened in edit mode\")\n}", "func (ac *ArticleController) Edit(w http.ResponseWriter, r *http.Request) {\n\t// u := userContext(r.Context())\n\t// debug: dummy user\n\tctx := r.Context()\n\tu := models.UserContext(ctx)\n\tif u.IsAdmin {\n\t\tp := httptreemux.ContextParams(ctx)\n\n\t\tidParam, _ := strconv.Atoi(p[\"id\"])\n\t\tif idParam <= 0 { // conversion failed or bad input\n\t\t\tsendJSON(\"Input not valid\", http.StatusBadRequest, w)\n\t\t\treturn\n\t\t}\n\n\t\tid := uint(idParam)\n\t\ttitle := r.FormValue(\"title\")\n\t\ttext := r.FormValue(\"text\")\n\n\t\ta := models.ArticleUpdate(id, title, text)\n\t\tif a.ID == 0 { // Something went wrong\n\t\t\tsendJSON(\"Error: impossible to edit article\", http.StatusInternalServerError, w)\n\t\t\treturn\n\t\t}\n\n\t\turl := r.URL.EscapedPath()\n\t\tcache.RemoveURL(url)\n\n\t\tw.Header().Set(\"Content-Location\", url)\n\t\tsendJSON(a, http.StatusOK, w)\n\t} else {\n\t\tsendJSON(\"You are not admin\", http.StatusForbidden, w)\n\t}\n}", "func UserEdit(u *User, p Payload) (*User, error) {\n\tconst qry = `\n\t\tUPDATE\n\t\t\tusers\n\t\tSET\n\t\t\tname = $1,\n\t\t\tuser_name = $2,\n\t\t\temail = $3,\n\t\t\tupdated_at = NOW()\n\t\tWHERE\n\t\t\tid = $4\n\t\tRETURNING *;\n\t`\n\n\trow := DBConn.QueryRow(\n\t\tqry,\n\t\tp[\"name\"],\n\t\tp[\"userName\"],\n\t\tp[\"email\"],\n\t\t(*u).ID)\n\n\terr := row.Scan(\n\t\t&u.ID,\n\t\t&u.Name,\n\t\t&u.Email,\n\t\t&u.UserName,\n\t\t&u.password,\n\t\t&u.CreatedAt,\n\t\t&u.UpdatedAt)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn u, nil\n}", "func Edit(writer http.ResponseWriter, request *http.Request, p httprouter.Params) {\n\n\tvar TP m.Thread\n\n\t//find the thread by id and assign it to TP\n\terr := m.Threads.Find(\"_id\", p.ByName(\"id\"), &TP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the thread by ID!!\")\n\t\thttp.Redirect(writer, request, \"/home\", 302)\n\t\treturn\n\t}\n\n\tvar UP m.User\n\n\t//get the User and assign to User UP struct\n\terr = m.Users.Find(\"_id\", TP.User, &UP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the user by ID!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\t// get the list of mongo collections\n\tcoll, err := m.ShowCollectionNames(m.DB)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Get the list of Collection!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\tdashlist := m.FindDetails{\n\t\tCollectionNames: coll,\n\t\tContentDetails: &TP,\n\t\tUser: &UP,\n\t}\n\n\tvar LIP m.LogInUser\n\n\terr = m.GetLogInUser(\"User\", &LIP, request)\n\tif err != nil {\n\t\tdashlist.LogInUser = nil\n\t\tLogger.Printf(\"Failed to get the login details %v\\n\", err)\n\t} else {\n\t\tdashlist.LogInUser = &LIP\n\t}\n\n\tgenerateHTML(writer, &dashlist, \"Layout\", \"ThreadLeftSideBar\", \"ThreadTopSideBar\", \"ThreadModal\", \"ThreadEdit\")\n}", "func EditPage(ctx *sweetygo.Context) error {\n\tctx.Set(\"title\", \"Edit\")\n\tctx.Set(\"editor\", true)\n\ttitle := ctx.Param(\"title\")\n\ttitle = strings.Replace(title, \"-\", \" \", -1)\n\tpost, err := model.GetPostByTitle(title)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx.Set(\"post\", post)\n\treturn ctx.Render(200, \"posts/edit\")\n}", "func editHandler(w http.ResponseWriter, r *http.Request, title string) {\n p := selectRow(title, w, r)\n renderTemplate(w, \"edit\", p)\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\r\n\tdb := Database.Dbconn()\r\n\t\r\n\tnId := r.URL.Query().Get(\"id\")\r\n\ttsql := fmt.Sprintf(\"SELECT * FROM employee.dbo.employee where Id='%s';\", nId)\r\n\tselDB, err := db.Query(tsql)\r\n\tif err != nil {\r\n panic(err.Error())\r\n\t}\r\n\r\n\tper :=persona{}\r\n\tfor selDB.Next(){\r\n\t\tvar (\r\n\t\t\tId string\r\n\t\t\tName string\r\n\t\t\tLocation string\r\n\t\t)\r\n\r\n\t\terr =selDB.Scan(&Id, &Name, &Location)\r\n\t\tif err != nil {\r\n\t\t\tpanic(err.Error())\r\n\t\t}\r\n\t\tper.Id=Id\r\n\t\tper.Name = Name\r\n\t\tper.Location = Location\r\n\t}\r\n\r\n\tlog.Println(per)\r\n\ttmpl.ExecuteTemplate(w, \"Show\", per)\r\n\r\n}", "func ViewUsers(w http.ResponseWriter, r *http.Request) { \n AuthorizePages(w,r) \n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewUsers.html\")\n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n userId := UserIds{\n UserId: r.FormValue(\"userId\"),\n }\n\n var successMessage string\n var isShow bool \n\n if (userId.UserId != \"\" ) {\n if (dbquery.DeleteManagerUser(\"User\",userId.UserId)){\n isShow = true\n successMessage = \"User Deleted Successfully\"\n }\n }\n\n var userList []helpers.User \n userList = dbquery.GetUserByRole(\"\",\"'User'\")\n t.Execute(w, AllUsersResponse{Users: userList, SuccessMessage: successMessage, IsShow: isShow}) \n}", "func LoadUsersPage(w http.ResponseWriter, r *http.Request) {\n\tnameOrNick := strings.ToLower(r.URL.Query().Get(\"user\"))\n\n\turl := fmt.Sprintf(\"%s/users?usuario=%s\", config.APIURL, nameOrNick)\n\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tvar users []models.User\n\tif err := json.NewDecoder(response.Body).Decode(&users); err != nil {\n\t\tresponses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"users.html\", users)\n}", "func Edit(w http.ResponseWriter, r *http.Request){\n\tidDoProduto := r.URL.Query().Get(\"id\")\n\tproduto := models.EditaProduto(idDoProduto)\n\ttemp.ExecuteTemplate(w, \"Edit\", produto)\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tdb := dbConn()\n\tnId := r.URL.Query().Get(\"id\")\n\tselDB, err := db.Query(\"SELECT * FROM Employee WHERE id=?\", nId)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\temp := Employee{}\n\tfor selDB.Next() {\n\t\tvar id int\n\t\tvar name, city string\n\t\terr = selDB.Scan(&id, &name, &city)\n\t\tif err != nil {\n\t\t\tpanic(err.Error())\n\t\t}\n\t\temp.Id = id\n\t\temp.Name = name\n\t\temp.City = city\n\t}\n\tgetTemplates().ExecuteTemplate(w, \"Edit\", emp)\n\tdefer db.Close()\n}", "func EditPageHandler(db *sql.DB, tmpl ExecuteTemplateFunc) http.HandlerFunc {\n\treturn handleErrors(func(w http.ResponseWriter, r *http.Request) error {\n\t\tblogslug := mux.Vars(r)[\"blogslug\"]\n\t\tpageslug := mux.Vars(r)[\"pageslug\"]\n\t\tdto, err := EditPageQuery(db, blogslug, pageslug)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn tmpl(w, \"editpage.html\", dto)\n\t})\n}", "func userPage(w http.ResponseWriter, r *http.Request){\n\tisLogged, name := CheckLoginStatus(w,r)\n\n\tif isLogged {\n\t\terr := templ.ExecuteTemplate(w, \"userHome\", name)\n\t\tif err != nil {\n\t\t\tfmt.Println(err.Error())\n\t\t}\n\t} else {\n\t\thttp.Redirect(w,r,\"/unauthorized\",http.StatusSeeOther)\n\t}\n}", "func (i interactor) UserEdit(userName string, fieldsToUpdate map[UpdatableProperty]*string) (*domain.User, error) {\n\tuser, err := i.userRW.GetByName(userName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif user.Name != userName {\n\t\treturn nil, errWrongUser\n\t}\n\tif user == nil {\n\t\treturn nil, ErrUserNotFound\n\t}\n\n\tdomain.UpdateUser(user,\n\t\tdomain.SetUserName(fieldsToUpdate[Name]),\n\t\tdomain.SetUserEmail(fieldsToUpdate[Email]),\n\t\tdomain.SetUserBio(fieldsToUpdate[Bio]),\n\t\tdomain.SetUserImageLink(fieldsToUpdate[ImageLink]),\n\t\tdomain.SetUserPassword(fieldsToUpdate[Password]),\n\t)\n\n\tif err := i.userValidator.CheckUser(*user); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := i.userRW.Save(*user); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn user, nil\n}", "func (d *webData) showUsersWeb(w http.ResponseWriter, r *http.Request) {\n\tp := storage.QueryAllUserInfo(d.PDB)\n\terr := d.tpl.ExecuteTemplate(w, \"showUserCompletePage\", p)\n\tif err != nil {\n\t\tlog.Println(\"showUsersWeb: template execution error = \", err)\n\t}\n\tfmt.Fprint(w, err)\n}", "func EditUser(u models.User, ID string) (bool, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\tdb := MongoCN.Database(\"meganeuradb\")\n\tcol := db.Collection(\"users\")\n\n\t//map of interface with string index\n\t//for validation reasons that\n\t//cant be done on json format\n\tuserMap := make(map[string]interface{})\n\tif len(u.Name) > 0 {\n\t\tuserMap[\"name\"] = u.Name\n\t}\n\tif len(u.LastName) > 0 {\n\t\tuserMap[\"lastName\"] = u.LastName\n\t}\n\n\tuserMap[\"birthDate\"] = u.BirthDate\n\n\tif len(u.Bio) > 0 {\n\t\tuserMap[\"bio\"] = u.Bio\n\t}\n\tif len(u.Banner) > 0 {\n\t\tuserMap[\"banner\"] = u.Banner\n\t}\n\tif len(u.Avatar) > 0 {\n\t\tuserMap[\"avatar\"] = u.Avatar\n\t}\n\tif len(u.Location) > 0 {\n\t\tuserMap[\"location\"] = u.Location\n\t}\n\tif len(u.Web) > 0 {\n\t\tuserMap[\"web\"] = u.Web\n\t}\n\n\t//updating string for mongoDB format\n\tupdtString := bson.M{\n\t\t\"$set\": userMap,\n\t}\n\n\t//id of param to ObjID\n\tobjID, _ := primitive.ObjectIDFromHex(ID)\n\n\t//get the doc OF the ID WITH \"EQUAL\"\n\tfilter := bson.M{\"_id\": bson.M{\"$eq\": objID}}\n\n\t//updating on mongodb\n\t_, err := col.UpdateOne(ctx, filter, updtString)\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func (repo *Repository) EditWikiPage(doer *User, oldWikiName, newWikiName, content, message string) error {\n\treturn repo.updateWikiPage(doer, oldWikiName, newWikiName, content, message, false)\n}", "func (config *AuthConfig) EditUserAuth(auth *UserAuth, defaultUserName string, editUser bool) error {\n\t// default the user name if its empty\n\tdefaultUsername := config.DefaultUsername\n\tif defaultUsername == \"\" {\n\t\tdefaultUsername = defaultUserName\n\t}\n\tif auth.Username == \"\" {\n\t\tauth.Username = defaultUsername\n\t}\n\n\tvar qs = []*survey.Question{}\n\n\tif editUser || auth.Username == \"\" {\n\t\tqs = append(qs, &survey.Question{\n\t\t\tName: \"username\",\n\t\t\tPrompt: &survey.Input{\n\t\t\t\tMessage: \"User name:\",\n\t\t\t\tDefault: auth.Username,\n\t\t\t},\n\t\t\tValidate: survey.Required,\n\t\t})\n\t}\n\tqs = append(qs, &survey.Question{\n\t\tName: \"apiToken\",\n\t\tPrompt: &survey.Input{\n\t\t\tMessage: \"API Token:\",\n\t\t\tDefault: auth.ApiToken,\n\t\t},\n\t\tValidate: survey.Required,\n\t})\n\treturn survey.Ask(qs, auth)\n}", "func (d *webData) modifyUsersWeb(w http.ResponseWriter, r *http.Request) {\n\tr.ParseForm()\n\tip := r.RemoteAddr\n\t//query the userDB for all users and put the returning slice with result in p\n\tallUsers := storage.QueryAllUserInfo(d.PDB)\n\tfmt.Println(\"---ALL USERS FROM DATABASE = \", allUsers)\n\n\t//Execute the web for modify users, range over allUsers to make the select user drop down menu\n\terr := d.tpl.ExecuteTemplate(w, \"modifyUserCompletePage\", allUsers)\n\tif err != nil {\n\t\tfmt.Fprint(w, \"template execution error = \", err)\n\t}\n\n\t//Execute the modifyUserSelection drop down menu template\n\terr = d.tpl.ExecuteTemplate(w, \"modifyUserSelection\", allUsers)\n\tif err != nil {\n\t\tfmt.Fprint(w, \"template execution error = \", err)\n\t}\n\n\t//Get the value (number) of the chosen user from form dropdown menu <select name=\"users\">\n\tnum, _ := strconv.Atoi(r.FormValue(\"users\"))\n\tvar singleUser storage.User\n\n\t//Find the selected single user chosen in dropdown in the slice of all users\n\tfor i := range allUsers {\n\t\t//Iterate over the complete struct of users until the chosen user is found\n\t\tif allUsers[i].Number == num {\n\t\t\t//Store the index nr in slice of the chosen user\n\t\t\tsingleUser = allUsers[i]\n\t\t\td.IndexUser = i\n\t\t}\n\t}\n\terr = d.tpl.ExecuteTemplate(w, \"modifyUser\", singleUser) //bruk bare en spesifik slice av struct og send til html template\n\tif err != nil {\n\t\tlog.Println(ip, \"modifyUsersWeb: error = \", err)\n\t}\n\n\tuForm := storage.User{}\n\t//get all the values from the user info fileds of the the\n\tgetFormValuesUserInfo(&uForm, r)\n\n\tchanged := false\n\tchanged, allUsers[d.IndexUser] = checkUserFormChanged(uForm, allUsers[d.IndexUser])\n\n\tfmt.Printf(\"---single user %v, type = %T\\n\", singleUser, singleUser)\n\tfmt.Printf(\"---uallUsers %v, type %T\\n\", allUsers[d.IndexUser], allUsers[d.IndexUser])\n\n\t//if any of the values was changed....update information into database\n\tif changed {\n\t\tstorage.UpdateUser(d.PDB, allUsers[d.IndexUser])\n\t}\n}", "func (r *OAuthProfileResource) Edit(id string, item OAuthProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+OAuthProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *InviteUserController) EditInvitation() {\n\tr := c.Ctx.Request\n\tw := c.Ctx.ResponseWriter\n\tinvitationViewModel := viewmodels.EditInviteUserViewModel{}\n\tInviteUserId := c.Ctx.Input.Param(\":inviteuserid\")\n\tcompanyTeamName := c.Ctx.Input.Param(\":companyTeamName\")\n\tstoredSession := ReadSession(w, r, companyTeamName)\n\n\tif r.Method == \"POST\" {\n\t\tinvitation := models.CompanyInvitations{}\n\t\tinvitation.FirstName = c.GetString(\"firstname\")\n\t\tinvitation.LastName = c.GetString(\"lastname\")\n\t\tinvitation.Email = c.GetString(\"emailid\")\n\t\tinvitation.UserType = c.GetString(\"usertype\")\n\n\t\tdbStatus := invitation.UpdateInviteUserById(c.AppEngineCtx, InviteUserId,companyTeamName)\n\t\tswitch dbStatus {\n\t\tcase true:\n\t\t\tw.Write([]byte(\"true\"))\n\t\tcase false:\n\t\t\tw.Write([]byte(\"false\"))\n\t\t}\n\n\t} else {\n\t\teditViewResult, DbStatus := models.GetAllUserFormCompanyEdit(c.AppEngineCtx,companyTeamName,InviteUserId)\n\t\tlog.Println(\"all\", editViewResult)\n\t\tswitch DbStatus {\n\t\tcase true:\n\n\n\t\t\tif editViewResult.UserResponse !=helpers.UserStatusDeleted{\n\t\t\t\tinvitationViewModel.FirstName = editViewResult.FirstName\n\t\t\t\tinvitationViewModel.LastName = editViewResult.LastName\n\t\t\t\tinvitationViewModel.UserType = editViewResult.UserType\n\t\t\t\tinvitationViewModel.UserResponse = editViewResult.UserResponse\n\t\t\t\tinvitationViewModel.PageType = helpers.SelectPageForEdit\n\t\t\t\tinvitationViewModel.CompanyTeamName = storedSession.CompanyTeamName\n\t\t\t\tinvitationViewModel.CompanyPlan = storedSession.CompanyPlan\n\t\t\t\tinvitationViewModel.AdminFirstName = storedSession.AdminFirstName\n\t\t\t\tinvitationViewModel.AdminLastName = storedSession.AdminLastName\n\t\t\t\tinvitationViewModel.EmailId = editViewResult.Email\n\t\t\t\tinvitationViewModel.InviteId = InviteUserId\n\t\t\t\tc.Data[\"vm\"] = invitationViewModel\n\t\t\t\tc.Layout = \"layout/layout.html\"\n\t\t\t\tc.TplName = \"template/add-invite-user.html\"\n\t\t\t}\n\n\t\tcase false:\n\t\t\tlog.Println(helpers.ServerConnectionError)\n\t\t}\n\n\t}\n}", "func (d *webData) modifyAdminWeb(w http.ResponseWriter, r *http.Request) {\n\tip := r.RemoteAddr\n\tadminID := 0\n\t//query the userDB for all users and put the returning slice with result in p\n\tu := storage.QuerySingleUserInfo(d.PDB, adminID)\n\n\t//Execute the web for modify users, range over p to make the select user drop down menu\n\terr := d.tpl.ExecuteTemplate(w, \"modifyUserCompletePage\", u)\n\tif err != nil {\n\t\tfmt.Fprint(w, \"Error: modifyAdminWeb: template execution error = \", err)\n\t}\n\n\t//Write out all the info of the selected user to the web\n\n\terr = d.tpl.ExecuteTemplate(w, \"modifyUser\", u) //bruk bare en spesifik slice av struct og send til html template\n\tif err != nil {\n\t\tlog.Println(ip, \"modifyAdminWeb: error = \", err)\n\t}\n\n\tr.ParseForm()\n\n\t//create a variable based on user to hold the values parsed from the modify web\n\tuForm := storage.User{}\n\t//get all the values like name etc. from the form, and put them in u\n\tgetFormValuesUserInfo(&uForm, r)\n\tchanged := false\n\tchanged, u = checkUserFormChanged(uForm, u)\n\n\t//Check what values that are changed\n\n\t//if any of the values was changed....update information into database\n\tif changed {\n\t\tstorage.UpdateUser(d.PDB, u)\n\n\t\t//Execute the redirect to modifyAdmin to refresh page\n\t\terr := d.tpl.ExecuteTemplate(w, \"redirectTomodifyAdmin\", u)\n\t\tif err != nil {\n\t\t\tfmt.Fprint(w, \"Error: modifyAdminWeb: template execution error = \", err)\n\t\t}\n\t}\n}", "func UserDetailsHandler(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\tcurrentUser := GetUser(r)\n\tuserProfile, _, errorUser := userService.RetrieveUserForAdmin(id)\n\tif errorUser == nil && userPermission.CurrentOrAdmin(currentUser, userProfile.ID) {\n\t\tif userPermission.CurrentOrAdmin(currentUser, userProfile.ID) {\n\t\t\tb := form.UserForm{}\n\t\t\tmodelHelper.BindValueForm(&b, r)\n\t\t\tlanguages.SetTranslationFromRequest(viewProfileEditTemplate, r, \"en-us\")\n\t\t\tavailableLanguages := languages.GetAvailableLanguages()\n\t\t\thtv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), availableLanguages, NewSearchForm(), Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)}\n\t\t\terr := viewProfileEditTemplate.ExecuteTemplate(w, \"index.html\", htv)\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlanguages.SetTranslationFromRequest(notFoundTemplate, r, \"en-us\")\n\t\terr := notFoundTemplate.ExecuteTemplate(w, \"index.html\", NotFoundTemplateVariables{Navigation{}, NewSearchForm(), GetUser(r), r.URL, mux.CurrentRoute(r)})\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n }\n}", "func (u *User) Edit(db *DB) (*User, error) {\n\tcoll := db.MongoClient.Collection(\"users\")\n\tctx := context.Background()\n\n\tfilter := bson.M{\n\t\t\"_id\": u.ID,\n\t}\n\n\t// only set fields that contain a value\n\tupdate := bson.M{\n\t\t\"$set\": u,\n\t}\n\n\t// update and return the updated document\n\tafter := options.After\n\topts := &options.FindOneAndUpdateOptions{\n\t\tReturnDocument: &after,\n\t}\n\n\tdoc := coll.FindOneAndUpdate(ctx, filter, update, opts)\n\tif doc.Err() != nil {\n\t\tif doc.Err() == mongo.ErrNoDocuments {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, NewErrorf(\"error updating user %s: %s\", u.ID, doc.Err())\n\t}\n\n\tvar user User\n\tif err := doc.Decode(&user); err != nil {\n\t\treturn nil, NewErrorf(\"error decoding user %s: %s\", u.ID, err)\n\t}\n\n\treturn &user, nil\n}", "func (r *Router) editUserImg(c *gin.Context) {\n\tidInt := Atoi(c, c.PostForm(\"id\"))\n\tCheckEditAuth(c, uint(idInt))\n\timg, err := c.FormFile(\"img\")\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"status\": -1,\n\t\t\t\"msg\": fmt.Errorf(\"invalid image: %v\", err),\n\t\t})\n\t\treturn\n\t}\n\tf, err := img.Open()\n\tif err != nil {\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"status\": -1,\n\t\t\t\"msg\": fmt.Errorf(\"read image failed: %v\", err),\n\t\t})\n\t\treturn\n\t}\n\timgByte := make([]byte, img.Size)\n\tfor {\n\t\t_, err := f.Read(imgByte)\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t}\n\n\terr = r.model.EditUser(uint(idInt), imgByte, \"\", \"\", \"\", 0, \"\", time.Now(), \"\", \"\")\n\tif err != nil {\n\t\tlogrus.Errorf(\"edit image error: %v\", err)\n\t\tc.JSON(http.StatusInternalServerError, gin.H{\n\t\t\t\"status\": -1,\n\t\t\t\"msg\": fmt.Errorf(\"failed to edit image: %v\", err),\n\t\t})\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"status\": 0,\n\t\t\"msg\": \"edit image success\",\n\t})\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\tarticle, _, err := article.ByID(c.DB, c.Param(\"id\"), c.UserID)\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tc.Redirect(uri)\n\t\treturn\n\t}\n\n\tv := c.View.New(\"article/edit\")\n\tc.Repopulate(v.Vars, \"tittle\")\n\tv.Vars[\"article\"] = article\n\tv.Render(w, r)\n}", "func (r *SSHProfileResource) Edit(id string, item SSHProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+SSHProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (h *MovieHandler) edit(w http.ResponseWriter, r *http.Request) {\n\t// Parse the id param from the URL and convert it into an int64.\n\tid, err := strconv.ParseInt(chi.URLParam(r, \"id\"), 10, 64)\n\tif err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Not Found\", http.StatusNotFound)\n\t\tlog.Println(\"Error:\", err)\n\t\treturn\n\t}\n\n\t// Call GetMovie to get the movie from the database.\n\tif movie, err := h.MovieService.GetMovie(id); err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Not Found\", http.StatusNotFound)\n\t\tlog.Println(\"Error:\", err)\n\t} else {\n\t\t// Render a HTML response and set status code.\n\t\trender.HTML(w, http.StatusOK, \"movie/edit.html\", movie)\n\t}\n}", "func LoadViewCreateUser(w http.ResponseWriter, r *http.Request) {\n\tutils.RunTemplate(w, \"register.html\", nil)\n}", "func (p *politeiawww) processEditUser(eu *www.EditUser, user *user.User) (*www.EditUserReply, error) {\n\tif eu.EmailNotifications != nil {\n\t\tuser.EmailNotifications = *eu.EmailNotifications\n\t}\n\n\t// Update the user in the database.\n\terr := p.db.UserUpdate(*user)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &www.EditUserReply{}, nil\n}", "func HandleEmailEditProfile(modules *modules.Modules) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\n\t\tuserManagement := modules.User()\n\n\t\t// Create a context of execution\n\t\tctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)\n\t\tdefer cancel()\n\n\t\t// Get the path parameters\n\t\tvars := mux.Vars(r)\n\t\tprojectID := vars[\"project\"]\n\t\tdbAlias := vars[\"dbAlias\"]\n\t\tid := vars[\"id\"]\n\n\t\t// Get the JWT token from header\n\t\ttoken := utils.GetTokenFromHeader(r)\n\n\t\t// Load the request from the body\n\t\treq := map[string]interface{}{}\n\t\t_ = json.NewDecoder(r.Body).Decode(&req)\n\t\tdefer utils.CloseTheCloser(r.Body)\n\n\t\tstatus, result, err := userManagement.EmailEditProfile(ctx, token, dbAlias, projectID, id, req[\"email\"].(string), req[\"name\"].(string), req[\"pass\"].(string))\n\n\t\tif err != nil {\n\t\t\t_ = utils.SendErrorResponse(w, status, err.Error())\n\t\t\treturn\n\t\t}\n\t\t_ = utils.SendResponse(w, status, result)\n\t}\n}", "func MembersEditDisplay(w http.ResponseWriter, r *http.Request) {\n\tauth := service.GetSessionMember(r)\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\n\tmemberID, _ := strconv.Atoi(id)\n\n\tmember := model.GetMemberByID(memberID)\n\tallTeams := model.GetAllTeam()\n\t_, teamList := model.GetTeamByMember(memberID)\n\tcompanies := model.GetAllCompany()\n\tdepartments := model.GetAllDepartment()\n\n\ttemplateData := map[string]interface{}{\n\t\t\"member\": member,\n\t\t\"allTeams\": allTeams.List,\n\t\t\"teamList\": teamList,\n\t\t\"companies\": companies,\n\t\t\"departments\": departments,\n\t\t\"title\": \"Edit Member\",\n\t\t\"auth\": auth,\n\t\t\"tab\": setting.MembersTab,\n\t\t\"useS3\": setting.UseS3Service(),\n\t}\n\tsns, err := model.GetSNSAccountByMemberID(memberID)\n\tif err == nil {\n\t\ttemplateData[\"SNSAccount\"] = sns.Github\n\t}\n\n\ttmpl := template.Must(template.ParseFiles(\"template/admin_members/member_edit.tmpl\", setting.AdminTemplate))\n\tif err := tmpl.ExecuteTemplate(w, \"base\", templateData); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n}", "func (d *webData) addUsersWeb(w http.ResponseWriter, r *http.Request) {\n\terr := d.tpl.ExecuteTemplate(w, \"addUserCompletePage\", \"some data\")\n\tif err != nil {\n\t\tlog.Println(\"addUsersWeb: template execution error = \", err)\n\t}\n\n\tr.ParseForm()\n\tu := storage.User{}\n\tgetFormValuesUserInfo(&u, r)\n\n\tif u.FirstName != \"\" {\n\t\tpid, _ := storage.QueryForLastUID(d.PDB)\n\t\t//increment the user index nr by one for the new used to add\n\t\tpid++\n\t\tfmt.Println(\"------pid ---------- = \", pid)\n\t\tprintln(\"addUsersWeb: UID = \", pid)\n\t\tu.Number = pid\n\t\tstorage.AddUser(d.PDB, u)\n\t}\n}", "func (m *MockHandler) UserEdit(userName string, newUser map[domain.UserUpdatableProperty]*string) (*domain.User, string, error) {\n\tret := m.ctrl.Call(m, \"UserEdit\", userName, newUser)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(string)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func UpdateUserProfileHandler(w http.ResponseWriter, r *http.Request) {\n\n}", "func InitEditPageHandler(db yoradb.PostRepository, templatesPath string) *EditPageHandler {\n\n\tpathes := make([]string, 3)\n\tpathes[0] = filepath.Join(templatesPath, \"layout.gohtml\")\n\tpathes[1] = filepath.Join(templatesPath, \"edit.gohtml\")\n\tpathes[2] = filepath.Join(templatesPath, \"empty_og.gohtml\")\n\n\ttempl, err := yotemplate.InitTemplate(pathes...)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tlog.Println(\"Edit page template is initialized.\")\n\n\treturn &EditPageHandler{template: templ, db: db}\n}", "func handlerView(w http.ResponseWriter, r *http.Request, title string) {\r\n\tp2, err := loadPage(title)\r\n\tif err != nil {\r\n\t\t//thiswill redirect the cliebt to the edit page so the content may be created\r\n\t\t//the http.redirect fucntion adds an HTTP status code\r\n\t\t//of fttp.statusFound(302) and a location header to the http response\r\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\r\n\t\tfmt.Println(err.Error())\r\n\t\tos.Exit(1)\r\n\t}\r\n\tfetchHTML(w, \"view\", p2)\r\n}", "func (t *Item) Edit(c *gin.Context) {\n\tid := c.Param(\"id\")\n\taid, err := strconv.ParseInt(id, 10, 64)\n\tif err != nil {\n\t\tc.String(500, \"%s\", err)\n\t\treturn\n\t}\n\titem, err := model.ItemOne(t.DB, aid)\n\tif err != nil {\n\t\tc.String(500, \"%s\", err)\n\t\treturn\n\t}\n\tc.HTML(http.StatusOK, \"edit.tmpl\", gin.H{\n\t\t\"item\": item,\n\t\t\"context\": c,\n\t\t\"csrf\": csrf.GetToken(c),\n\t})\n}", "func (r *DatasyncLocalProfileResource) Edit(id string, item DatasyncLocalProfileConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+DatasyncLocalProfileEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func USERS_GET_ProfileView(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tctx := appengine.NewContext(req)\n\tu, _ := GetUserFromSession(req)\n\tid, convErr := strconv.ParseInt(params.ByName(\"ID\"), 10, 64)\n\tif ErrorPage(ctx, res, nil, \"Invalid ID\", convErr, http.StatusBadRequest) {\n\t\treturn\n\t}\n\tci, getErr := GetUserFromID(ctx, id)\n\tif ErrorPage(ctx, res, u, \"Not a valid user ID\", getErr, http.StatusNotFound) {\n\t\treturn\n\t}\n\tlog.Infof(ctx, \"error ID: \", id)\n\tnotes, err := GetAllNotes(ctx, id)\n\tlog.Infof(ctx, \"error: \", len(notes))\n\tif ErrorPage(ctx, res, nil, \"Internal Server Error\", err, http.StatusSeeOther) {\n\t\treturn\n\t}\n\tscreen := struct {\n\t\tHeaderData\n\t\tData *User\n\t\tAllNotes []NoteOutput\n\t}{\n\t\t*MakeHeader(res, req, true, true),\n\t\tci,\n\t\tnotes,\n\t}\n\tServeTemplateWithParams(res, \"user-profile\", screen)\n}", "func ModProfile(w http.ResponseWriter, r *http.Request) {\n\tvar (\n\t\tt models.User\n\t\tstatus bool\n\t)\n\n\terr := json.NewDecoder(r.Body).Decode(&t)\n\tif err != nil {\n\t\thttp.Error(w, \"Data Wrong \"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tstatus, err = db.ModRe(t, IDUsuario)\n\tif err != nil {\n\t\thttp.Error(w, \"Error modifying user \"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tif !status {\n\t\thttp.Error(w, \"An attempt to modify the user failed \", 400)\n\t\treturn\n\t}\n\n\tw.WriteHeader(http.StatusCreated)\n}", "func (m *MockUserLogic) UserEdit(userName string, newUser map[domain.UserUpdatableProperty]*string) (*domain.User, string, error) {\n\tret := m.ctrl.Call(m, \"UserEdit\", userName, newUser)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(string)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func editStaff(c *gin.Context) {\n\tvar staff models.Staff\n\tvar staffID uint64\n\tvar err error\n\t// Get req data\n\tif staffID, err = strconv.ParseUint(c.Param(\"staffID\"), 10, 64); err != nil {\n\t\tfmt.Println(err)\n\t\tc.AbortWithStatusJSON(http.StatusOK, utils.ErrorMessage(\"bad request\", http.StatusBadRequest))\n\t\treturn\n\t}\n\tif err = c.BindJSON(&staff); err != nil {\n\t\tfmt.Println(err)\n\t\tc.AbortWithStatusJSON(http.StatusOK, utils.ErrorMessage(\"bad request\", http.StatusBadRequest))\n\t\treturn\n\t}\n\t// TO DO\n\tif exist := models.CheckUserExistbyID(staffID); !exist {\n\t\tc.AbortWithStatusJSON(http.StatusOK, utils.ErrorMessage(\"staff not found\", http.StatusNotFound))\n\t\treturn\n\t}\n\tif err = models.EditStaff(&staff); err != nil {\n\t\tfmt.Println(err)\n\t\tc.AbortWithStatusJSON(http.StatusOK, utils.ErrorMessage(\"internal error\", http.StatusInternalServerError))\n\t\treturn\n\t}\n\tc.AbortWithStatusJSON(http.StatusOK, utils.SuccessMessage(gin.H{\n\t\t\"status\": true,\n\t}))\n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle := r.URL.Path[len(\"/view\"):]\n\tp, _ := loadPage(title)\n\trenderTemplate(w, \"edit\", p)\n}", "func MembersEdit(w http.ResponseWriter, r *http.Request) {\n\tauth := service.GetSessionMember(r)\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\n\tvar teamList []int\n\n\tmemberID, _ := strconv.Atoi(id)\n\n\tif err := r.ParseMultipartForm(setting.FileMaxSize); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n\tcheckAvt := r.FormValue(\"check\")\n\tmember := model.GetMemberByID(memberID)\n\tmember.ID = memberID\n\tmember.Name = r.FormValue(\"name\")\n\tmember.LoginID = r.FormValue(\"loginID\")\n\tmember.RoleType, _ = strconv.Atoi(r.FormValue(\"role\"))\n\tmember.GenderType, _ = strconv.Atoi(r.FormValue(\"gender\"))\n\tmember.Status, _ = strconv.Atoi(r.FormValue(\"status\"))\n\tmember.Comment = sql.NullString{String: r.FormValue(\"comment\"), Valid: true}\n\tmember.CompanyID, _ = strconv.Atoi(r.FormValue(\"company\"))\n\tmember.DepartmentID, _ = strconv.Atoi(r.FormValue(\"department\"))\n\tgithubAccount := r.FormValue(\"githubAccount\")\n\n\t// timestamp is time if user not input date\n\ttimestamp, _ := time.Parse(\"2006-01-02 15:04:05\", \"0001-01-01 00:00:00\")\n\tbirthdayInput, _ := time.Parse(\"01-02-2006\", r.FormValue(\"birthday\"))\n\tif birthdayInput == timestamp {\n\t\tmember.Birthday = mysql.NullTime{Time: birthdayInput, Valid: false}\n\t} else {\n\t\tmember.Birthday = mysql.NullTime{Time: birthdayInput, Valid: true}\n\t}\n\n\tfor _, value := range r.PostForm[\"team\"] {\n\t\tteamID, _ := strconv.Atoi(value)\n\t\tif teamID != 0 {\n\t\t\tteamList = append(teamList, teamID)\n\t\t}\n\t}\n\n\tvalidateError := model.ValidateMember(member, r.ContentLength)\n\tsnsAccountErr := model.ValidateSNSAccount(githubAccount)\n\n\tif len(validateError) == 0 && len(snsAccountErr) == 0 {\n\t\tfile, handler, err := r.FormFile(\"avatar\")\n\t\tdefaultAvatar := setting.SetDefaultAvatar().MemberAvatar\n\n\t\tif err == nil {\n\t\t\toldImage := filepath.Base(member.PictureURL.String)\n\t\t\tpictureURL := handler.Filename\n\t\t\t// Create a temporary file\n\t\t\ttempFile, err := ioutil.TempFile(setting.ImageBaseURL, \"*\"+pictureURL)\n\t\t\t//get path of image\n\t\t\tavatar := tempFile.Name()\n\t\t\tif err != nil {\n\t\t\t\tLogger.Error(err.Error())\n\t\t\t}\n\t\t\tdefer tempFile.Close()\n\t\t\t// read all of the contents of our uploaded file into a byte array\n\t\t\tfileBytes, err := ioutil.ReadAll(file)\n\t\t\tif err != nil {\n\t\t\t\tLogger.Error(err.Error())\n\t\t\t}\n\t\t\t// write this byte array to our temporary file\n\t\t\ttempFile.Write(fileBytes)\n\n\t\t\t// if app running on EC2\n\t\t\tif setting.UseS3Service() {\n\t\t\t\t// delete old image\n\t\t\t\tif oldImage != filepath.Base(defaultAvatar) {\n\t\t\t\t\tservice.DeleteImageFromS3(oldImage, setting.MemberFolderType)\n\t\t\t\t}\n\n\t\t\t\t// save new image to aws S3\n\t\t\t\tservice.UploadImageToS3(avatar, setting.MemberFolderType)\n\t\t\t\tavatar = setting.S3BucketURL + setting.S3MemberFolder + filepath.Base(avatar)\n\t\t\t}\n\n\t\t\tmember.PictureURL = sql.NullString{String: avatar, Valid: true}\n\t\t} else if err != http.ErrMissingFile {\n\t\t\tLogger.Error(err.Error())\n\t\t}\n\n\t\t// if user delete avatar\n\t\tif checkAvt == setting.DeleteAvatar && member.PictureURL.String != defaultAvatar {\n\t\t\t// delete image on S3\n\t\t\tif setting.UseS3Service() {\n\t\t\t\tfileName := filepath.Base(member.PictureURL.String)\n\t\t\t\tservice.DeleteImageFromS3(fileName, setting.MemberFolderType)\n\t\t\t}\n\t\t\t// set default avatar\n\t\t\tmember.PictureURL = sql.NullString{String: defaultAvatar, Valid: true}\n\t\t}\n\n\t\tmodel.EditMember(member)\n\t\tsns, _ := model.GetSNSAccountByMemberID(memberID)\n\t\tsns.Github = githubAccount\n\t\tmodel.EditSNSAccount(sns)\n\n\t\t// get array of team of user\n\t\tmodel.EditTeamOfMember(memberID, teamList)\n\t\thttp.Redirect(w, r, \"/admin/members\", 301)\n\t}\n\n\t// get all team, company and department to select\n\tallTeams := model.GetAllTeam()\n\tcompanies := model.GetAllCompany()\n\tdepartments := model.GetAllDepartment()\n\n\tres := map[string]interface{}{\n\t\t\"member\": member,\n\t\t\"allTeams\": allTeams.List,\n\t\t\"companies\": companies,\n\t\t\"departments\": departments,\n\t\t\"SNSAccount\": githubAccount,\n\t\t\"validateError\": validateError,\n\t\t\"snsAccountError\": snsAccountErr,\n\t\t\"title\": \"Edit Member\",\n\t\t\"teamList\": teamList,\n\t\t\"auth\": auth,\n\t\t\"tab\": setting.MembersTab,\n\t\t\"useS3\": setting.UseS3Service(),\n\t}\n\n\ttmpl := template.Must(template.ParseFiles(\"template/admin_members/member_edit.tmpl\", setting.AdminTemplate))\n\tif err := tmpl.ExecuteTemplate(w, \"base\", res); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n}", "func ViewManagers(w http.ResponseWriter, r *http.Request) { \n AuthorizePages(w,r)\n w.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n t, err := template.ParseFiles(\"templates/viewManagers.html\")\n \n if err != nil {\n fmt.Println(err) // Ugly debug output\n w.WriteHeader(http.StatusInternalServerError) // Proper HTTP response\n return\n }\n \n userId := UserIds{\n ManagerId: r.FormValue(\"managerId\"),\n }\n\n var successMessage string\n var isShow bool \n\n if (userId.ManagerId != \"\" ) {\n if (dbquery.DeleteManagerUser(\"Manager\",userId.ManagerId)){\n isShow = true\n successMessage = \"Manager Deleted Successfully\"\n }\n }\n\n var managerList []helpers.User\n managerList = dbquery.GetUserByRole(\"\",\"'Manager'\")\n t.Execute(w, AllUsersResponse{Users: managerList, SuccessMessage: successMessage, IsShow: isShow}) \n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\t\t// path component of the requested URL\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\t// If the page is not found, redirects the client to the EDIT page so that the content may be created.\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\t// Adds an HTTP status code of http.StatusFound (302) and a Location header to the HTTP response.\n\t\treturn\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func (o *AuthUser) Reload(exec boil.Executor) error {\n\tret, err := FindAuthUser(exec, o.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*o = *ret\n\treturn nil\n}", "func LoadUserData(id int) error{\n\n\tuserPos, err := findUser(id)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tfmt.Errorf(\"Error: \",err.Error())\n\t\treturn err\n\t}\n\n\tloadUserDataAt(userPos)\n\n\treturn nil\n}", "func Profile(response http.ResponseWriter, request *http.Request) {\n\tswitch request.Method {\n\tcase \"GET\":\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\ttype detail struct {\n\t\t\tProfile model.User\n\t\t}\n\n\t\tdetails := detail{\n\t\t\tProfile: user,\n\t\t}\n\n\t\tif user.LoginState {\n\t\t\ttmp, err := template.ParseFiles(\n\t\t\t\t\"admin/template/template.gohtml\",\n\t\t\t\t\"admin/template/sidebar.gohtml\",\n\t\t\t\t\"admin/template/header.gohtml\",\n\t\t\t\t\"admin/template/footer.gohtml\",\n\t\t\t\t\"admin/profile.gohtml\",\n\t\t\t)\n\n\t\t\tif err != nil {\n\t\t\t\tlog.Print(err)\n\t\t\t\thttp.Error(response, \"internal server error\", http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ttmp.ExecuteTemplate(response, \"layout\", details)\n\t\t\treturn\n\n\t\t} else {\n\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\n\tcase \"POST\":\n\t\t//get current user from session the nfind in db.\n\t\tuserName := blogpost.GetUserName(request)\n\t\tuser, err := model.GetUser(userName)\n\n\t\tif err != nil {\n\t\t\t//handle err\n\t\t\tfmt.Fprint(response, `<p>You are not Logged in, Click <a href=\"/login\">Here</a> to Log in </p>`)\n\t\t\treturn\n\t\t}\n\n\t\t//check if current user is loggedin.\n\t\tif user.LoginState {\n\t\t\trequest.ParseMultipartForm(100000)\n\n\t\t\tuserName := request.FormValue(\"userName\")\n\t\t\tfirstname := request.FormValue(\"firstName\")\n\t\t\tlastName := request.FormValue(\"lastName\")\n\t\t\tPassWord := request.FormValue(\"password\")\n\t\t\tEmail := request.FormValue(\"email\")\n\t\t\tID, _ := primitive.ObjectIDFromHex(request.FormValue(\"ID\"))\n\t\t\taddress := request.FormValue(\"address\")\n\t\t\tCity := request.FormValue(\"city\")\n\t\t\tState := request.FormValue(\"state\")\n\t\t\tZip := request.FormValue(\"zip\")\n\t\t\tpics, header, err := request.FormFile(\"pics\")\n\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(response, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t//save profile image to upload folder.\n\t\t\t//refer \"github.com/ukane-philemon/RudigoNews/utils/saveimage\"\n\t\t\tsaveimage.SaveImage(pics, header)\n\n\t\t\t//Hash new password.\n\t\t\tPassWord = model.PasswordHash(PassWord)\n\n\t\t\tnewUser := model.User{\n\t\t\t\tID: ID,\n\t\t\t\tUserName: userName,\n\t\t\t\tEmail: Email,\n\t\t\t\tFirst: firstname,\n\t\t\t\tLast: lastName,\n\t\t\t\tPassword: PassWord,\n\t\t\t\tAddress: address,\n\t\t\t\tAvatar: header.Filename,\n\t\t\t\tCity: City,\n\t\t\t\tState: State,\n\t\t\t\tZip: Zip,\n\t\t\t}\n\n\t\t\tif model.UpdateUser(newUser, ID) == nil {\n\t\t\t\thttp.Redirect(response, request, \"/admin/profile\", http.StatusSeeOther)\n\t\t\t\tfmt.Print(\"user updated\")\n\n\t\t\t} else {\n\t\t\t\tmodel.CreateUser(newUser)\n\t\t\t}\n\n\t\t} else {\n\t\t\thttp.Redirect(response, request, \"/login\", http.StatusFound)\n\t\t}\n\tdefault:\n\t\thttp.Redirect(response, request, \"/login\", http.StatusForbidden)\n\t}\n\n}", "func (user *User) EditClient() (err error) {\n\t_, err = Db.Exec(\"update user set name=$1, email=$2, image=$3 where id=$4\",user.Name, user.Email, user.Image, user.ID)\n\nfmt.Println(err)\nreturn\n}", "func UserUpdate(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\n}", "func (uh *UserHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {\n\n\tloggedInUser := uh.Authentication(r)\n\tif loggedInUser == nil {\n\t\thttp.Redirect(w, r, \"/Login\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodGet {\n\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\ttoken, err := stringTools.CSRFToken(uh.CSRF)\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t}\n\t\tinputContainer := InputContainer{LoggedInUser: loggedInUser, CSRF: token}\n\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodPost {\n\n\t\tvar profilePic, cv string\n\t\tfirstname := r.FormValue(\"firstname\")\n\t\tlastname := r.FormValue(\"lastname\")\n\t\tphonenumber := r.FormValue(\"phonenumber\")\n\t\temail := r.FormValue(\"email\")\n\t\tjobTitle := r.FormValue(\"jobTitle\")\n\t\tcountry := r.FormValue(\"country\")\n\t\tcity := r.FormValue(\"city\")\n\t\tgender := r.FormValue(\"gender\")\n\t\tbio := r.FormValue(\"bio\")\n\t\tprefeS := r.FormValue(\"prefe\")\n\t\tprefe, _ := strconv.ParseInt(prefeS, 0, 0)\n\n\t\t// In Edit profile password will not be change be still it will be authenticated!\n\t\tpassword := \"ValidPassword123\"\n\n\t\tcsrfToken := r.FormValue(\"csrf\")\n\t\tok, errCRFS := stringTools.ValidCSRF(csrfToken, uh.CSRF)\n\n\t\tuser := entity.NewUser(firstname, lastname, email, profilePic, password, phonenumber, jobTitle, country, city, gender, cv, bio)\n\t\tuser.UID = loggedInUser.UID\n\t\tuser.Prefe = prefe\n\n\t\terrMap := uh.UService.Verification(user, entity.Identification{ConfirmPassword: \"ValidPassword123\", From: \"EditProfile\"})\n\t\tif !ok || errCRFS != nil {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\terrMap[\"csrf\"] = \"Invalid token used!\"\n\t\t}\n\n\t\tif len(errMap) > 0 {\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tpFilename, err := uh.ResourceExtractorUser(user.UID, \"profilePic\", \"image\", r)\n\n\t\tif err != nil && (err.Error() == \"file to large\" || err.Error() == \"invalid format\") {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\terrMap[\"profilePic\"] = \"File size should be less than 5MB!\"\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tcFilename, err := uh.ResourceExtractorUser(user.UID, \"cv\", \"file\", r)\n\n\t\tif err != nil && (err.Error() == \"file too large\" || err.Error() == \"invalid format\") {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\tswitch err.Error() {\n\t\t\tcase \"invalid format\":\n\t\t\t\terrMap[\"cv\"] = \"Only pdf format is allowed!\"\n\t\t\tcase \"file too large\":\n\t\t\t\terrMap[\"cv\"] = \"File size should be less than 5MB!\"\n\t\t\t}\n\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tuser.ProfilePic = pFilename\n\t\tuser.CV = cFilename\n\t\terr = uh.UService.EditUserProfile(user)\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/Login\", http.StatusSeeOther)\n\t\treturn\n\t}\n}", "func (v CustomersResource) Edit(c buffalo.Context) error {\n\tcustomer := &models.Customer{}\n\n\terr := v.scope(c).Find(customer, c.Param(\"customer_id\"))\n\tif err != nil {\n\t\treturn c.Error(404, err)\n\t}\n\t// Make customer available inside the html template\n\tc.Set(\"customer\", customer)\n\n\treturn c.Render(200, r.HTML(\"customers/edit.html\"))\n}", "func (v FaturasResource) Edit(c buffalo.Context) error {\n\treturn c.Error(404, errors.New(\"not available\"))\n}", "func UpdateUser(w http.ResponseWriter, r *http.Request) {\n\n}", "func UpdateUser(c *gin.Context) {}", "func EditHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Edit post\")\n}", "func (r *PoolCNAMEMembersResource) Edit(id string, item PoolCNAMEMembersConfig) error {\n\tif err := r.c.ModQuery(\"PUT\", BasePath+PoolCNAMEMembersEndpoint+\"/\"+id, item); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (app *appDB) updateProfile(w http.ResponseWriter, r *http.Request) {\r\n\t//redirect to main page if there's no cookie found\r\n\tif !session.Check(w, r) {\r\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\r\n\t\treturn\r\n\t}\r\n\tup := updatePage{}\r\n\tuserID, _ := session.Get(r)\r\n\r\n\tup.UserID = userID\r\n\tapp.render(w, profileTemplate, up)\r\n\treturn\r\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\r\n title := r.URL.Path[len(\"/view/\"):]\r\n p, err := loadPage(title)\r\n if err != nil {\r\n http.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\r\n return\r\n }\r\n renderTemplate(w, \"view\", p)\r\n}", "func ShowUser(w http.ResponseWriter, r *http.Request) {\n\tAddCors(&w)\n\n\tfmt.Printf(\"IN SHOW USER\")\n\t//pass in user ID from somewhere, try to get from url, maybe in a form when the link is hit\n\tuserInfo := pg.ReturnUser(1)\n\tfmt.Printf(\"IN SHOW USER2\")\n\t//Encode writes the JSON encoding of userInfo to the stream\n\tjson.NewEncoder(w).Encode(userInfo)\n\tfmt.Printf(\"IN SHOW USER3\")\n\t//returns json encoding of the data\n\tpagesJson, err := json.Marshal(userInfo)\n\tfmt.Printf(\"IN SHOW USER4\")\n\tif err != nil {\n\t\tlog.Fatal(\"Cannot encode to JSON \", err)\n\t}\n\n\tfmt.Printf(\"%s\", pagesJson)\n}", "func CurrentUserEditField(w http.ResponseWriter, r *http.Request) {\n\tuserID := CheckUserID(r.Context(), w)\n\tif userID == 0 {\n\t\treturn\n\t}\n\tquerier := handler.Querier()\n\tcontent, _ := querier.GetUser(userID)\n\n\tfields, err := permission.GetUpdateFields(r.Context(), content, userID)\n\tif err != nil {\n\t\tHandleError(err, w)\n\t\treturn\n\t}\n\n\tdata, _ := json.Marshal(fields)\n\tw.Write(data)\n}", "func loadPage(pn string, r *http.Request) (*Page, error) {\n\tdata := &Page{\n\t\tPageName: pn,\n\t}\n\n\t/* Get user name for filling in template too */\n\tsesh, _ := store.Get(r, \"loginSession\")\n\tuname, ok := sesh.Values[\"username\"].(string)\n\tif !ok {\n\t\treturn nil, &ClientSafeError{Msg: \"invalid username\"}\n\t}\n\tdata.Username = uname\n\t/* get user's role */\n\trole, err := getRoleNum(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch role {\n\tcase FACILITATOR:\n\t\tdata.Role = \"Facilitator\"\n\t\tdata.Messages, err = getNotifications(data.Username)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\tcase TEACHER:\n\t\tdata.Role = \"Teacher\"\n\tcase ADMIN:\n\t\tdata.Role = \"Admin\"\n\tdefault:\n\t\treturn nil, &ClientSafeError{Msg: \"insufficient access rights\"}\n\t}\n\n\treturn data, nil\n}", "func PrepareForEditUserDesc(roundTripper *mhttp.MockRoundTripper, rootURL, userName, description, user, passwd string) {\n\tformData := url.Values{}\n\tformData.Add(\"description\", description)\n\tpayload := strings.NewReader(formData.Encode())\n\n\trequest, _ := http.NewRequest(http.MethodPost, fmt.Sprintf(\"%s/user/%s/submitDescription\", rootURL, userName), payload)\n\trequest.Header.Add(httpdownloader.ContentType, httpdownloader.ApplicationForm)\n\tPrepareCommonPost(request, \"\", roundTripper, user, passwd, rootURL)\n\treturn\n}", "func (postL) LoadEditorUser(ctx context.Context, e boil.ContextExecutor, singular bool, maybePost interface{}, mods queries.Applicator) error {\n\tvar slice []*Post\n\tvar object *Post\n\n\tif singular {\n\t\tobject = maybePost.(*Post)\n\t} else {\n\t\tslice = *maybePost.(*[]*Post)\n\t}\n\n\targs := make([]interface{}, 0, 1)\n\tif singular {\n\t\tif object.R == nil {\n\t\t\tobject.R = &postR{}\n\t\t}\n\t\targs = append(args, object.EditorUserID)\n\t} else {\n\tOuter:\n\t\tfor _, obj := range slice {\n\t\t\tif obj.R == nil {\n\t\t\t\tobj.R = &postR{}\n\t\t\t}\n\n\t\t\tfor _, a := range args {\n\t\t\t\tif a == obj.EditorUserID {\n\t\t\t\t\tcontinue Outer\n\t\t\t\t}\n\t\t\t}\n\n\t\t\targs = append(args, obj.EditorUserID)\n\t\t}\n\t}\n\n\tquery := NewQuery(qm.From(`users`), qm.WhereIn(`id in ?`, args...))\n\tif mods != nil {\n\t\tmods.Apply(query)\n\t}\n\n\tresults, err := query.QueryContext(ctx, e)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to eager load User\")\n\t}\n\n\tvar resultSlice []*User\n\tif err = queries.Bind(results, &resultSlice); err != nil {\n\t\treturn errors.Wrap(err, \"failed to bind eager loaded slice User\")\n\t}\n\n\tif err = results.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close results of eager load for users\")\n\t}\n\tif err = results.Err(); err != nil {\n\t\treturn errors.Wrap(err, \"error occurred during iteration of eager loaded relations for users\")\n\t}\n\n\tif len(postAfterSelectHooks) != 0 {\n\t\tfor _, obj := range resultSlice {\n\t\t\tif err := obj.doAfterSelectHooks(ctx, e); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(resultSlice) == 0 {\n\t\treturn nil\n\t}\n\n\tif singular {\n\t\tforeign := resultSlice[0]\n\t\tobject.R.EditorUser = foreign\n\t\tif foreign.R == nil {\n\t\t\tforeign.R = &userR{}\n\t\t}\n\t\tforeign.R.EditorUserPosts = append(foreign.R.EditorUserPosts, object)\n\t\treturn nil\n\t}\n\n\tfor _, local := range slice {\n\t\tfor _, foreign := range resultSlice {\n\t\t\tif local.EditorUserID == foreign.ID {\n\t\t\t\tlocal.R.EditorUser = foreign\n\t\t\t\tif foreign.R == nil {\n\t\t\t\t\tforeign.R = &userR{}\n\t\t\t\t}\n\t\t\t\tforeign.R.EditorUserPosts = append(foreign.R.EditorUserPosts, local)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func userRolesShowPage(httpresponsewriter http.ResponseWriter, httprequest *http.Request) {\n\n\tsecurity.UserRolesShowPage(httpresponsewriter, httprequest, redisclient)\n}", "func (h EditPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\n\tres := EditURLPattern.FindStringSubmatch(r.URL.Path)\n\tif res == nil {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tpostID, err := strconv.ParseInt(res[1], 10, 64)\n\tif err != nil {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tep := &EditPage{}\n\n\tuser, ok := UserFromContext(r.Context())\n\tif ok {\n\t\tep.UserName = user.Name\n\t}\n\n\tif !user.EditPostPermit {\n\t\tw.WriteHeader(http.StatusForbidden)\n\t\tep.ErrorMessage = \"Недостаточно прав для редактирования статьи\"\n\t\tErrorTemplate.Execute(w, ep)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodGet {\n\n\t\tep.Post, err = h.db.GetPostByID(postID)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error during db query for edit page: %v\\n\", err)\n\t\t\thttp.NotFound(w, r)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(http.StatusOK)\n\n\t\th.template.Execute(w, ep)\n\t} else if r.Method == http.MethodPost {\n\t\terr = r.ParseForm()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error during edit form parse: %v\\n\", err)\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\tpost := &yoradb.Post{ID: postID}\n\n\t\tpost.Title = template.HTML(r.FormValue(\"title\"))\n\t\tpost.Description = template.HTML(r.FormValue(\"description\"))\n\t\tpost.ImageURL = r.FormValue(\"imageurl\")\n\t\tpost.Annotation = template.HTML(r.FormValue(\"annotation\"))\n\t\tpost.Text = template.HTML(r.FormValue(\"posttext\"))\n\n\t\terr = h.db.UpdatePost(post)\n\t\tif err != nil {\n\t\t\tep.Post = post\n\t\t\tep.ErrorMessage = err.Error()\n\n\t\t\tlog.Printf(\"Error during update post in DB: %v\\n\", err)\n\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\th.template.Execute(w, ep)\n\n\t\t\treturn\n\t\t}\n\n\t\tredirectURL := fmt.Sprintf(\"/post/%v\", post.ID)\n\t\thttp.Redirect(w, r, redirectURL, http.StatusSeeOther)\n\t}\n}", "func UserViewHandler(w http.ResponseWriter, req *http.Request) {\n\n\t// Get session values or redirect to Login\n\tsession, err := sessions.Store.Get(req, \"session\")\n\n\tif err != nil {\n\t\tlog.Println(\"error identifying session\")\n\t\thttp.Redirect(w, req, \"/login/\", 302)\n\t\treturn\n\t\t// in case of error\n\t}\n\n\t// Prep for user authentication\n\tsessionMap := getUserSessionValues(session)\n\n\tusername := sessionMap[\"username\"]\n\tloggedIn := sessionMap[\"loggedin\"]\n\tisAdmin := sessionMap[\"isAdmin\"]\n\n\tvars := mux.Vars(req)\n\tidString := vars[\"id\"]\n\n\tpk, err := strconv.Atoi(idString)\n\tif err != nil {\n\t\tpk = 0\n\t\tlog.Println(err)\n\t}\n\n\tfmt.Println(session)\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t\treturn\n\t}\n\n\tuser, err := database.PKLoadUser(db, int64(pk))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\tfmt.Println(\"Unable to load User\")\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t}\n\n\t// Validate that User == Admin\n\tIsAuthor := false\n\n\tif isAdmin != \"true\" {\n\t\thttp.Redirect(w, req, \"/\", 302)\n\t}\n\n\texps, err := database.ListUserExperiences(db, user.UserName)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlrs := []*models.LearningResource{}\n\tlrStrings := []string{}\n\n\tfor _, ex := range exps {\n\t\tif !isInString(lrStrings, ex.LearningResource.Path) {\n\t\t\tlrs = append(lrs, ex.LearningResource)\n\t\t\tlrStrings = append(lrStrings, ex.LearningResource.Path)\n\t\t}\n\t}\n\n\t// Determine overall progression\n\n\tvar targetTotal, currentTotal int\n\n\tfor _, s := range user.Streams {\n\t\ttargetTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][0]\n\t\tcurrentTotal += s.LearningTargets[user.LearnerProfile.CurrentYear][1]\n\t}\n\n\tcategories := map[string]int{\n\t\t\"currentTotal\": currentTotal,\n\t\t\"targetTotal\": targetTotal,\n\t}\n\n\tfor _, ex := range exps {\n\t\tcategories[ex.Stream.Name] += ex.Points\n\t\tcategories[\"max\"] += ex.Points\n\t}\n\n\twv := WebView{\n\t\tUser: user,\n\t\tIsAuthor: IsAuthor,\n\t\tIsLoggedIn: loggedIn,\n\t\tSessionUser: username,\n\t\tIsAdmin: isAdmin,\n\t\tLearningResources: lrs,\n\t\tExperiences: exps,\n\t\tCategoryMap: categories,\n\t\tUserFrame: true,\n\t\tNumMap: skillMap,\n\t\tStringMap: fontMap,\n\t\tArchitecture: baseArchitecture,\n\t}\n\n\tRender(w, \"templates/user_view.html\", wv)\n}", "func viewHandler(w http.ResponseWriter, r *http.Request) {\n\ttitle, err := getTitle(w, r)\n\tif err != nil {\n\t\treturn\n\t}\n\tp, err := loadPage(title)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/edit/\"+title, http.StatusFound)\n\t\treturn\n\t}\n\trenderTemplate(w, \"view\", p)\n}", "func (stdnt *Student) Edit(ctx context.Context) error {\n\tkey, err := datastore.DecodeKey(stdnt.ID)\n\tif err != nil {\n\t\treturn errors.New(err.Error())\n\t}\n\t_, err = datastore.Put(ctx, key, stdnt)\n\tif err != nil {\n\t\treturn errors.New(err.Error())\n\t}\n\treturn nil\n}" ]
[ "0.79898834", "0.7176029", "0.7114701", "0.6900312", "0.65417063", "0.65129733", "0.6501301", "0.6422901", "0.6404165", "0.6400111", "0.6383282", "0.637951", "0.63390213", "0.63242364", "0.6318961", "0.6313021", "0.6297971", "0.6294736", "0.6158294", "0.61528724", "0.61493605", "0.61292946", "0.61292946", "0.6084597", "0.60516423", "0.6044545", "0.5982185", "0.5973763", "0.5932749", "0.5901501", "0.58551115", "0.58534646", "0.58235896", "0.5819192", "0.57958496", "0.57850176", "0.57577115", "0.5714522", "0.56982875", "0.5697893", "0.56768274", "0.5651438", "0.5626673", "0.5617018", "0.5611499", "0.5607432", "0.55461335", "0.5518293", "0.5516081", "0.54925644", "0.54758936", "0.54663277", "0.5453231", "0.5437117", "0.543395", "0.5387423", "0.53857225", "0.5377995", "0.537694", "0.53726166", "0.53432846", "0.5338219", "0.53294426", "0.532119", "0.53066844", "0.53036153", "0.5285127", "0.5274209", "0.5265642", "0.52553874", "0.5249442", "0.5221225", "0.522098", "0.5219953", "0.52035415", "0.52023274", "0.5186786", "0.51864636", "0.5185127", "0.5178863", "0.51743776", "0.516504", "0.51632357", "0.5143136", "0.5141944", "0.51240605", "0.5107205", "0.5102399", "0.5092889", "0.5088261", "0.50613445", "0.50518644", "0.5043099", "0.5037618", "0.5026737", "0.50176644", "0.49958506", "0.49945095", "0.49893907", "0.49789807" ]
0.8349932
0
LoadUserPasswordEditPage Method to load page to update password
func LoadUserPasswordEditPage(w http.ResponseWriter, r *http.Request) { utils.RunTemplate(w, "update-password.html", nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func LoadUserEditPage(w http.ResponseWriter, r *http.Request) {\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tchannel := make(chan models.User)\n\n\tgo models.GetUserData(channel, userID, r)\n\n\tuser := <-channel\n\tif user.ID == 0 {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: \"Erro ao buscar o usuário\"})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-profile.html\", user)\n}", "func (h *AuthHandler) RenderUpdatePassword(w http.ResponseWriter, r *http.Request) {\n\tview := NewView(r)\n\tview.Render(w, \"auth/password\")\n}", "func ChangePasswordDisplay(w http.ResponseWriter, r *http.Request) {\n\tauth := service.GetSessionMember(r)\n\ttemplateData := map[string]interface{}{\n\t\t\"title\": \"Change Password\",\n\t\t\"auth\": auth,\n\t}\n\n\ttmpl := template.Must(template.ParseFiles(\"template/admin_members/change_password.tmpl\", setting.UserTemplate))\n\tif err := tmpl.ExecuteTemplate(w, \"base\", templateData); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n}", "func (h *AuthHandler) UpdatePassword(w http.ResponseWriter, r *http.Request) {\n\tview := NewView(r)\n\n\tuser := context.User(r.Context())\n\tif user == nil {\n\t\thttp.Redirect(w, r, \"/signin\", http.StatusFound)\n\t\treturn\n\t}\n\n\temail := user.Email\n\toldPassword := view.FormValue(\"oldPassword\", true)\n\tnewPassword := view.FormValue(\"newPassword\", true)\n\tconfirmPassword := view.FormValue(\"confirmPassword\", true)\n\n\tif view.HasError() {\n\t\tview.Render(w, \"auth/password\")\n\t\treturn\n\t}\n\n\tif len(newPassword) < h.PasswordLength || len(confirmPassword) < h.PasswordLength {\n\t\tview.InsertFlashError(\"Passwords must be at least \", h.PasswordLength, \" characters long\")\n\t\tview.Render(w, \"auth/password\")\n\t\treturn\n\t}\n\tif newPassword != confirmPassword {\n\t\tview.InsertFlashError(\"Passwords must be matched\")\n\t\tview.Render(w, \"auth/password\")\n\t\treturn\n\t}\n\n\terr := h.AuthInteractor.UpdatePassword(email, oldPassword, newPassword)\n\tif err != nil {\n\t\tview.InsertFlashError(err.Error())\n\t\tview.Render(w, \"auth/password\")\n\t\treturn\n\t}\n\n\tview.InsertFlash(\"Your password succesfully changed\")\n\tview.Render(w, \"auth/password\")\n}", "func ChangePassword(w http.ResponseWriter, r *http.Request) {\n\tauth := service.GetSessionMember(r)\n\tmember := model.GetMemberByID(auth.ID)\n\n\tif err := r.ParseMultipartForm(setting.FileMaxSize); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n\n\tnewPassword := r.FormValue(\"newPassword\")\n\tconfirmPassword := r.FormValue(\"confirmPassword\")\n\toldPassword := r.FormValue(\"oldPassword\")\n\n\tpasswordData := map[string]string{\n\t\t\"password\": newPassword,\n\t\t\"confirmPassword\": confirmPassword,\n\t}\n\n\tvalidateError := model.ValidatePassword(passwordData)\n\n\t// check if password is correct\n\t_, err := model.Authenticated(member.LoginID, oldPassword)\n\n\tif err != nil {\n\t\tvalidateError[\"oldPassword\"] = \"Password is not correct.\"\n\t}\n\n\tif len(validateError) == 0 {\n\t\tmodel.UpdatePassword(newPassword, member)\n\t\thttp.Redirect(w, r, \"/my_page\", 301)\n\t}\n\n\ttemplateData := map[string]interface{}{\n\t\t\"title\": \"Change Password\",\n\t\t\"validateError\": validateError,\n\t\t\"auth\": auth,\n\t}\n\n\ttmpl := template.Must(template.ParseFiles(\"template/admin_members/change_password.tmpl\", setting.UserTemplate))\n\tif err := tmpl.ExecuteTemplate(w, \"base\", templateData); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n}", "func (controller *UserController) GetEditPage(ctx *fasthttp.RequestCtx) {\n\tcontroller.getProfile(ctx, true)\n}", "func ChangePassword(templateDir string) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tu, a := currentUser(r)\n\t\tif u == \"\" {\n\t\t\thttp.Error(w, \"no user information\", http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\n\t\tif r.Method == \"GET\" {\n\t\t\tFetch(templateDir, \"changePassword.html\").Execute(w, u, a, m{})\n\t\t\treturn\n\t\t}\n\n\t\tr.ParseForm()\n\n\t\tp := r.FormValue(\"oldPassword\")\n\t\tpN := r.FormValue(\"newPassword\")\n\t\tpNC := r.FormValue(\"confirmNewPassword\")\n\n\t\t// Check that this user is actually who they claim they are\n\t\tok, err := database.CheckCredentials(u, p)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t} else if !ok {\n\t\t\tFetch(templateDir, \"changePassword.html\").Execute(w, u, a, m{Error: \"Invalid username or password\"})\n\t\t\treturn\n\t\t}\n\n\t\t// Make sure the user REALLY knows their new password and it isn't empty\n\t\tif pN != pNC || pN == \"\" {\n\t\t\tFetch(templateDir, \"changePassword.html\").Execute(w, u, a, m{Error: \"Passwords do not match.\"})\n\t\t\treturn\n\t\t}\n\n\t\t// Perform the password update\n\t\tbpass, err := bcrypt.GenerateFromPassword([]byte(pN), bcrypt.DefaultCost)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\terr = database.UpdatePassword(u, bpass)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\n\t\tFetch(templateDir, \"changePassword.html\").Execute(w, u, a, m{Success: \"Password updated successfully.\"})\n\t}\n}", "func UserUpdatePassword(id int, n string) {\n\tvar i int\n\ti = GetIndexOfUser(id)\n\tuserList[i].uPassword = n\n}", "func userUpdatedPassword(res http.ResponseWriter, req *http.Request) {\r\n\tfmt.Println(\"Htmlmain.userUpdatedPassword\")\r\n\r\n\tData := struct {\r\n\t\tPageName string\r\n\t\tUserName string\r\n\t\tMsgToUser string\r\n\t}{PageName: \"Updated Password\"}\r\n\r\n\tmyCookie, err := req.Cookie(\"CRA\")\r\n\tif err != nil {\r\n\t\thttp.Redirect(res, req, \"/logIn\", http.StatusSeeOther)\r\n\t} else {\r\n\t\tData.UserName = mapSessions[myCookie.Value]\r\n\t}\r\n\tif req.Method == http.MethodPost {\r\n\t\t//get user name and current password\r\n\t\tusername := req.FormValue(\"username\")\r\n\t\tpassword := req.FormValue(\"oldpassword\")\r\n\t\t//get user new password and confirm the new password\r\n\t\tnewpassword := req.FormValue(\"newpassword\")\r\n\t\tconfirmpassword := req.FormValue(\"confirmpassword\")\r\n\t\t_, mOk := ctms.ExistingCustomer(username)\r\n\t\tpOk := ctms.PasswordMatched(username, password)\r\n\t\tfmt.Println(\"here\")\r\n\t\tfmt.Println(username, password, mOk, pOk)\r\n\t\tif !mOk || !pOk {\r\n\t\t\tData.MsgToUser = \"The user name and password is not match! \"\r\n\t\t\tdefer fmt.Fprintf(res, \"<br><script>document.getElementById('MsgToUser').innerHTML = '%v';</script>\", Data.MsgToUser)\r\n\t\t\t// http.Redirect(res, req, \"/changepassword\", http.StatusSeeOther)\r\n\t\t} else if newpassword != confirmpassword {\r\n\t\t\tData.MsgToUser = \"New password and confrim password is not same!\"\r\n\t\t\tdefer fmt.Fprintf(res, \"<br><script>document.getElementById('MsgToUser').innerHTML = '%v';</script>\", Data.MsgToUser)\r\n\t\t\t// http.Redirect(res, req, \"/changepassword\", http.StatusSeeOther)\r\n\t\t} else if username == \"\" || password == \"\" {\r\n\t\t\tData.MsgToUser = \"Please insert username and password for verification!\"\r\n\t\t\tdefer fmt.Fprintf(res, \"<br><script>document.getElementById('MsgToUser').innerHTML = '%v';</script>\", Data.MsgToUser)\r\n\t\t} else {\r\n\t\t\tctms.ChangePassword(username, newpassword)\r\n\t\t\tData.MsgToUser = \"Password is updated!\"\r\n\t\t\tdefer fmt.Fprintf(res, \"<h4 class='Application'><a href='/menu'>Main Menu</a></h4><script>document.getElementById('MsgToUser').innerHTML = '%v';</script>\", Data.MsgToUser)\r\n\t\t}\r\n\t}\r\n\ttpl.ExecuteTemplate(res, \"ChangePassword.gohtml\", Data)\r\n}", "func ResetPasswordPage(c *fiber.Ctx) error {\n\tvar acc databasepack.Account\n\terr := c.BodyParser(&acc)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn c.Send([]byte(\"Wrong input.\"))\n\t}\n\t// The rest is here\n\treturn c.Send([]byte(databasepack.ResetPassword(acc)))\n}", "func updatePasswordHandler(w http.ResponseWriter, r *http.Request){\n\tuserId, err := strconv.ParseInt(r.FormValue(\"userId\"), 10, 64)\n\tcheck(err)\n\n\t// TODO: implement updatePassword form, and get actual password from there.\n\tpasswordHashInts := GetPasswordHash256(\"#NewPassword1234\")\n\n\t// Update user's password in the database.\n\tprf(\"passwordHashInts[0]: %T %#v\\n\", passwordHashInts[0], passwordHashInts[0])\n\tDbQuery(`\n\t\tUPDATE $$User\n\t\tSET PasswordHash = ARRAY[$2::bigint, $3::bigint, $4::bigint, $5::bigint]\n\t\tWHERE Id = $1::bigint`,\n\t\tuserId,\n\t\tpasswordHashInts[0],\n\t\tpasswordHashInts[1],\n\t\tpasswordHashInts[2],\n\t\tpasswordHashInts[3])\n\n\t// TODO: Send password update confirmation email\n\n\t// Create session (encrypted userId).\n\tCreateSession(w, r, userId)\n\n\tprf(\"Updated password for user %d\", userId)\n\n\tserveHtml(w, \"<h2>You successfully updated your password!</h2>\")\n}", "func changePasswordFormHandler(w http.ResponseWriter, r *http.Request) {\n\tctx := context.Background()\n\tsessionInfo := b.sessionEnforcer.EnforceValidSession(ctx, w, r)\n\tif sessionInfo.Authenticated != 1 {\n\t\tlog.Printf(\"changePasswordHandler not authenticated: %d\", sessionInfo.Authenticated)\n\t\thttp.Error(w, \"Not authenticated\", http.StatusForbidden)\n\t\treturn\n\t} else {\n\t\ttitle := b.webConfig.GetVarWithDefault(\"Title\", defTitle)\n\t\tresult := ChangePasswordHTML{\n\t\t\tTitle: title,\n\t\t\tOldPasswordValid: false,\n\t\t\tChangeSuccessful: false,\n\t\t\tShowNewForm: true,\n\t\t}\n\t\tb.pageDisplayer.DisplayPage(w, \"change_password_form.html\", result)\n\t}\n}", "func changePasswordHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Print(\"changePasswordHandler enter\")\n\tctx := context.Background()\n\tif b.authenticator == nil {\n\t\tvar err error\n\t\tb.authenticator, err = initAuth(ctx)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"changePasswordHandler authenticator could not be initialized: %v\", err)\n\t\t\thttp.Error(w, \"Server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\tsessionInfo := b.sessionEnforcer.EnforceValidSession(ctx, w, r)\n\tif sessionInfo.Authenticated != 1 {\n\t\tlog.Printf(\"changePasswordHandler not authenticated: %d\", sessionInfo.Authenticated)\n\t\thttp.Error(w, \"Not authenticated\", http.StatusForbidden)\n\t\treturn\n\t} else {\n\t\toldPassword := r.PostFormValue(\"OldPassword\")\n\t\tpassword := r.PostFormValue(\"Password\")\n\t\tresult := b.authenticator.ChangePassword(ctx, sessionInfo.User, oldPassword,\n\t\t\tpassword)\n\t\tif strings.Contains(r.Header.Get(\"Accept\"), \"application/json\") {\n\t\t\tsendJSON(w, result)\n\t\t} else {\n\t\t\ttitle := b.webConfig.GetVarWithDefault(\"Title\", defTitle)\n\t\t\tcontent := ChangePasswordHTML{\n\t\t\t\tTitle: title,\n\t\t\t\tOldPasswordValid: result.OldPasswordValid,\n\t\t\t\tChangeSuccessful: result.ChangeSuccessful,\n\t\t\t\tShowNewForm: result.ShowNewForm,\n\t\t\t}\n\t\t\tb.pageDisplayer.DisplayPage(w, \"change_password_form.html\", content)\n\t\t}\n\t}\n}", "func (db *MyConfigurations) showResetPasswordUpPage(c echo.Context) error {\n\tstatus, message := getFlashMessages(&c) // gets the flash message and status if there was any\n\tusers := models.GetAllUsers(db.GormDB) // gets all the users that are in the database\n\tformFields := getFormData(&c, []string{\"username\"})\n\treturn c.Render(http.StatusOK, \"signup.html\", echo.Map{\n\t\t\"status\": status, // pass the status of the flash message\n\t\t\"message\": message, // pass the message\n\t\t\"title\": \"تغيير كلمه السر\", // the title of the page\n\t\t\"hideNavBar\": true, // boolean to indicate weather or not the NavBar should be displayed\n\t\t\"users\": users, // pass the users array to display to the user\n\t\t\"buttonText\": \"تغيير كلمه السر\", // the action button text the should be displayed to the user\n\t\t\"formAction\": \"/reset-password\", // the URL that the form should be submitted to\n\t\t\"adminPasswordPlaceholder\": \"كلمه السر الخاصه بالوزير (او القديمه)\", // string that should be shown in the admin password input placeholder\n\t\t\"adminPasswordHelp\": \"يجب ادخال كلمه السر الخاصه بالوزير (او كلمه السر القديمه) لتتمكن من تغييرها\", // some helper text for the admin password field\n\t\t\"username\": formFields[\"username\"],\n\t\t\"resetPage\": true,\n\t})\n}", "func partialUpdatePassword(providedUser *models.User, payload inputs.ProfileInput) error {\n\n\tif payload.OldPassword == \"\" || payload.NewPassword == \"\" {\n\t\treturn nil\n\t}\n\n\tok, err := AuthorizationServices.ComparePasswords(payload.OldPassword, providedUser.Password)\n\tif !ok || err != nil {\n\t\treturn &utils.IncorrectPasswordError{}\n\t}\n\n\thashedPassword, _ := AuthorizationServices.GeneratePassword(payload.NewPassword)\n\n\tprovidedUser.Password = hashedPassword\n\n\treturn nil\n}", "func (h *userHandler) changePassword(ctx context.Context, rw http.ResponseWriter, r *http.Request) {\n\n\tvar user = &model.User{}\n\n\t_ = json.NewDecoder(r.Body).Decode(user)\n\n\tif user.Login == \"\" || user.Password == \"\" {\n\n\t\th.serv.writeResponse(ctx, rw, \"Login or password are empty\", http.StatusBadRequest, nil)\n\n\t\treturn\n\t}\n\n\terr := h.serv.DB.UserCol.UpdatePassword(ctx, user)\n\n\tif err != nil {\n\n\t\th.serv.writeResponse(ctx, rw, err.Error(), http.StatusBadRequest, user)\n\n\t\treturn\n\t}\n\n\th.serv.writeResponse(ctx, rw, \"password was updated\", http.StatusOK, user)\n\n\treturn\n\n}", "func RandomPasswordPage(c *fiber.Ctx) error {\n\tlogin := c.Params(\"login\")\n\thash := c.Params(\"hash\")\n\t// Just change it, if everything goes okay that is\n\treturn c.Send([]byte(databasepack.RandomPasswordUser(login, hash)))\n}", "func ShowPassword(ctx context.Context, s *testing.State) {\n\tconst PIN = \"123456789012\"\n\tenablePIN := s.Param().(testParams).EnablePIN\n\tautosubmit := s.Param().(testParams).Autosubmit\n\tvar creds chrome.Creds\n\n\t// Log in and log out to create a user pod on the login screen.\n\tfunc() {\n\t\tcr, err := chrome.New(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Chrome login failed: \", err)\n\t\t}\n\t\tdefer cr.Close(ctx)\n\t\tcreds = cr.Creds()\n\n\t\ttconn, err := cr.TestAPIConn(ctx)\n\t\tif err != nil {\n\t\t\ts.Fatal(\"Getting test API connection failed: \", err)\n\t\t}\n\t\tdefer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)\n\n\t\tif enablePIN {\n\t\t\t// Set up PIN through a connection to the Settings page.\n\t\t\tsettings, err := ossettings.Launch(ctx, tconn)\n\t\t\tif err != nil {\n\t\t\t\ts.Fatal(\"Failed to launch Settings app: \", err)\n\t\t\t}\n\t\t\ts.Log(\"Performing PIN set up\")\n\t\t\tif err := settings.EnablePINUnlock(cr, creds.Pass, PIN, autosubmit)(ctx); err != nil {\n\t\t\t\ts.Fatal(\"Failed to enable PIN unlock: \", err)\n\t\t\t}\n\t\t}\n\t}()\n\n\t// chrome.NoLogin() and chrome.KeepState() are needed to show the login screen with a user pod (instead of the OOBE login screen).\n\tcr, err := chrome.New(ctx,\n\t\tchrome.ExtraArgs(\"--skip-force-online-signin-for-testing\"),\n\t\tchrome.NoLogin(),\n\t\tchrome.KeepState(),\n\t\tchrome.LoadSigninProfileExtension(s.RequiredVar(\"ui.signinProfileTestExtensionManifestKey\")),\n\t)\n\tif err != nil {\n\t\ts.Fatal(\"Failed to start Chrome: \", err)\n\t}\n\tdefer cr.Close(ctx)\n\n\ttconn, err := cr.SigninProfileTestAPIConn(ctx)\n\tif err != nil {\n\t\ts.Fatal(\"Creating login test API connection failed: \", err)\n\t}\n\tdefer faillog.DumpUITreeOnError(ctx, s.OutDir(), s.HasError, tconn)\n\n\t// Wait for the login screen to be ready for PIN / Password entry.\n\tif st, err := lockscreen.WaitState(ctx, tconn, func(st lockscreen.State) bool { return st.ReadyForPassword }, 30*time.Second); err != nil {\n\t\ts.Fatalf(\"Failed waiting for the login screen to be ready for PIN / Password entry: %v, last state: %+v\", err, st)\n\t}\n\n\t// Clicking the \"Switch to password\" button to view the Password field when PIN autosubmit is enabled\n\tif autosubmit {\n\t\tif err := lockscreen.SwitchToPassword(ctx, tconn); err != nil {\n\t\t\ts.Fatal(\"Failed to click the Switch to password button: \", err)\n\t\t}\n\t}\n\n\t// Test the working of \"Show password\" and \"Hide password\" button on login screen.\n\tif enablePIN && !autosubmit {\n\t\tif err := showAndHidePassword(ctx, tconn, creds.User, PIN, true); err != nil {\n\t\t\ts.Fatal(\"Failed to Show/Hide PIN on login screen: \", err)\n\t\t}\n\t} else {\n\t\tif err := showAndHidePassword(ctx, tconn, creds.User, creds.Pass, false); err != nil {\n\t\t\ts.Fatal(\"Failed to Show/Hide Password on login screen: \", err)\n\t\t}\n\t}\n}", "func UpdatePassword(newPW string, userID int) {\n\tsqlStmt := `UPDATE tblUsers\n\t\t\t\tSET fldPassword = ?\n\t\t\t\tWHERE fldID = ?;`\n\n\tstmt, err := globals.Db.Prepare(sqlStmt)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tdefer stmt.Close()\n\n\t// Execute insert and replace with actual values.\n\t_, err = stmt.Exec(newPW, userID)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n}", "func (c *Config) UpdatePassword(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\n\tvar payload updatePasswordPayload\n\tif err := bjson.ReadJSON(&payload, r); err != nil {\n\t\tbjson.HandleError(w, err)\n\t\treturn\n\t}\n\n\tif err := valid.Raw(&payload); err != nil {\n\t\tbjson.HandleError(w, err)\n\t\treturn\n\t}\n\n\tu, err := c.UserStore.GetUserByID(ctx, payload.UserID)\n\tif err != nil {\n\t\tbjson.HandleError(w, errors.E(\n\t\t\terrors.Op(\"handlers.UpdatePassword\"),\n\t\t\terr,\n\t\t\thttp.StatusBadRequest))\n\n\t\treturn\n\t}\n\n\tif err := u.VerifyPasswordResetMagicLink(\n\t\tc.Magic,\n\t\tpayload.UserID,\n\t\tpayload.Timestamp,\n\t\tpayload.Signature,\n\t); err != nil {\n\t\tbjson.HandleError(w, err)\n\t\treturn\n\t}\n\n\tif err := magic.TooOld(payload.Timestamp); err != nil {\n\t\tbjson.HandleError(w, err)\n\t\treturn\n\t}\n\n\tu.ChangePassword(payload.Password)\n\tu.IsLocked = false\n\tu.AddEmail(u.Email)\n\tu.DeriveProperties()\n\n\tif err := c.UserStore.Commit(ctx, u); err != nil {\n\t\tbjson.HandleError(w, err)\n\t\treturn\n\t}\n\n\tbjson.WriteJSON(w, u, http.StatusOK)\n}", "func errorPasswordHandler(w http.ResponseWriter, r *http.Request) {\n\tp := Profile{}\n\trenderTemplate(w, \"loginError\", &p)\n}", "func ChangePass(w http.ResponseWriter, r *http.Request) {\r\n\tlogin := strings.Trim(r.FormValue(\"login\"), \" \")\r\n\tpass := strings.Trim(r.FormValue(\"pass\"), \" \")\r\n\r\n\t// Check params\r\n\tif login == \"\" || pass == \"\" {\r\n\t\twriteResponse(w, \"Login and password required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tnewPass := strings.Trim(r.FormValue(\"newPass\"), \" \")\r\n\tif newPass == \"\" {\r\n\t\twriteResponse(w, \"newPass required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tif Auth[login] != pass {\r\n\t\twriteResponse(w, \"Wrong pass\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser := model.User{}\r\n\terr := user.Get(login, pass) // в Auth можно сохранять id, чтобы не делать этот запрос\r\n\tlog.Println(\"user\", user)\r\n\tif err != nil {\r\n\t\twriteResponse(w, \"Something wrong\\n\", http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser.Pass = newPass\r\n\terr = user.Save()\r\n\tif err != nil {\r\n\t\twriteResponse(w, \"Error update password in database\\n\", http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\tAuth[user.Login] = user.Pass\r\n\r\n\twriteResponse(w, \"Password changed\\n\", http.StatusOK)\r\n}", "func (rep rep_users) UpdatePassword(id uint64, passwordHash string) error {\n\tstatement, erro := rep.db.Prepare(\"UPDATE usuarios SET senha = ? WHERE id = ?\")\n\n\tif erro != nil {\n\t\treturn erro\n\t}\n\n\tdefer statement.Close()\n\n\tif _, erro = statement.Exec(passwordHash, id); erro != nil {\n\t\treturn erro\n\t}\n\n\treturn nil\n}", "func (o *AuthUser) ReloadP(exec boil.Executor) {\n\tif err := o.Reload(exec); err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n}", "func (a *API) changePassword(w http.ResponseWriter, req *http.Request) {\n\tvars := mux.Vars(req)\n\tusername := vars[\"user\"]\n\tif username == config.Get().AdminAuthentication.Username {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusForbidden,\n\t\t\terr: errors.New(\"Cannot change administrator's password\"),\n\t\t})\n\t\treturn\n\t}\n\tif err := req.ParseForm(); err != nil {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusBadRequest,\n\t\t\terr: err,\n\t\t})\n\t\treturn\n\t}\n\tpassword := req.Form.Get(\"password\")\n\tif password == \"\" {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusBadRequest,\n\t\t\terr: errors.New(\"Incorrect change password form\"),\n\t\t})\n\t\treturn\n\t}\n\t// Check an user is existing\n\tpath := common.Path(model.DefaultUsersPrefix, common.Hash(username, crypto.MD5))\n\tresp, err := a.etcdcli.DoGet(path)\n\tif err != nil {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusInternalServerError,\n\t\t\terr: err,\n\t\t})\n\t\treturn\n\t}\n\tif len(resp.Kvs) == 0 {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusBadRequest,\n\t\t\terr: errors.New(\"Unknown user\"),\n\t\t})\n\t\treturn\n\t}\n\t// Hash for new password\n\thashedpw, err := common.GenerateBcryptHash(password, config.Get().PasswordHashingCost)\n\tif err != nil {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusInternalServerError,\n\t\t\terr: errors.Wrap(err, \"Something went wrong\"),\n\t\t})\n\t\treturn\n\t}\n\n\tuser := &model.User{\n\t\tUsername: username,\n\t\tPassword: hashedpw,\n\t}\n\t_ = user.Validate()\n\tr, _ := json.Marshal(&user)\n\t_, err = a.etcdcli.DoPut(path, string(r))\n\tif err != nil {\n\t\ta.respondError(w, apiError{\n\t\t\tcode: http.StatusInternalServerError,\n\t\t\terr: errors.Wrap(err, \"Unable to put a key-value pair into etcd\"),\n\t\t})\n\t\treturn\n\t}\n\ta.respondSuccess(w, http.StatusOK, nil)\n}", "func (_this *URL) SetPassword(value string) {\n\tinput := value\n\t_this.Value_JS.Set(\"password\", input)\n}", "func (h *AuthHandlers) ChangePwd(w http.ResponseWriter, req *http.Request) {\n\tvar err error\n\tvar data []byte\n\n\tsystemContext, err := h.getSystemContext(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"request context retrevial failure\")\n\t\tmiddleware.ReturnError(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tif data, err = ioutil.ReadAll(req.Body); err != nil {\n\t\tlog.Error().Err(err).Msg(\"read body error\")\n\t\tmiddleware.ReturnError(w, \"error reading changepwd data\", 500)\n\t\treturn\n\t}\n\tdefer req.Body.Close()\n\n\tloginDetails := &authz.LoginDetails{}\n\tif err := json.Unmarshal(data, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Msg(\"marshal body error\")\n\t\tmiddleware.ReturnError(w, \"error reading changepwd data\", 500)\n\t\treturn\n\t}\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"changepwd called\")\n\tif err := h.validate.Struct(loginDetails); err != nil {\n\t\tmiddleware.ReturnError(w, \"validation failure \"+err.Error(), 500)\n\t\treturn\n\t}\n\n\tloginDetails.OrgName = strings.ToLower(loginDetails.OrgName)\n\tloginDetails.Username = strings.ToLower(loginDetails.Username)\n\n\torgData, err := h.getOrgByName(req.Context(), systemContext, loginDetails.OrgName)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"failed to get organization from name\")\n\t\tmiddleware.ReturnError(w, \"forgot password confirm failed\", 403)\n\t\treturn\n\t}\n\n\tif _, err := h.authenticator.SetNewPassword(req.Context(), orgData, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"set new password failed\")\n\t\tmiddleware.ReturnError(w, \"set new password failed\", 403)\n\t\treturn\n\t}\n\n\tresp := make(map[string]string, 0)\n\tresp[\"status\"] = \"ok\"\n\n\trespData, _ := json.Marshal(resp)\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (s *Server) handleDashboardUserEdit() http.HandlerFunc {\n\tvar o sync.Once\n\tvar tpl *template.Template\n\n\t//steps on the page\n\tsteps := struct {\n\t\tStepDel string\n\t}{\n\t\tStepDel: \"stepDel\",\n\t}\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tctx, logger := GetLogger(s.getCtx(r))\n\t\to.Do(func() {\n\t\t\ttpl = s.loadWebTemplateDashboard(ctx, \"user-edit.html\")\n\t\t})\n\t\tctx, provider, data, _, ok := s.createTemplateDataDashboard(w, r.WithContext(ctx), tpl, true)\n\t\tif !ok {\n\t\t\treturn\n\t\t}\n\n\t\t//setup the breadcrumbs\n\t\tbreadcrumbs := []breadcrumb{\n\t\t\t{\"Users\", provider.GetURLUsers()},\n\t\t\t{\"Edit Team Member\", \"\"},\n\t\t}\n\t\tdata[TplParamBreadcrumbs] = breadcrumbs\n\t\tdata[TplParamActiveNav] = provider.GetURLUsers()\n\t\tdata[TplParamFormAction] = provider.GetURLUserEdit()\n\t\tdata[TplParamSteps] = steps\n\n\t\t//handle the input\n\t\tidStr := r.FormValue(URLParams.UserID)\n\t\tstep := r.FormValue(URLParams.Step)\n\n\t\t//prepare the data\n\t\tdata[TplParamUserID] = idStr\n\n\t\t//load the provider user\n\t\tid := uuid.FromStringOrNil(idStr)\n\t\tif id == uuid.Nil {\n\t\t\tlogger.Warnw(\"invalid uuid\", \"id\", idStr)\n\t\t\ts.SetCookieErr(w, Err)\n\t\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t\t\treturn\n\t\t}\n\t\tctx, providerUser, err := LoadProviderUserByProviderIDAndID(ctx, s.getDB(), provider.ID, &id)\n\t\tif err != nil {\n\t\t\tlogger.Errorw(\"load provider user\", \"error\", err, \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tif providerUser == nil {\n\t\t\tlogger.Errorw(\"no provider user\", \"id\", id)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\t\tdata[TplParamUser] = providerUser\n\n\t\t//prepare the confirmation modal\n\t\tdata[TplParamConfirmMsg] = GetMsgText(MsgUserDelConfirm)\n\t\tdata[TplParamConfirmSubmitName] = URLParams.Step\n\t\tdata[TplParamConfirmSubmitValue] = steps.StepDel\n\n\t\t//check the method\n\t\tif r.Method == http.MethodGet {\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//execute the correct operation\n\t\tvar msgKey MsgKey\n\t\tswitch step {\n\t\tcase steps.StepDel:\n\t\t\t//delete the provider user\n\t\t\tctx, err := DeleteUserProvider(ctx, s.getDB(), provider.ID, providerUser.ID)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Errorw(\"delete provider user\", \"error\", err, \"id\", providerUser.ID)\n\t\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tmsgKey = MsgUserDel\n\t\tdefault:\n\t\t\tlogger.Errorw(\"invalid step\", \"id\", providerUser.ID, \"step\", step)\n\t\t\tdata[TplParamErr] = GetErrText(Err)\n\t\t\ts.renderWebTemplate(w, r.WithContext(ctx), tpl, data)\n\t\t\treturn\n\t\t}\n\n\t\t//success\n\t\ts.SetCookieMsg(w, msgKey, providerUser.Login)\n\t\thttp.Redirect(w, r.WithContext(ctx), provider.GetURLUsers(), http.StatusSeeOther)\n\t}\n}", "func (h *auth) UpdatePassword(c echo.Context) error {\n\t// Filter params\n\tvar params service.UpdatePasswordParams\n\tif err := c.Bind(&params); err != nil {\n\t\tlog.Println(\"Could not get parameters:\", err)\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"Could not get parameters.\"))\n\t}\n\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\t// Check CurrentPassword presence.\n\tif params.CurrentPassword == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized,\n\t\t\tsferror.New(\"Your current password is required to change your password. Please update your application if you do not see this option.\"))\n\t}\n\n\t// Check NewPassword presence.\n\tif params.NewPassword == \"\" {\n\t\treturn c.JSON(http.StatusUnauthorized,\n\t\t\tsferror.New(\"Your new password is required to change your password. Please update your application if you do not see this option.\"))\n\t}\n\n\tuser := currentUser(c)\n\n\t// When id parameter passed, check it's the same like in bearer token.\n\tif c.Param(\"id\") != \"\" && c.Param(\"id\") != user.ID {\n\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"The given ID is not the user's one.\"))\n\t}\n\n\tservice := service.NewUser(h.db, h.sessions, params.APIVersion)\n\tpassword, err := service.Password(user, params)\n\tif err != nil {\n\t\tif h.db.IsAlreadyExists(err) {\n\t\t\treturn c.JSON(http.StatusUnauthorized, sferror.New(\"The email you entered is already taken. Please try again.\"))\n\t\t}\n\t\treturn err\n\t}\n\n\treturn c.JSON(http.StatusOK, password)\n}", "func (db *MyConfigurations) showResetPasswordByEmailPage(c echo.Context) error {\n\tstatus, message := getFlashMessages(&c) // gets the flash message and status if there was any\n\temail := c.QueryParam(\"email\")\n\thash := c.QueryParam(\"hash\")\n\tvar otp models.OTP\n\tdb.GormDB.Table(\"otps\").First(&otp, \"email = ? AND verification_code = ?\", email, hash)\n\tif otp.UserID == 0 {\n\t\treturn redirectWithFlashMessage(\"failure\", \"حدث خطأ ما برجاء اعاده المحاوله مره اخرى (او قم بأرسال البريد الالكتروني مره اخرى)\", \"/login\", &c)\n\t}\n\tformAction := \"/email-reset-password?email=\" + email + \"&hash=\" + hash\n\treturn c.Render(http.StatusOK, \"reset-password-by-email.html\", echo.Map{\n\t\t\"status\": status, // pass the status of the flash message\n\t\t\"message\": message, // pass the message\n\t\t\"hideNavBar\": true, // boolean to indicate weather or not the NavBar should be displayed\n\t\t\"formAction\": formAction, // the URL that the form should be submitted to\n\t})\n}", "func UpdatePassword(w http.ResponseWriter, r *http.Request) {\n\tr.ParseForm()\n\tpasswords, err := json.Marshal(map[string]string{\n\t\t\"now\": r.FormValue(\"now\"),\n\t\t\"new\": r.FormValue(\"new\"),\n\t})\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserID, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\turl := fmt.Sprintf(\"%s/users/%d/change-password\", config.APIURL, userID)\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodPost, url, bytes.NewBuffer(passwords))\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tresponses.JSON(w, response.StatusCode, nil)\n}", "func UpdatePassword(ex db.Execer, userid int64, pass string) error {\n\tif err := validPassword(pass); err != nil {\n\t\treturn err\n\t}\n\thashed, err := bcrypt.GenerateFromPassword([]byte(pass), bcrypt.DefaultCost)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstr := `\n\tINSERT INTO user_passwords (user_id, password)\n\tSELECT user_id, password FROM users WHERE user_id = ?\n\t`\n\t_, err = ex.Exec(str, userid)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstr = \"UPDATE users SET password = ? WHERE user_id = ?\"\n\t_, err = ex.Exec(str, hashed, userid)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func UpdatePassword(w http.ResponseWriter, r *http.Request) {\n\tuserID := r.Context().Value(utils.TokenContextKey).(string)\n\ttempAccout := &receivePasswordInfo{}\n\terr := json.NewDecoder(r.Body).Decode(tempAccout)\n\tif err != nil {\n\t\tutils.JSONRespnseWithErr(w, &utils.ErrPostDataNotCorrect)\n\t\treturn\n\t}\n\tmessage := models.UpdatePassword(userID, tempAccout.Password, tempAccout.NewPassword)\n\tutils.JSONResonseWithMessage(w, message)\n}", "func UserPassUpdate(w http.ResponseWriter, r *http.Request, u *User) error {\n\t// set the name and email from the form data\n\tpass := r.FormValue(\"password\")\n\tif err := u.SetPassword(pass); err != nil {\n\t\treturn RenderError(w, err, http.StatusBadRequest)\n\t}\n\t// save the updated password to the database\n\tif err := database.SaveUser(u); err != nil {\n\t\treturn RenderError(w, err, http.StatusBadRequest)\n\t}\n\treturn RenderText(w, http.StatusText(http.StatusOK), http.StatusOK)\n}", "func (h *Handler) EditPage(c echo.Context) error {\n\tm := echo.Map{}\n\tif err := c.Bind(&m); err != nil {\n\t\treturn err\n\t}\n\tnr, nt, route := m[\"newRoute\"].(string), m[\"newTitle\"].(string), m[\"route\"].(string)\n\n\tuserDataMap := utils.GetUserDataFromContext(&c)\n\temail := (*userDataMap)[\"email\"].(string)\n\n\tpage, err := h.pageStore.EditPage(email, route, nr, nt)\n\tif err != nil {\n\t\tutils.Logger.Error(err)\n\t\treturn c.JSON(http.StatusInternalServerError, createRes(false, nil, nil, http.StatusText(http.StatusInternalServerError)))\n\t}\n\treturn c.JSON(http.StatusOK, createRes(true, page, nil, \"\"))\n}", "func ApiSettingsPassword(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tif !lib.IsLoggedIn(r) {\n\t\tSendJsonMessage(w, http.StatusUnauthorized, false, \"Unauthorized.\")\n\t\treturn\n\t}\n\n\t// Get data from Request\n\tr.ParseForm()\n\tvalue := r.Form.Get(\"password\")\n\n\t// Simple Validation\n\tif value == \"\" {\n\t\tSendJsonMessage(w, http.StatusBadRequest, false, \"Unable to process your Request: Submit a valid value.\")\n\t\treturn\n\t}\n\n\t// Update Password\n\tadmin := lib.Admin{}\n\terr := admin.ChangePassword(value)\n\tif err != nil {\n\t\tSendJsonMessage(w, http.StatusInternalServerError, false, \"Unable to process your Request: \"+err.Error())\n\t\treturn\n\t}\n\tSendJsonMessage(w, http.StatusOK, true, \"\")\n}", "func UpdatePassword(context *gin.Context) {\n\tuserProfile := models.UserProfile{}\n\tcontext.ShouldBindBodyWith(&userProfile, binding.JSON)\n\n\tmodifiedCount, err := userprofileservice.UpdateByEmail(userProfile)\n\tif modifiedCount == 0 {\n\t\tcontext.JSON(http.StatusNotFound, gin.H{\"message\": \"User not found\"})\n\t\treturn\n\t}\n\n\tif err != nil {\n\t\tcontext.JSON(http.StatusInternalServerError, gin.H{\"message\": \"Failed to update user\"})\n\t\tcontext.Abort()\n\t\treturn\n\t}\n\n\tcontext.JSON(http.StatusOK, gin.H{\"message\": \"ok\"})\n}", "func (us *UserRpcService) ChangePassword(ctx context.Context,\n\tin *pb.User) (*pb.User, error) {\n\n\tLog.INFO(\"Updating password for user:%v\", in)\n\n\tstore := ctx.Value(\"user_store\").(UserStoreService)\n\tif store == nil {\n\t\tLog.ERROR(\"Failed to read user store from context\")\n\t\treturn nil, internalError\n\t}\n\n\t// Read the user details first.\n\tuser, err := store.Read(ctx, in)\n\tif err != nil {\n\t\tLog.ERROR(\"Failed to read user from store, err=%s\", err.Error())\n\t\treturn nil, internalError\n\t}\n\n\toutUser, err := store.Update(ctx, user, in)\n\tif err != nil {\n\t\tLog.ERROR(\"Failed to update user in store, err=%s\", err.Error())\n\t\treturn nil, internalError\n\t}\n\n\treturn outUser, nil\n}", "func (ctl UserController) Update(c *gin.Context) {\n\tvar body struct {\n\t\tPassword string `json:\"password\" binding:\"required\"`\n\t}\n\tif err := c.ShouldBindJSON(&body); err != nil {\n\t\tc.JSON(rootCtl.wrap(http.StatusUnprocessableEntity, err.Error()))\n\t\treturn\n\t}\n\n\tif err := microsoft.NewUser().UpdatePassword(c.Param(\"id\"), c.Param(\"uid\"), body.Password); err != nil {\n\t\tc.JSON(rootCtl.wrap(http.StatusInternalServerError, err.Error()))\n\t\treturn\n\t}\n\n\tc.JSON(rootCtl.wrap(http.StatusOK))\n}", "func (o *AuthUserUserPermission) ReloadP(exec boil.Executor) {\n\tif err := o.Reload(exec); err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n}", "func (as *AdminServer) ResetPassword(w http.ResponseWriter, r *http.Request) {\n\tu := ctx.Get(r, \"user\").(models.User)\n\tsession := ctx.Get(r, \"session\").(*sessions.Session)\n\tif !u.PasswordChangeRequired {\n\t\tFlash(w, r, \"info\", \"Please reset your password through the settings page\")\n\t\tsession.Save(r, w)\n\t\thttp.Redirect(w, r, \"/settings\", http.StatusTemporaryRedirect)\n\t\treturn\n\t}\n\tparams := newTemplateParams(r)\n\tparams.Title = \"Reset Password\"\n\tswitch {\n\tcase r.Method == http.MethodGet:\n\t\tparams.Flashes = session.Flashes()\n\t\tsession.Save(r, w)\n\t\tgetTemplate(w, \"reset_password\").ExecuteTemplate(w, \"base\", params)\n\t\treturn\n\tcase r.Method == http.MethodPost:\n\t\tnewPassword := r.FormValue(\"password\")\n\t\tconfirmPassword := r.FormValue(\"confirm_password\")\n\t\tnewHash, err := auth.ValidatePasswordChange(u.Hash, newPassword, confirmPassword)\n\t\tif err != nil {\n\t\t\tFlash(w, r, \"danger\", err.Error())\n\t\t\tparams.Flashes = session.Flashes()\n\t\t\tsession.Save(r, w)\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tgetTemplate(w, \"reset_password\").ExecuteTemplate(w, \"base\", params)\n\t\t\treturn\n\t\t}\n\t\tu.PasswordChangeRequired = false\n\t\tu.Hash = newHash\n\t\tif err = models.PutUser(&u); err != nil {\n\t\t\tFlash(w, r, \"danger\", err.Error())\n\t\t\tparams.Flashes = session.Flashes()\n\t\t\tsession.Save(r, w)\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\tgetTemplate(w, \"reset_password\").ExecuteTemplate(w, \"base\", params)\n\t\t\treturn\n\t\t}\n\t\t// TODO: We probably want to flash a message here that the password was\n\t\t// changed successfully. The problem is that when the user resets their\n\t\t// password on first use, they will see two flashes on the dashboard-\n\t\t// one for their password reset, and one for the \"no campaigns created\".\n\t\t//\n\t\t// The solution to this is to revamp the empty page to be more useful,\n\t\t// like a wizard or something.\n\t\tas.nextOrIndex(w, r)\n\t}\n}", "func (k *Keyring) LoadPassword(fp fingerprint.Fingerprint) (password string, gotPassword bool) {\n\tif k.noBackend() {\n\t\treturn \"\", false\n\t}\n\n\tif password, gotPassword = tryLoadFromPasswordFile(fp); gotPassword {\n\t\treturn\n\t}\n\n\titem, err := k.realKeyring.Get(makeKeyringKey(fp))\n\n\tif err != nil {\n\t\tif isNotFoundError(err) {\n\t\t\treturn \"\", false\n\t\t} else {\n\t\t\t// TODO: log that an unexpected error was encountered\n\t\t}\n\n\t}\n\tpassword = string(item.Data)\n\tgotPassword = true\n\treturn\n}", "func (m *MockDatabase) LoadPassword(ID string) (string, int64, error) {\n\targs := m.Called(ID)\n\treturn args.String(0), args.Get(1).(int64), args.Error(2)\n}", "func resetPassword(w http.ResponseWriter, req *http.Request) {\n\n\tuserData, _ := getUserAndSession(w, req)\n\n\tif !userData.LoggedIn {\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\tif req.Method == http.MethodPost {\n\n\t\t// Get posted password\n\t\tnewPassword := req.FormValue(\"password\")\n\n\t\t// Ecrypt password before storing it. If the encryption errs, respond with\n\t\t// an Internal Server Error.\n\t\tencryptedPassword, err := getEncryptedPassword(newPassword)\n\t\tif err != nil {\n\t\t\thttp.Error(w, \"Internal server error\", http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\t// Update user in dbUsers map\n\t\tuserData.Password = encryptedPassword\n\t\tdbUsers[userData.UserID] = userData\n\n\t\t// Redirect to Home page after changing password\n\t\thttp.Redirect(w, req, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\ttpl.ExecuteTemplate(w, \"resetPassword.gohtml\", userData)\n}", "func (a *UserAPI) ChangePassword(ctx *gin.Context) {\n\tpw := model.UserExternalPass{}\n\tif err := ctx.Bind(&pw); err == nil {\n\t\tuser := a.DB.GetUserByID(auth.GetUserID(ctx))\n\t\tuser.Pass = password.CreatePassword(pw.Pass, a.PasswordStrength)\n\t\ta.DB.UpdateUser(user)\n\t}\n}", "func PasswordChangeHandler(w http.ResponseWriter, r *http.Request) {\n\tun, p, ok := r.BasicAuth()\n\tif !ok {\n\t\tw.Header().Set(\"WWW-Authenticate\", fmt.Sprintf(`Basic realm=\"%s\"`, BasicAuthRealm))\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tw.Write([]byte(http.StatusText(http.StatusUnauthorized) + \"\\n\"))\n\t\treturn\n\t}\n\tu := &User{\n\t\tUsername: strings.ToLower(un),\n\t\tPassword: p,\n\t\tNewPassword: r.FormValue(\"password\"),\n\t}\n\tauth, aerr := u.Authenticated()\n\tif aerr != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tif !auth {\n\t\thttp.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tif reqIsAdmin(r) && r.FormValue(\"username\") != \"\" {\n\t\tu.Username = strings.ToLower(r.FormValue(\"username\"))\n\t} else if !reqIsAdmin(r) && r.FormValue(\"username\") != \"\" {\n\t\thttp.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tuerr := u.Get()\n\tif uerr != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tif u.AD {\n\t\thttp.Error(w, http.StatusText(http.StatusNetworkAuthenticationRequired), http.StatusBadRequest)\n\t\treturn\n\t}\n\tu, err := u.ChangePass()\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, \"Password Changed\\n\")\n}", "func UserPass(w http.ResponseWriter, r *http.Request, u *User) error {\n\treturn RenderTemplate(w, \"user_password.html\", struct{ User *User }{u})\n}", "func (n *User) UpdatePassword(p string) error {\n\tpasswordHash, err := bcrypt.GenerateFromPassword([]byte(p), 10)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(p, \"=>\", string(passwordHash))\n\tn.PasswordHash = string(passwordHash)\n\treturn nil\n}", "func (UserService) UpdatePassword(dto dto.UserEditPasswordDto) int64 {\n\tsalt, _ := account.MakeSalt()\n\tpwd, _ := account.HashPassword(dto.Password, salt)\n\tu := userDao.Get(dto.Id, false)\n\t//u.Password = pwd\n\t//u.Salt = salt\n\tc := userDao.Update(&u, map[string]interface{}{\n\t\t\"password\": pwd,\n\t\t\"salt\": salt,\n\t})\n\treturn c.RowsAffected\n}", "func showAndHidePassword(ctx context.Context, tconn *chrome.TestConn, username, password string, pin bool) error {\n\thiddenPwd := strings.Repeat(hiddenPwdChar, len(password))\n\n\tkb, err := input.Keyboard(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to get keyboard\")\n\t}\n\tdefer kb.Close()\n\n\tif pin {\n\t\t// Enter the PIN on login screen when PIN is enabled.\n\t\ttesting.ContextLog(ctx, \"Entering PIN on \\\"PIN or password\\\" field of login screen\")\n\t\tif err := lockscreen.EnterPIN(ctx, tconn, kb, password); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to enter in PIN\")\n\t\t}\n\t} else {\n\t\t// Enter password on login screen.\n\n\t\ttesting.ContextLog(ctx, \"Entering password on login screen\")\n\t\tif err := lockscreen.TypePassword(ctx, tconn, username, password, kb); err != nil {\n\t\t\treturn errors.Wrap(err, \"failed to type password\")\n\t\t}\n\t}\n\n\t// Click the \"Show password\" button and verify that the viewed PIN / Password matches the user entered value.\n\tif err := lockscreen.ShowPassword(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to click the Show password button\")\n\t}\n\tpasswordField, err := lockscreen.UserPassword(ctx, tconn, username, pin)\n\tif err != nil {\n\t\treturn errors.New(\"failed to read PIN / Password\")\n\t}\n\tif passwordField.Value != password {\n\t\treturn errors.New(\"PIN / Password revealed after clicking the Show password button is not matching with the user entered value\")\n\t}\n\n\t// Verify that the PIN / Password goes hidden after clicking the \"Hide password\" button.\n\tif err := lockscreen.HidePassword(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to click the Hide password button\")\n\t}\n\tpasswordVal, err := lockscreen.UserPassword(ctx, tconn, username, pin)\n\tif err != nil {\n\t\treturn errors.New(\"failed to read PIN / Password that is hidden\")\n\t}\n\tif passwordVal.Value != hiddenPwd {\n\t\treturn errors.New(\"PIN / Password is not hidden after clicking the Hide password button\")\n\t}\n\n\t// Verify that when the user clicks the \"Show password\" button, the viewed PIN / Password goes hidden automatically after 5s timeout.\n\tif err := waitForPasswordHidden(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"PIN / Password is not hidden after the timeout\")\n\t}\n\treturn nil\n}", "func loadMainLogin(w http.ResponseWriter, r *http.Request) {\n\ts := tmpls.Lookup(\"mainLogin.tmpl\")\n\tp := &Page{\n\t\tPageName: \"mainLogin\",\n\t\tRole: \"\",\n\t\tUsername: \"\",\n\t\tCalendar: false,\n\t}\n\ts.ExecuteTemplate(w, \"content\", p)\n}", "func (g Graph) ChangeOwnPassword(w http.ResponseWriter, r *http.Request) {\n\tctx := r.Context()\n\tu, ok := revactx.ContextGetUser(ctx)\n\tif !ok {\n\t\tg.logger.Error().Msg(\"user not in context\")\n\t\terrorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, \"user not in context\")\n\t\treturn\n\t}\n\n\tsanitizedPath := strings.TrimPrefix(r.URL.Path, \"/graph/v1.0/\")\n\t_, err := godata.ParseRequest(r.Context(), sanitizedPath, r.URL.Query())\n\tif err != nil {\n\t\tg.logger.Err(err).Interface(\"query\", r.URL.Query()).Msg(\"query error\")\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tcpw := libregraph.NewPasswordChangeWithDefaults()\n\terr = StrictJSONUnmarshal(r.Body, cpw)\n\tif err != nil {\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tcurrentPw := cpw.GetCurrentPassword()\n\tif currentPw == \"\" {\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, \"current password cannot be empty\")\n\t\treturn\n\t}\n\n\tnewPw := cpw.GetNewPassword()\n\tif newPw == \"\" {\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, \"new password cannot be empty\")\n\t\treturn\n\t}\n\n\tif newPw == currentPw {\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, \"new password must be differnt from current password\")\n\t\treturn\n\t}\n\n\tauthReq := &gateway.AuthenticateRequest{\n\t\tType: \"basic\",\n\t\tClientId: u.Username,\n\t\tClientSecret: currentPw,\n\t}\n\tclient, err := g.gatewaySelector.Next()\n\tif err != nil {\n\t\terrorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, \"could not select next gateway client, aborting\")\n\t\treturn\n\t}\n\tauthRes, err := client.Authenticate(r.Context(), authReq)\n\tif err != nil {\n\t\terrorcode.ServiceNotAvailable.Render(w, r, http.StatusInternalServerError, err.Error())\n\t\treturn\n\t}\n\n\tswitch authRes.Status.Code {\n\tcase cs3rpc.Code_CODE_OK:\n\t\tbreak\n\tcase cs3rpc.Code_CODE_UNAUTHENTICATED, cs3rpc.Code_CODE_PERMISSION_DENIED:\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, \"wrong current password\")\n\t\treturn\n\tdefault:\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusInternalServerError, \"password change failed\")\n\t\treturn\n\t}\n\n\tnewPwProfile := libregraph.NewPasswordProfile()\n\tnewPwProfile.SetPassword(newPw)\n\tchanges := libregraph.NewUser()\n\tchanges.SetPasswordProfile(*newPwProfile)\n\t_, err = g.identityBackend.UpdateUser(ctx, u.Id.OpaqueId, *changes)\n\tif err != nil {\n\t\terrorcode.InvalidRequest.Render(w, r, http.StatusInternalServerError, \"password change failed\")\n\t\tg.logger.Debug().Err(err).Str(\"userid\", u.Id.OpaqueId).Msg(\"failed to update user password\")\n\t\treturn\n\t}\n\n\tcurrentUser := revactx.ContextMustGetUser(r.Context())\n\tg.publishEvent(\n\t\tctx,\n\t\tevents.UserFeatureChanged{\n\t\t\tExecutant: currentUser.Id,\n\t\t\tUserID: u.Id.OpaqueId,\n\t\t\tFeatures: []events.UserFeature{\n\t\t\t\t{Name: \"password\", Value: \"***\"},\n\t\t\t},\n\t\t},\n\t)\n\n\trender.Status(r, http.StatusNoContent)\n\trender.NoContent(w, r)\n}", "func ChangePassword(op string, np string, _id primitive.ObjectID, c *mongo.Client)\t(models.User, error)\t{\n\t// Get user from id\n\tfmt.Print(\"I was here\")\n\tstringUserID := _id.Hex()\n\tuser, err := GetUserByID(stringUserID, c)\n\tfmt.Print(\"I was here***\")\n\tif err!=nil {\n\t\treturn models.User{}, err\n\t}\n\tfmt.Print(\"I was here****\")\n\tif !util.MatchesWithHash(op, user.Password) {\n\t\treturn models.User{}, errors.New(\"Incorrect Password\")\n\t}\n\tfmt.Print(\"I was here-2\")\n\tuserCollection := c.Database(\"folks\").Collection(\"users\")\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\tpasswordHash, _ := util.HashPassword(np)\n\tfmt.Print(\"I was here-3\")\n\terr = userCollection.FindOneAndUpdate(\n\t\tctx,\n\t\tbson.M{\"_id\": _id},\n\t\tbson.D{\n\t\t\t{\"$set\", bson.D{{\"password\", passwordHash}}},\n\t\t},\n\t).Decode(&user)\n\tfmt.Print(\"I was here-4\")\n\tif err != nil{\n\t\treturn models.User{}, err\n\t}\n\n\treturn user, nil\n\n}", "func UpdatePasswordHandler(repo UpdatePasswordOrganizationRepository) func(w http.ResponseWriter, r *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvar handlerForm map[string]string\n\n\t\terr := requestToJSONObject(r, &handlerForm)\n\t\tif err != nil {\n\t\t\tHandleHTTPError(w, http.StatusBadRequest, err)\n\t\t\treturn\n\t\t}\n\n\t\tuserID := GetUserID(r)\n\t\torganization, err := repo.Get(userID)\n\n\t\tvar cPassword, nPassword string\n\t\tvar ok bool\n\n\t\tif cPassword, ok = handlerForm[\"currentPassword\"]; !ok {\n\t\t\tHandleHTTPError(w, http.StatusBadRequest, errors.New(\"você deve informar senha atual\"))\n\t\t\treturn\n\t\t}\n\n\t\tif nPassword, ok = handlerForm[\"newPassword\"]; !ok {\n\t\t\tHandleHTTPError(w, http.StatusBadRequest, errors.New(\"você deve informar a nova senha\"))\n\t\t\treturn\n\t\t}\n\n\t\tif _, err = repo.ChangePassword(*organization, cPassword, nPassword); err != nil {\n\t\t\tHandleHTTPError(w, http.StatusUnauthorized, err)\n\t\t\treturn\n\t\t}\n\n\t\tHandleHTTPSuccessNoContent(w)\n\t}\n}", "func (userInfo *NoAuthUserInfo) UpdatePassword(id string, passwordInfo *passwordChangeInfo) (int, error) {\n\treturn 0, errors.New(\"Update not supported\")\n}", "func (h *Handler) ChangePassword(args []string) error {\n\told, err := h.Term.ReadPassword(\"Enter your old password:\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tgood, err := h.CurrentUser.CheckPassword(old)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif good {\n\t\tnew1, err := h.Term.ReadPassword(\"Enter your new password:\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tnew2, err := h.Term.ReadPassword(\"Repeat your new password:\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif new1 == new2 {\n\t\t\tif len(new1) > 0 {\n\t\t\t\t_, err1 := h.writeToUser(\"Setting new password...\")\n\t\t\t\tif err1 != nil {\n\t\t\t\t\treturn err1\n\t\t\t\t}\n\t\t\t\treturn h.CurrentUser.SetPassword(new1)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"unable to use empty password!\")\n\t\t}\n\t\treturn fmt.Errorf(\"passwords do not match\")\n\t}\n\treturn fmt.Errorf(\"wrong password\")\n}", "func ChangePassword(userName string, password string, newPassword string, customCols map[string]interface{}) error {\n\tif len(userName) == 0 {\n\t\treturn errors.New(\"A user name is required to change a password\")\n\t} else if len(password) == 0 {\n\t\treturn errors.New(\"A password is required to change a password\")\n\t} else if len(newPassword) == 0 {\n\t\treturn errors.New(\"A new password is required to change a password\")\n\t} else if checkStringSQLInjection(userName) {\n\t\treturn errors.New(\"Malicious characters detected\")\n\t} else if !checkCustomRequirements(customCols, customPasswordChangeRequirements) {\n\t\treturn errors.New(\"Incorrect data supplied\")\n\t}\n\n\t//FIRST TWO ARE id, password IN THAT ORDER\n\tvar vals []interface{} = []interface{}{new(int), new([]byte)}\n\tvar valsList []interface{} = []interface{}{}\n\n\t//CONSTRUCT SELECT QUERY\n\tselectQuery := \"Select \" + usersColumnID + \", \" + usersColumnPassword + \", \"\n\tif customCols != nil {\n\t\tfor key, val := range customCols {\n\t\t\tselectQuery = selectQuery + key + \", \"\n\t\t\t//MAINTAIN THE ORDER IN WHICH THE COLUMNS WERE DECLARED VIA A SLICE\n\t\t\tvals = append(vals, new(interface{}))\n\t\t\tvalsList = append(valsList, []interface{}{val, customAccountInfo[key].dataType, key})\n\t\t}\n\t}\n\tselectQuery = selectQuery[0:len(selectQuery)-2] + \" FROM \" + tableUsers + \" WHERE \" + usersColumnName + \"=\\\"\" + userName + \"\\\" LIMIT 1;\"\n\n\t//EXECUTE SELECT QUERY\n\tcheckRows, err := database.Query(selectQuery)\n\tif err != nil {\n\t\treturn err\n\t}\n\t//\n\tcheckRows.Next()\n\tif scanErr := checkRows.Scan(vals...); scanErr != nil {\n\t\tcheckRows.Close()\n\t\treturn errors.New(\"Login or password is incorrect\")\n\t}\n\tcheckRows.Close()\n\n\t//\n\tdbIndex := *(vals[0]).(*int) // USE FOR SERVER CALLBACK & MAKE DATABASE RESPONSE MAP\n\tdbPass := *(vals[1]).(*[]byte)\n\n\t//COMPARE HASHED PASSWORDS\n\tif !helpers.CheckPasswordHash(password, dbPass) {\n\t\treturn errors.New(\"Login or password is incorrect\")\n\t}\n\n\t//ENCRYPT NEW PASSWORD\n\tpassHash, hashErr := helpers.HashPassword(newPassword, encryptionCost)\n\tif hashErr != nil {\n\t\treturn hashErr\n\t}\n\n\t//UPDATE THE PASSWORD\n\t_, updateErr := database.Exec(\"UPDATE \" + tableUsers + \" SET \" + usersColumnPassword + \"=\\\"\" + passHash + \"\\\" WHERE \" + usersColumnID + \"=\" + strconv.Itoa(dbIndex) + \" LIMIT 1;\")\n\tif updateErr != nil {\n\t\treturn updateErr\n\t}\n\n\t//\n\treturn nil\n}", "func (h *UserHandler) UpdatePassword(c *gin.Context) {\n\tcurrentUser, err := h.userSrv.GetCurrentUser(c)\n\tif err != nil {\n\t\trespondError(c, http.StatusUnauthorized, err.Error())\n\t\treturn\n\t}\n\n\t// get data from body\n\tvar userVals serializers.UserUpdatePasswordRequest\n\tif err := c.ShouldBindJSON(&userVals); err != nil {\n\t\trespondError(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\n\tif err := currentUser.CheckPassword(*userVals.OldPassowrd); err != nil {\n\t\trespondError(c, http.StatusForbidden, errors.PasswordIncorrect.Error())\n\t\treturn\n\t}\n\n\tif *userVals.NewPassword != *userVals.PasswordConfirmation {\n\t\trespondError(c, http.StatusUnprocessableEntity, errors.ConfirmationPasswordIncorrect.Error())\n\t\treturn\n\t}\n\n\tvar data = map[string]interface{}{\n\t\t\"jwt\": nil,\n\t\t\"password\": *userVals.NewPassword,\n\t}\n\n\tif errUpdate := h.userSrv.UpdatePassword(currentUser, data); errUpdate != nil {\n\t\trespondError(c, http.StatusUnprocessableEntity, errUpdate.Error())\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, serializers.Resp{Result: \"Password Updated\", Error: nil})\n}", "func (u *Users) ResetPw(w http.ResponseWriter, r *http.Request) {\n\tvar vd views.Data\n\tvar form ResetPwForm\n\tvd.Yield = &form\n\tif err := parseURLParams(r, &form); err != nil {\n\t\tvd.SetAlert(err)\n\t}\n\tu.ResetPwView.Render(w, r, vd)\n}", "func RedirectToChangePassword(w http.ResponseWriter, r *http.Request, h *render.Renderer) {\n\thttp.Redirect(w, r, \"/login/change-password\", http.StatusSeeOther)\n\treturn\n}", "func (c *Client) ChangePassword(cp *www.ChangePassword) (*www.ChangePasswordReply, error) {\n\tresponseBody, err := c.makeRequest(http.MethodPost,\n\t\twww.PoliteiaWWWAPIRoute, www.RouteChangePassword, cp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar cpr www.ChangePasswordReply\n\terr = json.Unmarshal(responseBody, &cpr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal ChangePasswordReply: %v\", err)\n\t}\n\n\tif c.cfg.Verbose {\n\t\terr := prettyPrintJSON(cpr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn &cpr, nil\n}", "func (p *politeiawww) processChangePassword(email string, cp www.ChangePassword) (*www.ChangePasswordReply, error) {\n\tvar reply www.ChangePasswordReply\n\n\t// Get user from db.\n\tu, err := p.userByEmail(email)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Check the user's password.\n\terr = bcrypt.CompareHashAndPassword(u.HashedPassword,\n\t\t[]byte(cp.CurrentPassword))\n\tif err != nil {\n\t\treturn nil, www.UserError{\n\t\t\tErrorCode: www.ErrorStatusInvalidPassword,\n\t\t}\n\t}\n\n\t// Validate the new password.\n\terr = validatePassword(cp.NewPassword)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Hash the user's password.\n\thashedPassword, err := p.hashPassword(cp.NewPassword)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add the updated user information to the db.\n\tu.HashedPassword = hashedPassword\n\terr = p.db.UserUpdate(*u)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = p.emailUserPasswordChanged(email)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &reply, nil\n}", "func UpdatePassword(db sqlx.Execer, id int64, newpassword string) error {\n\tif err := ValidatePassword(newpassword); err != nil {\n\t\treturn errors.Wrap(err, \"validation error\")\n\t}\n\n\tpwHash, err := hashPassword(newpassword)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Add the new user.\n\t_, err = db.Exec(\"update \\\"user\\\" set password_hash = $1, updated_at = now() where id = $2\",\n\t\tpwHash, id)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"update error\")\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"id\": id,\n\t}).Info(\"user password updated\")\n\treturn nil\n\n}", "func (o LookupUserResultOutput) Password() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupUserResult) string { return v.Password }).(pulumi.StringOutput)\n}", "func (u *User) UpdatePassword(db *pg.DB) error {\n\tpass, err := bcrypt.GenerateFromPassword([]byte(u.Password), bcrypt.DefaultCost)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn err\n\t}\n\n\tu.Password = string(pass)\n\t_, err = db.Model(u).WherePK().Update()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (repository Users) UpdatePassword(password string, userID uint64) error {\n\n\tstatement, error := repository.db.Prepare(\"UPDATE users SET password = ? where id = ?\")\n\n\tif error != nil {\n\t\treturn error\n\t}\n\n\tdefer statement.Close()\n\n\tif _, error = statement.Exec(password, userID); error != nil {\n\t\treturn error\n\t}\n\n\treturn nil\n}", "func UserEdit(w http.ResponseWriter, r *http.Request, u *User) error {\n\treturn RenderTemplate(w, \"user_profile.html\", struct{ User *User }{u})\n}", "func (d *webData) modifyAdminWeb(w http.ResponseWriter, r *http.Request) {\n\tip := r.RemoteAddr\n\tadminID := 0\n\t//query the userDB for all users and put the returning slice with result in p\n\tu := storage.QuerySingleUserInfo(d.PDB, adminID)\n\n\t//Execute the web for modify users, range over p to make the select user drop down menu\n\terr := d.tpl.ExecuteTemplate(w, \"modifyUserCompletePage\", u)\n\tif err != nil {\n\t\tfmt.Fprint(w, \"Error: modifyAdminWeb: template execution error = \", err)\n\t}\n\n\t//Write out all the info of the selected user to the web\n\n\terr = d.tpl.ExecuteTemplate(w, \"modifyUser\", u) //bruk bare en spesifik slice av struct og send til html template\n\tif err != nil {\n\t\tlog.Println(ip, \"modifyAdminWeb: error = \", err)\n\t}\n\n\tr.ParseForm()\n\n\t//create a variable based on user to hold the values parsed from the modify web\n\tuForm := storage.User{}\n\t//get all the values like name etc. from the form, and put them in u\n\tgetFormValuesUserInfo(&uForm, r)\n\tchanged := false\n\tchanged, u = checkUserFormChanged(uForm, u)\n\n\t//Check what values that are changed\n\n\t//if any of the values was changed....update information into database\n\tif changed {\n\t\tstorage.UpdateUser(d.PDB, u)\n\n\t\t//Execute the redirect to modifyAdmin to refresh page\n\t\terr := d.tpl.ExecuteTemplate(w, \"redirectTomodifyAdmin\", u)\n\t\tif err != nil {\n\t\t\tfmt.Fprint(w, \"Error: modifyAdminWeb: template execution error = \", err)\n\t\t}\n\t}\n}", "func (app *application) EditUser(w http.ResponseWriter, r *http.Request) {\n\tid := chi.URLParam(r, \"id\")\n\tuserID, _ := strconv.Atoi(id)\n\n\tvar user models.User\n\n\terr := app.readJSON(w, r, &user)\n\tif err != nil {\n\t\tapp.badRequest(w, r, err)\n\t\treturn\n\t}\n\n\tif userID > 0 { // For an existing user, update the user record\n\t\terr = app.DB.EditUser(user)\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\n\t\tif user.Password != \"\" {\n\t\t\tnewHash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 12)\n\t\t\tif err != nil {\n\t\t\t\tapp.badRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terr = app.DB.UpdatePasswordForUser(user, string(newHash))\n\t\t\tif err != nil {\n\t\t\t\tapp.badRequest(w, r, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t} else { // For a new user, simply add the user to the users table\n\t\tnewHash, err := bcrypt.GenerateFromPassword([]byte(user.Password), 12)\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t\terr = app.DB.AddUser(user, string(newHash))\n\t\tif err != nil {\n\t\t\tapp.badRequest(w, r, err)\n\t\t\treturn\n\t\t}\n\t}\n\n\tvar resp struct {\n\t\tError bool `json:\"error\"`\n\t\tMessage string `json:\"message\"`\n\t}\n\n\tresp.Error = false\n\tapp.writeJSON(w, http.StatusOK, resp)\n}", "func InitPassword(db *sql.DB) (string, error) {\n\n\tClearScreen()\n\n\tpassIsSet := CheckStoredPassword(db)\n\n\tvar password = \"\"\n\n\tif passIsSet == false {\n\t\tpassword, _ := setPassword(db)\n\t\treturn password, nil\n\t}\n\tif passIsSet == true {\n\t\tpassword, err := checkPassword(db)\n\t\tif err != nil {\n\t\t\tPrintOrange(\"Sorry, your password appears to be incorrect!\")\n\t\t\tos.Exit(1)\n\t\t}\n\t\treturn password, nil\n\t}\n\n\treturn password, nil\n\n}", "func ChangeUserPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *model.Configuration) error {\n\tif rs == nil {\n\t\treturn errors.New(\"pdfcpu: ChangeUserPassword: missing rs\")\n\t}\n\n\tif conf == nil {\n\t\treturn errors.New(\"pdfcpu: missing configuration for change user password\")\n\t}\n\n\tconf.Cmd = model.CHANGEUPW\n\tconf.UserPW = pwOld\n\tconf.UserPWNew = &pwNew\n\n\treturn Optimize(rs, w, conf)\n}", "func (o UserOutput) Password() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *User) pulumi.StringPtrOutput { return v.Password }).(pulumi.StringPtrOutput)\n}", "func (o UserOutput) Password() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *User) pulumi.StringPtrOutput { return v.Password }).(pulumi.StringPtrOutput)\n}", "func (c *RegistrationController) SetPassword(w http.ResponseWriter, r *http.Request) {\n\n\t// parse the JSON coming from the client\n\tvar passRequest passwordRequest\n\tdecoder := json.NewDecoder(r.Body)\n\n\t// check if the parsing succeeded\n\tif err := decoder.Decode(&passRequest); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Error parsing form values failed\")\n\t\treturn\n\t}\n\n\tif err := passwordsAreValid(passRequest.Password, passRequest.PasswordConfirmation); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Password invalid\")\n\t\treturn\n\t}\n\n\t//validate link\n\tuser, err := models.FindUserByVerificationUUID(passRequest.UUID)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error setting password: %v is not a valid UUID\", passRequest.UUID)\n\t\tc.BadRequest(w, nil, \"Error verifying email address: %v is not a valid user identifier\", passRequest.UUID)\n\t\treturn\n\t}\n\n\tif !user.PasswordInvalid {\n\t\tc.Error500(w, nil, \"Password is already set\")\n\t\treturn\n\t}\n\n\tif err := user.UpdatePassword(passRequest.Password); err != nil {\n\t\tlog.Printf(\"Error updating the password in the database: %v\", err)\n\t\tc.Error500(w, err, \"Error updating the password in the database\")\n\t\treturn\n\t}\n\n\tc.Plain(\"\", w, r)\n\treturn\n}", "func (us *UserService) ChangePassword(ctx context.Context, user resources.User, password string) error {\n\tuserID, err := user.ID()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = us.call(ctx, \"one.user.passwd\", userID, password)\n\treturn err\n}", "func UpdatePassword(w http.ResponseWriter, r *http.Request, userID string) {\n\t//parse body\n\tvar updateRequest requests.UpdatePasswordRequest\n\terr := json.NewDecoder(r.Body).Decode(&updateRequest)\n\n\t//check if body was valid\n\tif err != nil {\n\t\thttp.Error(w, messages.BAD_REQUEST, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t//get password(-hash) of current user\n\tcurrentUserHash := database.GetPasswordHashForUserId(userID)\n\n\t// make sure that the (user-)password which the user provided is valid\n\tencryption.CheckPassword(updateRequest.UserPassword, currentUserHash)\n\n\t//password was valid\n\tif !checker.Check(updateRequest.Password, checker.PASSWORD_REGEX) {\n\t\t// password was invalid --> return error\n\t\thttp.Error(w, messages.PASSWORD_INVALID, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t//get current time\n\tcurrentTime := time.Now()\n\n\t//encrypt the new password\n\tencryptedPassword, nonce := encryption.ToSecuredPassword(updateRequest.Password, updateRequest.UserPassword, currentTime)\n\n\tpassword := models.Password{\n\t\tPasswordID: uuid.MustParse(updateRequest.PasswordID),\n\t\tPassword: encryptedPassword,\n\t\tNonce: nonce,\n\t\tUseLocation: updateRequest.UseLocation,\n\t\tCreatedOn: currentTime,\n\t}\n\n\t// ... and update password entry in database\n\tdatabase.UpdatePassword(userID, &password)\n\n\t//return ok\n\tw.WriteHeader(200)\n}", "func (handler *Handler) handlePasswordUpdate(w http.ResponseWriter, r *http.Request) {\n\n\t//We have gone through the auth, so we should know the id of the logged in user\n\tloggedInUser := r.Context().Value(\"user\").(int) //Grab the id of the user that send the request\n\n\t//Create a new password change object\n\tinfo := updatePasswordChangeStruct{}\n\n\t//Now get the json info\n\terr := json.NewDecoder(r.Body).Decode(&info)\n\tif err != nil {\n\t\tutils.ReturnJsonError(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\n\t}\n\n\t//Now update the password\n\terr = handler.userHelper.passwordChange(loggedInUser, info)\n\n\t//Check to see if the user was created\n\tif err == nil {\n\t\tutils.ReturnJsonStatus(w, http.StatusAccepted, true, \"password_change_success\")\n\t} else {\n\t\tutils.ReturnJsonError(w, http.StatusForbidden, err)\n\t}\n\n}", "func setupPassword(a *app.App) error {\r\n\tfound := false\r\n\terr := a.DB.View(func(tx *bolt.Tx) error {\r\n\t\tb := tx.Bucket([]byte(\"settings\"))\r\n\t\th := b.Get([]byte(\"password-hash\"))\r\n\t\tif h != nil {\r\n\t\t\tfound = true\r\n\t\t}\r\n\t\treturn nil\r\n\t})\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\tif found {\r\n\t\treturn nil\r\n\t}\r\n\t// generate password if not found\r\n\treturn generatePassword(a)\r\n}", "func (a *api) h_POST_users_userId_password(c *gin.Context) {\n\tlogin := c.Param(\"userId\")\n\taCtx := a.getAuthContext(c)\n\tif a.errorResponse(c, aCtx.AuthZUser(login)) {\n\t\treturn\n\t}\n\n\tusr := &User{}\n\tif a.errorResponse(c, bindAppJson(c, usr)) {\n\t\treturn\n\t}\n\n\terr := a.Dc.SetUserPasswd(login, ptr2string(usr.Password, \"\"))\n\tif a.errorResponse(c, err) {\n\t\ta.logger.Warn(\"Could not set user password for user \", login, \", err=\", err, \". Will leave it intact\")\n\t\treturn\n\t}\n\n\ta.logger.Info(\"Password for user \", login, \", was changed successfully!\")\n\n\tc.Status(http.StatusNoContent)\n}", "func setDpPasswordPlain(password string) {\n\tb32password := base32.StdEncoding.EncodeToString([]byte(password))\n\tdpPassword = &b32password\n}", "func (p *Password) Update(pwd string) {\n\t*p = Password(pwd)\n\t_ = p.rehash()\n}", "func (o *Auth) ReloadP(exec boil.Executor) {\n\tif err := o.Reload(exec); err != nil {\n\t\tpanic(boil.WrapErr(err))\n\t}\n}", "func ChangePasswordHandler(ur UserRepo) func(c *gin.Context) {\n\treturn func(c *gin.Context) {\n\t\tcid, _ := c.Get(\"client_id\")\n\t\tclientId := cid.(string)\n\n\t\tuid := c.Param(\"id\")\n\n\t\ttype param struct {\n\t\t\tOldPassword string `json:\"old_password\"`\n\t\t\tNewPassword string `json:\"new_password\"`\n\t\t}\n\n\t\tvar p param\n\t\tif err := c.ShouldBind(&p); err != nil {\n\t\t\tcErr := sdkcmn.ErrInvalidRequest(err)\n\t\t\tc.JSON(cErr.StatusCode, cErr)\n\t\t\treturn\n\t\t}\n\n\t\terr := ur.ChangePassword(context.Background(), clientId, uid, p.OldPassword, p.NewPassword)\n\t\tif err != nil {\n\t\t\tcErr := err.(sdkcmn.AppError)\n\t\t\tc.JSON(cErr.StatusCode, cErr)\n\t\t\treturn\n\t\t}\n\n\t\tc.JSON(http.StatusOK, sdkcmn.SimpleSuccessResponse(\"ok\"))\n\t}\n}", "func LoadUserPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tuserID, err := strconv.ParseUint(parameters[\"userId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tcookie, _ := cookies.Read(r)\n\tuserIDLogged, _ := strconv.ParseUint(cookie[\"id\"], 10, 64)\n\n\tuser, err := models.SearchCompleteUser(userID, r)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tif userID == userIDLogged {\n\t\thttp.Redirect(w, r, \"/profile\", 302)\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"user.html\", struct {\n\t\tUser models.User\n\t\tUserLoggedID uint64\n\t}{\n\t\tUser: user,\n\t\tUserLoggedID: userIDLogged,\n\t})\n}", "func LoadEditPage(w http.ResponseWriter, r *http.Request) {\n\tparameters := mux.Vars(r)\n\tpublicationID, err := strconv.ParseUint(parameters[\"publicationId\"], 10, 64)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusBadRequest, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\turl := fmt.Sprintf(\"%s/publications/%d\", config.APIURL, publicationID)\n\tresponse, err := requests.RequestsWithAuthentication(r, http.MethodGet, url, nil)\n\tif err != nil {\n\t\tresponses.JSON(w, http.StatusInternalServerError, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode >= 400 {\n\t\tresponses.TreatStatusCode(w, response)\n\t\treturn\n\t}\n\n\tvar publication models.Publication\n\tif err = json.NewDecoder(response.Body).Decode(&publication); err != nil {\n\t\tresponses.JSON(w, http.StatusUnprocessableEntity, responses.ErrorAPI{Err: err.Error()})\n\t\treturn\n\t}\n\n\tutils.RunTemplate(w, \"edit-publication.html\", publication)\n}", "func DoRecoverPassword(_ http.ResponseWriter, r *http.Request) {\n\tr.ParseForm()\n\n}", "func (uh *UserHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {\n\n\tloggedInUser := uh.Authentication(r)\n\tif loggedInUser == nil {\n\t\thttp.Redirect(w, r, \"/Login\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodGet {\n\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\ttoken, err := stringTools.CSRFToken(uh.CSRF)\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t}\n\t\tinputContainer := InputContainer{LoggedInUser: loggedInUser, CSRF: token}\n\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\treturn\n\t}\n\n\tif r.Method == http.MethodPost {\n\n\t\tvar profilePic, cv string\n\t\tfirstname := r.FormValue(\"firstname\")\n\t\tlastname := r.FormValue(\"lastname\")\n\t\tphonenumber := r.FormValue(\"phonenumber\")\n\t\temail := r.FormValue(\"email\")\n\t\tjobTitle := r.FormValue(\"jobTitle\")\n\t\tcountry := r.FormValue(\"country\")\n\t\tcity := r.FormValue(\"city\")\n\t\tgender := r.FormValue(\"gender\")\n\t\tbio := r.FormValue(\"bio\")\n\t\tprefeS := r.FormValue(\"prefe\")\n\t\tprefe, _ := strconv.ParseInt(prefeS, 0, 0)\n\n\t\t// In Edit profile password will not be change be still it will be authenticated!\n\t\tpassword := \"ValidPassword123\"\n\n\t\tcsrfToken := r.FormValue(\"csrf\")\n\t\tok, errCRFS := stringTools.ValidCSRF(csrfToken, uh.CSRF)\n\n\t\tuser := entity.NewUser(firstname, lastname, email, profilePic, password, phonenumber, jobTitle, country, city, gender, cv, bio)\n\t\tuser.UID = loggedInUser.UID\n\t\tuser.Prefe = prefe\n\n\t\terrMap := uh.UService.Verification(user, entity.Identification{ConfirmPassword: \"ValidPassword123\", From: \"EditProfile\"})\n\t\tif !ok || errCRFS != nil {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\terrMap[\"csrf\"] = \"Invalid token used!\"\n\t\t}\n\n\t\tif len(errMap) > 0 {\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tpFilename, err := uh.ResourceExtractorUser(user.UID, \"profilePic\", \"image\", r)\n\n\t\tif err != nil && (err.Error() == \"file to large\" || err.Error() == \"invalid format\") {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\terrMap[\"profilePic\"] = \"File size should be less than 5MB!\"\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tcFilename, err := uh.ResourceExtractorUser(user.UID, \"cv\", \"file\", r)\n\n\t\tif err != nil && (err.Error() == \"file too large\" || err.Error() == \"invalid format\") {\n\t\t\tif len(errMap) == 0 {\n\t\t\t\terrMap = make(map[string]string)\n\t\t\t}\n\t\t\tswitch err.Error() {\n\t\t\tcase \"invalid format\":\n\t\t\t\terrMap[\"cv\"] = \"Only pdf format is allowed!\"\n\t\t\tcase \"file too large\":\n\t\t\t\terrMap[\"cv\"] = \"File size should be less than 5MB!\"\n\t\t\t}\n\n\t\t\tuh.CSRF, _ = stringTools.GenerateRandomBytes(30)\n\t\t\ttoken, _ := stringTools.CSRFToken(uh.CSRF)\n\t\t\tinputContainer := InputContainer{LoggedInUser: user, Error: errMap, CSRF: token}\n\t\t\tuh.Temp.ExecuteTemplate(w, \"ProfilePage.html\", inputContainer)\n\t\t\treturn\n\t\t}\n\n\t\tuser.ProfilePic = pFilename\n\t\tuser.CV = cFilename\n\t\terr = uh.UService.EditUserProfile(user)\n\t\tif err != nil {\n\t\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\thttp.Redirect(w, r, \"/Login\", http.StatusSeeOther)\n\t\treturn\n\t}\n}", "func (a *UserApiService) ChangePasswordExecute(r UserApiChangePasswordRequest) (*User, *http.Response, error) {\n\tvar (\n\t\tlocalVarHTTPMethod = http.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tformFiles []formFile\n\t\tlocalVarReturnValue *User\n\t)\n\n\tlocalBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, \"UserApiService.ChangePassword\")\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}\n\t}\n\n\tlocalVarPath := localBasePath + \"/v1/password\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\tlocalVarFormParams := url.Values{}\n\tif r.changePasswordRequest == nil {\n\t\treturn localVarReturnValue, nil, reportError(\"changePasswordRequest is required and must be specified\")\n\t}\n\n\t// to determine the Content-Type header\n\tlocalVarHTTPContentTypes := []string{\"application/json\"}\n\n\t// set Content-Type header\n\tlocalVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)\n\tif localVarHTTPContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHTTPContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHTTPHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)\n\tif localVarHTTPHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHTTPHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = r.changePasswordRequest\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 == 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.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\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.error = formatErrorMessage(localVarHTTPResponse.Status, &v)\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 (_this *URL) Password() string {\n\tvar ret string\n\tvalue := _this.Value_JS.Get(\"password\")\n\tret = (value).String()\n\treturn ret\n}", "func ChangePassword(c *gin.Context) {\n\tuser := c.MustGet(\"user\").(models.User)\n\toldPass := c.PostForm(\"oldPassword\")\n\tnewPass := c.PostForm(\"newPassword\")\n\tnewRetypePass := c.PostForm(\"newRetypePassword\")\n\n\tif oldPass == \"\" || newPass == \"\" || newRetypePass == \"\" {\n\t\terrors.MissingParameters.Apply(c)\n\t\treturn\n\t}\n\n\tif newPass != newRetypePass {\n\t\terrors.BadParameters.Apply(c)\n\t\treturn\n\t}\n\n\toldPassValid := user.CheckPassword(oldPass)\n\tif !oldPassValid {\n\t\terrors.InvalidCredentials.Apply(c)\n\t\treturn\n\t}\n\n\tif err := user.SetPassword(newPass); err != nil {\n\t\tc.AbortWithError(500, err)\n\t\treturn\n\t}\n\n\tif err := db.DB.Save(&user).Error; err != nil {\n\t\terrors.DB.Apply(c)\n\t\treturn\n\t}\n}", "func NewPassword(w http.ResponseWriter, r *http.Request) {\n\tbody, err := ioutil.ReadAll(r.Body)\n\tvar fPass models.Password\n\terr = json.Unmarshal(body, &fPass)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tpassword := fPass.Password\n\temail := fPass.Email\n\totp := fPass.Otp\n\n\t// 1. Check email\n\tusers := auth.EmailPassword(fPass.Email)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tconform := security.Validate(otp, \"sakldgofsagofiusahf\")\n\tfmt.Println(users)\n\tfmt.Println(conform)\n\tif users == true && conform == true {\n\t\tuser := auth.SetPassword(email, password)\n\t\tfmt.Println(user)\n\t\tfmt.Println(\"Password update\")\n\t}\n\n\t// user := models.User{}\n\n\tresponses.JSON(w, http.StatusOK, conform)\n}", "func (db *gjDatabase) updateUserPassword(email, password string) error {\n\tcryptPw, cryptError := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)\n\tif cryptError != nil {\n\t\treturn cryptError\n\t}\n\tif err := db.open(); err != nil {\n\t\treturn err\n\t}\n\tdefer db.close()\n\n\tusrPath := []string{\"users\", email}\n\treturn db.bolt.SetValue(usrPath, \"password\", string(cryptPw))\n}", "func EditPage(c *fiber.Ctx) error {\n\t// Firstly checks if given table exists\n\tname := c.Params(\"name\")\n\tT := databasepack.FindTable(name)\n\tif T < 0 {\n\t\treturn c.Send([]byte(\"No table with such name!\"))\n\t}\n\t// Next checks if the user can actually perform this action\n\tif !databasepack.Allowed(querypack.INFO.Roles, \"editor_\"+name) {\n\t\treturn c.Send([]byte(\"Permission declined!\"))\n\t}\n\t// Lastly posts given post\n\tdatabasepack.CreatePosts(c.Body(), name, T)\n\treturn c.Send([]byte(\"Successfully edited!\"))\n}", "func (p *LDAPUserProvider) UpdatePassword(inputUsername string, newPassword string) error {\n\tconn, err := p.connect(p.configuration.User, p.configuration.Password)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to update password. Cause: %w\", err)\n\t}\n\tdefer conn.Close()\n\n\tprofile, err := p.getUserProfile(conn, inputUsername)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to update password. Cause: %w\", err)\n\t}\n\n\tswitch {\n\tcase p.supportExtensionPasswdModify:\n\t\tmodifyRequest := ldap.NewPasswordModifyRequest(\n\t\t\tprofile.DN,\n\t\t\t\"\",\n\t\t\tnewPassword,\n\t\t)\n\n\t\terr = conn.PasswordModify(modifyRequest)\n\tcase p.configuration.Implementation == schema.LDAPImplementationActiveDirectory:\n\t\tmodifyRequest := ldap.NewModifyRequest(profile.DN, nil)\n\t\tutf16 := unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM)\n\t\t// The password needs to be enclosed in quotes\n\t\t// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/6e803168-f140-4d23-b2d3-c3a8ab5917d2\n\t\tpwdEncoded, _ := utf16.NewEncoder().String(fmt.Sprintf(\"\\\"%s\\\"\", newPassword))\n\t\tmodifyRequest.Replace(\"unicodePwd\", []string{pwdEncoded})\n\n\t\terr = conn.Modify(modifyRequest)\n\tdefault:\n\t\tmodifyRequest := ldap.NewModifyRequest(profile.DN, nil)\n\t\tmodifyRequest.Replace(\"userPassword\", []string{newPassword})\n\n\t\terr = conn.Modify(modifyRequest)\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to update password. Cause: %w\", err)\n\t}\n\n\treturn nil\n}", "func (userHandlersImpl UserHandlersImpl) ResendPassword(w http.ResponseWriter, req *http.Request) {\n\tctx := req.Context()\n\tvars := mux.Vars(req)\n\tid := vars[\"id\"]\n\tlog.Logger(ctx).Info(\"in request\")\n\n\terr := userHandlersImpl.userSvc.ResendPassword(ctx, id)\n\tif err != nil {\n\t\tWriteHTTPError(w, http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tresp := \"\"\n\tWriteOKResponse(w, resp)\n}", "func (client IdentityClient) getUserUIPasswordInformation(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/users/{userId}/uiPassword\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response GetUserUIPasswordInformationResponse\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\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func ResetPassword(w http.ResponseWriter, r *http.Request) {\n\tauth := service.GetSessionMember(r)\n\tvars := mux.Vars(r)\n\tid := vars[\"id\"]\n\n\tmemberID, _ := strconv.Atoi(id)\n\tmember := model.GetMemberByID(memberID)\n\n\tif err := r.ParseMultipartForm(setting.FileMaxSize); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n\n\tnewPassword := r.FormValue(\"newPassword\")\n\tconfirmPassword := r.FormValue(\"confirmPassword\")\n\n\tpasswordData := map[string]string{\n\t\t\"password\": newPassword,\n\t\t\"confirmPassword\": confirmPassword,\n\t}\n\n\tvalidateError := model.ValidatePassword(passwordData)\n\n\tif len(validateError) == 0 {\n\t\tmodel.UpdatePassword(newPassword, member)\n\t\thttp.Redirect(w, r, \"/admin/members/\"+id, 301)\n\t}\n\n\ttemplateData := map[string]interface{}{\n\t\t\"title\": \"Reset Password\",\n\t\t\"validateError\": validateError,\n\t\t\"id\": id,\n\t\t\"auth\": auth,\n\t\t\"tab\": setting.MembersTab,\n\t}\n\n\ttmpl := template.Must(template.ParseFiles(\"template/admin_members/reset_password.tmpl\", setting.AdminTemplate))\n\tif err := tmpl.ExecuteTemplate(w, \"base\", templateData); err != nil {\n\t\tLogger.Error(err.Error())\n\t}\n}", "func (u *User) ChangePassword(tx *pop.Connection) (*validate.Errors, error) {\n\t// find user by email\n\tquery := tx.Where(\"email = ?\", u.Email)\n\tqueryUser := User{}\n\terr := query.First(&queryUser)\n\tif err != nil {\n\t\treturn nil, errors.New(\"User not found\")\n\t}\n\tlog.Infof(\"%s == %s\\n\", u.ResetTokenConfirm, queryUser.ResetToken)\n\tif u.ResetTokenConfirm != queryUser.ResetToken {\n\t\treturn nil, errors.New(\"Tokens do not match\")\n\t}\n\tqueryUser.Password = u.Password\n\tqueryUser.PasswordConfirm = u.PasswordConfirm\n\treturn queryUser.Update(tx)\n}", "func UpdatePassword(username string, oldPass string, newPass string, rePass string) error {\n\tif newPass != rePass {\n\t\treturn errors.New(\"The second entry of the new password doesn't match\")\n\t}\n\terr := updatePassword(username, oldPass, newPass)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn errors.New(\"Incorrect username or old password\")\n\t}\n\treturn nil\n}", "func PasswordResetGetHandler(ctx *enliven.Context) {\n\tcode, ok := ctx.Vars[\"code\"]\n\tif !ok || code == \"\" {\n\t\tctx.Forbidden()\n\t\treturn\n\t}\n\n\tdb := database.GetDatabase()\n\tu := User{}\n\tdb.Where(\"Verification_Code = ?\", code).First(&u)\n\n\tif u.ID == 0 {\n\t\tctx.Forbidden()\n\t\treturn\n\t}\n\n\tctx.ExecuteBaseTemplate(\"user_password_reset\")\n}" ]
[ "0.67488396", "0.6476385", "0.6416797", "0.6239708", "0.6090162", "0.59930485", "0.5971036", "0.5931909", "0.5879905", "0.5876025", "0.5868366", "0.5835726", "0.5772224", "0.5759482", "0.5756564", "0.5750805", "0.57443166", "0.5680604", "0.56190014", "0.5585063", "0.55615014", "0.5530129", "0.552834", "0.552443", "0.55199957", "0.5518907", "0.5517453", "0.55092365", "0.54878974", "0.54719806", "0.5455738", "0.54379797", "0.54229033", "0.54155153", "0.54121655", "0.5404884", "0.54009223", "0.5373627", "0.536958", "0.53690994", "0.53660923", "0.53632337", "0.5360021", "0.53488374", "0.53393596", "0.53385603", "0.53211737", "0.5316982", "0.5302116", "0.5300099", "0.5287797", "0.52826345", "0.5275119", "0.5273769", "0.5262776", "0.52591115", "0.5231172", "0.5231008", "0.5218444", "0.521751", "0.51885325", "0.51653975", "0.5160545", "0.51460886", "0.513452", "0.5132452", "0.5129314", "0.5116317", "0.5112099", "0.50971055", "0.5095652", "0.5091", "0.5091", "0.508456", "0.5084494", "0.5078944", "0.5073771", "0.507162", "0.50695753", "0.50599945", "0.50578946", "0.5055454", "0.5050326", "0.5043852", "0.5041004", "0.5039901", "0.50250715", "0.50217897", "0.5014529", "0.50128293", "0.50108886", "0.50106096", "0.50068456", "0.50046706", "0.5002706", "0.4994209", "0.499366", "0.49856406", "0.49814582", "0.4981288" ]
0.894935
0
/ PlaceholdersApiServiceTests Read slide placeholder info. Test for PlaceholdersApi.GetSlidesPlaceholder method
func TestGetSlidesPlaceholder(t *testing.T) { request := createGetSlidesPlaceholderRequest() e := initializeTest("GetSlidesPlaceholder", "", "") if e != nil { t.Errorf("Error: %v.", e) return } c := getTestApiClient() r, _, e := c.PlaceholdersApi.GetSlidesPlaceholder(request) if e != nil { t.Errorf("Error: %v.", e) return } if r.Code != 200 && r.Code != 201 { t.Errorf("Wrong response code: %d.", r.Code) return } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestGetSlidesPlaceholders(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n e := initializeTest(\"GetSlidesPlaceholders\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholders(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholderInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidplaceholderIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.placeholderIndex = invalidizeTestParamValue(request.placeholderIndex, \"placeholderIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"placeholderIndex\", request.placeholderIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"placeholderIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholders\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"storage\", r.Code, e)\n}", "func GetPlaceHolders(conf *viper.Viper) Placeholders {\n\tlist := parseMap(conf.AllSettings())\n\n\tproperties := CreateProperties(list)\n\n\treturn Placeholders{properties}\n}", "func TestGetSlidesPlaceholderInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"folder\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"password\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"folder\", r.Code, e)\n}", "func TestGetSlidesApiInfo(t *testing.T) {\n e := initializeTest(\"GetSlidesApiInfo\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesApiInfo()\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (a *ClinicalMetadataServiceApiService) GetSlide(ctx _context.Context, slideId string) (Ga4ghSlide, *_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 Ga4ghSlide\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/{slide_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"slide_id\"+\"}\", _neturl.QueryEscape(fmt.Sprintf(\"%v\", slideId)), -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\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v Ga4ghSlide\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\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 TestGetSlidesPlaceholdersInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"password\", r.Code, e)\n}", "func TestNotesSlideGetFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.GetNotesSlide(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func GetPlaceHolder(count int) string {\n\tif count > 0 {\n\t\tstr := strings.Repeat(\"?, \", count)\n\t\treturn str[:len(str)-2]\n\t}\n\n\treturn \"\"\n}", "func TestNotesSlideExistsFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.NotesSlideExists(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestSlideCommentsGet(t *testing.T) {\n\tvar slideIndex int32 = 1\n\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresponse, _, e := c.SlidesApi.GetSlideComments(fileName, slideIndex, password, folderName, \"\")\n\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tif len(response.GetList()) != 2 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 2, len(response.GetList()))\n\t\treturn\n\t}\n\n\tif len(response.GetList()[0].GetChildComments()) != 1 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 1, len(response.GetList()[0].GetChildComments()))\n\t\treturn\n\t}\n}", "func TestGetSlidesDocument(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n e := initializeTest(\"GetSlidesDocument\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocument(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestNotesSlideGetFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.GetNotesSlideOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func (ref *UIElement) PlaceholderValue() string {\n\tret, _ := ref.StringAttr(PlaceholderValueAttribute)\n\treturn ret\n}", "func (p *Projection) slideName() (string, error) {\n\tparts := strings.Split(p.ContentObjectID, \"/\")\n\tif len(parts) != 2 {\n\t\treturn \"\", fmt.Errorf(\"invalid content_object_id `%s`, expected one '/'\", p.ContentObjectID)\n\t}\n\n\tif p.Type != \"\" && parts[0] == \"meeting\" {\n\t\treturn p.Type, nil\n\t}\n\treturn parts[0], nil\n}", "func (a *ClinicalMetadataServiceApiService) SearchSlides(ctx _context.Context, body Ga4ghSearchSlidesRequest) (Ga4ghSearchSlidesResponse, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Ga4ghSearchSlidesResponse\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/search\"\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{\"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 = &body\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 Ga4ghSearchSlidesResponse\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\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 TestNotesSlideExistsFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.NotesSlideExistsOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func (a *SlidesApiService) GetApiInfo() (IApiInfo, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFiles [][]byte\n\t \tsuccessPayload IApiInfo\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.GetApiUrl() + \"/slides/info\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\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{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHttpResponse, responseBytes, err := a.client.makeRequest(nil, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFiles)\n\tresponseBody := bytes.NewReader(responseBytes)\n\tif localVarHttpResponse != nil && localVarHttpResponse.StatusCode >= 300 {\n\t\tvar errorMessage ErrorMessage\n\t\tif err = json.NewDecoder(responseBody).Decode(&errorMessage); err != nil {\n\t\t\treturn successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, reportError(string(responseBytes))\n\t}\n\n\tsuccessPayloadObject, err := createObjectForType(\"ApiInfo\", responseBytes)\n\tif err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif err = json.NewDecoder(responseBody).Decode(successPayloadObject); err != nil {\n\t\tif sp, ok := successPayloadObject.(IApiInfo); ok {\n\t\t\treturn sp, localVarHttpResponse, err\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif successPayload, _ = successPayloadObject.(IApiInfo); true {\n\t}\n\n\treturn successPayload, localVarHttpResponse, err\n}", "func NeedPlaceholder(t string) bool {\n\tswitch t {\n\tcase SecretVariable, KeyVariable, SSHKeyVariable, PGPKeyVariable:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func GetQiskitPlayground(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *QiskitPlaygroundState, opts ...pulumi.ResourceOption) (*QiskitPlayground, error) {\n\tvar resource QiskitPlayground\n\terr := ctx.ReadResource(\"kubernetes:singhp11.io/v1:QiskitPlayground\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func TestGetSlidesDocumentInvalidname(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"name\", r.Code, e)\n}", "func Placeholder(num int) string {\n\treturn strings.Join(SliceFill(num, \"?\"), \",\")\n}", "func TestGetSlidesDocumentWithFormat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocumentWithFormat(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n assertBinaryResponse(r, t)\n}", "func Placeholder(w http.ResponseWriter, r *http.Request) {\n\tlog.Debugf(\"Method: %s\", r.Method)\n\tlog.Debugf(\"URL: %s\", r.URL.String())\n\tbodyContents, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(\"Couldn't read the body of the request\"))\n\t}\n\tlog.Debugf(\"Body: %s\", string(bodyContents))\n\tw.WriteHeader(http.StatusNotImplemented)\n}", "func Placeholder(scope *Scope, dtype tf.DataType, optional ...PlaceholderAttr) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Placeholder\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func TestNotesSlideDownloadFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadNotesSlide(fileName, 1, \"png\", nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func privateDataPlaceholder() string {\n\treturn \"[PRIVATE DATA HIDDEN]\"\n}", "func TestPutSlidesSlideSize(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n e := initializeTest(\"PutSlidesSlideSize\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesSlideSize(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestNotesSlidePortions(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphIndex int32 = 1\n\tvar portionCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tportions, _, e := c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewPortion()\n\tdto.Text = \"New portion\"\n\tdto.FontBold = \"True\"\n\tportion, _, e := c.SlidesApi.CreateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\tdto2 := slidescloud.NewPortion()\n\tdto2.Text = \"Updated portion\"\n\tdto2.FontHeight = 22\n\tportion, _, e = c.SlidesApi.UpdateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, dto2, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetFontHeight() != dto2.GetFontHeight() {\n\t\tt.Errorf(\"Wrong portion font height. Expected %v but was %v.\", dto2.GetFontHeight(), portion.GetFontHeight())\n\t\treturn\n\t}\n\tif portion.GetText() != dto2.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto2.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n}", "func (d *ceph) getPlaceholderVolume() Volume {\n\treturn NewVolume(d, d.name, VolumeType(\"incus\"), ContentTypeFS, d.config[\"ceph.osd.pool_name\"], nil, nil)\n}", "func (d *portworx) getRestContainerPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.TargetPort.IntVal, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api target port not found in service\")\n}", "func TestNotesSlideParagraphs(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tparagraphs, _, e := c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n\n\tportion := slidescloud.NewPortion()\n\tportion.Text = \"New Paragraph\"\n\tdto := slidescloud.NewParagraph()\n\tdto.Alignment = \"Right\"\n\tdto.PortionList = []slidescloud.IPortion{portion}\n\tparagraph, _, e := c.SlidesApi.CreateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\tdto = slidescloud.NewParagraph()\n\tdto.Alignment = \"Center\"\n\tparagraph, _, e = c.SlidesApi.UpdateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n}", "func (s *System) GetCachedSlide(affirmationIndex, winWidth, winHeight int) (pixbuf *gdk.Pixbuf, found bool) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\t// Clear the cache if our window size has changed.\n\ts.clearSlideCacheIfNecessary(winWidth, winHeight)\n\n\t// Get the cached value.\n\tpixbuf, found = s.cachedSlides[affirmationIndex]\n\tif !found {\n\t\treturn nil, false\n\t}\n\n\treturn pixbuf, true\n}", "func PlaceholderClient(ipaddress string, status string) error {\n\n\tlogit.Info.Println(\"Placeholder called\")\n\tclient, err := rpc.DialHTTP(\"tcp\", ipaddress)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: dialing:\" + err.Error())\n\t\treturn err\n\t}\n\tif client == nil {\n\t\tlogit.Error.Println(\"Placeholder: client was nil\")\n\t\treturn errors.New(\"client was nil from rpc dial\")\n\t}\n\n\tvar command Command\n\n\terr = client.Call(\"Command.Placeholder\", &status, &command)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: error \" + err.Error())\n\t\treturn err\n\t}\n\tlogit.Info.Println(\"status=\" + status)\n\n\treturn nil\n}", "func TestGetSlidesDocumentWithFormatInvalidname(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"name\", int32(r.StatusCode), e)\n}", "func TestGetSlidesDocumentInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"storage\", r.Code, e)\n}", "func (u *User) GetBotInlinePlaceholder() (value string, ok bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\tif !u.Flags.Has(19) {\n\t\treturn value, false\n\t}\n\treturn u.BotInlinePlaceholder, true\n}", "func (p *parser) GetPictures(a *goquery.Selection) []string {\n\tv := picture{area: a, cleanImg: p.cleanImg}\n\tv.setDetail()\n\treturn v.data\n}", "func (stc *STemplatesController) Info() (*srv_tmpl.Pool, error) {\n\tresponse, err := stc.c.ClientFlow.HTTPMethod(\"GET\", endpointFTemplate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !response.status {\n\t\treturn nil, errors.New(response.body)\n\t}\n\n\tstemplatepool := &srv_tmpl.Pool{}\n\tpool_str, err := json.Marshal(response.BodyMap()[\"DOCUMENT_POOL\"])\n\terr = json.Unmarshal([]byte(pool_str), stemplatepool)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn stemplatepool, err\n}", "func (m Model) placeholderView() string {\n\tvar (\n\t\tv string\n\t\tp = m.Placeholder\n\t\tstyle = m.PlaceholderStyle.Inline(true).Render\n\t)\n\n\t// Cursor\n\tif m.blink {\n\t\tv += m.cursorView(style(p[:1]))\n\t} else {\n\t\tv += m.cursorView(p[:1])\n\t}\n\n\t// The rest of the placeholder text\n\tv += style(p[1:])\n\n\treturn m.PromptStyle.Render(m.Prompt) + v\n}", "func GetEntryFromPlaceholder(ctx context.Context, r repo.Repository, defp snapshot.HasDirEntryOrNil) (fs.Entry, error) {\n\tde, err := defp.DirEntryOrNil(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to get direntry from placeholder\")\n\t}\n\n\trepoFSLog(ctx).Debugf(\"GetDirEntryFromPlaceholder %v %v \", r, de)\n\n\treturn EntryFromDirEntry(r, de), nil\n}", "func (v *Values) GetMetadata(stepName string) interface{} {\n\treturn v.getStepData(stepName, MetadataKey)\n}", "func TestPanicOnSameParamPlaceholder(t *testing.T) {\n\tdefer func() {\n\t\tv := recover()\n\t\tif v == nil {\n\t\t\tt.Fatalf(\"expected a panic, but nothing happened\")\n\t\t}\n\t}()\n\n\trunTest(t, func(s *Session) {\n\t\ts.Handle(\"model.$id.type.$id\")\n\t}, nil)\n}", "func getRequiredVariables() map[string]interface{} {\n\tvariables := map[string]interface{}{\n\t\t\"competition\": competitionName,\n\t\t\"secret_name\": kaggleApiSecret,\n\t}\n\treturn variables\n}", "func getLabels(\n docker *client.Client,\n containerId string) (labels map[string]string, err error) {\n\n inspect, err := docker.ContainerInspect(context.Background(), containerId)\n if err != nil {\n return\n }\n\n labels = inspect.Config.Labels\n return\n}", "func mustGetContainer(g *gomega.WithT, objs *objectSet, deploymentName, containerName string) map[string]interface{} {\n\tobj := objs.kind(\"Deployment\").nameEquals(deploymentName)\n\tg.Expect(obj).Should(gomega.Not(gomega.BeNil()))\n\tcontainer := obj.Container(containerName)\n\tg.Expect(container).Should(gomega.Not(gomega.BeNil()))\n\treturn container\n}", "func TestGetSlidesDocumentWithFormatInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"storage\", int32(r.StatusCode), e)\n}", "func TestConvertSlidePostFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadSlide(fileName, 1, \"pdf\", nil, nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func TestGetQuestion() {\n\tresponse, err := http.Get(\"http://localhost:8000/game\")\n if err != nil {\n\t\tlog.Fatalln(err) \n\t} else {\n \t\tdefer response.Body.Close()\n contents, err := ioutil.ReadAll(response.Body)\n if err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n fmt.Printf(\"%s\", string(contents))\n }\n}", "func picturesMock(w http.ResponseWriter, r *http.Request) {\n\tjson := `{\"copyright\":\"Amir H. Abolfath\",\"date\":\"2019-12-06\",\"explanation\":\"This frame.\",\"hdurl\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath.jpg\",\"media_type\":\"image\",\"service_version\":\"v1\",\"title\":\"Pleiades to Hyades\",\"url\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath1024.jpg\"}`\n\tw.WriteHeader(200)\n\t_, _ = w.Write([]byte(json))\n}", "func TestPutSlidesSlideSizeInvalidheight(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"height\", r.Code, e)\n}", "func (wrapper *workflowTemplateInterfaceWrapper) Get(name string) (*wfv1.WorkflowTemplate, error) {\n\treturn wrapper.clientset.Get(name, metav1.GetOptions{})\n}", "func (m *WebPartData) GetDescription()(*string) {\n val, err := m.GetBackingStore().Get(\"description\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func TestPostSlidesSplit(t *testing.T) {\n request := createPostSlidesSplitRequest()\n e := initializeTest(\"PostSlidesSplit\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PostSlidesSplit(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestPutSlidesSlideSizeInvalidname(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"name\", r.Code, e)\n}", "func TestNotesSlideShapes(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeCount int32 = 3\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tshapes, _, e := c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewShape()\n\tdto.X = 100\n\tdto.Y = 100\n\tdto.Width = 500\n\tdto.Height = 200\n\tdto.ShapeType = \"Rectangle\"\n\tdto.Text = \"New shape\"\n\tshape, _, e := c.SlidesApi.CreateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", dto, nil, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto.Text = \"Updated shape\"\n\tshape, _, e = c.SlidesApi.UpdateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n}", "func (s *Store) UnsafeGetDefinition(name string) *Definition {\n\ts.mu.RLock()\n\tt := s.tasks[name]\n\ts.mu.RUnlock()\n\treturn t\n}", "func (t *Link) GetUnknownPreview() (v interface{}) {\n\treturn t.preview[0].unknown_\n\n}", "func TestPutSlidesDocumentFromHtml(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesDocumentFromHtml(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (p PostgresqlDialect) Placeholder(index int) string {\n\treturn fmt.Sprintf(\"$%d\", index+1)\n}", "func (t taskInst) getContainer(named string) *ecs.Container {\n\tfor _, c := range t.Containers {\n\t\tif c != nil && ptr.StringValue(c.Name) == named {\n\t\t\treturn c\n\t\t}\n\t}\n\n\treturn nil\n}", "func (test *Test) GetIP(projectName string, ip string) (models.IP, error) {\n\treturn tests.NormalIPs[0], nil\n}", "func TestGetSlidesDocumentWithFormatInvalidformat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.format = invalidizeTestParamValue(request.format, \"format\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"format\", request.format)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"format\", int32(r.StatusCode), e)\n}", "func (m Message) GetPool(f *field.PoolField) quickfix.MessageRejectError {\n\treturn m.Body.Get(f)\n}", "func (m Message) GetPool(f *field.PoolField) quickfix.MessageRejectError {\n\treturn m.Body.Get(f)\n}", "func (m *WebPartData) GetTitle()(*string) {\n val, err := m.GetBackingStore().Get(\"title\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (t *TestBehaviour) RunGetICLATemplateWatermark() {\n\tfrisby.Create(\"Fetch ICLA with no watermark\").\n\t\tGet(t.apiURL + fmt.Sprintf(\"/template/%s/preview?claType=icla\", claGroupID)).\n\t\tSend().\n\t\tExpectStatus(200).\n\t\tAfterText(func(F *frisby.Frisby, text string, err error) {\n\t\t\treader := bytes.NewReader([]byte(text))\n\t\t\tF.Expect(func(F *frisby.Frisby) (bool, string) {\n\t\t\t\tok, err := api.HasWatermarks(reader, &pdfcpu.Configuration{})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, fmt.Errorf(\"error when checking for watermark : %w\", err).Error()\n\t\t\t\t}\n\t\t\t\tif ok {\n\t\t\t\t\treturn false, \"the file already has watermark can't continue with the tests for icla\"\n\t\t\t\t}\n\n\t\t\t\treturn true, \"success getting icla with no watermark\"\n\t\t\t})\n\t\t})\n\n\tfrisby.Create(\"Fetch ICLA with watermark\").\n\t\tGet(t.apiURL + fmt.Sprintf(\"/template/%s/preview?claType=icla&watermark=true\", claGroupID)).\n\t\tSend().\n\t\tExpectStatus(200).\n\t\tAfterText(func(F *frisby.Frisby, text string, err error) {\n\t\t\treader := bytes.NewReader([]byte(text))\n\t\t\tF.Expect(func(F *frisby.Frisby) (bool, string) {\n\t\t\t\tok, err := api.HasWatermarks(reader, &pdfcpu.Configuration{})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, fmt.Errorf(\"error when checking for watermark : %w\", err).Error()\n\t\t\t\t}\n\t\t\t\tif !ok {\n\t\t\t\t\treturn false, \"missing watermark for icla\"\n\t\t\t\t}\n\n\t\t\t\treturn true, \"success getting watermark for icla\"\n\t\t\t})\n\t\t})\n}", "func (m *TemplateParameter) GetDescription()(*string) {\n val, err := m.GetBackingStore().Get(\"description\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (r readOnlyInjections) TryGet(key string) (interface{}, bool) {\n\tv, ok := r.IContainer.data[key]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\tif v.obj != nil {\n\t\treturn v.obj, true\n\t}\n\tif r.threadData != nil {\n\t\tif v, ok := r.threadData[key]; ok {\n\t\t\treturn v, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func findpicture(citytag string, pagenumber int) Photo{\n\tvar p Photo\n\tapi_key := \"f02cd0b3f01902b08393489f9ad04eab\"\n\tstr := fmt.Sprintf(\"https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=%s&tags=%s&has_geo=true&extras=geo&per_page=1&format=json&nojsoncallback=1&page=%d\",api_key, citytag, pagenumber)\n\n\tm, err := apicaller.Callapi(str)\n\tif (err != nil){\n\t\tfmt.Println(err)\n\t\treturn p\n\t}\n\tdecodepicture(m, &p)\n\treturn p\n}", "func getPi(w http.ResponseWriter, r *http.Request) {\n\t// Get pi name from request\n\tvars := mux.Vars(r)\n\tpiname := vars[\"piname\"]\n\n\t// Retrieve pi object from data store\n\tc := appengine.NewContext(r)\n\tq := datastore.NewQuery(piListKind).Filter(\"name =\", piname)\n\tt := q.Run(c)\n\tvar pi Pi\n\t_, err := t.Next(&pi)\n\tif err == datastore.Done {\n\t\thttp.Error(w, \"404 Not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Return JSON representatikon of Pi object\n\tbuffer, _ := json.MarshalIndent(pi, \"\", \" \")\n\tfmt.Fprint(w, string(buffer))\n}", "func (m *ManagementTemplateStep) GetDescription()(*string) {\n val, err := m.GetBackingStore().Get(\"description\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*string)\n }\n return nil\n}", "func (s *optFlagImpl) Placeholder(placeholder string) (opt OptFlag) {\n\ts.working.DefaultValuePlaceholder = placeholder\n\treturn s\n}", "func (o *Command) GetPresentation(rw io.Writer, req io.Reader) command.Error {\n\tvar request IDArg\n\n\terr := json.NewDecoder(req).Decode(&request)\n\tif err != nil {\n\t\tlogutil.LogInfo(logger, CommandName, GetPresentationCommandMethod, err.Error())\n\t\treturn command.NewValidationError(InvalidRequestErrorCode, fmt.Errorf(\"request decode : %w\", err))\n\t}\n\n\tif request.ID == \"\" {\n\t\tlogutil.LogDebug(logger, CommandName, GetPresentationCommandMethod, errEmptyPresentationID)\n\t\treturn command.NewValidationError(InvalidRequestErrorCode, fmt.Errorf(errEmptyPresentationID))\n\t}\n\n\tvp, err := o.verifiableStore.GetPresentation(request.ID)\n\tif err != nil {\n\t\tlogutil.LogError(logger, CommandName, GetPresentationCommandMethod, \"get vp : \"+err.Error(),\n\t\t\tlogutil.CreateKeyValueString(vpID, request.ID))\n\n\t\treturn command.NewValidationError(GetPresentationErrorCode, fmt.Errorf(\"get vp : %w\", err))\n\t}\n\n\tvpBytes, err := vp.MarshalJSON()\n\tif err != nil {\n\t\tlogutil.LogError(logger, CommandName, GetPresentationCommandMethod, \"marshal vp : \"+err.Error(),\n\t\t\tlogutil.CreateKeyValueString(vpID, request.ID))\n\n\t\treturn command.NewValidationError(GetPresentationErrorCode, fmt.Errorf(\"marshal vp : %w\", err))\n\t}\n\n\tcommand.WriteNillableResponse(rw, &Presentation{\n\t\tVerifiablePresentation: vpBytes,\n\t}, logger)\n\n\tlogutil.LogDebug(logger, CommandName, GetPresentationCommandMethod, \"success\",\n\t\tlogutil.CreateKeyValueString(vpID, request.ID))\n\n\treturn nil\n}", "func createStepDescription(containerName string, pod *corev1.Pod) string {\n\tcontainers, _, isInit := kube.GetContainersWithStatusAndIsInit(pod)\n\n\tfor _, c := range containers {\n\t\tcontainer := c\n\t\t_, args := kube.GetCommandAndArgs(&container, isInit)\n\t\tif container.Name == containerName && len(args) > 0 {\n\t\t\tif args[0] == \"-url\" && len(args) > 1 {\n\t\t\t\treturn args[1]\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c *CvpClient) GetContainerByName(query string) (*Container, error) {\n\tgetContainerURL := \"/provisioning/searchTopology.do?queryParam=\" + query + \"&startIndex=0&endIndex=0\"\n\trespbody, err := c.Get(getContainerURL)\n\trespContainer := GetContainer{}\n\terr = json.Unmarshal(respbody, &respContainer)\n\tif err != nil {\n\t\tlog.Printf(\"Error decoding getcontainer :%s\\n\", err)\n\t\treturn nil, err\n\t}\n\tif len(respContainer.ContainerList) == 0 {\n\t\treturn nil, fmt.Errorf(\"No container named \\\"%s\\\" found\", query)\n\t}\n\treturn &respContainer.ContainerList[0], err\n}", "func (i *Interface) GetTitle() string { return i.Title }", "func GetByNameNoRetry(name string) (*machineconfigv1.MachineConfigPool, error) {\n\tmcp := &machineconfigv1.MachineConfigPool{}\n\tkey := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: metav1.NamespaceNone,\n\t}\n\terr := testclient.Client.Get(context.TODO(), key, mcp)\n\treturn mcp, err\n}", "func (s *Service) getExperimentDetail(c *gin.Context) {}", "func (f *TemplateFinder) GetMetadata(template *templatev1.Template, vm *ovirtsdk.Vm) (map[string]string, map[string]string, error) {\n\tos, err := f.osFinder.FindOperatingSystem(vm)\n\tif err != nil {\n\t\treturn map[string]string{}, map[string]string{}, err\n\t}\n\tworkload := getWorkload(vm)\n\tflavor := defaultFlavor\n\tlabels := templates.OSLabelBuilder(&os, &workload, &flavor)\n\n\tkey := fmt.Sprintf(templates.TemplateNameOsAnnotation, os)\n\tannotations := map[string]string{\n\t\tkey: template.GetAnnotations()[key],\n\t}\n\treturn labels, annotations, nil\n}", "func PlaceholderExtension() gval.Language {\n\treturn placeholderExtension\n}", "func (a *SatellitesApiService) ReadPool(ctx _context.Context, cloud string, satellite string, pool string) (Pool, *_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 Pool\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/v1/satellites/{cloud}/{satellite}/{pool}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"cloud\"+\"}\", _neturl.QueryEscape(parameterToString(cloud, \"\")) , -1)\n\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"satellite\"+\"}\", _neturl.QueryEscape(parameterToString(satellite, \"\")) , -1)\n\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"pool\"+\"}\", _neturl.QueryEscape(parameterToString(pool, \"\")) , -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\tif localVarHTTPResponse.StatusCode == 200 {\n\t\t\tvar v Pool\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\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 (d *Dummy) GetDescription() string {\n\treturn d.description\n}", "func (p *Poll) GetMetadata(userID string, permission bool) (*Metadata, error) {\n\tanswers, err := p.getVotedAnswers(userID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Metadata{\n\t\tPollID: p.ID,\n\t\tUserID: userID,\n\t\tAdminPermission: permission,\n\t\tVotedAnswers: answers,\n\t\tSettingPublicAddOption: p.Settings.PublicAddOption,\n\t}, nil\n}", "func (r readOnlyInjections) Get(key string) interface{} {\n\tv, _ := r.TryGet(key)\n\treturn v\n}", "func (s *PicturesService) Get(ctx context.Context, id string) (*Picture, error) {\n\treq, err := s.client.NewGetRequest(fmt.Sprintf(\"%s/%s\", picturesPath, id))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresp, err := s.client.Do(ctx, req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"status code not expected, got:%d\", resp.StatusCode)\n\t}\n\n\tpicture := &Picture{}\n\tif err := json.NewDecoder(resp.Body).Decode(picture); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn picture, nil\n}", "func (t *TestSpec) GetPodMetadata() (map[string]string, error) {\n\tresult := make(map[string]string)\n\tfilter := `{range .items[*]}{@.metadata.name}{\"=\"}{@.status.podIP}{\"\\n\"}{end}`\n\n\tres := t.Kub.Get(helpers.DefaultNamespace, fmt.Sprintf(\"pods -l zgroup=%s\", t.Prefix))\n\tdata, err := res.Filter(filter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, line := range strings.Split(data.String(), \"\\n\") {\n\t\tvals := strings.Split(line, \"=\")\n\t\tif len(vals) == 2 {\n\t\t\tresult[vals[0]] = vals[1]\n\t\t}\n\t}\n\treturn result, nil\n}", "func (e *runtimeInfoService) getFromUnknownRuntime(ctx context.Context, containerId string) (runtime.ContainerMetadata, error) {\n\tfor _, enricher := range e.enrichers {\n\t\tmetadata, err := enricher.Get(ctx, containerId)\n\n\t\tif err == nil {\n\t\t\treturn metadata, nil\n\t\t}\n\t}\n\n\treturn runtime.ContainerMetadata{}, errfmt.Errorf(\"no runtime found for container\")\n}", "func Test_DeviceService_Get_EmptyIP(t *testing.T) {\n\ts := DeviceService{}\n\t_, err := s.Get(\"\")\n\tassert.Error(t, err)\n}", "func getTestFlowStockDelays(e *httpexpect.Expect, t *testing.T) {\n\ttestCases := []testCase{\n\t\tnotLoggedTestCase,\n\t\t{\n\t\t\tToken: testCtx.User.Token,\n\t\t\tStatus: http.StatusOK,\n\t\t\tParam: \"90\",\n\t\t\tBodyContains: []string{`\"FlowStockDelays\"`},\n\t\t},\n\t}\n\n\tf := func(tc testCase) *httpexpect.Response {\n\t\treturn e.GET(\"/api/flow_stock_delays\").WithQuery(\"Days\", tc.Param).\n\t\t\tWithHeader(\"Authorization\", \"Bearer \"+tc.Token).Expect()\n\t}\n\tfor _, r := range chkTestCases(testCases, f, \"GetTestFlowStockDelays\") {\n\t\tt.Error(r)\n\t}\n}", "func ReadyToGlide(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {\n\tfname := p.Get(\"filename\", \"glide.yaml\").(string)\n\tif _, err := os.Stat(fname); err != nil {\n\t\tcwd, _ := os.Getwd()\n\t\treturn false, fmt.Errorf(\"%s is missing from %s\", fname, cwd)\n\t}\n\treturn true, nil\n}", "func (e *runtimeInfoService) getFromKnownRuntime(ctx context.Context, containerId string, containerRuntime runtime.RuntimeId) (runtime.ContainerMetadata, error) {\n\tenricher := e.enrichers[containerRuntime]\n\tif enricher != nil {\n\t\treturn enricher.Get(ctx, containerId)\n\t}\n\treturn runtime.ContainerMetadata{}, errfmt.Errorf(\"unsupported runtime\")\n}" ]
[ "0.7325185", "0.679921", "0.66586685", "0.6514135", "0.6494961", "0.6260296", "0.62142336", "0.60560626", "0.5829638", "0.55940074", "0.5421928", "0.536023", "0.5311861", "0.5275907", "0.52423954", "0.51497036", "0.5075654", "0.49031842", "0.4850704", "0.4837694", "0.47478005", "0.4653557", "0.46355155", "0.45719495", "0.45189244", "0.44691387", "0.4462558", "0.44455364", "0.44374916", "0.4423103", "0.44151175", "0.44074425", "0.4386404", "0.43841404", "0.43601957", "0.43600816", "0.43556172", "0.4347286", "0.43420488", "0.43305486", "0.43005118", "0.42724302", "0.42639196", "0.42629316", "0.42434946", "0.42324957", "0.42226195", "0.42143488", "0.420239", "0.4201248", "0.41887224", "0.41711032", "0.4157892", "0.41419688", "0.41252023", "0.41100615", "0.40987405", "0.4088185", "0.40666333", "0.40655574", "0.4064253", "0.4063569", "0.4046248", "0.40426356", "0.402984", "0.4018601", "0.40170762", "0.40149242", "0.4004128", "0.40003827", "0.39895818", "0.3986191", "0.3986191", "0.39840356", "0.3981323", "0.3970514", "0.39679462", "0.39651084", "0.3958689", "0.3951004", "0.39503342", "0.3948925", "0.39477217", "0.39473596", "0.39454892", "0.39433053", "0.39428777", "0.39341012", "0.3932493", "0.39305732", "0.39270326", "0.3921629", "0.39215124", "0.39201003", "0.3917029", "0.39047337", "0.39028475", "0.39022663", "0.38982946", "0.3897044" ]
0.7779537
0
/ PlaceholdersApiServiceTests Read slide placeholder info. Test for PlaceholdersApi.GetSlidesPlaceholder method with invalid name
func TestGetSlidesPlaceholderInvalidname(t *testing.T) { request := createGetSlidesPlaceholderRequest() request.name = invalidizeTestParamValue(request.name, "name", "string").(string) e := initializeTest("GetSlidesPlaceholder", "name", request.name) if e != nil { t.Errorf("Error: %v.", e) return } r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request) assertError(t, "GetSlidesPlaceholder", "name", r.Code, e) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestGetSlidesPlaceholder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n e := initializeTest(\"GetSlidesPlaceholder\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholder(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholders(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n e := initializeTest(\"GetSlidesPlaceholders\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholders(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholdersInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidplaceholderIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.placeholderIndex = invalidizeTestParamValue(request.placeholderIndex, \"placeholderIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"placeholderIndex\", request.placeholderIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"placeholderIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholders\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"folder\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"password\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"folder\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"password\", r.Code, e)\n}", "func GetPlaceHolders(conf *viper.Viper) Placeholders {\n\tlist := parseMap(conf.AllSettings())\n\n\tproperties := CreateProperties(list)\n\n\treturn Placeholders{properties}\n}", "func TestGetSlidesDocumentInvalidname(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"name\", r.Code, e)\n}", "func TestGetSlidesApiInfo(t *testing.T) {\n e := initializeTest(\"GetSlidesApiInfo\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesApiInfo()\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func GetPlaceHolder(count int) string {\n\tif count > 0 {\n\t\tstr := strings.Repeat(\"?, \", count)\n\t\treturn str[:len(str)-2]\n\t}\n\n\treturn \"\"\n}", "func TestGetSlidesDocumentWithFormatInvalidname(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"name\", int32(r.StatusCode), e)\n}", "func TestNotesSlideGetFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.GetNotesSlide(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func (a *ClinicalMetadataServiceApiService) GetSlide(ctx _context.Context, slideId string) (Ga4ghSlide, *_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 Ga4ghSlide\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/{slide_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"slide_id\"+\"}\", _neturl.QueryEscape(fmt.Sprintf(\"%v\", slideId)), -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\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v Ga4ghSlide\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\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 TestPutSlidesSlideSizeInvalidname(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"name\", r.Code, e)\n}", "func NeedPlaceholder(t string) bool {\n\tswitch t {\n\tcase SecretVariable, KeyVariable, SSHKeyVariable, PGPKeyVariable:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func TestNotesSlideExistsFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.NotesSlideExists(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func (p *Projection) slideName() (string, error) {\n\tparts := strings.Split(p.ContentObjectID, \"/\")\n\tif len(parts) != 2 {\n\t\treturn \"\", fmt.Errorf(\"invalid content_object_id `%s`, expected one '/'\", p.ContentObjectID)\n\t}\n\n\tif p.Type != \"\" && parts[0] == \"meeting\" {\n\t\treturn p.Type, nil\n\t}\n\treturn parts[0], nil\n}", "func TestPutSlidesDocumentFromHtmlInvalidname(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"name\", r.Code, e)\n}", "func TestNotesSlideGetFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.GetNotesSlideOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func Placeholder(w http.ResponseWriter, r *http.Request) {\n\tlog.Debugf(\"Method: %s\", r.Method)\n\tlog.Debugf(\"URL: %s\", r.URL.String())\n\tbodyContents, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(\"Couldn't read the body of the request\"))\n\t}\n\tlog.Debugf(\"Body: %s\", string(bodyContents))\n\tw.WriteHeader(http.StatusNotImplemented)\n}", "func TestGetSlidesDocument(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n e := initializeTest(\"GetSlidesDocument\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocument(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestSlideCommentsGet(t *testing.T) {\n\tvar slideIndex int32 = 1\n\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresponse, _, e := c.SlidesApi.GetSlideComments(fileName, slideIndex, password, folderName, \"\")\n\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tif len(response.GetList()) != 2 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 2, len(response.GetList()))\n\t\treturn\n\t}\n\n\tif len(response.GetList()[0].GetChildComments()) != 1 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 1, len(response.GetList()[0].GetChildComments()))\n\t\treturn\n\t}\n}", "func TestPostSlidesSplitInvalidname(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"name\", r.Code, e)\n}", "func (ref *UIElement) PlaceholderValue() string {\n\tret, _ := ref.StringAttr(PlaceholderValueAttribute)\n\treturn ret\n}", "func TestNotesSlideExistsFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.NotesSlideExistsOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestPanicOnSameParamPlaceholder(t *testing.T) {\n\tdefer func() {\n\t\tv := recover()\n\t\tif v == nil {\n\t\t\tt.Fatalf(\"expected a panic, but nothing happened\")\n\t\t}\n\t}()\n\n\trunTest(t, func(s *Session) {\n\t\ts.Handle(\"model.$id.type.$id\")\n\t}, nil)\n}", "func Placeholder(num int) string {\n\treturn strings.Join(SliceFill(num, \"?\"), \",\")\n}", "func privateDataPlaceholder() string {\n\treturn \"[PRIVATE DATA HIDDEN]\"\n}", "func TestPostSlidesDocumentInvalidname(t *testing.T) {\n request := createPostSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesDocument(request)\n assertError(t, \"PostSlidesDocument\", \"name\", r.Code, e)\n}", "func Placeholder(scope *Scope, dtype tf.DataType, optional ...PlaceholderAttr) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Placeholder\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func TestPutNewPresentationInvalidname(t *testing.T) {\n request := createPutNewPresentationRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutNewPresentation\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutNewPresentation(request)\n assertError(t, \"PutNewPresentation\", \"name\", r.Code, e)\n}", "func TestGetSlidesDocumentInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"storage\", r.Code, e)\n}", "func TestPostSlidesSaveAsInvalidname(t *testing.T) {\n request := createPostSlidesSaveAsRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesSaveAs\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.PostSlidesSaveAs(request)\n assertError(t, \"PostSlidesSaveAs\", \"name\", int32(r.StatusCode), e)\n}", "func GetByNameNoRetry(name string) (*machineconfigv1.MachineConfigPool, error) {\n\tmcp := &machineconfigv1.MachineConfigPool{}\n\tkey := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: metav1.NamespaceNone,\n\t}\n\terr := testclient.Client.Get(context.TODO(), key, mcp)\n\treturn mcp, err\n}", "func TestGetSlidesDocumentWithFormatInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"storage\", int32(r.StatusCode), e)\n}", "func PlaceholderClient(ipaddress string, status string) error {\n\n\tlogit.Info.Println(\"Placeholder called\")\n\tclient, err := rpc.DialHTTP(\"tcp\", ipaddress)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: dialing:\" + err.Error())\n\t\treturn err\n\t}\n\tif client == nil {\n\t\tlogit.Error.Println(\"Placeholder: client was nil\")\n\t\treturn errors.New(\"client was nil from rpc dial\")\n\t}\n\n\tvar command Command\n\n\terr = client.Call(\"Command.Placeholder\", &status, &command)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: error \" + err.Error())\n\t\treturn err\n\t}\n\tlogit.Info.Println(\"status=\" + status)\n\n\treturn nil\n}", "func (a *ClinicalMetadataServiceApiService) SearchSlides(ctx _context.Context, body Ga4ghSearchSlidesRequest) (Ga4ghSearchSlidesResponse, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Ga4ghSearchSlidesResponse\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/search\"\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{\"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 = &body\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 Ga4ghSearchSlidesResponse\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\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 TestGetSlidesDocumentWithFormatInvalidformat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.format = invalidizeTestParamValue(request.format, \"format\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"format\", request.format)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"format\", int32(r.StatusCode), e)\n}", "func TestGetSlidesDocumentWithFormat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocumentWithFormat(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n assertBinaryResponse(r, t)\n}", "func GetQiskitPlayground(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *QiskitPlaygroundState, opts ...pulumi.ResourceOption) (*QiskitPlayground, error) {\n\tvar resource QiskitPlayground\n\terr := ctx.ReadResource(\"kubernetes:singhp11.io/v1:QiskitPlayground\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (d *ceph) getPlaceholderVolume() Volume {\n\treturn NewVolume(d, d.name, VolumeType(\"incus\"), ContentTypeFS, d.config[\"ceph.osd.pool_name\"], nil, nil)\n}", "func (a *SlidesApiService) GetApiInfo() (IApiInfo, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFiles [][]byte\n\t \tsuccessPayload IApiInfo\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.GetApiUrl() + \"/slides/info\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\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{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHttpResponse, responseBytes, err := a.client.makeRequest(nil, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFiles)\n\tresponseBody := bytes.NewReader(responseBytes)\n\tif localVarHttpResponse != nil && localVarHttpResponse.StatusCode >= 300 {\n\t\tvar errorMessage ErrorMessage\n\t\tif err = json.NewDecoder(responseBody).Decode(&errorMessage); err != nil {\n\t\t\treturn successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, reportError(string(responseBytes))\n\t}\n\n\tsuccessPayloadObject, err := createObjectForType(\"ApiInfo\", responseBytes)\n\tif err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif err = json.NewDecoder(responseBody).Decode(successPayloadObject); err != nil {\n\t\tif sp, ok := successPayloadObject.(IApiInfo); ok {\n\t\t\treturn sp, localVarHttpResponse, err\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif successPayload, _ = successPayloadObject.(IApiInfo); true {\n\t}\n\n\treturn successPayload, localVarHttpResponse, err\n}", "func (c *CvpClient) GetContainerByName(query string) (*Container, error) {\n\tgetContainerURL := \"/provisioning/searchTopology.do?queryParam=\" + query + \"&startIndex=0&endIndex=0\"\n\trespbody, err := c.Get(getContainerURL)\n\trespContainer := GetContainer{}\n\terr = json.Unmarshal(respbody, &respContainer)\n\tif err != nil {\n\t\tlog.Printf(\"Error decoding getcontainer :%s\\n\", err)\n\t\treturn nil, err\n\t}\n\tif len(respContainer.ContainerList) == 0 {\n\t\treturn nil, fmt.Errorf(\"No container named \\\"%s\\\" found\", query)\n\t}\n\treturn &respContainer.ContainerList[0], err\n}", "func TestNotesSlidePortions(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphIndex int32 = 1\n\tvar portionCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tportions, _, e := c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewPortion()\n\tdto.Text = \"New portion\"\n\tdto.FontBold = \"True\"\n\tportion, _, e := c.SlidesApi.CreateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\tdto2 := slidescloud.NewPortion()\n\tdto2.Text = \"Updated portion\"\n\tdto2.FontHeight = 22\n\tportion, _, e = c.SlidesApi.UpdateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, dto2, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetFontHeight() != dto2.GetFontHeight() {\n\t\tt.Errorf(\"Wrong portion font height. Expected %v but was %v.\", dto2.GetFontHeight(), portion.GetFontHeight())\n\t\treturn\n\t}\n\tif portion.GetText() != dto2.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto2.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n}", "func TestPutSlidesSlideSize(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n e := initializeTest(\"PutSlidesSlideSize\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesSlideSize(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestNotesSlideDownloadFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadNotesSlide(fileName, 1, \"png\", nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func parsePlaceholder(s string, funcs map[string]interface{}) (p tePlaceholder, err error) {\n\tconst (\n\t\tdot = \".\"\n\t\tinvoke = \"()\"\n\t\tindexLeft = \"[\"\n\t\tindexRight = \"]\"\n\t)\n\n\tif s==\"\"{\n\t\treturn\n\t}\n\n\tstrs := strings.Split(s, pipe)\n\tskipFirst := false\n\tif len(strs[0])>0 && strs[0][0] == 'a' {\n\t\tif i, err := strconvh.ParseInt(strs[0][1:]); err == nil {\n\t\t\tp.argNum = i\n\t\t\tskipFirst = true\n\t\t}\n\t}\n\n\tif skipFirst {\n\t\tstrs = strs[1:]\n\t}\n\n\tfor _, str := range strs {\n\t\tif len(str) == 0 {\n\t\t\terr = errors.New(\"unable to parse empty placeholder in '\" + s + \"'\")\n\t\t\treturn\n\t\t}\n\t\tswitch {\n\t\tcase str == \"*\":\n\t\t\tp.funcs = append(p.funcs, dereferencer{})\n\t\tcase str == \"&\":\n\t\t\tp.funcs = append(p.funcs, addrGetter{})\n\t\tcase strings.HasPrefix(str, dot) && strings.HasSuffix(str, invoke): // Method\n\t\t\tname := str[len(dot) : len(str)-len(invoke)]\n\t\t\tif !IsValidExportedIdent(name) {\n\t\t\t\terr = errors.New(\"invalid method name: '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncMethod(name))\n\t\tcase strings.HasPrefix(str, dot): // Field\n\t\t\tname := str[len(dot):]\n\t\t\tif !IsValidExportedIdent(name) {\n\t\t\t\terr = errors.New(\"invalid field name: '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncGetter(name))\n\t\tcase strings.HasSuffix(str, invoke): // Function\n\t\t\tname := str[:len(str)-len(invoke)]\n\t\t\tf, ok := funcs[name]\n\t\t\tif !ok {\n\t\t\t\terr = errors.New(\"unknown function '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncSimple{f})\n\t\tcase strings.HasPrefix(str, indexLeft) && strings.HasSuffix(str, indexRight): // Access by index\n\t\t\tiStr := str[len(indexLeft) : len(str)-len(indexRight)]\n\t\t\tvar i int\n\t\t\ti, err = strconvh.ParseInt(iStr)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, Index(i))\n\t\tdefault:\n\t\t\terr = errors.New(\"unknown element in placeholder: '\" + str + \"'\")\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func mustGetContainer(g *gomega.WithT, objs *objectSet, deploymentName, containerName string) map[string]interface{} {\n\tobj := objs.kind(\"Deployment\").nameEquals(deploymentName)\n\tg.Expect(obj).Should(gomega.Not(gomega.BeNil()))\n\tcontainer := obj.Container(containerName)\n\tg.Expect(container).Should(gomega.Not(gomega.BeNil()))\n\treturn container\n}", "func (s *Store) UnsafeGetDefinition(name string) *Definition {\n\ts.mu.RLock()\n\tt := s.tasks[name]\n\ts.mu.RUnlock()\n\treturn t\n}", "func GetByName(name string) (*machineconfigv1.MachineConfigPool, error) {\n\tmcp := &machineconfigv1.MachineConfigPool{}\n\tkey := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: metav1.NamespaceNone,\n\t}\n\terr := testclient.GetWithRetry(context.TODO(), key, mcp)\n\treturn mcp, err\n}", "func TestNotesSlideParagraphs(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tparagraphs, _, e := c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n\n\tportion := slidescloud.NewPortion()\n\tportion.Text = \"New Paragraph\"\n\tdto := slidescloud.NewParagraph()\n\tdto.Alignment = \"Right\"\n\tdto.PortionList = []slidescloud.IPortion{portion}\n\tparagraph, _, e := c.SlidesApi.CreateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\tdto = slidescloud.NewParagraph()\n\tdto.Alignment = \"Center\"\n\tparagraph, _, e = c.SlidesApi.UpdateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n}", "func (d *portworx) getRestContainerPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.TargetPort.IntVal, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api target port not found in service\")\n}", "func createStepDescription(containerName string, pod *corev1.Pod) string {\n\tcontainers, _, isInit := kube.GetContainersWithStatusAndIsInit(pod)\n\n\tfor _, c := range containers {\n\t\tcontainer := c\n\t\t_, args := kube.GetCommandAndArgs(&container, isInit)\n\t\tif container.Name == containerName && len(args) > 0 {\n\t\t\tif args[0] == \"-url\" && len(args) > 1 {\n\t\t\t\treturn args[1]\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func picturesMock(w http.ResponseWriter, r *http.Request) {\n\tjson := `{\"copyright\":\"Amir H. Abolfath\",\"date\":\"2019-12-06\",\"explanation\":\"This frame.\",\"hdurl\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath.jpg\",\"media_type\":\"image\",\"service_version\":\"v1\",\"title\":\"Pleiades to Hyades\",\"url\":\"https://apod.nasa.gov/apod/image/1912/TaurusAbolfath1024.jpg\"}`\n\tw.WriteHeader(200)\n\t_, _ = w.Write([]byte(json))\n}", "func GetEntryFromPlaceholder(ctx context.Context, r repo.Repository, defp snapshot.HasDirEntryOrNil) (fs.Entry, error) {\n\tde, err := defp.DirEntryOrNil(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to get direntry from placeholder\")\n\t}\n\n\trepoFSLog(ctx).Debugf(\"GetDirEntryFromPlaceholder %v %v \", r, de)\n\n\treturn EntryFromDirEntry(r, de), nil\n}", "func getLabels(\n docker *client.Client,\n containerId string) (labels map[string]string, err error) {\n\n inspect, err := docker.ContainerInspect(context.Background(), containerId)\n if err != nil {\n return\n }\n\n labels = inspect.Config.Labels\n return\n}", "func TestPutSlidesSlideSizeInvalidheight(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"height\", r.Code, e)\n}", "func (p PostgresqlDialect) Placeholder(index int) string {\n\treturn fmt.Sprintf(\"$%d\", index+1)\n}", "func replaceKeptnPlaceholders(input string, event adapter.EventContentAdapter) string {\n\tresult := input\n\n\t// first we do the regular keptn values\n\tresult = strings.Replace(result, \"$CONTEXT\", event.GetShKeptnContext(), -1)\n\tresult = strings.Replace(result, \"$EVENT\", event.GetEvent(), -1)\n\tresult = strings.Replace(result, \"$SOURCE\", event.GetSource(), -1)\n\tresult = strings.Replace(result, \"$PROJECT\", event.GetProject(), -1)\n\tresult = strings.Replace(result, \"$STAGE\", event.GetStage(), -1)\n\tresult = strings.Replace(result, \"$SERVICE\", event.GetService(), -1)\n\tresult = strings.Replace(result, \"$DEPLOYMENT\", event.GetDeployment(), -1)\n\tresult = strings.Replace(result, \"$TESTSTRATEGY\", event.GetTestStrategy(), -1)\n\n\t// now we do the labels\n\tfor key, value := range event.GetLabels() {\n\t\tresult = strings.Replace(result, \"$LABEL.\"+key, value, -1)\n\t}\n\n\t// now we do all environment variables\n\tfor _, env := range os.Environ() {\n\t\tpair := strings.SplitN(env, \"=\", 2)\n\t\tresult = strings.Replace(result, \"$ENV.\"+pair[0], pair[1], -1)\n\t}\n\n\t// TODO: iterate through k8s secrets!\n\n\treturn result\n}", "func (t taskInst) getContainer(named string) *ecs.Container {\n\tfor _, c := range t.Containers {\n\t\tif c != nil && ptr.StringValue(c.Name) == named {\n\t\t\treturn c\n\t\t}\n\t}\n\n\treturn nil\n}", "func PlaceholderExtension() gval.Language {\n\treturn placeholderExtension\n}", "func TestGetQuestion() {\n\tresponse, err := http.Get(\"http://localhost:8000/game\")\n if err != nil {\n\t\tlog.Fatalln(err) \n\t} else {\n \t\tdefer response.Body.Close()\n contents, err := ioutil.ReadAll(response.Body)\n if err != nil {\n\t\t\tlog.Fatalln(err)\n\t\t}\n fmt.Printf(\"%s\", string(contents))\n }\n}", "func TestPostSlidesDocumentInvalidtemplateStorage(t *testing.T) {\n request := createPostSlidesDocumentRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PostSlidesDocument\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesDocument(request)\n assertError(t, \"PostSlidesDocument\", \"templateStorage\", r.Code, e)\n}", "func (m Model) placeholderView() string {\n\tvar (\n\t\tv string\n\t\tp = m.Placeholder\n\t\tstyle = m.PlaceholderStyle.Inline(true).Render\n\t)\n\n\t// Cursor\n\tif m.blink {\n\t\tv += m.cursorView(style(p[:1]))\n\t} else {\n\t\tv += m.cursorView(p[:1])\n\t}\n\n\t// The rest of the placeholder text\n\tv += style(p[1:])\n\n\treturn m.PromptStyle.Render(m.Prompt) + v\n}", "func getTestFlowStockDelays(e *httpexpect.Expect, t *testing.T) {\n\ttestCases := []testCase{\n\t\tnotLoggedTestCase,\n\t\t{\n\t\t\tToken: testCtx.User.Token,\n\t\t\tStatus: http.StatusOK,\n\t\t\tParam: \"90\",\n\t\t\tBodyContains: []string{`\"FlowStockDelays\"`},\n\t\t},\n\t}\n\n\tf := func(tc testCase) *httpexpect.Response {\n\t\treturn e.GET(\"/api/flow_stock_delays\").WithQuery(\"Days\", tc.Param).\n\t\t\tWithHeader(\"Authorization\", \"Bearer \"+tc.Token).Expect()\n\t}\n\tfor _, r := range chkTestCases(testCases, f, \"GetTestFlowStockDelays\") {\n\t\tt.Error(r)\n\t}\n}", "func TestPostSlidesSplit(t *testing.T) {\n request := createPostSlidesSplitRequest()\n e := initializeTest(\"PostSlidesSplit\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PostSlidesSplit(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (v *Values) GetMetadata(stepName string) interface{} {\n\treturn v.getStepData(stepName, MetadataKey)\n}", "func TestNotesSlideShapes(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeCount int32 = 3\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tshapes, _, e := c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewShape()\n\tdto.X = 100\n\tdto.Y = 100\n\tdto.Width = 500\n\tdto.Height = 200\n\tdto.ShapeType = \"Rectangle\"\n\tdto.Text = \"New shape\"\n\tshape, _, e := c.SlidesApi.CreateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", dto, nil, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto.Text = \"Updated shape\"\n\tshape, _, e = c.SlidesApi.UpdateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n}", "func getWrappedPlaceholder(fieldType int, arg string) string {\n\tif fieldType == String {\n\t\treturn \"'\" + arg + \"'\"\n\t} else {\n\t\treturn arg\n\t}\n}", "func TestGetSlidesDocumentInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"folder\", r.Code, e)\n}", "func TestGetSlidesDocumentWithFormatInvalidjpegQuality(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.jpegQuality = invalidizeTestParamValue(request.jpegQuality, \"jpegQuality\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"jpegQuality\", request.jpegQuality)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"jpegQuality\", int32(r.StatusCode), e)\n}", "func (stc *STemplatesController) Info() (*srv_tmpl.Pool, error) {\n\tresponse, err := stc.c.ClientFlow.HTTPMethod(\"GET\", endpointFTemplate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !response.status {\n\t\treturn nil, errors.New(response.body)\n\t}\n\n\tstemplatepool := &srv_tmpl.Pool{}\n\tpool_str, err := json.Marshal(response.BodyMap()[\"DOCUMENT_POOL\"])\n\terr = json.Unmarshal([]byte(pool_str), stemplatepool)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn stemplatepool, err\n}", "func (g *sqliteGrammar) Placeholder(n int) string {\n\tif n < 0 {\n\t\tpanic(\"qb: negative Placeholder count\")\n\t}\n\tif n == 0 {\n\t\treturn \"\"\n\t}\n\tif n == 1 {\n\t\treturn \"?\"\n\t}\n\n\tvar (\n\t\tp = \", ?\"\n\t\tb = make([]byte, len(p)*n)\n\t\tw = copy(b, p)\n\t)\n\n\tfor w < len(b) {\n\t\tcopy(b[w:], b[:w])\n\t\tw *= 2\n\t}\n\tif len(b) >= len(p) {\n\t\tb = b[2:]\n\t}\n\n\treturn *(*string)(unsafe.Pointer(&b))\n}", "func (s *optFlagImpl) Placeholder(placeholder string) (opt OptFlag) {\n\ts.working.DefaultValuePlaceholder = placeholder\n\treturn s\n}", "func PlaceholderV2(scope *Scope, dtype tf.DataType, shape tf.Shape) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype, \"shape\": shape}\n\topspec := tf.OpSpec{\n\t\tType: \"PlaceholderV2\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func (u *User) GetBotInlinePlaceholder() (value string, ok bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\tif !u.Flags.Has(19) {\n\t\treturn value, false\n\t}\n\treturn u.BotInlinePlaceholder, true\n}", "func TestPutSlidesSlideSizeInvalidstorage(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"storage\", r.Code, e)\n}", "func (i InjectWrapper) MustGetNamedObject(sample interface{}, name string) interface{} {\n\tsampleType := reflect.TypeOf(sample)\n\tif sampleType.Kind() != reflect.Ptr {\n\t\tpanic(fmt.Sprintf(\"Sample must be interface, found %T\", sample))\n\t}\n\tfor _, obj := range i.objects {\n\t\tif reflect.TypeOf(obj.Value) == sampleType && obj.Name == name {\n\t\t\treturn obj.Value\n\t\t}\n\t}\n\tpanic(fmt.Sprintf(\"Object not found: %s.%T\", name, sample))\n}", "func getRequiredVariables() map[string]interface{} {\n\tvariables := map[string]interface{}{\n\t\t\"competition\": competitionName,\n\t\t\"secret_name\": kaggleApiSecret,\n\t}\n\treturn variables\n}", "func TestPutSlidesDocumentFromHtmlInvalidstorage(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"storage\", r.Code, e)\n}", "func TestPostSlidesSplitInvalidstorage(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"storage\", r.Code, e)\n}", "func TestPutSlidesDocumentFromHtml(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesDocumentFromHtml(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestPutNewPresentationInvalidtemplateStorage(t *testing.T) {\n request := createPutNewPresentationRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PutNewPresentation\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutNewPresentation(request)\n assertError(t, \"PutNewPresentation\", \"templateStorage\", r.Code, e)\n}", "func TestGetSlidesDocumentWithFormatInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"folder\", int32(r.StatusCode), e)\n}", "func (e *runtimeInfoService) getFromUnknownRuntime(ctx context.Context, containerId string) (runtime.ContainerMetadata, error) {\n\tfor _, enricher := range e.enrichers {\n\t\tmetadata, err := enricher.Get(ctx, containerId)\n\n\t\tif err == nil {\n\t\t\treturn metadata, nil\n\t\t}\n\t}\n\n\treturn runtime.ContainerMetadata{}, errfmt.Errorf(\"no runtime found for container\")\n}", "func Test_DeviceService_Get_EmptyIP(t *testing.T) {\n\ts := DeviceService{}\n\t_, err := s.Get(\"\")\n\tassert.Error(t, err)\n}", "func (p Dialect) Placeholder(idx int) string { return \"$\" + strconv.Itoa(idx+1) }", "func replaceKeptnPlaceholders(input string, keptnEvent BaseKeptnEvent) string {\n\tresult := input\n\n\t// first we do the regular keptn values\n\tresult = strings.Replace(result, \"$TIMESTRING\", keptnEvent.time, -1)\n\tresult = strings.Replace(result, \"$TIMEUTCSTRING\", keptnEvent.timeutc, -1)\n\tresult = strings.Replace(result, \"$TIMEUTCMS\", keptnEvent.timeutcms, -1)\n\n\tresult = strings.Replace(result, \"$CONTEXT\", keptnEvent.context, -1)\n\tresult = strings.Replace(result, \"$EVENT\", keptnEvent.event, -1)\n\tresult = strings.Replace(result, \"$SOURCE\", keptnEvent.source, -1)\n\n\tresult = strings.Replace(result, \"$PROJECT\", keptnEvent.project, -1)\n\tresult = strings.Replace(result, \"$STAGE\", keptnEvent.stage, -1)\n\tresult = strings.Replace(result, \"$SERVICE\", keptnEvent.service, -1)\n\tresult = strings.Replace(result, \"$DEPLOYMENT\", keptnEvent.deployment, -1)\n\tresult = strings.Replace(result, \"$TESTSTRATEGY\", keptnEvent.testStrategy, -1)\n\n\tresult = strings.Replace(result, \"$DEPLOYMENTURILOCAL\", keptnEvent.deploymentURILocal, -1)\n\tresult = strings.Replace(result, \"$DEPLOYMENTURIPUBLIC\", keptnEvent.deploymentURIPublic, -1)\n\n\tresult = strings.Replace(result, \"$ACTION\", keptnEvent.action, -1)\n\n\tresult = strings.Replace(result, \"$PROBLEMID\", keptnEvent.problemID, -1)\n\tresult = strings.Replace(result, \"$PROBLEMSTATE\", keptnEvent.problemState, -1)\n\tresult = strings.Replace(result, \"$PID\", keptnEvent.pid, -1)\n\tresult = strings.Replace(result, \"$PROBLEMTITLE\", keptnEvent.problemTitle, -1)\n\tresult = strings.Replace(result, \"$PROBLEMURL\", keptnEvent.problemURL, -1)\n\n\t// now we do the labels\n\tfor key, value := range keptnEvent.labels {\n\t\tresult = strings.Replace(result, \"$LABEL_\"+strings.ToUpper(key), value, -1)\n\t}\n\n\t// now we do the remediation values\n\tfor remediationKey, remediationValue := range keptnEvent.remediationValues {\n\t\tresult = strings.Replace(result, \"$VALUE_\"+strings.ToUpper(remediationKey), remediationValue, -1)\n\t}\n\n\t// now we do all environment variables\n\tfor _, env := range os.Environ() {\n\t\tpair := strings.SplitN(env, \"=\", 2)\n\t\tresult = strings.Replace(result, \"$ENV_\"+strings.ToUpper(pair[0]), pair[1], -1)\n\t}\n\n\t// TODO: iterate through k8s secrets!\n\n\treturn result\n}", "func TestPostSlidesSplitInvalidheight(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PostSlidesSplit\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"height\", r.Code, e)\n}", "func TestConvertSlidePostFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadSlide(fileName, 1, \"pdf\", nil, nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func (wrapper *workflowTemplateInterfaceWrapper) Get(name string) (*wfv1.WorkflowTemplate, error) {\n\treturn wrapper.clientset.Get(name, metav1.GetOptions{})\n}", "func TestAzureDevOpsServiceEndpointDockerRegistry_Read_DoesNotSwallowError(t *testing.T) {\n\tctrl := gomock.NewController(t)\n\tdefer ctrl.Finish()\n\n\tr := resourceServiceEndpointDockerRegistry()\n\tresourceData := schema.TestResourceDataRaw(t, r.Schema, nil)\n\tflattenServiceEndpointDockerRegistry(resourceData, &dockerRegistryTestServiceEndpoint, dockerRegistryTestServiceEndpointProjectID)\n\n\tbuildClient := azdosdkmocks.NewMockServiceendpointClient(ctrl)\n\tclients := &config.AggregatedClient{ServiceEndpointClient: buildClient, Ctx: context.Background()}\n\n\texpectedArgs := serviceendpoint.GetServiceEndpointDetailsArgs{EndpointId: dockerRegistryTestServiceEndpoint.Id, Project: dockerRegistryTestServiceEndpointProjectID}\n\tbuildClient.\n\t\tEXPECT().\n\t\tGetServiceEndpointDetails(clients.Ctx, expectedArgs).\n\t\tReturn(nil, errors.New(\"GetServiceEndpoint() Failed\")).\n\t\tTimes(1)\n\n\terr := r.Read(resourceData, clients)\n\trequire.Contains(t, err.Error(), \"GetServiceEndpoint() Failed\")\n}", "func getAlmExample(almExamples []map[string]interface{}, crd, operator string) (map[string]interface{}, error) {\n\tfor _, example := range almExamples {\n\t\tif example[\"kind\"].(string) == crd {\n\t\t\treturn example, nil\n\t\t}\n\t}\n\treturn nil, errors.Errorf(\"could not find example yaml definition for %q service in %q Operator's definition.\", crd, operator)\n}", "func TestPutSlidesSlideSizeInvalidwidth(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.width = invalidizeTestParamValue(request.width, \"width\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"width\", request.width)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"width\", r.Code, e)\n}" ]
[ "0.7901926", "0.74805623", "0.7233861", "0.71421075", "0.7117637", "0.6880689", "0.6629213", "0.64757365", "0.6033508", "0.58257645", "0.5821665", "0.56473374", "0.56432563", "0.5346573", "0.53247285", "0.51859546", "0.5177103", "0.50451505", "0.5012712", "0.49621698", "0.49007854", "0.48683858", "0.4843727", "0.4815708", "0.48067656", "0.47852537", "0.4768823", "0.47418767", "0.47311497", "0.47152832", "0.46929806", "0.46777", "0.465143", "0.46300793", "0.4602465", "0.46021187", "0.45975584", "0.45801345", "0.4538289", "0.45257702", "0.45069742", "0.44938514", "0.4491214", "0.44415894", "0.44373354", "0.44168073", "0.44016135", "0.43978202", "0.43846902", "0.43739098", "0.43557727", "0.43366966", "0.43350115", "0.43077272", "0.42935243", "0.428518", "0.428403", "0.42754468", "0.42731366", "0.42554086", "0.42467734", "0.4242759", "0.4241337", "0.4238174", "0.4235645", "0.42189258", "0.42109072", "0.41984898", "0.41980717", "0.41975012", "0.41899738", "0.41692966", "0.41664293", "0.41634053", "0.41565654", "0.41518486", "0.4140752", "0.41393718", "0.4132979", "0.4131885", "0.41316053", "0.41284806", "0.41281027", "0.41191337", "0.41130343", "0.4106408", "0.41054478", "0.40836525", "0.40831903", "0.40677866", "0.40671802", "0.40626228", "0.4059869", "0.4058565", "0.4049471", "0.40472254", "0.40470135", "0.40355805", "0.40320137", "0.40289387" ]
0.74381477
2
/ PlaceholdersApiServiceTests Read slide placeholder info. Test for PlaceholdersApi.GetSlidesPlaceholder method with invalid slideIndex
func TestGetSlidesPlaceholderInvalidslideIndex(t *testing.T) { request := createGetSlidesPlaceholderRequest() request.slideIndex = invalidizeTestParamValue(request.slideIndex, "slideIndex", "int32").(int32) e := initializeTest("GetSlidesPlaceholder", "slideIndex", request.slideIndex) if e != nil { t.Errorf("Error: %v.", e) return } r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request) assertError(t, "GetSlidesPlaceholder", "slideIndex", r.Code, e) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestGetSlidesPlaceholderInvalidplaceholderIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.placeholderIndex = invalidizeTestParamValue(request.placeholderIndex, \"placeholderIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"placeholderIndex\", request.placeholderIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"placeholderIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholders\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n e := initializeTest(\"GetSlidesPlaceholder\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholder(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholders(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n e := initializeTest(\"GetSlidesPlaceholders\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholders(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholderInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"folder\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"password\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"folder\", r.Code, e)\n}", "func GetPlaceHolders(conf *viper.Viper) Placeholders {\n\tlist := parseMap(conf.AllSettings())\n\n\tproperties := CreateProperties(list)\n\n\treturn Placeholders{properties}\n}", "func TestGetSlidesPlaceholdersInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"password\", r.Code, e)\n}", "func GetPlaceHolder(count int) string {\n\tif count > 0 {\n\t\tstr := strings.Repeat(\"?, \", count)\n\t\treturn str[:len(str)-2]\n\t}\n\n\treturn \"\"\n}", "func TestGetSlidesApiInfo(t *testing.T) {\n e := initializeTest(\"GetSlidesApiInfo\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesApiInfo()\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (a *ClinicalMetadataServiceApiService) GetSlide(ctx _context.Context, slideId string) (Ga4ghSlide, *_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 Ga4ghSlide\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/{slide_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"slide_id\"+\"}\", _neturl.QueryEscape(fmt.Sprintf(\"%v\", slideId)), -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\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v Ga4ghSlide\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\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 TestNotesSlideGetFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.GetNotesSlide(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func TestSlideCommentsGet(t *testing.T) {\n\tvar slideIndex int32 = 1\n\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresponse, _, e := c.SlidesApi.GetSlideComments(fileName, slideIndex, password, folderName, \"\")\n\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tif len(response.GetList()) != 2 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 2, len(response.GetList()))\n\t\treturn\n\t}\n\n\tif len(response.GetList()[0].GetChildComments()) != 1 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 1, len(response.GetList()[0].GetChildComments()))\n\t\treturn\n\t}\n}", "func TestNotesSlideExistsFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.NotesSlideExists(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestGetSlidesDocumentInvalidname(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"name\", r.Code, e)\n}", "func (p PostgresqlDialect) Placeholder(index int) string {\n\treturn fmt.Sprintf(\"$%d\", index+1)\n}", "func TestGetSlidesDocument(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n e := initializeTest(\"GetSlidesDocument\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocument(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func Placeholder(num int) string {\n\treturn strings.Join(SliceFill(num, \"?\"), \",\")\n}", "func TestGetSlidesDocumentWithFormatInvalidname(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"name\", int32(r.StatusCode), e)\n}", "func (p *Projection) slideName() (string, error) {\n\tparts := strings.Split(p.ContentObjectID, \"/\")\n\tif len(parts) != 2 {\n\t\treturn \"\", fmt.Errorf(\"invalid content_object_id `%s`, expected one '/'\", p.ContentObjectID)\n\t}\n\n\tif p.Type != \"\" && parts[0] == \"meeting\" {\n\t\treturn p.Type, nil\n\t}\n\treturn parts[0], nil\n}", "func (s *System) GetCachedSlide(affirmationIndex, winWidth, winHeight int) (pixbuf *gdk.Pixbuf, found bool) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\t// Clear the cache if our window size has changed.\n\ts.clearSlideCacheIfNecessary(winWidth, winHeight)\n\n\t// Get the cached value.\n\tpixbuf, found = s.cachedSlides[affirmationIndex]\n\tif !found {\n\t\treturn nil, false\n\t}\n\n\treturn pixbuf, true\n}", "func TestNotesSlideGetFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.GetNotesSlideOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func (ref *UIElement) PlaceholderValue() string {\n\tret, _ := ref.StringAttr(PlaceholderValueAttribute)\n\treturn ret\n}", "func TestGetSlidesDocumentInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"storage\", r.Code, e)\n}", "func TestNotesSlideExistsFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.NotesSlideExistsOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestGetSlidesDocumentWithFormatInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"storage\", int32(r.StatusCode), e)\n}", "func (p Dialect) Placeholder(idx int) string { return \"$\" + strconv.Itoa(idx+1) }", "func TestGetSlidesDocumentWithFormatInvalidformat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.format = invalidizeTestParamValue(request.format, \"format\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"format\", request.format)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"format\", int32(r.StatusCode), e)\n}", "func TestPutSlidesSlideSizeInvalidname(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"name\", r.Code, e)\n}", "func TestNotesSlidePortions(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphIndex int32 = 1\n\tvar portionCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tportions, _, e := c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewPortion()\n\tdto.Text = \"New portion\"\n\tdto.FontBold = \"True\"\n\tportion, _, e := c.SlidesApi.CreateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\tdto2 := slidescloud.NewPortion()\n\tdto2.Text = \"Updated portion\"\n\tdto2.FontHeight = 22\n\tportion, _, e = c.SlidesApi.UpdateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, dto2, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetFontHeight() != dto2.GetFontHeight() {\n\t\tt.Errorf(\"Wrong portion font height. Expected %v but was %v.\", dto2.GetFontHeight(), portion.GetFontHeight())\n\t\treturn\n\t}\n\tif portion.GetText() != dto2.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto2.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n}", "func (d *portworx) getRestContainerPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.TargetPort.IntVal, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api target port not found in service\")\n}", "func TestNotesSlideParagraphs(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tparagraphs, _, e := c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n\n\tportion := slidescloud.NewPortion()\n\tportion.Text = \"New Paragraph\"\n\tdto := slidescloud.NewParagraph()\n\tdto.Alignment = \"Right\"\n\tdto.PortionList = []slidescloud.IPortion{portion}\n\tparagraph, _, e := c.SlidesApi.CreateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\tdto = slidescloud.NewParagraph()\n\tdto.Alignment = \"Center\"\n\tparagraph, _, e = c.SlidesApi.UpdateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n}", "func TestPanicOnSameParamPlaceholder(t *testing.T) {\n\tdefer func() {\n\t\tv := recover()\n\t\tif v == nil {\n\t\t\tt.Fatalf(\"expected a panic, but nothing happened\")\n\t\t}\n\t}()\n\n\trunTest(t, func(s *Session) {\n\t\ts.Handle(\"model.$id.type.$id\")\n\t}, nil)\n}", "func TestPutSlidesSlideSize(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n e := initializeTest(\"PutSlidesSlideSize\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesSlideSize(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (g *sqliteGrammar) Placeholder(n int) string {\n\tif n < 0 {\n\t\tpanic(\"qb: negative Placeholder count\")\n\t}\n\tif n == 0 {\n\t\treturn \"\"\n\t}\n\tif n == 1 {\n\t\treturn \"?\"\n\t}\n\n\tvar (\n\t\tp = \", ?\"\n\t\tb = make([]byte, len(p)*n)\n\t\tw = copy(b, p)\n\t)\n\n\tfor w < len(b) {\n\t\tcopy(b[w:], b[:w])\n\t\tw *= 2\n\t}\n\tif len(b) >= len(p) {\n\t\tb = b[2:]\n\t}\n\n\treturn *(*string)(unsafe.Pointer(&b))\n}", "func DisablesTestReadIndexTask_IgnoreHiddenPics(t *testing.T) {\n\tc := Container(t)\n\tdefer c.Close()\n\n\tu := c.CreateUser()\n\tu.User.Capability = append(u.User.Capability, schema.User_PIC_INDEX)\n\tu.Update()\n\n\tp1 := c.CreatePic()\n\tp3 := c.CreatePic()\n\t// A hard deletion\n\tp3.Pic.DeletionStatus = &schema.Pic_DeletionStatus{\n\t\tActualDeletedTs: schema.ToTs(time.Now()),\n\t}\n\tp3.Update()\n\n\ttask := ReadIndexPicsTask{\n\t\tDB: c.DB(),\n\t\tCtx: CtxFromUserID(context.Background(), u.User.UserId),\n\t}\n\n\tif err := task.Run(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif len(task.Pics) != 1 || !proto.Equal(p1.Pic, task.Pics[0]) {\n\t\tt.Fatalf(\"Unable to find %s in\\n %s\", p1, task.Pics)\n\t}\n}", "func NeedPlaceholder(t string) bool {\n\tswitch t {\n\tcase SecretVariable, KeyVariable, SSHKeyVariable, PGPKeyVariable:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func TestPutSlidesSlideSizeInvalidheight(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"height\", r.Code, e)\n}", "func Placeholder(w http.ResponseWriter, r *http.Request) {\n\tlog.Debugf(\"Method: %s\", r.Method)\n\tlog.Debugf(\"URL: %s\", r.URL.String())\n\tbodyContents, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(\"Couldn't read the body of the request\"))\n\t}\n\tlog.Debugf(\"Body: %s\", string(bodyContents))\n\tw.WriteHeader(http.StatusNotImplemented)\n}", "func (test *Test) GetIP(projectName string, ip string) (models.IP, error) {\n\treturn tests.NormalIPs[0], nil\n}", "func (a *ClinicalMetadataServiceApiService) SearchSlides(ctx _context.Context, body Ga4ghSearchSlidesRequest) (Ga4ghSearchSlidesResponse, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Ga4ghSearchSlidesResponse\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/search\"\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{\"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 = &body\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 Ga4ghSearchSlidesResponse\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\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 privateDataPlaceholder() string {\n\treturn \"[PRIVATE DATA HIDDEN]\"\n}", "func TestGetSlidesDocumentWithFormat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocumentWithFormat(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n assertBinaryResponse(r, t)\n}", "func Placeholder(scope *Scope, dtype tf.DataType, optional ...PlaceholderAttr) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Placeholder\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func TestPostSlidesDocumentInvalidtemplateStorage(t *testing.T) {\n request := createPostSlidesDocumentRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PostSlidesDocument\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesDocument(request)\n assertError(t, \"PostSlidesDocument\", \"templateStorage\", r.Code, e)\n}", "func TestPutSlidesDocumentFromHtmlInvalidname(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"name\", r.Code, e)\n}", "func (s *Store) UnsafeGetDefinition(name string) *Definition {\n\ts.mu.RLock()\n\tt := s.tasks[name]\n\ts.mu.RUnlock()\n\treturn t\n}", "func TestGetSlidesDocumentWithFormatInvalidjpegQuality(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.jpegQuality = invalidizeTestParamValue(request.jpegQuality, \"jpegQuality\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"jpegQuality\", request.jpegQuality)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"jpegQuality\", int32(r.StatusCode), e)\n}", "func TestNotesSlideDownloadFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadNotesSlide(fileName, 1, \"png\", nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func TestPutSlidesSlideSizeInvalidwidth(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.width = invalidizeTestParamValue(request.width, \"width\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"width\", request.width)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"width\", r.Code, e)\n}", "func TestPostSlidesSplitInvalidheight(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PostSlidesSplit\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"height\", r.Code, e)\n}", "func PlaceholderClient(ipaddress string, status string) error {\n\n\tlogit.Info.Println(\"Placeholder called\")\n\tclient, err := rpc.DialHTTP(\"tcp\", ipaddress)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: dialing:\" + err.Error())\n\t\treturn err\n\t}\n\tif client == nil {\n\t\tlogit.Error.Println(\"Placeholder: client was nil\")\n\t\treturn errors.New(\"client was nil from rpc dial\")\n\t}\n\n\tvar command Command\n\n\terr = client.Call(\"Command.Placeholder\", &status, &command)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: error \" + err.Error())\n\t\treturn err\n\t}\n\tlogit.Info.Println(\"status=\" + status)\n\n\treturn nil\n}", "func TestPutSlidesSlideSizeInvalidstorage(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"storage\", r.Code, e)\n}", "func (a *SlidesApiService) GetApiInfo() (IApiInfo, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFiles [][]byte\n\t \tsuccessPayload IApiInfo\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.GetApiUrl() + \"/slides/info\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\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{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHttpResponse, responseBytes, err := a.client.makeRequest(nil, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFiles)\n\tresponseBody := bytes.NewReader(responseBytes)\n\tif localVarHttpResponse != nil && localVarHttpResponse.StatusCode >= 300 {\n\t\tvar errorMessage ErrorMessage\n\t\tif err = json.NewDecoder(responseBody).Decode(&errorMessage); err != nil {\n\t\t\treturn successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, reportError(string(responseBytes))\n\t}\n\n\tsuccessPayloadObject, err := createObjectForType(\"ApiInfo\", responseBytes)\n\tif err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif err = json.NewDecoder(responseBody).Decode(successPayloadObject); err != nil {\n\t\tif sp, ok := successPayloadObject.(IApiInfo); ok {\n\t\t\treturn sp, localVarHttpResponse, err\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif successPayload, _ = successPayloadObject.(IApiInfo); true {\n\t}\n\n\treturn successPayload, localVarHttpResponse, err\n}", "func TestGetSlidesDocumentInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"folder\", r.Code, e)\n}", "func GetQiskitPlayground(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *QiskitPlaygroundState, opts ...pulumi.ResourceOption) (*QiskitPlayground, error) {\n\tvar resource QiskitPlayground\n\terr := ctx.ReadResource(\"kubernetes:singhp11.io/v1:QiskitPlayground\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (u *User) GetBotInlinePlaceholder() (value string, ok bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\tif !u.Flags.Has(19) {\n\t\treturn value, false\n\t}\n\treturn u.BotInlinePlaceholder, true\n}", "func TestPutNewPresentationInvalidtemplateStorage(t *testing.T) {\n request := createPutNewPresentationRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PutNewPresentation\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutNewPresentation(request)\n assertError(t, \"PutNewPresentation\", \"templateStorage\", r.Code, e)\n}", "func (s *EmptyStore) IgnitionGet(id string) (string, error) {\n\treturn \"\", fmt.Errorf(\"no Ignition Config %s\", id)\n}", "func TestPostSlidesSplitInvalidname(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"name\", r.Code, e)\n}", "func (gdt *Vector3) Slide(n Vector3) Vector3 {\n\targ0 := gdt.getBase()\n\targ1 := n.getBase()\n\n\tret := C.go_godot_vector3_slide(GDNative.api, arg0, arg1)\n\n\treturn Vector3{base: &ret}\n\n}", "func (m Model) placeholderView() string {\n\tvar (\n\t\tv string\n\t\tp = m.Placeholder\n\t\tstyle = m.PlaceholderStyle.Inline(true).Render\n\t)\n\n\t// Cursor\n\tif m.blink {\n\t\tv += m.cursorView(style(p[:1]))\n\t} else {\n\t\tv += m.cursorView(p[:1])\n\t}\n\n\t// The rest of the placeholder text\n\tv += style(p[1:])\n\n\treturn m.PromptStyle.Render(m.Prompt) + v\n}", "func TestPostSlidesSplit(t *testing.T) {\n request := createPostSlidesSplitRequest()\n e := initializeTest(\"PostSlidesSplit\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PostSlidesSplit(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (d *portworx) getRestPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.Port, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api port not found in service\")\n}", "func TestCheckRequiredTemplate_Read_DoesNotSwallowError(t *testing.T) {\n\tctrl := gomock.NewController(t)\n\tdefer ctrl.Finish()\n\n\tr := ResourceCheckRequiredTemplate()\n\tresourceData := schema.TestResourceDataRaw(t, r.Schema, nil)\n\tflattenErr := flattenCheckRequiredTemplate(resourceData, &requiredTemplateCheckTest, requiredTemplateCheckProjectID)\n\n\tpipelinesChecksClient := azdosdkmocks.NewMockPipelineschecksextrasClient(ctrl)\n\tclients := &client.AggregatedClient{PipelinesChecksClientExtras: pipelinesChecksClient, Ctx: context.Background()}\n\n\texpectedArgs := pipelineschecksextras.GetCheckConfigurationArgs{\n\t\tId: requiredTemplateCheckTest.Id,\n\t\tProject: &requiredTemplateCheckProjectID,\n\t\tExpand: converter.ToPtr(pipelineschecksextras.CheckConfigurationExpandParameterValues.Settings),\n\t}\n\n\tpipelinesChecksClient.\n\t\tEXPECT().\n\t\tGetCheckConfiguration(clients.Ctx, expectedArgs).\n\t\tReturn(nil, errors.New(\"GetServiceEndpoint() Failed\")).\n\t\tTimes(1)\n\n\terr := r.Read(resourceData, clients)\n\trequire.Contains(t, err.Error(), \"GetServiceEndpoint() Failed\")\n\trequire.Nil(t, flattenErr)\n}", "func TestPutSlidesDocumentFromHtmlInvalidstorage(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"storage\", r.Code, e)\n}", "func (v *Values) GetMetadata(stepName string) interface{} {\n\treturn v.getStepData(stepName, MetadataKey)\n}", "func TestPostSlidesDocumentInvalidname(t *testing.T) {\n request := createPostSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesDocument(request)\n assertError(t, \"PostSlidesDocument\", \"name\", r.Code, e)\n}", "func (d *ceph) getPlaceholderVolume() Volume {\n\treturn NewVolume(d, d.name, VolumeType(\"incus\"), ContentTypeFS, d.config[\"ceph.osd.pool_name\"], nil, nil)\n}", "func TestPutNewPresentationInvalidname(t *testing.T) {\n request := createPutNewPresentationRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutNewPresentation\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutNewPresentation(request)\n assertError(t, \"PutNewPresentation\", \"name\", r.Code, e)\n}", "func TestGetSlidesDocumentWithFormatInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"folder\", int32(r.StatusCode), e)\n}", "func (s SliceIter) Peek() interface{} {\n\tval := reflect.ValueOf(s.slice)\n\treturn val.Index(0).Interface()\n}", "func TestNotesSlideShapes(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeCount int32 = 3\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tshapes, _, e := c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewShape()\n\tdto.X = 100\n\tdto.Y = 100\n\tdto.Width = 500\n\tdto.Height = 200\n\tdto.ShapeType = \"Rectangle\"\n\tdto.Text = \"New shape\"\n\tshape, _, e := c.SlidesApi.CreateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", dto, nil, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto.Text = \"Updated shape\"\n\tshape, _, e = c.SlidesApi.UpdateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n}", "func GetEntryFromPlaceholder(ctx context.Context, r repo.Repository, defp snapshot.HasDirEntryOrNil) (fs.Entry, error) {\n\tde, err := defp.DirEntryOrNil(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to get direntry from placeholder\")\n\t}\n\n\trepoFSLog(ctx).Debugf(\"GetDirEntryFromPlaceholder %v %v \", r, de)\n\n\treturn EntryFromDirEntry(r, de), nil\n}", "func TestPostSlidesSplitInvalidwidth(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.width = invalidizeTestParamValue(request.width, \"width\", \"int32\").(int32)\n e := initializeTest(\"PostSlidesSplit\", \"width\", request.width)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"width\", r.Code, e)\n}", "func (t *Link) GetUnknownPreview() (v interface{}) {\n\treturn t.preview[0].unknown_\n\n}", "func TestPostSlidesSplitInvalidstorage(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"storage\", r.Code, e)\n}", "func (r readOnlyInjections) TryGet(key string) (interface{}, bool) {\n\tv, ok := r.IContainer.data[key]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\tif v.obj != nil {\n\t\treturn v.obj, true\n\t}\n\tif r.threadData != nil {\n\t\tif v, ok := r.threadData[key]; ok {\n\t\t\treturn v, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func TestConvertSlidePostFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadSlide(fileName, 1, \"pdf\", nil, nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func (h *IPPortIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex {\n\tvar metadata []MetadataIndex\n\n\tif pod.Status.GetPodIP() == \"\" {\n\t\treturn metadata\n\t}\n\n\t// Add pod IP\n\tmetadata = append(metadata, MetadataIndex{\n\t\tIndex: pod.Status.GetPodIP(),\n\t\tData: h.metaGen.PodMetadata(pod),\n\t})\n\n\tfor _, container := range pod.Spec.Containers {\n\t\tfor _, port := range container.Ports {\n\t\t\tif port.GetContainerPort() != 0 {\n\n\t\t\t\tmetadata = append(metadata, MetadataIndex{\n\t\t\t\t\tIndex: fmt.Sprintf(\"%s:%d\", pod.Status.GetPodIP(), port.GetContainerPort()),\n\t\t\t\t\tData: h.metaGen.ContainerMetadata(pod, container.GetName()),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn metadata\n}", "func (stc *STemplatesController) Info() (*srv_tmpl.Pool, error) {\n\tresponse, err := stc.c.ClientFlow.HTTPMethod(\"GET\", endpointFTemplate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !response.status {\n\t\treturn nil, errors.New(response.body)\n\t}\n\n\tstemplatepool := &srv_tmpl.Pool{}\n\tpool_str, err := json.Marshal(response.BodyMap()[\"DOCUMENT_POOL\"])\n\terr = json.Unmarshal([]byte(pool_str), stemplatepool)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn stemplatepool, err\n}", "func GetByNameNoRetry(name string) (*machineconfigv1.MachineConfigPool, error) {\n\tmcp := &machineconfigv1.MachineConfigPool{}\n\tkey := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: metav1.NamespaceNone,\n\t}\n\terr := testclient.Client.Get(context.TODO(), key, mcp)\n\treturn mcp, err\n}", "func Test_DeviceService_Get_EmptyIP(t *testing.T) {\n\ts := DeviceService{}\n\t_, err := s.Get(\"\")\n\tassert.Error(t, err)\n}", "func TestPutSlidesDocumentFromHtml(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesDocumentFromHtml(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func (l *Ledger) GetIrreversibleSlideWindow() int64 {\n\tdefaultIrreversibleSlideWindow := l.GenesisBlock.GetConfig().GetIrreversibleSlideWindow()\n\treturn defaultIrreversibleSlideWindow\n}", "func (m NoStipulationsRepeatingGroup) Get(i int) NoStipulations {\n\treturn NoStipulations{m.RepeatingGroup.Get(i)}\n}", "func TestAzureDevOpsServiceEndpointDockerRegistry_Read_DoesNotSwallowError(t *testing.T) {\n\tctrl := gomock.NewController(t)\n\tdefer ctrl.Finish()\n\n\tr := resourceServiceEndpointDockerRegistry()\n\tresourceData := schema.TestResourceDataRaw(t, r.Schema, nil)\n\tflattenServiceEndpointDockerRegistry(resourceData, &dockerRegistryTestServiceEndpoint, dockerRegistryTestServiceEndpointProjectID)\n\n\tbuildClient := azdosdkmocks.NewMockServiceendpointClient(ctrl)\n\tclients := &config.AggregatedClient{ServiceEndpointClient: buildClient, Ctx: context.Background()}\n\n\texpectedArgs := serviceendpoint.GetServiceEndpointDetailsArgs{EndpointId: dockerRegistryTestServiceEndpoint.Id, Project: dockerRegistryTestServiceEndpointProjectID}\n\tbuildClient.\n\t\tEXPECT().\n\t\tGetServiceEndpointDetails(clients.Ctx, expectedArgs).\n\t\tReturn(nil, errors.New(\"GetServiceEndpoint() Failed\")).\n\t\tTimes(1)\n\n\terr := r.Read(resourceData, clients)\n\trequire.Contains(t, err.Error(), \"GetServiceEndpoint() Failed\")\n}", "func TestGetSlidesDocumentInvalidpassword(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"password\", r.Code, e)\n}", "func GetConfigContainerNotFound(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.ContainerController, id string) http.ResponseWriter {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) {}\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// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/api/v2/container/%v/config\", id),\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"ContainerTest\"), rw, req, prms)\n\tgetConfigCtx, _err := app.NewGetConfigContainerContext(goaCtx, req, service)\n\tif _err != nil {\n\t\te, ok := _err.(goa.ServiceError)\n\t\tif !ok {\n\t\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t\t}\n\t\tt.Errorf(\"unexpected parameter validation error: %+v\", e)\n\t\treturn nil\n\t}\n\n\t// Perform action\n\t_err = ctrl.GetConfig(getConfigCtx)\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 != 404 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 404\", rw.Code)\n\t}\n\n\t// Return results\n\treturn rw\n}", "func (wrapper *workflowTemplateInterfaceWrapper) Get(name string) (*wfv1.WorkflowTemplate, error) {\n\treturn wrapper.clientset.Get(name, metav1.GetOptions{})\n}", "func placeholders(n int) string {\n\ta := make([]string, n)\n\tfor i := range a {\n\t\ta[i] = \"?\"\n\t}\n\treturn strings.Join(a, \",\")\n}", "func TestPostSlidesSaveAsInvalidname(t *testing.T) {\n request := createPostSlidesSaveAsRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesSaveAs\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.PostSlidesSaveAs(request)\n assertError(t, \"PostSlidesSaveAs\", \"name\", int32(r.StatusCode), e)\n}", "func mustGetContainer(g *gomega.WithT, objs *objectSet, deploymentName, containerName string) map[string]interface{} {\n\tobj := objs.kind(\"Deployment\").nameEquals(deploymentName)\n\tg.Expect(obj).Should(gomega.Not(gomega.BeNil()))\n\tcontainer := obj.Container(containerName)\n\tg.Expect(container).Should(gomega.Not(gomega.BeNil()))\n\treturn container\n}", "func TestGetSlidesDocumentWithFormatInvalidpassword(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"password\", int32(r.StatusCode), e)\n}", "func TestSlideCommentsDelete(t *testing.T) {\n\tvar slideIndex int32 = 1\n\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresponse, _, e := c.SlidesApi.DeleteSlideComments(fileName, slideIndex, \"\", password, folderName, \"\")\n\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tif len(response.GetList()) != 0 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 0, len(response.GetList()))\n\t\treturn\n\t}\n}" ]
[ "0.7618128", "0.756309", "0.7497457", "0.707565", "0.66573054", "0.64436734", "0.6300607", "0.6155968", "0.5719219", "0.5514356", "0.55130297", "0.53745484", "0.535465", "0.5219113", "0.5197766", "0.51614887", "0.49438956", "0.4868958", "0.478047", "0.4749041", "0.47034314", "0.4692433", "0.4656155", "0.46200636", "0.4589771", "0.45438388", "0.45213014", "0.45126325", "0.4503738", "0.44323638", "0.44046804", "0.43766087", "0.43697178", "0.43694785", "0.436429", "0.4350122", "0.4345529", "0.43236288", "0.43143228", "0.4309081", "0.43080333", "0.43043005", "0.43035957", "0.42936787", "0.42698717", "0.42664814", "0.42380875", "0.42216372", "0.4168904", "0.41672185", "0.4163389", "0.41341504", "0.41151556", "0.4110679", "0.41087446", "0.41024506", "0.40840682", "0.40697992", "0.40694916", "0.40630633", "0.4056706", "0.4047148", "0.4047088", "0.40352625", "0.40301558", "0.4016203", "0.40093088", "0.3997646", "0.3995938", "0.39928895", "0.3988888", "0.39789143", "0.39788467", "0.39772967", "0.39762715", "0.39695615", "0.39592442", "0.3956004", "0.39533737", "0.3947608", "0.3947608", "0.3943542", "0.39379606", "0.39326343", "0.39319727", "0.39253813", "0.3924228", "0.39239118", "0.3916557", "0.39130348", "0.3912239", "0.39043674", "0.38981518", "0.38974977", "0.38942972", "0.3893349", "0.38925618", "0.38918906", "0.3886426", "0.38824895" ]
0.7812776
0
/ PlaceholdersApiServiceTests Read slide placeholder info. Test for PlaceholdersApi.GetSlidesPlaceholder method with invalid placeholderIndex
func TestGetSlidesPlaceholderInvalidplaceholderIndex(t *testing.T) { request := createGetSlidesPlaceholderRequest() request.placeholderIndex = invalidizeTestParamValue(request.placeholderIndex, "placeholderIndex", "int32").(int32) e := initializeTest("GetSlidesPlaceholder", "placeholderIndex", request.placeholderIndex) if e != nil { t.Errorf("Error: %v.", e) return } r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request) assertError(t, "GetSlidesPlaceholder", "placeholderIndex", r.Code, e) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestGetSlidesPlaceholder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n e := initializeTest(\"GetSlidesPlaceholder\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholder(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholderInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholder\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidslideIndex(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.slideIndex = invalidizeTestParamValue(request.slideIndex, \"slideIndex\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesPlaceholders\", \"slideIndex\", request.slideIndex)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"slideIndex\", r.Code, e)\n}", "func TestGetSlidesPlaceholders(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n e := initializeTest(\"GetSlidesPlaceholders\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.PlaceholdersApi.GetSlidesPlaceholders(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestGetSlidesPlaceholderInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidname(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"name\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidstorage(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"storage\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"folder\", r.Code, e)\n}", "func GetPlaceHolders(conf *viper.Viper) Placeholders {\n\tlist := parseMap(conf.AllSettings())\n\n\tproperties := CreateProperties(list)\n\n\treturn Placeholders{properties}\n}", "func TestGetSlidesPlaceholdersInvalidfolder(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"folder\", r.Code, e)\n}", "func TestGetSlidesPlaceholderInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholderRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholder\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholder(request)\n assertError(t, \"GetSlidesPlaceholder\", \"password\", r.Code, e)\n}", "func TestGetSlidesPlaceholdersInvalidpassword(t *testing.T) {\n request := createGetSlidesPlaceholdersRequest()\n request.password = invalidizeTestParamValue(request.password, \"password\", \"string\").(string)\n e := initializeTest(\"GetSlidesPlaceholders\", \"password\", request.password)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().PlaceholdersApi.GetSlidesPlaceholders(request)\n assertError(t, \"GetSlidesPlaceholders\", \"password\", r.Code, e)\n}", "func GetPlaceHolder(count int) string {\n\tif count > 0 {\n\t\tstr := strings.Repeat(\"?, \", count)\n\t\treturn str[:len(str)-2]\n\t}\n\n\treturn \"\"\n}", "func TestGetSlidesApiInfo(t *testing.T) {\n e := initializeTest(\"GetSlidesApiInfo\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesApiInfo()\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func Placeholder(num int) string {\n\treturn strings.Join(SliceFill(num, \"?\"), \",\")\n}", "func (p PostgresqlDialect) Placeholder(index int) string {\n\treturn fmt.Sprintf(\"$%d\", index+1)\n}", "func TestNotesSlideGetFromStorage(t *testing.T) {\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.GetNotesSlide(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func (a *ClinicalMetadataServiceApiService) GetSlide(ctx _context.Context, slideId string) (Ga4ghSlide, *_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 Ga4ghSlide\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/{slide_id}\"\n\tlocalVarPath = strings.Replace(localVarPath, \"{\"+\"slide_id\"+\"}\", _neturl.QueryEscape(fmt.Sprintf(\"%v\", slideId)), -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\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v Ga4ghSlide\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\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 (ref *UIElement) PlaceholderValue() string {\n\tret, _ := ref.StringAttr(PlaceholderValueAttribute)\n\treturn ret\n}", "func TestSlideCommentsGet(t *testing.T) {\n\tvar slideIndex int32 = 1\n\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresponse, _, e := c.SlidesApi.GetSlideComments(fileName, slideIndex, password, folderName, \"\")\n\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tif len(response.GetList()) != 2 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 2, len(response.GetList()))\n\t\treturn\n\t}\n\n\tif len(response.GetList()[0].GetChildComments()) != 1 {\n\t\tt.Errorf(\"Expected %v, but was %v\", 1, len(response.GetList()[0].GetChildComments()))\n\t\treturn\n\t}\n}", "func TestNotesSlideExistsFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := c.SlidesApi.NotesSlideExists(fileName, 1, \"password\", folderName, \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestGetSlidesDocumentInvalidname(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"name\", r.Code, e)\n}", "func (g *sqliteGrammar) Placeholder(n int) string {\n\tif n < 0 {\n\t\tpanic(\"qb: negative Placeholder count\")\n\t}\n\tif n == 0 {\n\t\treturn \"\"\n\t}\n\tif n == 1 {\n\t\treturn \"?\"\n\t}\n\n\tvar (\n\t\tp = \", ?\"\n\t\tb = make([]byte, len(p)*n)\n\t\tw = copy(b, p)\n\t)\n\n\tfor w < len(b) {\n\t\tcopy(b[w:], b[:w])\n\t\tw *= 2\n\t}\n\tif len(b) >= len(p) {\n\t\tb = b[2:]\n\t}\n\n\treturn *(*string)(unsafe.Pointer(&b))\n}", "func TestGetSlidesDocument(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n e := initializeTest(\"GetSlidesDocument\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocument(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func Placeholder(scope *Scope, dtype tf.DataType, optional ...PlaceholderAttr) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype}\n\tfor _, a := range optional {\n\t\ta(attrs)\n\t}\n\topspec := tf.OpSpec{\n\t\tType: \"Placeholder\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func NeedPlaceholder(t string) bool {\n\tswitch t {\n\tcase SecretVariable, KeyVariable, SSHKeyVariable, PGPKeyVariable:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}", "func TestGetSlidesDocumentWithFormatInvalidname(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"name\", int32(r.StatusCode), e)\n}", "func (p Dialect) Placeholder(idx int) string { return \"$\" + strconv.Itoa(idx+1) }", "func TestPanicOnSameParamPlaceholder(t *testing.T) {\n\tdefer func() {\n\t\tv := recover()\n\t\tif v == nil {\n\t\t\tt.Fatalf(\"expected a panic, but nothing happened\")\n\t\t}\n\t}()\n\n\trunTest(t, func(s *Session) {\n\t\ts.Handle(\"model.$id.type.$id\")\n\t}, nil)\n}", "func TestNotesSlideGetFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.GetNotesSlideOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(result.GetText()) == 0 {\n\t\tt.Errorf(\"Note text is empty.\")\n\t\treturn\n\t}\n}", "func Placeholder(w http.ResponseWriter, r *http.Request) {\n\tlog.Debugf(\"Method: %s\", r.Method)\n\tlog.Debugf(\"URL: %s\", r.URL.String())\n\tbodyContents, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\tw.Write([]byte(\"Couldn't read the body of the request\"))\n\t}\n\tlog.Debugf(\"Body: %s\", string(bodyContents))\n\tw.WriteHeader(http.StatusNotImplemented)\n}", "func (d *portworx) getRestContainerPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.TargetPort.IntVal, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api target port not found in service\")\n}", "func TestGetSlidesDocumentInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"storage\", r.Code, e)\n}", "func privateDataPlaceholder() string {\n\treturn \"[PRIVATE DATA HIDDEN]\"\n}", "func TestNotesSlideExistsFromRequest(t *testing.T) {\n\tsource, e := ioutil.ReadFile(localTestFile)\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tresult, _, e := slidescloud.GetTestApiClient().SlidesApi.NotesSlideExistsOnline(source, 1, \"password\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif !result.GetExists() {\n\t\tt.Errorf(\"Note does not exist.\")\n\t\treturn\n\t}\n}", "func TestGetSlidesDocumentWithFormatInvalidstorage(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"storage\", int32(r.StatusCode), e)\n}", "func PlaceholderClient(ipaddress string, status string) error {\n\n\tlogit.Info.Println(\"Placeholder called\")\n\tclient, err := rpc.DialHTTP(\"tcp\", ipaddress)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: dialing:\" + err.Error())\n\t\treturn err\n\t}\n\tif client == nil {\n\t\tlogit.Error.Println(\"Placeholder: client was nil\")\n\t\treturn errors.New(\"client was nil from rpc dial\")\n\t}\n\n\tvar command Command\n\n\terr = client.Call(\"Command.Placeholder\", &status, &command)\n\tif err != nil {\n\t\tlogit.Error.Println(\"Placeholder: error \" + err.Error())\n\t\treturn err\n\t}\n\tlogit.Info.Println(\"status=\" + status)\n\n\treturn nil\n}", "func (p *Projection) slideName() (string, error) {\n\tparts := strings.Split(p.ContentObjectID, \"/\")\n\tif len(parts) != 2 {\n\t\treturn \"\", fmt.Errorf(\"invalid content_object_id `%s`, expected one '/'\", p.ContentObjectID)\n\t}\n\n\tif p.Type != \"\" && parts[0] == \"meeting\" {\n\t\treturn p.Type, nil\n\t}\n\treturn parts[0], nil\n}", "func TestNotesSlidePortions(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphIndex int32 = 1\n\tvar portionCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tportions, _, e := c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewPortion()\n\tdto.Text = \"New portion\"\n\tdto.FontBold = \"True\"\n\tportion, _, e := c.SlidesApi.CreateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\tdto2 := slidescloud.NewPortion()\n\tdto2.Text = \"Updated portion\"\n\tdto2.FontHeight = 22\n\tportion, _, e = c.SlidesApi.UpdateSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, dto2, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif portion.GetFontBold() != dto.GetFontBold() {\n\t\tt.Errorf(\"Wrong portion font bold. Expected %v but was %v.\", dto.GetFontBold(), portion.GetFontBold())\n\t\treturn\n\t}\n\tif portion.GetFontHeight() != dto2.GetFontHeight() {\n\t\tt.Errorf(\"Wrong portion font height. Expected %v but was %v.\", dto2.GetFontHeight(), portion.GetFontHeight())\n\t\treturn\n\t}\n\tif portion.GetText() != dto2.GetText() {\n\t\tt.Errorf(\"Wrong portion text. Expected %v but was %v.\", dto2.GetText(), portion.GetText())\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount)+1 {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlidePortion(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, portionCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tportions, _, e = c.SlidesApi.GetSpecialSlidePortions(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(portions.GetItems()) != int(portionCount) {\n\t\tt.Errorf(\"Wrong portion count. Expected %v but was %v.\", portionCount, len(portions.GetItems()))\n\t\treturn\n\t}\n}", "func (s *System) GetCachedSlide(affirmationIndex, winWidth, winHeight int) (pixbuf *gdk.Pixbuf, found bool) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\t// Clear the cache if our window size has changed.\n\ts.clearSlideCacheIfNecessary(winWidth, winHeight)\n\n\t// Get the cached value.\n\tpixbuf, found = s.cachedSlides[affirmationIndex]\n\tif !found {\n\t\treturn nil, false\n\t}\n\n\treturn pixbuf, true\n}", "func TestNotesSlideParagraphs(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeIndex int32 = 2\n\tvar paragraphCount int32 = 1\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tparagraphs, _, e := c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n\n\tportion := slidescloud.NewPortion()\n\tportion.Text = \"New Paragraph\"\n\tdto := slidescloud.NewParagraph()\n\tdto.Alignment = \"Right\"\n\tdto.PortionList = []slidescloud.IPortion{portion}\n\tparagraph, _, e := c.SlidesApi.CreateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, dto, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\tdto = slidescloud.NewParagraph()\n\tdto.Alignment = \"Center\"\n\tparagraph, _, e = c.SlidesApi.UpdateSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif paragraph.GetAlignment() != dto.GetAlignment() {\n\t\tt.Errorf(\"Wrong paragraph alignment. Expected %v but was %v.\", dto.GetAlignment(), paragraph.GetAlignment())\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount)+1 {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks())+1)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideParagraph(fileName, slideIndex, \"notesSlide\", shapeIndex, paragraphCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tparagraphs, _, e = c.SlidesApi.GetSpecialSlideParagraphs(fileName, slideIndex, \"notesSlide\", shapeIndex, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(paragraphs.GetParagraphLinks()) != int(paragraphCount) {\n\t\tt.Errorf(\"Wrong paragraph count. Expected %v but was %v.\", paragraphCount, len(paragraphs.GetParagraphLinks()))\n\t\treturn\n\t}\n}", "func (u *User) GetBotInlinePlaceholder() (value string, ok bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\tif !u.Flags.Has(19) {\n\t\treturn value, false\n\t}\n\treturn u.BotInlinePlaceholder, true\n}", "func TestGetSlidesDocumentWithFormatInvalidformat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.format = invalidizeTestParamValue(request.format, \"format\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"format\", request.format)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"format\", int32(r.StatusCode), e)\n}", "func GetQiskitPlayground(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *QiskitPlaygroundState, opts ...pulumi.ResourceOption) (*QiskitPlayground, error) {\n\tvar resource QiskitPlayground\n\terr := ctx.ReadResource(\"kubernetes:singhp11.io/v1:QiskitPlayground\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func TestPutSlidesSlideSizeInvalidheight(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PutSlidesSlideSize\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"height\", r.Code, e)\n}", "func TestPutSlidesSlideSizeInvalidname(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"name\", r.Code, e)\n}", "func (test *Test) GetIP(projectName string, ip string) (models.IP, error) {\n\treturn tests.NormalIPs[0], nil\n}", "func (d *ceph) getPlaceholderVolume() Volume {\n\treturn NewVolume(d, d.name, VolumeType(\"incus\"), ContentTypeFS, d.config[\"ceph.osd.pool_name\"], nil, nil)\n}", "func (m Model) placeholderView() string {\n\tvar (\n\t\tv string\n\t\tp = m.Placeholder\n\t\tstyle = m.PlaceholderStyle.Inline(true).Render\n\t)\n\n\t// Cursor\n\tif m.blink {\n\t\tv += m.cursorView(style(p[:1]))\n\t} else {\n\t\tv += m.cursorView(p[:1])\n\t}\n\n\t// The rest of the placeholder text\n\tv += style(p[1:])\n\n\treturn m.PromptStyle.Render(m.Prompt) + v\n}", "func TestPutSlidesSlideSize(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n e := initializeTest(\"PutSlidesSlideSize\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PutSlidesSlideSize(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func DisablesTestReadIndexTask_IgnoreHiddenPics(t *testing.T) {\n\tc := Container(t)\n\tdefer c.Close()\n\n\tu := c.CreateUser()\n\tu.User.Capability = append(u.User.Capability, schema.User_PIC_INDEX)\n\tu.Update()\n\n\tp1 := c.CreatePic()\n\tp3 := c.CreatePic()\n\t// A hard deletion\n\tp3.Pic.DeletionStatus = &schema.Pic_DeletionStatus{\n\t\tActualDeletedTs: schema.ToTs(time.Now()),\n\t}\n\tp3.Update()\n\n\ttask := ReadIndexPicsTask{\n\t\tDB: c.DB(),\n\t\tCtx: CtxFromUserID(context.Background(), u.User.UserId),\n\t}\n\n\tif err := task.Run(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif len(task.Pics) != 1 || !proto.Equal(p1.Pic, task.Pics[0]) {\n\t\tt.Fatalf(\"Unable to find %s in\\n %s\", p1, task.Pics)\n\t}\n}", "func placeholders(n int) string {\n\ta := make([]string, n)\n\tfor i := range a {\n\t\ta[i] = \"?\"\n\t}\n\treturn strings.Join(a, \",\")\n}", "func TestGetSlidesDocumentWithFormat(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.GetSlidesDocumentWithFormat(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n assertBinaryResponse(r, t)\n}", "func (a *ClinicalMetadataServiceApiService) SearchSlides(ctx _context.Context, body Ga4ghSearchSlidesRequest) (Ga4ghSearchSlidesResponse, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue Ga4ghSearchSlidesResponse\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/slides/search\"\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{\"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 = &body\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 Ga4ghSearchSlidesResponse\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\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 PlaceholderV2(scope *Scope, dtype tf.DataType, shape tf.Shape) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"dtype\": dtype, \"shape\": shape}\n\topspec := tf.OpSpec{\n\t\tType: \"PlaceholderV2\",\n\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func TestPostSlidesSplitInvalidheight(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.height = invalidizeTestParamValue(request.height, \"height\", \"int32\").(int32)\n e := initializeTest(\"PostSlidesSplit\", \"height\", request.height)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"height\", r.Code, e)\n}", "func (s *optFlagImpl) Placeholder(placeholder string) (opt OptFlag) {\n\ts.working.DefaultValuePlaceholder = placeholder\n\treturn s\n}", "func (t *Link) GetUnknownPreview() (v interface{}) {\n\treturn t.preview[0].unknown_\n\n}", "func (a *SlidesApiService) GetApiInfo() (IApiInfo, *http.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = strings.ToUpper(\"Get\")\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFiles [][]byte\n\t \tsuccessPayload IApiInfo\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.GetApiUrl() + \"/slides/info\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := url.Values{}\n\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{\n\t\t\"application/json\",\n\t\t}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tlocalVarHttpResponse, responseBytes, err := a.client.makeRequest(nil, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFiles)\n\tresponseBody := bytes.NewReader(responseBytes)\n\tif localVarHttpResponse != nil && localVarHttpResponse.StatusCode >= 300 {\n\t\tvar errorMessage ErrorMessage\n\t\tif err = json.NewDecoder(responseBody).Decode(&errorMessage); err != nil {\n\t\t\treturn successPayload, localVarHttpResponse, reportError(localVarHttpResponse.Status)\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, reportError(string(responseBytes))\n\t}\n\n\tsuccessPayloadObject, err := createObjectForType(\"ApiInfo\", responseBytes)\n\tif err != nil {\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif err = json.NewDecoder(responseBody).Decode(successPayloadObject); err != nil {\n\t\tif sp, ok := successPayloadObject.(IApiInfo); ok {\n\t\t\treturn sp, localVarHttpResponse, err\n\t\t}\n\t\treturn successPayload, localVarHttpResponse, err\n\t}\n\tif successPayload, _ = successPayloadObject.(IApiInfo); true {\n\t}\n\n\treturn successPayload, localVarHttpResponse, err\n}", "func GetEntryFromPlaceholder(ctx context.Context, r repo.Repository, defp snapshot.HasDirEntryOrNil) (fs.Entry, error) {\n\tde, err := defp.DirEntryOrNil(ctx)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to get direntry from placeholder\")\n\t}\n\n\trepoFSLog(ctx).Debugf(\"GetDirEntryFromPlaceholder %v %v \", r, de)\n\n\treturn EntryFromDirEntry(r, de), nil\n}", "func PlaceholderExtension() gval.Language {\n\treturn placeholderExtension\n}", "func replaceKeptnPlaceholders(input string, event adapter.EventContentAdapter) string {\n\tresult := input\n\n\t// first we do the regular keptn values\n\tresult = strings.Replace(result, \"$CONTEXT\", event.GetShKeptnContext(), -1)\n\tresult = strings.Replace(result, \"$EVENT\", event.GetEvent(), -1)\n\tresult = strings.Replace(result, \"$SOURCE\", event.GetSource(), -1)\n\tresult = strings.Replace(result, \"$PROJECT\", event.GetProject(), -1)\n\tresult = strings.Replace(result, \"$STAGE\", event.GetStage(), -1)\n\tresult = strings.Replace(result, \"$SERVICE\", event.GetService(), -1)\n\tresult = strings.Replace(result, \"$DEPLOYMENT\", event.GetDeployment(), -1)\n\tresult = strings.Replace(result, \"$TESTSTRATEGY\", event.GetTestStrategy(), -1)\n\n\t// now we do the labels\n\tfor key, value := range event.GetLabels() {\n\t\tresult = strings.Replace(result, \"$LABEL.\"+key, value, -1)\n\t}\n\n\t// now we do all environment variables\n\tfor _, env := range os.Environ() {\n\t\tpair := strings.SplitN(env, \"=\", 2)\n\t\tresult = strings.Replace(result, \"$ENV.\"+pair[0], pair[1], -1)\n\t}\n\n\t// TODO: iterate through k8s secrets!\n\n\treturn result\n}", "func TestNotesSlideDownloadFromStorage(t *testing.T) {\n\tfolderName := \"TempSlidesSDK\"\n\tfileName := \"test.pptx\"\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DownloadNotesSlide(fileName, 1, \"png\", nil, nil, \"password\", folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n}", "func mustGetContainer(g *gomega.WithT, objs *objectSet, deploymentName, containerName string) map[string]interface{} {\n\tobj := objs.kind(\"Deployment\").nameEquals(deploymentName)\n\tg.Expect(obj).Should(gomega.Not(gomega.BeNil()))\n\tcontainer := obj.Container(containerName)\n\tg.Expect(container).Should(gomega.Not(gomega.BeNil()))\n\treturn container\n}", "func (s *Store) UnsafeGetDefinition(name string) *Definition {\n\ts.mu.RLock()\n\tt := s.tasks[name]\n\ts.mu.RUnlock()\n\treturn t\n}", "func TestPostSlidesDocumentInvalidtemplateStorage(t *testing.T) {\n request := createPostSlidesDocumentRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PostSlidesDocument\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesDocument(request)\n assertError(t, \"PostSlidesDocument\", \"templateStorage\", r.Code, e)\n}", "func TestGetSlidesDocumentWithFormatInvalidjpegQuality(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.jpegQuality = invalidizeTestParamValue(request.jpegQuality, \"jpegQuality\", \"int32\").(int32)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"jpegQuality\", request.jpegQuality)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"jpegQuality\", int32(r.StatusCode), e)\n}", "func (stc *STemplatesController) Info() (*srv_tmpl.Pool, error) {\n\tresponse, err := stc.c.ClientFlow.HTTPMethod(\"GET\", endpointFTemplate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !response.status {\n\t\treturn nil, errors.New(response.body)\n\t}\n\n\tstemplatepool := &srv_tmpl.Pool{}\n\tpool_str, err := json.Marshal(response.BodyMap()[\"DOCUMENT_POOL\"])\n\terr = json.Unmarshal([]byte(pool_str), stemplatepool)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn stemplatepool, err\n}", "func TestPutSlidesDocumentFromHtmlInvalidname(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"name\", r.Code, e)\n}", "func PlaceholderWithDefault(scope *Scope, input tf.Output, shape tf.Shape) (output tf.Output) {\n\tif scope.Err() != nil {\n\t\treturn\n\t}\n\tattrs := map[string]interface{}{\"shape\": shape}\n\topspec := tf.OpSpec{\n\t\tType: \"PlaceholderWithDefault\",\n\t\tInput: []tf.Input{\n\t\t\tinput,\n\t\t},\n\t\tAttrs: attrs,\n\t}\n\top := scope.AddOperation(opspec)\n\treturn op.Output(0)\n}", "func getRequiredVariables() map[string]interface{} {\n\tvariables := map[string]interface{}{\n\t\t\"competition\": competitionName,\n\t\t\"secret_name\": kaggleApiSecret,\n\t}\n\treturn variables\n}", "func (v *Values) GetMetadata(stepName string) interface{} {\n\treturn v.getStepData(stepName, MetadataKey)\n}", "func (s SliceIter) Peek() interface{} {\n\tval := reflect.ValueOf(s.slice)\n\treturn val.Index(0).Interface()\n}", "func (s *EmptyStore) IgnitionGet(id string) (string, error) {\n\treturn \"\", fmt.Errorf(\"no Ignition Config %s\", id)\n}", "func generatePlaceholders(n int) string {\n\tplaceholders := strings.Builder{}\n\tfor i := 1; i <= n; i++ {\n\t\tif i > 1 {\n\t\t\tplaceholders.WriteByte(',')\n\t\t}\n\t\tplaceholders.WriteString(fmt.Sprintf(\"$%d\", i))\n\t}\n\treturn placeholders.String()\n}", "func TestPostSlidesSplitInvalidname(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.name = invalidizeTestParamValue(request.name, \"name\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"name\", request.name)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"name\", r.Code, e)\n}", "func TestPostSlidesSplit(t *testing.T) {\n request := createPostSlidesSplitRequest()\n e := initializeTest(\"PostSlidesSplit\", \"\", \"\")\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n c := getTestApiClient()\n r, _, e := c.DocumentApi.PostSlidesSplit(request)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n if r.Code != 200 && r.Code != 201 {\n t.Errorf(\"Wrong response code: %d.\", r.Code)\n return\n }\n}", "func TestPutNewPresentationInvalidtemplateStorage(t *testing.T) {\n request := createPutNewPresentationRequest()\n request.templateStorage = invalidizeTestParamValue(request.templateStorage, \"templateStorage\", \"string\").(string)\n e := initializeTest(\"PutNewPresentation\", \"templateStorage\", request.templateStorage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutNewPresentation(request)\n assertError(t, \"PutNewPresentation\", \"templateStorage\", r.Code, e)\n}", "func TestGetSlidesDocumentInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocument\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.GetSlidesDocument(request)\n assertError(t, \"GetSlidesDocument\", \"folder\", r.Code, e)\n}", "func (h *IPPortIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex {\n\tvar metadata []MetadataIndex\n\n\tif pod.Status.GetPodIP() == \"\" {\n\t\treturn metadata\n\t}\n\n\t// Add pod IP\n\tmetadata = append(metadata, MetadataIndex{\n\t\tIndex: pod.Status.GetPodIP(),\n\t\tData: h.metaGen.PodMetadata(pod),\n\t})\n\n\tfor _, container := range pod.Spec.Containers {\n\t\tfor _, port := range container.Ports {\n\t\t\tif port.GetContainerPort() != 0 {\n\n\t\t\t\tmetadata = append(metadata, MetadataIndex{\n\t\t\t\t\tIndex: fmt.Sprintf(\"%s:%d\", pod.Status.GetPodIP(), port.GetContainerPort()),\n\t\t\t\t\tData: h.metaGen.ContainerMetadata(pod, container.GetName()),\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\n\treturn metadata\n}", "func (p *CockroachDriver) IndexPlaceholders() bool {\n\treturn true\n}", "func TestPutSlidesSlideSizeInvalidstorage(t *testing.T) {\n request := createPutSlidesSlideSizeRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesSlideSize\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesSlideSize(request)\n assertError(t, \"PutSlidesSlideSize\", \"storage\", r.Code, e)\n}", "func Test_DeviceService_Get_EmptyIP(t *testing.T) {\n\ts := DeviceService{}\n\t_, err := s.Get(\"\")\n\tassert.Error(t, err)\n}", "func TestNotesSlideShapes(t *testing.T) {\n\tvar slideIndex int32 = 1\n\tvar shapeCount int32 = 3\n\tc := slidescloud.GetTestApiClient()\n\t_, e := c.SlidesApi.CopyFile(\"TempTests/\"+fileName, folderName+\"/\"+fileName, \"\", \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\n\tshapes, _, e := c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto := slidescloud.NewShape()\n\tdto.X = 100\n\tdto.Y = 100\n\tdto.Width = 500\n\tdto.Height = 200\n\tdto.ShapeType = \"Rectangle\"\n\tdto.Text = \"New shape\"\n\tshape, _, e := c.SlidesApi.CreateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", dto, nil, nil, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\tdto.Text = \"Updated shape\"\n\tshape, _, e = c.SlidesApi.UpdateSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, dto, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif shape.(slidescloud.IShape).GetText() != dto.GetText() {\n\t\tt.Errorf(\"Wrong shape text. Expected %v but was %v.\", dto.GetText(), shape.(slidescloud.IShape).GetText())\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount)+1 {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n\n\t_, _, e = c.SlidesApi.DeleteSpecialSlideShape(fileName, slideIndex, \"notesSlide\", shapeCount+1, password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tshapes, _, e = c.SlidesApi.GetSpecialSlideShapes(fileName, slideIndex, \"notesSlide\", password, folderName, \"\", \"\")\n\tif e != nil {\n\t\tt.Errorf(\"Error: %v.\", e)\n\t\treturn\n\t}\n\tif len(shapes.GetShapesLinks()) != int(shapeCount) {\n\t\tt.Errorf(\"Wrong shape count. Expected %v but was %v.\", shapeCount+1, len(shapes.GetShapesLinks()))\n\t\treturn\n\t}\n}", "func GetConfigContainerNotFound(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.ContainerController, id string) http.ResponseWriter {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) {}\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// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/api/v2/container/%v/config\", id),\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"ContainerTest\"), rw, req, prms)\n\tgetConfigCtx, _err := app.NewGetConfigContainerContext(goaCtx, req, service)\n\tif _err != nil {\n\t\te, ok := _err.(goa.ServiceError)\n\t\tif !ok {\n\t\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t\t}\n\t\tt.Errorf(\"unexpected parameter validation error: %+v\", e)\n\t\treturn nil\n\t}\n\n\t// Perform action\n\t_err = ctrl.GetConfig(getConfigCtx)\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 != 404 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 404\", rw.Code)\n\t}\n\n\t// Return results\n\treturn rw\n}", "func (p *parser) GetPictures(a *goquery.Selection) []string {\n\tv := picture{area: a, cleanImg: p.cleanImg}\n\tv.setDetail()\n\treturn v.data\n}", "func TestPostSlidesSplitInvalidstorage(t *testing.T) {\n request := createPostSlidesSplitRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PostSlidesSplit\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PostSlidesSplit(request)\n assertError(t, \"PostSlidesSplit\", \"storage\", r.Code, e)\n}", "func (d *portworx) getRestPort() (int32, error) {\n\tsvc, err := k8sCore.GetService(schedops.PXServiceName, d.namespace)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor _, port := range svc.Spec.Ports {\n\t\tif port.Name == \"px-api\" {\n\t\t\treturn port.Port, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"px-api port not found in service\")\n}", "func (m NoStipulationsRepeatingGroup) Get(i int) NoStipulations {\n\treturn NoStipulations{m.RepeatingGroup.Get(i)}\n}", "func (m *MockDriver) UseIndexPlaceholders() bool {\n\treturn false\n}", "func parsePlaceholder(s string, funcs map[string]interface{}) (p tePlaceholder, err error) {\n\tconst (\n\t\tdot = \".\"\n\t\tinvoke = \"()\"\n\t\tindexLeft = \"[\"\n\t\tindexRight = \"]\"\n\t)\n\n\tif s==\"\"{\n\t\treturn\n\t}\n\n\tstrs := strings.Split(s, pipe)\n\tskipFirst := false\n\tif len(strs[0])>0 && strs[0][0] == 'a' {\n\t\tif i, err := strconvh.ParseInt(strs[0][1:]); err == nil {\n\t\t\tp.argNum = i\n\t\t\tskipFirst = true\n\t\t}\n\t}\n\n\tif skipFirst {\n\t\tstrs = strs[1:]\n\t}\n\n\tfor _, str := range strs {\n\t\tif len(str) == 0 {\n\t\t\terr = errors.New(\"unable to parse empty placeholder in '\" + s + \"'\")\n\t\t\treturn\n\t\t}\n\t\tswitch {\n\t\tcase str == \"*\":\n\t\t\tp.funcs = append(p.funcs, dereferencer{})\n\t\tcase str == \"&\":\n\t\t\tp.funcs = append(p.funcs, addrGetter{})\n\t\tcase strings.HasPrefix(str, dot) && strings.HasSuffix(str, invoke): // Method\n\t\t\tname := str[len(dot) : len(str)-len(invoke)]\n\t\t\tif !IsValidExportedIdent(name) {\n\t\t\t\terr = errors.New(\"invalid method name: '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncMethod(name))\n\t\tcase strings.HasPrefix(str, dot): // Field\n\t\t\tname := str[len(dot):]\n\t\t\tif !IsValidExportedIdent(name) {\n\t\t\t\terr = errors.New(\"invalid field name: '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncGetter(name))\n\t\tcase strings.HasSuffix(str, invoke): // Function\n\t\t\tname := str[:len(str)-len(invoke)]\n\t\t\tf, ok := funcs[name]\n\t\t\tif !ok {\n\t\t\t\terr = errors.New(\"unknown function '\" + name + \"'\")\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, FuncSimple{f})\n\t\tcase strings.HasPrefix(str, indexLeft) && strings.HasSuffix(str, indexRight): // Access by index\n\t\t\tiStr := str[len(indexLeft) : len(str)-len(indexRight)]\n\t\t\tvar i int\n\t\t\ti, err = strconvh.ParseInt(iStr)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tp.funcs = append(p.funcs, Index(i))\n\t\tdefault:\n\t\t\terr = errors.New(\"unknown element in placeholder: '\" + str + \"'\")\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func getLabels(\n docker *client.Client,\n containerId string) (labels map[string]string, err error) {\n\n inspect, err := docker.ContainerInspect(context.Background(), containerId)\n if err != nil {\n return\n }\n\n labels = inspect.Config.Labels\n return\n}", "func TestCheckRequiredTemplate_Read_DoesNotSwallowError(t *testing.T) {\n\tctrl := gomock.NewController(t)\n\tdefer ctrl.Finish()\n\n\tr := ResourceCheckRequiredTemplate()\n\tresourceData := schema.TestResourceDataRaw(t, r.Schema, nil)\n\tflattenErr := flattenCheckRequiredTemplate(resourceData, &requiredTemplateCheckTest, requiredTemplateCheckProjectID)\n\n\tpipelinesChecksClient := azdosdkmocks.NewMockPipelineschecksextrasClient(ctrl)\n\tclients := &client.AggregatedClient{PipelinesChecksClientExtras: pipelinesChecksClient, Ctx: context.Background()}\n\n\texpectedArgs := pipelineschecksextras.GetCheckConfigurationArgs{\n\t\tId: requiredTemplateCheckTest.Id,\n\t\tProject: &requiredTemplateCheckProjectID,\n\t\tExpand: converter.ToPtr(pipelineschecksextras.CheckConfigurationExpandParameterValues.Settings),\n\t}\n\n\tpipelinesChecksClient.\n\t\tEXPECT().\n\t\tGetCheckConfiguration(clients.Ctx, expectedArgs).\n\t\tReturn(nil, errors.New(\"GetServiceEndpoint() Failed\")).\n\t\tTimes(1)\n\n\terr := r.Read(resourceData, clients)\n\trequire.Contains(t, err.Error(), \"GetServiceEndpoint() Failed\")\n\trequire.Nil(t, flattenErr)\n}", "func TestGetSlidesDocumentWithFormatInvalidfolder(t *testing.T) {\n request := createGetSlidesDocumentWithFormatRequest()\n request.folder = invalidizeTestParamValue(request.folder, \"folder\", \"string\").(string)\n e := initializeTest(\"GetSlidesDocumentWithFormat\", \"folder\", request.folder)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n _, r, e := getTestApiClient().DocumentApi.GetSlidesDocumentWithFormat(request)\n assertError(t, \"GetSlidesDocumentWithFormat\", \"folder\", int32(r.StatusCode), e)\n}", "func (r readOnlyInjections) TryGet(key string) (interface{}, bool) {\n\tv, ok := r.IContainer.data[key]\n\tif !ok {\n\t\treturn nil, false\n\t}\n\tif v.obj != nil {\n\t\treturn v.obj, true\n\t}\n\tif r.threadData != nil {\n\t\tif v, ok := r.threadData[key]; ok {\n\t\t\treturn v, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func GetByNameNoRetry(name string) (*machineconfigv1.MachineConfigPool, error) {\n\tmcp := &machineconfigv1.MachineConfigPool{}\n\tkey := types.NamespacedName{\n\t\tName: name,\n\t\tNamespace: metav1.NamespaceNone,\n\t}\n\terr := testclient.Client.Get(context.TODO(), key, mcp)\n\treturn mcp, err\n}", "func (c *CvpClient) GetContainerByName(query string) (*Container, error) {\n\tgetContainerURL := \"/provisioning/searchTopology.do?queryParam=\" + query + \"&startIndex=0&endIndex=0\"\n\trespbody, err := c.Get(getContainerURL)\n\trespContainer := GetContainer{}\n\terr = json.Unmarshal(respbody, &respContainer)\n\tif err != nil {\n\t\tlog.Printf(\"Error decoding getcontainer :%s\\n\", err)\n\t\treturn nil, err\n\t}\n\tif len(respContainer.ContainerList) == 0 {\n\t\treturn nil, fmt.Errorf(\"No container named \\\"%s\\\" found\", query)\n\t}\n\treturn &respContainer.ContainerList[0], err\n}", "func TestPutSlidesDocumentFromHtmlInvalidstorage(t *testing.T) {\n request := createPutSlidesDocumentFromHtmlRequest()\n request.storage = invalidizeTestParamValue(request.storage, \"storage\", \"string\").(string)\n e := initializeTest(\"PutSlidesDocumentFromHtml\", \"storage\", request.storage)\n if e != nil {\n t.Errorf(\"Error: %v.\", e)\n return\n }\n r, _, e := getTestApiClient().DocumentApi.PutSlidesDocumentFromHtml(request)\n assertError(t, \"PutSlidesDocumentFromHtml\", \"storage\", r.Code, e)\n}", "func getTestFlowStockDelays(e *httpexpect.Expect, t *testing.T) {\n\ttestCases := []testCase{\n\t\tnotLoggedTestCase,\n\t\t{\n\t\t\tToken: testCtx.User.Token,\n\t\t\tStatus: http.StatusOK,\n\t\t\tParam: \"90\",\n\t\t\tBodyContains: []string{`\"FlowStockDelays\"`},\n\t\t},\n\t}\n\n\tf := func(tc testCase) *httpexpect.Response {\n\t\treturn e.GET(\"/api/flow_stock_delays\").WithQuery(\"Days\", tc.Param).\n\t\t\tWithHeader(\"Authorization\", \"Bearer \"+tc.Token).Expect()\n\t}\n\tfor _, r := range chkTestCases(testCases, f, \"GetTestFlowStockDelays\") {\n\t\tt.Error(r)\n\t}\n}" ]
[ "0.7621378", "0.7582608", "0.7352041", "0.7241707", "0.67065245", "0.65239376", "0.63721323", "0.62590486", "0.57924837", "0.5644563", "0.561969", "0.55195695", "0.53890467", "0.5360754", "0.50424826", "0.48752633", "0.48446065", "0.48370668", "0.48054647", "0.47395724", "0.4733997", "0.46634093", "0.45674676", "0.4564064", "0.4519784", "0.45172015", "0.4487372", "0.447176", "0.4466439", "0.4442246", "0.44101363", "0.44095445", "0.4387579", "0.4371409", "0.43257177", "0.43169874", "0.4296828", "0.4288599", "0.42829278", "0.42508897", "0.4240845", "0.42275846", "0.42132697", "0.4210444", "0.42034528", "0.41989332", "0.4192439", "0.41803446", "0.41737294", "0.4158915", "0.41377488", "0.41349518", "0.4119002", "0.41092044", "0.41038266", "0.40798315", "0.40751433", "0.40616062", "0.40564784", "0.4048634", "0.40455347", "0.40438902", "0.40427238", "0.40414003", "0.40400636", "0.40397638", "0.40293422", "0.4022947", "0.40101933", "0.3998504", "0.39820653", "0.3981731", "0.39802366", "0.396726", "0.39642143", "0.3963433", "0.39610413", "0.39542684", "0.39499128", "0.39498422", "0.39462292", "0.39453188", "0.39411962", "0.39223224", "0.39186394", "0.3917921", "0.3914849", "0.3914104", "0.39066127", "0.39025518", "0.3900097", "0.38899568", "0.38808292", "0.38794267", "0.3878661", "0.38777426", "0.38749528", "0.3872595", "0.3867953", "0.38640344" ]
0.76513666
0