0xrawsec / golang-evtx

GNU General Public License v3.0
157 stars 26 forks source link

Cannot Find Package "evtx" #1

Closed fligi7 closed 6 years ago

fligi7 commented 7 years ago

Perhaps I'm doing something wrong here (apologies for bothering if I am).

$ mkdir /home/user/Go $ export GOPATH=/home/user/Go $ go get github.com/0xrawsec/golang-evtx $ go get github.com/0xrawsec/golang-utils $ cd src/github.com/0xrawsec/golang-evtx/tools/evtxdump $ make linux

GOARCH=386 GOOS=linux go build -ldflags "-s -w" -o "release"/linux/evtxdump-386 evtxdump.go evtxdump.go:25:2: cannot find package "evtx" in any of: /usr/lib/golang/src/evtx (from $GOROOT) /home/labadmin/Go/src/evtx (from $GOPATH) makefile:23: recipe for target 'linux' failed make: *** [linux] Error 1

Obviously it's not looking in the right place nor finding the evtx package it's looking for that is clearly within the repo here and just in a different spot (it's in /home/user/Go/src/github.com/0xrawsec/golang-evtx/evtx versus where it's looking in /home/user/Go/src/evtx). Just not sure what I need to do differently to fix that.

qjerome commented 7 years ago

Hi fligi7 No problem and sorry for the delay, I am a little bit busy. This is right that I should have explained a little bit more how to compile it. I will also release soon with pre-compiled binaries for several OS. Usually, I use go get to import go packages to use project as external libraries to a project. And that is true that this way, you cannot compile the tools. Instead you have to do.

export GOPATH=/home/user/Go/go-evtx/src
cd $GOPATH
git clone https://github.com/0xrawsec/golang-evtx ./
go get github.com/0xrawsec/golang-utils
cd tools/
make linux

I hope you are going to manage to compile and use the tool. Any other comment and feedback is welcome. Have a nice WE.

fligi7 commented 7 years ago

Unfortunately, that still fails as well.

# mkdir -p /home/user/Go/go-evtx/src # export GOPATH=/home/user/Go/go-evtx/src # cd $GOPATH # git clone https://github.com/0xrawsec/golang-evtx ./

Cloning into '.'... remote: Counting objects: 37, done. remote: Compressing objects: 100% (33/33), done. remote: Total 37 (delta 2), reused 33 (delta 2), pack-reused 0 Unpacking objects: 100% (37/37), done. Checking connectivity... done.

# go get github.com/0xrawsec/golang-utils

package github.com/0xrawsec/golang-utils: no buildable Go source files in /home/user/Go/go-evtx/src/src/github.com/0xrawsec/golang-utils

And, with the above error, we know the make is going to fail...

# cd tools/ # make linux

cd evtxdump; make linux make[1]: Entering directory '/home/user/Go/go-evtx/src/tools/evtxdump' GOARCH=386 GOOS=linux go build -ldflags "-s -w" -o "release"/linux/evtxdump-386 evtxdump.go evtxdump.go:25:2: cannot find package "evtx" in any of: /usr/lib/golang/src/evtx (from $GOROOT) /home/user/Go/go-evtx/src/src/evtx (from $GOPATH) makefile:23: recipe for target 'linux' failed make[1]: [linux] Error 1 make[1]: Leaving directory '/home/user/Go/go-evtx/src/tools/evtxdump' makefile:6: recipe for target 'linux' failed make: [linux] Error 2

qjerome commented 7 years ago

This one should work

IPATH="/home/user/Go/go-evtx/"
mkdir -p $IPATH
export GOPATH=$IPATH
cd $GOPATH
git clone https://github.com/0xrawsec/golang-evtx ./src
go get github.com/0xrawsec/golang-utils
cd src/tools/
make linux

The error "no buildable Go source files ..." just means that go get does not manage to find any main file. But the dependencies are downloaded anyway. I should just put an empty package main in the root of my project to silent this.

The mistake was that go get downloads the dependencies in $GOPATH/src and thus the dependencies were located under /home/user/Go/go-evtx/src/src since we already have a src in $GOPATH. And thus, go build cannot find the package at the right location.

fligi7 commented 7 years ago

'tworks! Thanks for the assist/clarification.