Skip to content

os: executable FileMode bit is not set on Windows #41809

Open
@gochist

Description

@gochist

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

$ go version
go version go1.13.8 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\june.yi\AppData\Local\go-build
set GOENV=C:\Users\june.yi\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\june.yi\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\june.yi\Aset GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\june.yi\A
ppData\Local\Temp\go-build564788466=/tmp/go-build -gno-record-gcc-switches

What did you do?

I ran the code to check if a file is executable on Windows.

package main

import "os"

func main() {
	f, err := os.Stat("C:\\Users\\june.yi\\Downloads\\SopsSecretGenerator_1.3.1_windows_amd64.exe")

	if err == nil {
		println(f.Mode())
		println(f.Mode() & 0111 == 0000)
	}
}

What did you expect to see?

Bit operation was performed to implement a function that checks whether a file is executable. However, it seems that the executable bit is not set even though it is an executable file on Windows.

493
false

(493==0755)

What did you see instead?

438
true

(438==0644)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions