Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: Please tell me the meaning of 255. #2583

Open
itcuihao opened this issue Dec 15, 2020 · 4 comments
Open

question: Please tell me the meaning of 255. #2583

itcuihao opened this issue Dec 15, 2020 · 4 comments

Comments

@itcuihao
Copy link

  • With issues:
    Please tell me the meaning of 255.

Description

How to reproduce

func countParams(path string) uint8 {
	var n uint
	for i := 0; i < len(path); i++ {
		if path[i] != ':' && path[i] != '*' {
			continue
		}
		n++
	}
	if n >= 255 {
		return 255
	}
	return uint8(n)
}
  • go version:go version go1.13 windows/amd64
  • gin version (or commit ref): master
  • operating system:
@Doarakko
Copy link
Contributor

uint8 is unsigned integer 8 bit.
8 bits can represent 0 to 255(2**8-1)

@itcuihao
Copy link
Author

Does it mean that the length of path cannot exceed 255? Why is it so set?

@cpl
Copy link

cpl commented Dec 20, 2020

If I am reading the function correctly, it's counting the named params (:name, :id in the defined path) and not the path length. Check the function usage to understand the possible limtations around it.

@yeqown
Copy link

yeqown commented Jan 22, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants