bytedance / mockey

a simple and easy-to-use golang mock library
Apache License 2.0
619 stars 23 forks source link

Compile failed on Windows #62

Closed HeRaNO closed 1 week ago

HeRaNO commented 3 weeks ago

Describe the bug

Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:47:17: undefined: syscall.Mmap
Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:47:45: undefined: syscall.PROT_READ
Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:47:63: undefined: syscall.PROT_WRITE
Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:47:83: undefined: syscall.MAP_ANON
Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:47:100: undefined: syscall.MAP_PRIVATE
Error: C:\Users\runneradmin\go\pkg\mod\github.com\bytedance\mockey@v1.2.11\internal\monkey\common\page.go:51:17: undefined: syscall.Munmap

To Reproduce

Steps to reproduce the behavior:

  1. Compile this project on Windows

Expected behavior

Compile shouldn't fail on Windows.

Mockey version:

v1.2.11

Environment:

set GO111MODULE=
  set GOARCH=amd64
  set GOBIN=
  set GOCACHE=C:\Users\runneradmin\AppData\Local\go-build
  set GOENV=C:\Users\runneradmin\AppData\Roaming\go\env
  set GOEXE=.exe
  set GOEXPERIMENT=
  set GOFLAGS=
  set GOHOSTARCH=amd64
  set GOHOSTOS=windows
  set GOINSECURE=
  set GOMODCACHE=C:\Users\runneradmin\go\pkg\mod
  set GONOPROXY=
  set GONOSUMDB=
  set GOOS=windows
  set GOPATH=C:\Users\runneradmin\go
  set GOPRIVATE=
  set GOPROXY=https://proxy.golang.org,direct
  set GOROOT=C:\hostedtoolcache\windows\go\1.23.0\x64
  set GOSUMDB=sum.golang.org
  set GOTMPDIR=
  set GOTOOLCHAIN=auto
  set GOTOOLDIR=C:\hostedtoolcache\windows\go\1.23.0\x64\pkg\tool\windows_amd64
  set GOVCS=
  set GOVERSION=go1.23.0
  set GODEBUG=
  set GOTELEMETRY=local
  set GOTELEMETRYDIR=C:\Users\runneradmin\AppData\Roaming\go\telemetry
  set GCCGO=gccgo
  set GOAMD64=v1
  set AR=ar
  set CC=gcc
  set CXX=g++
  set CGO_ENABLED=1
  set GOMOD=D:\a\hertz\hertz\go.mod
  set GOWORK=
  set CGO_CFLAGS=-O2 -g
  set CGO_CPPFLAGS=
  set CGO_CXXFLAGS=-O2 -g
  set CGO_FFLAGS=-O2 -g
  set CGO_LDFLAGS=-O2 -g
  set PKG_CONFIG=pkg-config
  set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\RUNNER~1\AppData\Local\Temp\go-build3876640346=/tmp/go-build -gno-record-gcc-switches

Additional context

Check this action

Workflow isn't enabled on Windows and macOS. Maybe we can switch the workflows to Github host runners. Now Github runners have arm64 and x86 arch with Linux, Windows and macOS support.

Sychorius commented 3 weeks ago

@HeRaNO We'll fix it soon You can downgrade to v1.2.10 and add -ldflags=-checklinkname=0 into the test command

Sychorius commented 1 week ago

@HeRaNO fixed in v1.2.12