Skip to content

Commit e9932b4

Browse files
authored
Merge pull request #44 from AkihiroSuda/dev
analyzer: suppress redundant output
2 parents 3beff5a + dcff267 commit e9932b4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/analyzer/analyzer.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ type Opts struct {
2929

3030
func New(ctx context.Context, opts Opts) (*analysis.Analyzer, error) {
3131
inst := &instance{
32-
Opts: opts,
33-
gusser: modpath.NewGuesser(),
32+
Opts: opts,
33+
gusser: modpath.NewGuesser(),
34+
processedSums: make(map[string]struct{}),
3435
}
3536
a := &analysis.Analyzer{
3637
Name: "gosocialcheck",
@@ -45,7 +46,8 @@ func New(ctx context.Context, opts Opts) (*analysis.Analyzer, error) {
4546

4647
type instance struct {
4748
Opts
48-
gusser *modpath.Guesser
49+
gusser *modpath.Guesser
50+
processedSums map[string]struct{}
4951
}
5052

5153
func run(ctx context.Context, inst *instance) func(*analysis.Pass) (any, error) {
@@ -99,6 +101,10 @@ func run(ctx context.Context, inst *instance) func(*analysis.Pass) (any, error)
99101
continue
100102
}
101103
h1 := goSum[modV.Path+" "+modV.Version]
104+
if _, ok := inst.processedSums[h1]; ok {
105+
continue
106+
}
107+
inst.processedSums[h1] = struct{}{}
102108
slog.DebugContext(ctx, "module", "path", p, "modpath", modV.Path, "modver", modV.Version, "h1", h1)
103109
hit, err := inst.Opts.Cache.Lookup(ctx, h1)
104110
if err != nil {

0 commit comments

Comments
 (0)