Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined structs running pact-go/v2 #349

Closed
tobiasjaster opened this issue Sep 30, 2023 · 3 comments
Closed

undefined structs running pact-go/v2 #349

tobiasjaster opened this issue Sep 30, 2023 · 3 comments
Labels
invalid Indicates that an issue, pull request, or discussion is no longer relevant

Comments

@tobiasjaster
Copy link

Software versions

v2.0.1

  • OS: Windows 10
  • Consumer Pact library: pact-go v2.0.1
  • Provider Pact library: -
  • Golang Version: v1.21.1
  • Golang environment:

set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=~\AppData\Local\go-build set GOENV=~\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=~\go\pkg\mod set GOOS=windows set GOPATH=~\go set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.21.1 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=0 set GOMOD=~\go\src\spielwiese\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 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=~\AppData\Local\Temp\go-build2984282734=/tmp/go-build -gno-record-gcc-switches

Expected behaviour

Get new pact-json

Actual behaviour

raised error due to many mistakes

Steps to reproduce

Create folder with attached file inside.
Install pact-go/v2 like pact-go documentation

Relevent log files

`
$ go test -v -run .

github.com/pact-foundation/pact-go/v2/message/v4

......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\asynchronous_message.go:23:28: undefined: mockserver.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\asynchronous_message.go:213:28: undefined: mockserver.MessageServer
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:20:21: undefined: native.MessageServer
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:37:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:62:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:97:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:104:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:146:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:153:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:183:24: undefined: native.Message
......\pkg\mod\github.com\pact-foundation\pact-go\[email protected]\message\v4\synchronous_message.go:183:24: too many errors
FAIL pact2example [build failed]
`

But what I noticed is that in VSCode all modules where not found which contain cgo-code. So I guess that might have something to do with cgo?!?

pact2example_test.zip

@mefellows
Copy link
Member

Why is CGO_ENABLED=0 ? That will definitely be an issue.

Here is an example working project: https://github.com/pactflow/terraform-provider-pact/

Ideally could you please provide a full project/repository that can be cloned that demonstrates the issue? Closing until you can demonstrate the problem.

@mefellows mefellows added the invalid Indicates that an issue, pull request, or discussion is no longer relevant label Dec 15, 2023
@tobiasjaster
Copy link
Author

You are right. After I had some difficulties getting a reasonable gcc to run with Windows, which also recognizes the libpact_ffi.dll, I decided to switch to devcontainer. Unfortunately, my first attempts under alpine with musl also drove me almost to despair. Using a Debian image with full gcc, everything went smoothly with PACTv2. Thanks for the hint with CGO_ENABLE=1

@mefellows
Copy link
Member

There is some guidance on Alpine here, perhaps I could bring in a summary of that into this repo. TL;DR - it's not supported due to the use of musl and although it's possible to make it work, it's likely to be unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Indicates that an issue, pull request, or discussion is no longer relevant
Projects
None yet
Development

No branches or pull requests

2 participants