gnormal / gnorm

A database-first code generator for any language
https://gnorm.org
Other
487 stars 40 forks source link

Build instructions don't work as given #135

Open llimllib opened 4 years ago

llimllib commented 4 years ago

The readme says:

For best results, use the magefile in the root of the repo, which will do all the build-time magic. To run it, install mage, then just run mage build.

$ go get github.com/magefile/mage
$ mage build

But when I do that, it does not succeed:

$ cd /tmp

$ go get github.com/magefile/mage

$ git clone git@github.com:gnormal/gnorm.git
Cloning into 'gnorm'...
remote: Enumerating objects: 68, done.
remote: Counting objects: 100% (68/68), done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 3426 (delta 23), reused 39 (delta 18), pack-reused 3358
Receiving objects: 100% (3426/3426), 11.72 MiB | 4.13 MiB/s, done.
Resolving deltas: 100% (1192/1192), done.

$ cd gnorm/

$ mage build
can't load package: package ./.: code in directory /tmp/gnorm expects import "gnorm.org/gnorm"
can't load package: package ./cli: code in directory /tmp/gnorm/cli expects import "gnorm.org/gnorm/cli"
can't load package: package ./database: code in directory /tmp/gnorm/database expects import "gnorm.org/gnorm/database"
can't load package: package ./database/drivers/mysql: code in directory /tmp/gnorm/database/drivers/mysql expects import "gnorm.org/gnorm/database/drivers/mysql"
can't load package: package ./database/drivers/mysql/gnorm: code in directory /tmp/gnorm/database/drivers/mysql/gnorm expects import "gnorm.org/gnorm/database/drivers/mysql/gnorm"
can't load package: package ./database/drivers/postgres: code in directory /tmp/gnorm/database/drivers/postgres expects import "gnorm.org/gnorm/database/drivers/postgres"
can't load package: package ./database/drivers/postgres/gnorm: code in directory /tmp/gnorm/database/drivers/postgres/gnorm expects import "gnorm.org/gnorm/database/drivers/postgres/gnorm"
can't load package: package ./environ: code in directory /tmp/gnorm/environ expects import "gnorm.org/gnorm/environ"
can't load package: package ./run: code in directory /tmp/gnorm/run expects import "gnorm.org/gnorm/run"
Error: running "go generate ./..." failed with exit code 1
go env Output
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/llimllib/go/bin"
GOCACHE="/Users/llimllib/Library/Caches/go-build"
GOENV="/Users/llimllib/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/llimllib/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r4/mc760j7j6xjdgr5p5hxk_xrw0000gq/T/go-build851379401=/tmp/go-build -gno-record-gcc-switches -fno-common"

llimllib commented 4 years ago

oh! this is pre-go modules code so it needs to be cloned into GOPATH I'm guessing

llimllib commented 4 years ago

I got a little closer by that, but it still didn't work:

$ mkdir -p ~/go/src/gnorm.org/

$ mv gnorm ~/go/src/gnorm.org/

$ cd ~/go/src/gnorm.org/gnorm/

$ mage build
database/drivers/mysql/parse.go:19: running "gnorm": exec: "gnorm": executable file not found in $PATH
database/drivers/postgres/parse.go:18: running "gnorm": exec: "gnorm": executable file not found in $PATH
Error: running "go generate ./..." failed with exit code 1

$ set | grep PATH
PATH=...:/Users/llimllib/go/bin:...

$ set | grep GO
GOBIN=/Users/llimllib/go/bin
GOPATH=/Users/llimllib/go

It complains about gnorm not being in my path; you can see that ~/go/bin is in both my PATH and GOBIN, but building still doesn't work.

I'm not going to continue investigating here, but will happily try things out if you have suggestions or questions I can run on my system.

natefinch commented 4 years ago

you can just go install gnorm.org/gnorm it won't generate the built-in docs or embed the version info in the binary, but it'll still work just fine. I should probably simplify the build instructions a lot... the mage build target does a lot of stuff that normal people probably don't care about (like requiring hugo to build the web docs that get embedded into the binary).

llimllib commented 4 years ago

yeah, I had no trouble installing with go get, just wanted to let you know that the for best results build instructions didn't work for me.

Also the config template references testdata/<something>.tpl but gnorm init creates templates/<something>.gotmpl files, so gnorm init-> edit config file -> gnorm preview, as per the documentation, does not work unless you change those by hand. Want me to file an issue on that as well?

natefinch commented 4 years ago

I get it. Thanks. And yes, please file another issue for the other problem. I appreciate it!