Not able to compile on Windows
For the following block of code:
store, err := certstore.Open()
if err != nil {
return nil, err
}
defer store.Close()
I get the following error:
➜ certstore-test env GOOS=windows GOARCH=amd64 go build
# github.com/github/smimesign/certstore
../../../go/pkg/mod/github.com/github/[email protected]/certstore/certstore.go:17:9: undefined: openStore
Go version: go1.22.1 Platforms: macOS(arm64), windows (amd64)
The code compiles fine for macOS, it fails for Windows when trying from macOS or Windows.
I have the same problem, Did you solve it?
@rthacker87 No, I haven't solved it ☹️
I was puzzled by this as well. I discovered that the problem is that anything that includes C code directly like this package does needs a C compiler configured ready to go. This is often the case on a Mac, but unfortunately is not the case on windows.
I am building on GO 1.20.
I installed mingw with choco: choco install mingw and made sure that the C:\ProgramData\mingw64\mingw64\bin path was added and then it worked.
I did run into a problem with certstore\certstore_windows.go:641:29: cannot convert cmsg (variable of type *_Ctype_char) to type _Ctype_HANDLE so I just commented it out...
//defer C.LocalFree(C.HLOCAL(cmsg))
UPDATE:
The proper fix is in https://github.com/github/smimesign/pull/114/commits/84f3ae395fee57ef8dd82802cef0d27f25a1b9ef
defer C.LocalFree(C.HLOCAL(unsafe.Pointer(cmsg)))