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

pass pointer instead of slice to Find(...) method #1229

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

sivukhin
Copy link

I ran govanish linter for this repo and it reported few issues:

2025/01/13 00:54:13 module path: /home/sivukhin/code/answer
2025/01/13 00:54:13 ready to compile project at path '/home/sivukhin/code/answer' for assembly inspection
2025/01/13 00:54:13 ready to parse assembly output
2025/01/13 00:54:52 ready to normalize assembly lines (size 330)
2025/01/13 00:54:55 built func registry: 1301 entries
2025/01/13 00:54:55 ready to analyze module AST
2025/01/13 00:54:55 it seems like your code vanished from compiled binary: func=[GetUnreviewedRevisionInfo], file=[/home/sivukhin/code/answer/internal/service/object_info/object_info.go], lines=[82-82], snippet:
	return nil, err
2025/01/13 00:54:55 it seems like your code vanished from compiled binary: func=[Add], file=[/home/sivukhin/code/answer/internal/controller/answer_controller.go], lines=[288-289], snippet:
	handler.HandleResponse(ctx, errors.Forbidden(reason.RankFailToMeetTheCondition), nil)
2025/01/13 00:54:55 it seems like your code vanished from compiled binary: func=[GetAnswerList], file=[/home/sivukhin/code/answer/internal/repo/answer/answer_repo.go], lines=[207-208], snippet:
	item.ID = uid.EnShortID(item.ID)
2025/01/13 00:54:55 it seems like your code vanished from compiled binary: func=[GetAnswerPage], file=[/home/sivukhin/code/answer/internal/repo/answer/answer_repo.go], lines=[225-226], snippet:
	item.ID = uid.EnShortID(item.ID)
2025/01/13 00:54:55 it seems like your code vanished from compiled binary: func=[GetQuestionList], file=[/home/sivukhin/code/answer/internal/repo/question/question_repo.go], lines=[272-272], snippet:
	item.ID = uid.DeShortID(item.ID)

Last three of reported issues look suspicious because ID conversion actually shouldn't be removed by Golang from the final ASM instruction list. Looking more closely to the code it seems like there is a bug as slice passed by value to the Find(...) method and seems like go compiler can derive that slice length will be unchanged - so will be zero for the whole function body.

@shuashuai shuashuai requested a review from LinkinStars January 13, 2025 01:47
@LinkinStars LinkinStars self-assigned this Jan 13, 2025
@LinkinStars LinkinStars changed the base branch from main to dev January 13, 2025 08:28
Copy link
Member

@LinkinStars LinkinStars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

@LinkinStars LinkinStars merged commit 6d84720 into apache:dev Jan 13, 2025
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

Successfully merging this pull request may close these issues.

2 participants