Skip to content

修复可能的 context 泄露以及遗漏的错误处理 #1965

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

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

huiyifyj
Copy link
Contributor

  • .gitignore: 忽略 Windows 下编译的二进制文件和 SQLite 数据文件
  • 修复结构体 tag 字段的错误使用, 结构体的 tag 字段的多个 key-value 对需要使用空格分隔
  • 处理返回的 cancel 函数, 避免 context 泄露
  • 修复 UpdateCasbinApi 方法遗漏的错误处理

结构体的 tag 字段的多个 key-value 对需要使用空格分隔,否则会有以下警告:
struct field tag `json:"attachments" form:"attachments" gorm:"column:attachments;comment:相关附件;"swaggertype:"array,object"` not compatible with reflect.StructTag.Get: key:"value" pairs not separated by spaces
不处理 cancel 相关返回函数,会造成 context 一直停留在 background.
the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak
@pixelmaxQm pixelmaxQm merged commit 2bf423b into flipped-aurora:main Dec 17, 2024
8 checks passed
@huiyifyj huiyifyj deleted the err-and-ctx branch December 19, 2024 09:38
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