olebedev / go-starter-kit

[abandoned] Golang isomorphic react/hot reloadable/redux/css-modules/SSR starter kit
Other
2.82k stars 359 forks source link

Add ability to clone the template anywhere outside $GOPATH #58

Closed ultimatesolution closed 7 years ago

ultimatesolution commented 7 years ago

A small obvious improvement. Cloning outside $GOPATH makes the developer's life a bit easier.

olebedev commented 7 years ago

The previous implementation was $GOPATH independent. But i had to use $GOPATH properly because of vendor usage. Does deps management working as expected for you? Which golang version do you use?

ultimatesolution commented 7 years ago
$ go version
go version go1.6.1 linux/amd64

This works OK if go-bindata and srlt have been added to the $PATH:

cd /tmp
git clone https://github.com/ultimatesolution/go-starter-kit foo
cd foo
make install build serve
olebedev commented 7 years ago

I follow you instruction above, make install build serve step produces this:

ash: 9711a63e46e90d555fa9  
Version: webpack 1.13.2
Time: 2620ms
     Asset     Size  Chunks             Chunk Names
 bundle.js  1.05 MB       0  [emitted]  bundle
bundle.css  9.44 kB       0  [emitted]  bundle
    + 298 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
Child extract-text-webpack-plugin:
        + 2 hidden modules
/usr/local/Cellar/go/workspace/bin/go-bindata -pkg=main -prefix=server/data -o=server/bindata.go server/data/...
server/app.go:8:2: cannot find package "github.com/elazarl/go-bindata-assetfs" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/github.com/elazarl/go-bindata-assetfs (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/github.com/elazarl/go-bindata-assetfs (from $GOPATH)
server/app.go:9:2: cannot find package "github.com/itsjamie/go-bindata-templates" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/github.com/itsjamie/go-bindata-templates (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/github.com/itsjamie/go-bindata-templates (from $GOPATH)
server/api.go:6:2: cannot find package "gopkg.in/labstack/echo.v1" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/gopkg.in/labstack/echo.v1 (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/gopkg.in/labstack/echo.v1 (from $GOPATH)
server/app.go:13:2: cannot find package "gopkg.in/labstack/echo.v1/middleware" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/gopkg.in/labstack/echo.v1/middleware (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/gopkg.in/labstack/echo.v1/middleware (from $GOPATH)
server/react.go:11:2: cannot find package "gopkg.in/olebedev/go-duktape-fetch.v2" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/gopkg.in/olebedev/go-duktape-fetch.v2 (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/gopkg.in/olebedev/go-duktape-fetch.v2 (from $GOPATH)
server/react.go:12:2: cannot find package "gopkg.in/olebedev/go-duktape.v2" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/gopkg.in/olebedev/go-duktape.v2 (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/gopkg.in/olebedev/go-duktape.v2 (from $GOPATH)
make: *** [/usr/local/Cellar/go/workspace/bin/foo] Error 1

Seems it NOT works OK. Besides, go-bindata and srlt may not be installed at the target dev workspace.

ultimatesolution commented 7 years ago
server/app.go:8:2: cannot find package "github.com/elazarl/go-bindata-assetfs" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/github.com/elazarl/go-bindata-assetfs (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/github.com/elazarl/go-bindata-assetfs (from $GOPATH)
server/app.go:9:2: cannot find package "github.com/itsjamie/go-bindata-templates" in any of:
    /usr/local/Cellar/go/1.7.1/libexec/src/github.com/itsjamie/go-bindata-templates (from $GOROOT)
    /usr/local/Cellar/go/workspace/src/github.com/itsjamie/go-bindata-templates (from $GOPATH)
...

This could be fixed with

go get -d ./server

added to the Makefile. It could be added to install step since this is installing dependencies.

Besides, go-bindata and srlt may not be installed at the target dev workspace.

go-bindata: correct, it is installed in $(GO_BINDATA) step. srlt: could not see installing this tool in the Makefile. Should it be installed separately with go get github.com/olebedev/srlt?

ultimatesolution commented 7 years ago

Fixed issues you have mentioned about. Working version is here: https://github.com/ultimatesolution/go-starter-kit/tree/fix1

This works:

docker run -ti --rm --dns 8.8.8.8 alpine /bin/sh

then

set -e
apk add --no-cache go git make nodejs alpine-sdk
mkdir /gopath
export GOPATH=/gopath
export PATH=$PATH:$GOPATH/bin
go get github.com/olebedev/srlt
git clone https://github.com/ultimatesolution/go-starter-kit foo
cd foo
git checkout b22a7b1
make install build serve

I'll create a new pull request if you approve this version.

joelnb commented 7 years ago

Won't building this out of $GOPATH make it ignore all of the vendored dependencies? It looks that way from the quick look at the changes I had & if so I don't agree with this idea.

It is possible vendored libs will be used even outside of a $GOPATH in future though so then I think it would be very useful - see these issues for more information on the subject: 1, 2.

olebedev commented 7 years ago

Thanks @ultimatesolution for this PR, bit it's not relevant for project usage. Similar corner-cases could be done outside of the project.