Skip to content

Commit

Permalink
修复filter不生效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
M09Ic committed Nov 15, 2022
1 parent df3497c commit 5ad24f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/chainreactors/files v0.2.4
github.com/chainreactors/ipcs v0.0.9
github.com/chainreactors/logs v0.6.1
github.com/chainreactors/parsers v0.2.6
github.com/chainreactors/parsers v0.2.8
github.com/jessevdk/go-flags v1.5.0
github.com/panjf2000/ants/v2 v2.5.0
golang.org/x/net v0.0.0-20190603091049-60506f45cf65
Expand Down
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/chainreactors/ipcs v0.0.9 h1:4Onroq7gXLG5SLCCgNDx3JmtLxB4XgepGdHCtLp1
github.com/chainreactors/ipcs v0.0.9/go.mod h1:E9M3Ohyq0TYQLlV4i2dbM9ThBZB1Nnd7Oexoie2xLII=
github.com/chainreactors/logs v0.6.1 h1:+wLVqxErUyWYayAx6x+m5LA6jQBiHcLdTAJtiOUMoZU=
github.com/chainreactors/logs v0.6.1/go.mod h1:Y0EtAnoF0kiASIJUnXN0pcOt420iRpHOAnOhEphzRHA=
github.com/chainreactors/parsers v0.2.6 h1:yT7sh0xFHAA82BIKm3fHM3yLnhP7k7mGR/c6udM1E4k=
github.com/chainreactors/parsers v0.2.6/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
github.com/chainreactors/parsers v0.2.8 h1:97iv29dYCw+Yye/MzSkgdK0DPBDjSbS2k+RsdkHo1v4=
github.com/chainreactors/parsers v0.2.8/go.mod h1:Z9weht+lnFCk7UcwqFu6lXpS7u5vttiy0AJYOAyCCLA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
3 changes: 3 additions & 0 deletions v2/internal/core/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func InitConfig(config *Config) (*Config, error) {

if config.Results != nil && config.Filters != nil {
var results parsers.GOGOResults
if !config.FilterOr {
results = config.Results
}
for _, filter := range config.Filters {
if config.FilterOr {
results = append(results, config.Results.FilterWithString(filter)...)
Expand Down
5 changes: 4 additions & 1 deletion v2/internal/core/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ func FormatOutput(filename, outFilename, outf, filenamef string, filters []strin
} else if rd != nil && rd.Data != nil {
if len(filters) > 0 {
var results parsers.GOGOResults
if !filterOr {
results = rd.Data
}
for _, filter := range filters {
if filterOr {
results = append(results, rd.Filter(filter)...)
} else {
results = results.FilterWithString(filter)
results = rd.Data.FilterWithString(filter)
}
}
rd.Data = results
Expand Down

0 comments on commit 5ad24f8

Please sign in to comment.