Hello,
Could you please help me with the following code with O_DIRECT and array. I tried to implement direct io and stuck with weird behaviour of alignment writes created from array. Following code doesn't work: package main import ( "os" "syscall" ) func main() { var p [2 << 16]byte for i := 0; i < len(p); i++ { p[i] = byte(' ' + i%('~'-' ')) } f, _ := os.OpenFile("/tmp/1.txt", os.O_TRUNC|os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0666) defer f.Close() f.Write(p[:]) } But, if I make a copy of that array – it's OK: package main import ( "os" "syscall" ) func main() { var p [2 << 16]byte for i := 0; i < len(p); i++ { p[i] = byte(' ' + i%('~'-' ')) } f, _ := os.OpenFile("/tmp/1.txt", os.O_TRUNC|os.O_CREATE|os.O_WRONLY|syscall.O_DIRECT, 0666) defer f.Close() var a []byte // <----- copy a = append(a, p[:]...) // <----/ f.Write(a) } Can't figure this out. And how to catch such behaviour in runtime. Thank you! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.