Home / Function/ findWildcard() — gin Function Reference

findWildcard() — gin Function Reference

Architecture documentation for the findWildcard() function in tree.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  10c537e5_647e_9949_f47a_4a50718bf85b["findWildcard()"]
  1a47c43a_b5cc_8545_a924_5d7bc35fb4bc["insertChild()"]
  1a47c43a_b5cc_8545_a924_5d7bc35fb4bc -->|calls| 10c537e5_647e_9949_f47a_4a50718bf85b
  style 10c537e5_647e_9949_f47a_4a50718bf85b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tree.go lines 253–286

func findWildcard(path string) (wildcard string, i int, valid bool) {
	// Find start
	escapeColon := false
	for start, c := range []byte(path) {
		if escapeColon {
			escapeColon = false
			if c == ':' {
				continue
			}
			panic("invalid escape string in path '" + path + "'")
		}
		if c == '\\' {
			escapeColon = true
			continue
		}
		// A wildcard starts with ':' (param) or '*' (catch-all)
		if c != ':' && c != '*' {
			continue
		}

		// Find end and check for invalid characters
		valid = true
		for end, c := range []byte(path[start+1:]) {
			switch c {
			case '/':
				return path[start : start+1+end], start, valid
			case ':', '*':
				valid = false
			}
		}
		return path[start:], start, valid
	}
	return "", -1, false
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does findWildcard() do?
findWildcard() is a function in the gin codebase.
What calls findWildcard()?
findWildcard() is called by 1 function(s): insertChild.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free