jonnenauha / obj-simplify

Object File (.obj) simplifier
MIT License
133 stars 16 forks source link

Run Instructions in README #2

Closed countable closed 7 years ago

countable commented 7 years ago

Hi there;

I'm a non-go user and struggling to actually build/run the program. I realize it's likely user error but including a note may save many hours for folks like me :) Would it be possible to include instructions to get going for people like me who havn't ever touched go? ie)

git clone <repo>
cd obj-simplify
go build

This actually fails as-is with "cannot find package "github.com/jonnenauha/obj-simplify/objectfile", running in the golang official Docker container, so I assume that's a functional go build environment.

jonnenauha commented 7 years ago

You can indeed build simple go apps by just cloning it to a folder, but once sub packages are involved I think it just tries to find then from GOPATH. Getting into golang dev env is quite easy but there are quirks like these that make it a bit harder :) I think they are actively working on getting this stuff better.

Anyhow, something like this needs to be done

  1. Install go, check go version that its in your path
  2. Setup GOPATH
    • For me I create a go-workspace dir somewhere in my home dir or on windows just C:\dev\go-workspace
    • Export env variable GOPATH=<the_dir_you_made>
  3. Open a shell to test the env variable is there echo $GOPATH or echo %GOPATH% on windows.
  4. mkdir -p $GOPATH/src/github.com/jonnenauha
  5. cd $GOPATH/src/github.com/jonnenauha and git clone <repo>

Now its in the correct place, if you look at the code how its resolving into the subpackage objectfile its the path from $GOPATH/src, this is why it could not resolve it when you just plain clone it somewhere.

I think I don't have external package deps, just the std lib, but usually you run these to build a go project.

go get      # fetches dependency packages automatically to `$GOPATH/src`
go build    # build the binary to the projects directory
go install  # builds and installs the project into $GOPATH/bin that you can put to your PATH

A but off a hassle but this stuff is only done once per dev env.

Edit: Golang website has pretty good info how to setup this stuff up. I think the non-obvious part is you need to clone into the correct place in GOPATH.

Once GOPATH env variable is there. You can also do the clone into the correct place by running go get github.com/jonnenauha/obj-simplify just like any other depencency. You only (well I personally) really manually clone it when you are working on a project or the git repo is private, go get cant still clone private repos afaik.

countable commented 7 years ago

Wow, thanks for all the detail! It's working now. I think the last method is easiest for complete noobs like me with no understanding of go's paths and dep management. It seems that in an environment with go properly installed such as the official docker container, this will work.

go get github.com/jonnenauha/obj-simplify
obj-simplify -h