BuzzDenver (4) [Avatar] Offline
#1
I cloned the github repo and trying to run the example. I get:

balazs@miles:~/src/goinaction-code/chapter2/sample$ go run main.go
main.go:7:2: cannot find package "github.com/goinaction/code/chapter2/sample/matchers" in any of:
/usr/lib/go/src/github.com/goinaction/code/chapter2/sample/matchers (from $GOROOT)
($GOPATH not set)
main.go:8:2: cannot find package "github.com/goinaction/code/chapter2/sample/search" in any of:
/usr/lib/go/src/github.com/goinaction/code/chapter2/sample/search (from $GOROOT)
($GOPATH not set)
balazs@miles:~/src/goinaction-code/chapter2/sample$ go version
go version go1.5.1 linux/amd64


Is it a version incompatibility ?
Bill Kennedy (69) [Avatar] Offline
#2
That URL does not look right?

https://github.com/goinaction/code

The code is here and therefore on disk it needs to be loaded here

$GOPATH/src/github.com/goinaction/code

Can you please check this is setup. If you need help send me an email bill@ardanlabs.com
BuzzDenver (4) [Avatar] Offline
#3
Thanks Bill. I was under the mistaken impression that those modules somehow get loaded over the net and maybe cached locally. All good now.
431502 (1) [Avatar] Offline
#4
I am also having problems getting the sample code to work.
C:/Go\bin\go.exe run C:/Go/workspace/src/github.com/goinaction/code/chapter2/sample/main.go
2016/12/02 15:04:37 Register default matcher
2016/12/02 15:04:37 open data/data.json: The system cannot find the path specified.
2016/12/02 15:04:37 Register rss matcher
exit status 1 


This is the error i am getting, i have everything setup in %GOPATH%/src/github.com/goinaction/code
I'm running the main.go in chapter 2 example.
robert.panzer (3) [Avatar] Offline
#5
Hm... requiring the user to download the code to some random position looks like an example of how to not do it.
It would have been nice to have the instructions in the book in particular as the example comprehends many different aspects and could invite the user to play with it.
jamsilver (3) [Avatar] Offline
#6
This is how I executed the example code
1. Installed Go (see the official instructions here). I used homebrew (as I'm on OSX):

brew install go


2. Used the go get tool to fetch the book example code into the GOROOT:

go get github.com/goinaction/code


3. Move into the chapter directory I want (I'm using OSX with the default GOROOT of ~/go):

cd ~/go/src/github.com/goinaction/code/chapter2/sample/


4. Run it:

go run main.go


I agree with the above commenter(s), instructions for how to run the examples seem conspicuous in their absence in chapter two. I note that in the following chapter the go get tool and remote imports get a bit more treatment, but it would perhaps be helpful to provide some explicit early instructions for running the code in a future edition.

HTH
Bill Kennedy (69) [Avatar] Offline
#7
Thanks for the feedback and I agree! At this point there is not much I can do. If I write a 2nd edition this is something I will fix!