// pathAppendQueryFromCtx append query string to path in bytes
481329
func (r *Router) trimTrailingSlash(path string) (string, bool) {
	if len(path) > one && path[len(path)-one] == SlashByte {
		return path[:len(path)-one], true
	}

	return path, false
}
538511
func (c *Client) Search(path, query string) (list []os.FileInfo, err error) {
	var start uint64

more:
	out, err := c.Files.Search(&dropbox.SearchInput{
		Mode:  dropbox.SearchModeFilename,
		Path:  path,
		Query: query,
		Start: start,
	})

	if err != nil {
		return
	}

	for _, match := range out.Matches {
		list = append(list, &FileInfo{match.Metadata})
	}

	if out.More {
		start = out.Start
		goto more
	}

	return
}
410172
func (m MiddlewareFunc) PathEndsWith(tests ...string) MiddlewareFunc {
	return func(h HandlerFunc) HandlerFunc {
		return func(c *Context) error {
			for _, test := range tests {
				if strings.HasSuffix(c.Request().URL().Path, test) {
					return m(h)(c)
				}
			}
			return h(c)
		}
	}
}
64349
func (l *OSFileSystemLoader) AddPath(path string) {
	l.dirs = append(l.dirs, path)
}
1128040
func (d *Diskv) pathFor(pathKey *PathKey) string {
	return filepath.Join(d.BasePath, filepath.Join(pathKey.Path...))
}
818754
func query(v interface{}) string {
	var buf bytes.Buffer
	writeQuery(&buf, reflect.TypeOf(v), false)
	return buf.String()
}
1332789
func (g *Container) ArrayAppendP(value interface{}, path string) error {
	return g.ArrayAppend(value, strings.Split(path, ".")...)
}
356577
func BlockIndexPathCtx(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		pathIdxStr := chi.URLParam(r, "idx")
		idx, err := strconv.Atoi(pathIdxStr)
		if err != nil {
			apiLog.Infof("No/invalid idx value (int64): %v", err)
			http.Error(w, "Valid index not provided", http.StatusBadRequest)
			return
		}
		ctx := context.WithValue(r.Context(), ctxBlockIndex, idx)
		next.ServeHTTP(w, r.WithContext(ctx))
	})
}
303692
func (b *Builder) AppendPathPrefix(childPath string) *Builder {
	b.pathPrefix = fmt.Sprintf("%s/%s", b.pathPrefix, childPath)
	return b
}
324438
func (cli *Client) getAPIPath(ctx context.Context, p string, query url.Values) string {
	var apiPath string
	if cli.negotiateVersion && !cli.negotiated {
		cli.NegotiateAPIVersion(ctx)
	}
	if cli.version != "" {
		v := strings.TrimPrefix(cli.version, "v")
		apiPath = path.Join(cli.basePath, "/v"+v, p)
	} else {
		apiPath = path.Join(cli.basePath, p)
	}
	return (&url.URL{Path: apiPath, RawQuery: query.Encode()}).String()
}
1340987
func GetQueryKey(q *protocol.KontrolQuery) (string, error) {
	fields := q.Fields()

	if q.Username == "" {
		return "", errors.New("Empty username field")
	}

	// Validate query and build key.
	path := "/"

	empty := false   // encountered with empty field?
	empytField := "" // for error log

	// http://golang.org/doc/go1.3#map, order is important and we can't rely on
	// maps because the keys are not ordered :)
	for _, key := range keyOrder {
		v := fields[key]
		if v == "" {
			empty = true
			empytField = key
			continue
		}

		if empty && v != "" {
			return "", fmt.Errorf("Invalid query. Query option is not set: %s", empytField)
		}

		path = path + v + "/"
	}

	path = strings.TrimSuffix(path, "/")

	return path, nil
}
635277
func (p *Importer) absPath(path string) (string, error) {
	// TODO(gri) This should be using p.ctxt.AbsPath which doesn't
	// exist but probably should. See also issue #14282.
	return filepath.Abs(path)
}
792958
func (r *ResponseMatcher) Path(p string) *ResponseMatcher {
	r.mux.mu.Lock()
	defer r.mux.mu.Unlock()
	r.path = p
	return r
}
1365962
func (tx *Tx) Queryx(query string, args ...interface{}) (*Rows, error) {
	r, err := tx.Tx.Query(query, args...)
	if err != nil {
		return nil, err
	}
	return &Rows{Rows: r, unsafe: tx.unsafe, Mapper: tx.Mapper}, err
}
786421
func (r *Route) URLPath(pairs ...string) (*url.URL, error) {
	if r.err != nil {
		return nil, r.err
	}
	if r.regexp.path == nil {
		return nil, errors.New("mux: route doesn't have a path")
	}
	values, err := r.prepareVars(pairs...)
	if err != nil {
		return nil, err
	}
	path, err := r.regexp.path.url(values)
	if err != nil {
		return nil, err
	}
	return &url.URL{
		Path: path,
	}, nil
}
1235347
func (t *TermsLookup) Path(path string) *TermsLookup {
	t.path = path
	return t
}
33955
func ModuleFromPath(path string, addGopathToPath bool) (module *Module) {
	path = filepath.ToSlash(path)
	gopathList := filepath.SplitList(build.Default.GOPATH)
	// Strip away the vendor folder
	if i := strings.Index(path, "/vendor/"); i > 0 {
		path = path[i+len("vendor/"):]
	}

	// See if the path exists in the module based
	for i := range Modules {
		if addGopathToPath {
			for _, gopath := range gopathList {
				if strings.Contains(filepath.ToSlash(filepath.Clean(filepath.Join(gopath, "src", path))), Modules[i].Path) {
					module = Modules[i]
					break
				}
			}
		} else {
			if strings.Contains(path, Modules[i].ImportPath) {
				module = Modules[i]
				break
			}

		}

		if module != nil {
			break
		}
	}
	// Default to the app module if not found
	if module == nil {
		module = appModule
	}
	return
}