Code Monkey home page Code Monkey logo

Comments (14)

sagarkal avatar sagarkal commented on July 26, 2024

I had to run the pact-go_linux_amd64 file, not pact-go..
Moreover, when I run
go run -v <my_test_name.go>

It does not run. Instead it gives me an error that it could not find the functions from dsl.

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

Hi Sagakal,

You do not need to put either of those binaries on the path, just the pact-go_<os/arch> binary needs to go on the path.

Can you please please provide complete steps to reproduce, including code to test?

Thanks.

from pact-go.

sagarkal avatar sagarkal commented on July 26, 2024

So I added the binary pact-go_<os/arch> to PATH, then when I ran the command

pact-go daemon

It still says

pact-go: command not found

But it worked when I ran

pact-go_linux_amd64 daemon

The daemon started as follows:

2017/07/05 08:27:07 [INFO] daemon - starting daemon on network: tcp address: port: 6666 2017/07/05 08:27:07 method Shutdown has wrong number of ins: 1 2017/07/05 08:27:07 method StartDaemon has wrong number of ins: 4

Until here everything is fine

Then, I followed the below steps as mentioned on your README

  1. Start the daemon with ./pact-go daemon.
  2. cd /examples.
  3. go run -v consumer.go.

After the 3rd step, it throws the below error:

consumer.go:10:2: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation/pact-go/dsl

I also tried creating a file consumer_test.go with the code content that is on your README and ran it

go test -v consumer_test.go'

I still got the same error:

# command-line-arguments
consumer_test.go:5:2: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation/pact-go/dsl

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

Yes, the binary from the zip file is going to contain the OS arch so you will need to rename accordingly.

How have you retrieved the code? Did you do a go get to install or some other way? Can you compile pact go? Could you please share the contents of your Go setup - environment variables, version etc.?

I just tried with the following steps in a fresh $GOPATH, after starting a daemon as per above:

export GOPATH=/tmp/go
cd /tmp
go get github.com/pact-foundation/pact-go
cd $GOPATH/src/github.com/pact-foundation/pact-go/examples
go run consumer.go
2017/07/07 22:31:18 [DEBUG] pact setup logging
2017/07/07 22:31:18 [DEBUG] pact setup
2017/07/07 22:31:18 [DEBUG] client: starting a server
2017/07/07 22:31:18 [DEBUG] creating an HTTP client
2017/07/07 22:31:18 [DEBUG] waiting for port 6666 to become available
2017/07/07 22:31:18 [DEBUG] waiting for port 51939 to become available
2017/07/07 22:31:18 [DEBUG] pact add interaction
2017/07/07 22:31:18 [DEBUG] pact setup logging
2017/07/07 22:31:18 [DEBUG] pact setup
2017/07/07 22:31:18 [DEBUG] pact add interaction
2017/07/07 22:31:18 [DEBUG] pact setup logging
2017/07/07 22:31:18 [DEBUG] pact setup
2017/07/07 22:31:18 [DEBUG] pact verify
2017/07/07 22:31:18 [DEBUG] mock service add interaction
2017/07/07 22:31:18 [DEBUG] mock service response Body: Set interactions
2017/07/07 22:31:18 [DEBUG] mock service add interaction
2017/07/07 22:31:18 [DEBUG] mock service response Body: Set interactions
2017/07/07 22:31:18 [DEBUG] mock service verify
2017/07/07 22:31:18 [DEBUG] mock service response Body: Interactions matched
2017/07/07 22:31:18 [DEBUG] mock service delete interactions
2017/07/07 22:31:18 [DEBUG] mock service response Body: Deleted interactions
Test Passed!
2017/07/07 22:31:18 [DEBUG] teardown
2017/07/07 22:31:18 [DEBUG] client: stop server
2017/07/07 22:31:18 [DEBUG] creating an HTTP client
2017/07/07 22:31:18 [DEBUG] waiting for port 6666 to become available

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

FYI I updated the README yesterday with slightly better instructions, as per the notes in the above comment.

from pact-go.

sagarkal avatar sagarkal commented on July 26, 2024

Ok, so I tried the README instructions again

I unzipped linux-amd64.tar.gz and renamed pact-go_linux_amd64 to pact-go and added the extracted folder to the PATH. Then I ran pact-go. Works fine as shown below

pact-go
Pact Go is a utility that wraps a number of external applications into
an idiomatic Golang interface and CLI, providing a mock service and DSL for
the consumer project, and interaction playback and verification for the
service provider project.

Usage:
  pact-go [command]

Available Commands:
  daemon      Creates a daemon for the Pact DSLs to communicate with
  version     Print the version number of Pact Go

Flags:
  -h, --help              help for pact-go
  -l, --logLevel string   Set the logging level (DEBUG, INFO, ERROR) (default "INFO")
  -t, --toggle            Help message for toggle
  -v, --verbose           verbose output (default true)

Use "pact-go [command] --help" for more information about a command.

Then I ran 'go get github.com/pact-foundation/pact-go', but got the below error

package pact-go_linux_amd64: unrecognized import path "pact-go_linux_amd64" (import path does not begin with hostname)

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

Looks like it could be a Golang configuration issue. What is your GOPATH?

Have you attempted to clone this project and build it (e.g. go build -o pact-go)? This could be enlightening.

from pact-go.

sagarkal avatar sagarkal commented on July 26, 2024

I cloned the project and tried building it locally. It did not work. The value of GOROOT and the result of trying to build the project locally is below:

