Closed lysShub closed 2 months ago
//go:build linux // +build linux package main import ( "bytes" "fmt" "io" _ "net/http/pprof" "os" "github.com/edsrzf/mmap-go" ) func main() { f, err := os.Open("/proc/net/tcp") if err != nil { panic(err) } b1, err := io.ReadAll(f) if err != nil { panic(err) } fmt.Println("normal", bytes.Count(b1, []byte{'\n'})) b2, err := mmap.Map(f, mmap.RDONLY, 0) if err != nil { panic(err) } fmt.Println("mmap", bytes.Count(b2, []byte{'\n'})) }
output:
normal 7 panic: invalid argument goroutine 1 [running]: main.main() /root/atest/main.go:27 +0x18d exit status 2
output: