🔄Update: Lecture-2

This commit is contained in:
2025-10-17 22:15:22 +08:00
parent 79a2c8b766
commit a7b7373b98
4 changed files with 111 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"fmt"
"log"
"github.com/google/gopacket/pcap"
)
func main() {
devices, err := pcap.FindAllDevs()
if err != nil {
log.Fatal(err)
}
// Print: Device
fmt.Println("Device Found: ")
for _, device := range devices {
fmt.Println("\n[Name] ", device.Name)
fmt.Println("[Description] ", device.Description)
fmt.Println("[Devices addresses] ", device.Description)
for _, address := range device.Addresses {
fmt.Println("- IP address", address.IP)
fmt.Println("- Subnet mask", address.Netmask)
}
}
}