Skip to content

Commit

Permalink
fix: remove outdated example test (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ullaakut authored Oct 11, 2024
1 parent 282fbd9 commit 1bef796
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,3 @@ func ExampleScanner_simple() {
)
// Output: Scan successful: 3 hosts up
}

// A scanner can be given custom idiomatic filters for both hosts
// and ports.
func ExampleScanner_filters() {
s, err := NewScanner(
context.Background(),
WithTargets("google.com", "facebook.com"),
WithPorts("843"),
WithFilterHost(func(h Host) bool {
// Filter out hosts with no open ports.
for idx := range h.Ports {
if h.Ports[idx].Status() == "closed" {
return true
}
}
return false
}),
)
if err != nil {
log.Fatalf("unable to create nmap scanner: %v", err)
}

scanResult, _, err := s.Run()
if err != nil {
log.Fatalf("nmap encountered an error: %v", err)
}

fmt.Printf(
"Filtered out hosts %d / Original number of hosts: %d\n",
len(scanResult.Hosts),
scanResult.Stats.Hosts.Total,
)
// Output: Filtered out hosts 1 / Original number of hosts: 2
}

0 comments on commit 1bef796

Please sign in to comment.