Home / Function/ RandStringBytesMaskImprSrcSB() — gin Function Reference

RandStringBytesMaskImprSrcSB() — gin Function Reference

Architecture documentation for the RandStringBytesMaskImprSrcSB() function in bytesconv_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  4eb1d727_3880_cd01_9901_65a9a995c9b5["RandStringBytesMaskImprSrcSB()"]
  69530ef4_f5f3_deb3_9a65_117780f0140b["bytesconv_test.go"]
  4eb1d727_3880_cd01_9901_65a9a995c9b5 -->|defined in| 69530ef4_f5f3_deb3_9a65_117780f0140b
  ce67aad0_60c6_a9a5_3e65_a289b3820ad1["TestStringToBytes()"]
  ce67aad0_60c6_a9a5_3e65_a289b3820ad1 -->|calls| 4eb1d727_3880_cd01_9901_65a9a995c9b5
  style 4eb1d727_3880_cd01_9901_65a9a995c9b5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

internal/bytesconv/bytesconv_test.go lines 62–79

func RandStringBytesMaskImprSrcSB(n int) string {
	sb := strings.Builder{}
	sb.Grow(n)
	// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
	for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
		if remain == 0 {
			cache, remain = src.Int63(), letterIdxMax
		}
		if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
			sb.WriteByte(letterBytes[idx])
			i--
		}
		cache >>= letterIdxBits
		remain--
	}

	return sb.String()
}

Subdomains

Frequently Asked Questions

What does RandStringBytesMaskImprSrcSB() do?
RandStringBytesMaskImprSrcSB() is a function in the gin codebase, defined in internal/bytesconv/bytesconv_test.go.
Where is RandStringBytesMaskImprSrcSB() defined?
RandStringBytesMaskImprSrcSB() is defined in internal/bytesconv/bytesconv_test.go at line 62.
What calls RandStringBytesMaskImprSrcSB()?
RandStringBytesMaskImprSrcSB() is called by 1 function(s): TestStringToBytes.

Analyze Your Own Codebase

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

Try Supermodel Free