sagar@sagar-Precision-5510:~/go/src/pact-go$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/sagar/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build906463852=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
sagar@sagar-Precision-5510:~/go/src/pact-go$ go build -o pact-go
main.go:3:8: cannot find package "github.com/pact-foundation/pact-go/command" in any of:
	/home/sagar/go/src/pact-go/vendor/github.com/pact-foundation/pact-go/command (vendor tree)
	/usr/local/go/src/github.com/pact-foundation/pact-go/command (from $GOROOT)
	/home/sagar/go/src/github.com/pact-foundation/pact-go/command (from $GOPATH)
sagar@sagar-Precision-5510:~/go/src/pact-go$ 

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

Your GOPATH is "/home/sagar/go" but it looks like you've cloned the project in "/home/sagar/go/src/pact-go" - is this correct?

The project should be cloned in "/home/sagar/go/src/github.com/pact-foundation/pact-go".

The fact that the CI builds are also working tells me that there's something wrong with your Go environment.

from pact-go.

sagarkal avatar sagarkal commented on July 26, 2024

Sorry about that, so I cloned your repo under "/home/sagar/go/src/github.com and tried to build as follows:

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ go build -o pact-go
can't load package: package github.com/pact-foundation: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation
sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ cd pact-go/
sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation/pact-go$ go build -o pact-go
can't load package: package github.com/pact-foundation/pact-go: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation/pact-go
sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation/pact-go$ 

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

from pact-go.

sagarkal avatar sagarkal commented on July 26, 2024

Sorry for the delayed response. I checked out the project under the github.com directory. Full path is available below in the result of 'pwd' command

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ pwd
/home/sagar/go/src/github.com/pact-foundation
sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ ls
dsl  pact-go

I ran the build command first in pact-foundation directory and then also in pact-foundation/pact-go directory. The output is as below:

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ pwd
/home/sagar/go/src/github.com/pact-foundation

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ ls
dsl  pact-go

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ go build -o pact-go
can't load package: package github.com/pact-foundation: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation$ cd pact-go/

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation/pact-go$ ls
dsl

sagar@sagar-Precision-5510:~/go/src/github.com/pact-foundation/pact-go$ go build -o pact-go
can't load package: package github.com/pact-foundation/pact-go: no buildable Go source files in /home/sagar/go/src/github.com/pact-foundation/pact-go

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

I don't know what's going on with your cloning process, but you are missing a tonne of files.

Here is what your folder should look like, after a successful clone in the right place:

matt ~/go/src/github.com/pact-foundation/pact-go λ ls -larth
total 17688
-rw-r--r--   1 mfellows  staff   1.1K 23 May  2016 LICENSE
drwxr-xr-x   3 mfellows  staff   102B  6 Jun  2016 ..
-rw-r--r--   1 mfellows  staff   1.5K  7 Jun  2016 vendor.yml
drwxr-xr-x   5 mfellows  staff   170B  7 Jun  2016 vendor
-rw-r--r--   1 mfellows  staff   394B  7 Jun  2016 .gitignore
-rw-r--r--   1 mfellows  staff   174B  7 Jun  2016 .codeclimate.yml
drwxr-xr-x  11 mfellows  staff   374B 24 Mar 12:10 examples
-rw-r--r--   1 mfellows  staff   102B 12 Apr 18:15 main.go
-rw-r--r--   1 mfellows  staff   371B  1 May 21:56 Makefile
drwxr-xr-x   4 mfellows  staff   136B  1 May 22:19 log
-rw-r--r--   1 mfellows  staff    12K 12 May 12:39 CHANGELOG.md
drwxr-xr-x   8 mfellows  staff   272B 20 Jun 23:55 types
drwxr-xr-x   9 mfellows  staff   306B 21 Jun 00:00 command
drwxr-xr-x  12 mfellows  staff   408B 21 Jun 00:00 daemon
drwxr-xr-x   4 mfellows  staff   136B 21 Jun 00:01 utils
drwxr-xr-x  11 mfellows  staff   374B 21 Jun 00:17 scripts
drwxr-xr-x   8 mfellows  staff   272B 26 Jun 08:08 build
drwxr-xr-x   5 mfellows  staff   170B 26 Jun 08:09 output
-rw-r--r--   1 mfellows  staff   1.1K 26 Jun 08:37 wercker.yml
drwxr-xr-x  10 mfellows  staff   340B 26 Jun 08:44 dist
-rw-r--r--   1 mfellows  staff   2.1K 26 Jun 18:10 CONTRIBUTING.md
drwxr-xr-x   6 mfellows  staff   204B 26 Jun 18:16 pacts
drwxr-xr-x   4 mfellows  staff   136B 26 Jun 18:21 logs
drwxr-xr-x  22 mfellows  staff   748B 26 Jun 18:30 dsl
drwxr-xr-x   3 mfellows  staff   102B 26 Jun 18:45 reports
-rw-r--r--   1 mfellows  staff    17K  4 Jul 08:15 README.md
-rw-r--r--   1 mfellows  staff   9.7K  4 Jul 08:17 doc.go
drwxr-xr-x  37 mfellows  staff   1.2K 18 Jul 20:26 .
drwxr-xr-x  15 mfellows  staff   510B 20 Jul 08:05 .git
matt ~/go/src/github.com/pact-foundation/pact-go λ

from pact-go.

mefellows avatar mefellows commented on July 26, 2024

Sorry @sagarkal, I'm going to mark this as invalid for now. If we can reliably reproduce this (e.g. create Docker, Vagrant or another similar automated setup ) I'm happy to look at it again.

from pact-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.