fix(sortedlist): 修复 All() 方法中因 nil 值导致的 panic 问题 #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修复内容
在
sortedlist
包的appendValue
函数中,修正了All
方法初始化迭代器时将nil
作为第一个元素添加到数据切片中,导致后续类型断言iter.Value().(Segment)
时发生 panic 的问题。bug 来源于相关issue:#3具体修改
将原先的条件判断:
修改为:
确保只有非 nil 的值才会被添加到迭代器的数据切片中,从而避免类型断言时的 panic。