//多余的换行--add by lyken 20160819
334924
func DepriveMutiBreak(s string) string {
	re, _ := regexp.Compile(`([^\n\f\r\t 　 ]*)([ 　 ]*[\n\f\r\t]+[ 　 ]*)+`)
	return re.ReplaceAllString(s, "${1}\n")

}
1068675
func (c *Copier) Run() {
	for src, w := range c.srcs {
		c.copyJobs.Add(1)
		go c.copySrc(src, w)
	}
}
431590
func (d *commandSQLAll) Run() error {
	sqls, indexes := getDbCreateSQL(d.al)
	var all []string
	for i, mi := range modelCache.allOrdered() {
		queries := []string{sqls[i]}
		for _, idx := range indexes[mi.table] {
			queries = append(queries, idx.SQL)
		}
		sql := strings.Join(queries, "\n")
		all = append(all, sql)
	}
	fmt.Println(strings.Join(all, "\n\n"))

	return nil
}
66882
func (interview *Interview) Run() (map[string]interface{}, error) {
	answers := make(map[string]interface{}, len(interview.Questions))
	for index, question := range interview.Questions {
		// If they haven't set the answer type, set it to String
		if question.AnswerKind == reflect.Invalid {
			question.AnswerKind = reflect.String
		}

		// If they haven't set a key, return an error
		if question.Key == "" {
			return nil, fmt.Errorf("Question %d has no key", index)
		}

		// If they haven't set the text for a question, return an error
		if question.Text == "" {
			return nil, fmt.Errorf("Question %d has no text", index)
		}

		answer, err := interview.getAnswer(&question)
		if err == nil {
			answers[question.Key] = answer
		} else {
			return answers, err
		}
	}
	return answers, nil
}
1139065
func Run(argv interface{}, fn CommandFunc, descs ...string) int {
	return RunWithArgs(argv, os.Args, fn, descs...)
}
1290414
func (c *Cron) Add(s Schedule, j Job) {

	entry := &Entry{
		Schedule: s,
		Job:      j,
	}

	if !c.running {
		c.entries = append(c.entries, entry)
		return
	}
	c.add <- entry
}
1142804
func (h Handler) Append(cmd common.SetRequest) error {
	_, err := h.doRequest(cmd, common.RequestAppend)
	return err
}
707816
func (i *DefaultInterpreter) Execute(
	expression string,
	ctx *Context) (interface{}, error) {
	funcs := template.FuncMap{}
	for k, v := range i.Funcs {
		funcs[k] = v
	}
	var res interface{}
	resultEvaluated := false
	funcs["set"] = func(r interface{}) interface{} {
		res = r
		resultEvaluated = true
		return r
	}
	funcs["eval"] = func(intrpr, expr string) (interface{}, error) {
		return ctx.EvalExpr(intrpr, expr, ctx)
	}
	templName := fmt.Sprintf("<<%s>>", ctx.LongName)
	left := i.LeftDelim
	right := i.RightDelim
	if left == "" {
		left = "{{"
	}
	if right == "" {
		right = "}}"
	}
	if i.AutoEnclose &&
		!(strings.HasPrefix(expression, left) &&
			strings.HasSuffix(expression, right)) {
		expression = fmt.Sprintf("%s%s%s", left, expression, right)
	}
	t, err := template.
		New(templName).
		Delims(left, right).
		Funcs(funcs).
		Parse(expression)
	if err != nil {
		return nil, err
	}
	var buf bytes.Buffer
	err = t.Execute(&buf, ctx)
	if err != nil {
		return nil, err
	}
	if resultEvaluated {
		return res, nil
	}
	return buf.String(), nil
}
1122984
func (this *SafeRpcConnPools) Call(addr, method string, args interface{}, resp interface{}) error {
	connPool, exists := this.Get(addr)
	if !exists {
		return fmt.Errorf("%s has no connection pool", addr)
	}

	conn, err := connPool.Get()
	if err != nil || conn == nil { //conn可能为空,这也属于异常情况 add by niean
		return fmt.Errorf("%s get connection fail: conn %v, err %v", addr, conn, err)
	}

	rpcClient := conn.(RpcClient)
	callTimeout := time.Duration(this.CallTimeout) * time.Millisecond

	done := make(chan error, 1)
	go func() {
		done <- rpcClient.Call(method, args, resp)
	}()

	select {
	case <-time.After(callTimeout):
		connPool.ForceClose(conn)
		return fmt.Errorf("CallTimeout: %s", addr)
	case err = <-done:
		if err != nil {
			connPool.ForceClose(conn)
		} else {
			connPool.Release(conn)
		}
		return err
	}
}
972166
func (c *diffCommand) Run(ctx *cmd.Context) error {
	client, err := c.getAPI()
	if err != nil {
		return err
	}
	defer func() { _ = client.Close() }()

	// Partially apply our time format
	formatTime := func(t time.Time) string {
		return common.FormatTime(&t, c.isoTime)
	}

	deltas, err := client.BranchInfo(c.branchName, c.detailed, formatTime)
	if err != nil {
		return errors.Trace(err)
	}
	return errors.Trace(c.out.Write(ctx, deltas))
}
855419
func main() {
	if len(os.Args) != 4 {
		fmt.Fprintf(os.Stderr, "expected 3 arguments, got %d\n", len(os.Args)-1)
		exit.Exit(1)
	}

	// No error checking here, it's a contrived example after all.
	a, _ := strconv.Atoi(os.Args[2])
	b, _ := strconv.Atoi(os.Args[3])

	var op func(int, int) int
	switch os.Args[1] {
	case "add":
		op = add
	case "sub":
		op = sub
	default:
		fmt.Fprintf(os.Stderr, "unknown operation: %s\n", os.Args[1])
		exit.Exit(1)
	}

	fmt.Println(op(a, b))
}
216433
func (ari *ARInGO) Call(method, reqUrl string, data url.Values) (reply []byte, err error) {
	var reqBody io.Reader
	switch method {
	case HTTP_GET: // Add data inside url
		u, _ := url.ParseRequestURI(reqUrl)
		u.RawQuery = data.Encode()
		reqUrl = u.String()
	case HTTP_POST, HTTP_DELETE:
		reqBody = bytes.NewBufferString(data.Encode())
	default:
		return nil, fmt.Errorf("Unrecognized method: %s", method)
	}
	req, err := http.NewRequest(method, reqUrl, reqBody)
	if err != nil {
		return nil, err
	}
	req.Header.Set("User-Agent", ari.userAgent)
	req.SetBasicAuth(ari.username, ari.password)
	resp, err := ari.httpClient.Do(req)
	if err != nil {
		return nil, err
	} else if resp.StatusCode == 204 { // No content status code
		return nil, nil
	} else if resp.StatusCode != 200 {
		return nil, NewErrUnexpectedReplyCode(resp.StatusCode)
	}
	defer resp.Body.Close()
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	if method != HTTP_GET {
		return nil, nil
	}
	return respBody, nil

}
800936
func (e *Identify2WithUID) Run(m libkb.MetaContext) (err error) {

	m = m.WithLogTag("ID2")

	n := fmt.Sprintf("Identify2WithUID#Run(UID=%v, Assertion=%s)", e.arg.Uid, e.arg.UserAssertion)
	defer m.TraceTimed(n, func() error { return err })()
	m.Debug("| Full Arg: %+v", e.arg)

	if e.arg.Uid.IsNil() {
		return libkb.NoUIDError{}
	}

	// Only the first send matters, but we don't want to block the subsequent no-op
	// sends. This code will break when we have more than 100 unblocking opportunities.
	ch := make(chan error, 100)

	e.resultCh = ch
	go e.run(m)
	err = <-ch

	// Potentially reset the error based on the error and the calling context.
	err = e.resetError(m, err)
	return err
}
542329
func (c *ExpandSpec) Execute(args []string) error {
	if len(args) != 1 {
		return errors.New("The expand command requires the single swagger document url to be specified")
	}

	swaggerDoc := args[0]
	specDoc, err := loads.Spec(swaggerDoc)
	if err != nil {
		return err
	}

	exp, err := specDoc.Expanded()
	if err != nil {
		return err
	}

	return writeToFile(exp.Spec(), !c.Compact, c.Format, string(c.Output))
}
756599
func (c *Cron) AddFunc(spec string, cmd func()) error {
	return c.AddJob(spec, FuncJob(cmd))
}
312827
func (a *Application) Run() int {
	if len(os.Args) < 1 {
		panic("shell-provided arguments are not present")
	}
	arguments := os.Args[1:]
	// $ program
	//           ^ no args
	if len(arguments) == 0 {
		if a.Default == nil {
			a.println(a.globalHelp())
			return 0
		}

		return a.Default(*newContext(a))
	}

	yankeeGoHome := func(errMsg string) {
		a.printerr(errMsg)
		os.Exit(1)
	}

	subcommandName := arguments[0]
	subcommand := a.commandByName(subcommandName)

	if subcommandName == "help" {
		// $ program help
		//           ^ one argument
		if len(arguments) <= 1 {
			a.println(a.globalHelp())
			return 0
		}

		command := a.commandByName(arguments[1])
		if command != nil {
			a.println(a.commandHelp(command))
			return 0
		}

		topic := a.topicByName(arguments[1])
		if topic != nil {
			a.println(topic.Text)
			return 0
		}

		yankeeGoHome("no such command or help topic")
	}

	if subcommandName == "version" {
		if subcommand != nil {
			return subcommand.Run(Context{})
		}

		a.printf("%s version %s\n", a.Name, a.Version)
		return 0
	}

	if subcommand != nil {
		context, err := a.parseContext(subcommand.Flags, arguments[1:])
		if err != nil {
			yankeeGoHome(err.Error())
		}

		return subcommand.Run(*context)
	}

	yankeeGoHome("unknown subcommand \"" + subcommandName + "\"\n")
	return 1
}
1092800
func (r *Run) Error(err error) {
	r.errsMutex.Lock()
	r.errs = append(r.errs, err)
	r.errsMutex.Unlock()
}