This is an attempt to mmap
a file and write a single byte:
package main
import (
"fmt"
"os"
"syscall"
)
func main() {
file, _ := os.Open("/tmp/data")
mmap, _ := syscall.Mmap(int(file.Fd()), 0, 100, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED)
fmt.Printf("cap is %d", cap(mmap))
mmap[0] = 0
syscall.Munmap(mmap)
}
Despite length is set to 100, mmap
capacity is always 0. What went wrong in the system call?