Home / Function/ exampleFromPath() — gin Function Reference

exampleFromPath() — gin Function Reference

Architecture documentation for the exampleFromPath() function in githubapi_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  0f251ec6_14b4_8106_498e_821d4e2701cd["exampleFromPath()"]
  1646b258_e7f1_cf1f_a20c_d424353f229f["TestShouldBindUri()"]
  1646b258_e7f1_cf1f_a20c_d424353f229f -->|calls| 0f251ec6_14b4_8106_498e_821d4e2701cd
  d481f77e_8cd4_8033_4129_01f247749eb5["TestBindUri()"]
  d481f77e_8cd4_8033_4129_01f247749eb5 -->|calls| 0f251ec6_14b4_8106_498e_821d4e2701cd
  e8015410_516c_1aef_08a0_a9d9b75b0c12["TestBindUriError()"]
  e8015410_516c_1aef_08a0_a9d9b75b0c12 -->|calls| 0f251ec6_14b4_8106_498e_821d4e2701cd
  402e91d6_1dc1_1679_a526_c5dc3a682eb4["TestGithubAPI()"]
  402e91d6_1dc1_1679_a526_c5dc3a682eb4 -->|calls| 0f251ec6_14b4_8106_498e_821d4e2701cd
  style 0f251ec6_14b4_8106_498e_821d4e2701cd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

githubapi_test.go lines 405–438

func exampleFromPath(path string) (string, Params) {
	output := new(strings.Builder)
	params := make(Params, 0, 6)
	start := -1
	for i, c := range path {
		if c == ':' {
			start = i + 1
		}
		if start >= 0 {
			if c == '/' {
				value := strconv.Itoa(rand.Intn(100000))
				params = append(params, Param{
					Key:   path[start:i],
					Value: value,
				})
				output.WriteString(value)
				output.WriteRune(c)
				start = -1
			}
		} else {
			output.WriteRune(c)
		}
	}
	if start >= 0 {
		value := strconv.Itoa(rand.Intn(100000))
		params = append(params, Param{
			Key:   path[start:],
			Value: value,
		})
		output.WriteString(value)
	}

	return output.String(), params
}

Domain

Subdomains

Frequently Asked Questions

What does exampleFromPath() do?
exampleFromPath() is a function in the gin codebase.
What calls exampleFromPath()?
exampleFromPath() is called by 4 function(s): TestBindUri, TestBindUriError, TestGithubAPI, TestShouldBindUri.

Analyze Your Own Codebase

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

Try Supermodel Free