How ullaakut/nmap works
Project type and purpose
• This is a Go library that provides idiomatic bindings to the Nmap network scanner.
• Purpose: allow Go programs to build and run Nmap scans, parse the XML output into Go structs, and offer filtering/streaming/async capabilities.
File structure
• Top-level files:
• errors.go, xml.go, nmap.go, iflist.go — core logic for building options, invoking Nmap, parsing XML, listing interfaces
• options*.go — each file defines a category of Nmap command-line options (host discovery, OS detection, scripts, timing, etc.)
• pkg/osfamilies — definitions of OS families (helper enums)
• examples/ — sample programs illustrating use of the API (basic scans, async, progress, streaming, filtering)
• tests/ — integration tests with fake_nmap shell scripts and sample XML files
• CI config (.github/workflows), Go linting (.golangci.yml), module files (go.mod, go.sum)
Key insights from the README
• The library wraps every native Nmap option in a WithXXX function, uses context for timeouts, returns Go structs + warnings.
• Supports synchronous, asynchronous, progress streaming, output to io.Writer, file output.
• Encourages filtering by host/port and integrates with other tools (e.g., Cameradar).