fix(hostman): cmdline option range panic

This commit is contained in:
Zexi Li
2022-01-21 11:40:25 +08:00
parent b932984ba6
commit 43f4800cb8
+5 -3
View File
@@ -66,12 +66,14 @@ func (o Option) ToString() string {
type OptionFilter func(Option) bool
func (cl *Cmdline) FilterOption(filter OptionFilter) {
for i, op := range cl.options {
opts := make([]Option, 0)
for _, op := range cl.options {
if filter(op) {
// remove this option
cl.options = append(cl.options[:i], cl.options[i+1:]...)
continue
}
opts = append(opts, op)
}
cl.options = opts
}
func (cl *Cmdline) AddOption(opts ...Option) *Cmdline {