Radar · Go · Archive · Week 48 · Nov 24 – 30, 2025
syscall: add Open O_* flags for Windows FILE_FLAG_* flags
Worth knowingstdlib
- What changed
- New constants
O_FILE_FLAG_*are added togolang.org/x/sys/windows, andsyscall.Openon Windows accepts these flags and returns an error if unrecognized bits are supplied. - Production impact
- The source does not say.
- Try it
- Use
syscall.OpenwithO_FILE_FLAG_DELETE_ON_CLOSEon Windows and observe the flag is passed to the OS. - Source
- github.com/golang/go/issues/73676
Understand it, then run it
Run it now
// This program demonstrates the current limitation on Windows: the
// syscall package does not expose O_OVERLAPPED (or any FILE_FLAG_*
// flags) and therefore os.Open cannot open a file for overlapped I/O.
// Running this on Windows will simply open the file in the default
// mode and print any error that occurs. The change described in the
// issue would allow passing O_OVERLAPPED to syscall.Open, but that
// constant is not available in Go 1.27.1.
package main
import (
"fmt"
"syscall"
)
func main() {
// Attempt to open a file with the default read-only flag.
// On Windows this will not request overlapped I/O.
fd, err := syscall.Open("example.txt", syscall.O_RDONLY, 0)
if err != nil {
fmt.Printf("open error: %v\n", err)
return
}
defer syscall.Close(fd)
fmt.Println("file opened successfully (no overlapped flag available)")
}
What it printed when we ran it on Go 1.27.1
open error: no such file or directory
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed