Skip to content

x/sys/windows: missing GetFileTime function on Windows #21541

Closed
@skillian

Description

@skillian

What version of Go are you using (go version)?

Go 1.8.3

Does this issue reproduce with the latest release?

I am able to reproduce this with Go 1.8.3 which seems to be the latest stable version available from golang.org.

What operating system and processor architecture are you using (go env)?

Windows 10 on x86_64

Output of go env:

set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Users\spkillian@outlook.com\Dropbox\dev\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\SPKIL_~1\AppData\Local\Temp\go-build427541383=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

This is for a missing syscall function, so I suppose a minimum reproducible program would be:

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import (
    "fmt"
    "os"
    "syscall"
)

const (
    anyFile = "any_file.txt"
)

func main() {
    var creationTime syscall.Filetime
    var lastAccessTime syscall.Filetime
    var lastWriteTime syscall.Filetime

    utf16FileName, err := syscall.UTF16FromString(anyFile)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Failed to convert string %q to UTF16: %v", anyFile, err)
    }

    err = syscall.GetFileTime(utf16FileName, &creationTime, &lastAccessTime, &lastWriteTime)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error getting FileTime of file %v: %v", anyFile, err)
        return
    }
    // do something with creationTime, lastAccessTime and/or lastWriteTime
    return
}

Go Playground

What did you expect to see?

syscall.GetFileName should be defined on Windows, like syscall.SetFileTime

What did you see instead?

PowerShell output:
github.com\skillian\getfiletime\expected.go:23: undefined: syscall.GetFileTime

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions