// End executes the command list.
18281
func (cl *CommandList) End() error {

	// Tell MPD to start an OK command list:
	beginID, beginErr := cl.client.cmd("command_list_ok_begin")
	if beginErr != nil {
		return beginErr
	}
	cl.client.text.StartResponse(beginID)
	cl.client.text.EndResponse(beginID)

	// Ensure the queue is cleared regardless.
	defer cl.cmdQ.Init()

	// Issue all of the queued up commands in the list:
	for e := cl.cmdQ.Front(); e != nil; e = e.Next() {
		cmdID, cmdErr := cl.client.cmd(e.Value.(*command).cmd)
		if cmdErr != nil {
			return cmdErr
		}
		cl.client.text.StartResponse(cmdID)
		cl.client.text.EndResponse(cmdID)
	}

	// Tell MPD to end the command list and do the operations.
	endID, endErr := cl.client.cmd("command_list_end")
	if endErr != nil {
		return endErr
	}
	cl.client.text.StartResponse(endID)
	defer cl.client.text.EndResponse(endID)

	// Get the responses back and check for errors:
	for e := cl.cmdQ.Front(); e != nil; e = e.Next() {
		switch e.Value.(*command).typeOf {

		case cmdNoReturn:
			if err := cl.client.readOKLine("list_OK"); err != nil {
				return err
			}

		case cmdAttrReturn:
			a, aErr := cl.client.readAttrs("list_OK")
			if aErr != nil {
				return aErr
			}
			pa := e.Value.(*command).promise.(*PromisedAttrs)
			pa.attrs = a
			pa.computed = true

		case cmdIDReturn:
			a, aErr := cl.client.readAttrs("list_OK")
			if aErr != nil {
				return aErr
			}
			rid, ridErr := strconv.Atoi(a["Id"])
			if ridErr != nil {
				return ridErr
			}
			*(e.Value.(*command).promise.(*PromisedID)) = PromisedID(rid)

		}
	}

	// Finalize the command list with the last OK:
	return cl.client.readOKLine("OK")
}
903134
func endCmdArgs(args []string, off int) []string {
	return append(args[0:off], append([]string{"--"}, args[off:]...)...)
}
1240405
func (w *ResponseWriter) finish() {

	// Determine if we should Base64 encode the output
	contentType := w.response.Headers["Content-Type"]

	// Only encode text content types without base64 encoding
	w.response.IsBase64Encoded = !textContentTypesRegexp.MatchString(contentType)

	if w.response.IsBase64Encoded {
		w.response.Body = base64.StdEncoding.EncodeToString(w.output.Bytes())
	} else {
		w.response.Body = w.output.String()
	}
}
384378
func (dec *Decoder) end() error {
	switch dec.curr.Kind() {
	case reflect.Struct:
		if err := dec.findStructField(); err != nil {
			return err
		}
	case reflect.Map:
		// leave backward compatibility for access to maps by .
		dec.walkInMap(dec.field)
	}
	if dec.value == "" {
		return nil
	}
	return dec.decode()
}
1131258
func Execute(main interface{}) error {
	com, err := Command(main)
	if err != nil {
		return fmt.Errorf("getting command: %v", err)
	}

	return com.Execute()
}
1180081
func (f *Flow) End() *Flow {
	f.add(action{
		kind: actionEnd,
	})

	return f
}
438246
func (list *List) Exit() {

	// Should go down to the last option
	for list.Index != len(list.options) {
		list.Index++
		list.Cursor.MoveDown(1)
	}

	list.Println()
	list.Println()
	list.Print(ShowCursor)

	os.Exit(1)
}
323658
func (c *ClientConn) Terminate(r *TerminateRequest) (err error) {
	err = handlePanic(func() (err error) {
		reqMap := &map[string]interface{}{}
		ConvertToGeneral(r, reqMap)
		msg, err := c.Request("terminate", *reqMap)
		if err != nil {
			return
		}
		if msg["success"] != "yes" {
			return fmt.Errorf("[Terminate] %s", msg["errmsg"])
		}
		return
	})
	return
}
1220867
func (t *Trace) finish() {
	if t.End.IsZero() {
		t.End = time.Now()
	}
}
779157
func (m *Command) Close() error {
	defer close(m.done)
	eg := errgroup.Group{}
	eg.Go(m.Handler.Close)
	eg.Go(m.Server.Close)
	if m.gossipMemberSet != nil {
		eg.Go(m.gossipMemberSet.Close)
	}
	if closer, ok := m.logOutput.(io.Closer); ok {
		// If closer is os.Stdout or os.Stderr, don't close it.
		if closer != os.Stdout && closer != os.Stderr {
			eg.Go(closer.Close)
		}
	}

	err := eg.Wait()
	return errors.Wrap(err, "closing everything")
}
792114
func (l *loop) terminate(err error) {
	l.mux.Lock()
	defer l.mux.Unlock()
	if l.err == nil {
		l.err = err
	}
	if l.status != Running {
		return
	}
	l.status = Stopping
	select {
	case <-l.stopC:
	default:
		close(l.stopC)
	}
}
680249
func (w *SSTFileWriter) Finish() error {
	var cErr *C.char
	C.rocksdb_sstfilewriter_finish(w.c, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}
1367277
func (ctx *Context) End(code int, buf ...[]byte) (err error) {
	if ctx.Res.ended.swapTrue() {
		var body []byte
		if len(buf) > 0 {
			body = buf[0]
		}
		err = ctx.Res.respond(code, body)
	} else {
		err = ErrInternalServerError.WithMsg("request ended before ctx.End")
	}
	return
}
907865
func (aw *AnsiWriter) finish(parse func([]byte) error) error {
	var err error

	if parse != nil {
		err = parse(aw.buf[2:])
	}

	aw.buf = nil
	return err
}
199025
func (c *TasksCountCall) End(end float64) *TasksCountCall {
	c.urlParams_.Set("end", fmt.Sprint(end))
	return c
}
480736
func (c *MongoController) End() revel.Result {
	// This is necessary since End() will be called no matter what
	// (revel.FINALLY) so it may not be connected in which case MongoSession
	// were a nil pointer and panic
	if c.MongoSession != nil {
		c.MongoSession.Close()
	}
	return nil
}
313157
func exit(code int) {
	for _, fn := range atExit {
		if err := fn(); err != nil {
			fmt.Fprintln(os.Stderr, "atExit:", err)
		}
	}
	os.Exit(code)
}