You need these tools installed in order to develop Gocho:
- Yarn (ui)
- NodeJS (ui)
- GNU Make (for general process building)
- Go (for main code compilation)
- go-bindata (for embedding UI inside final binary).
Installing go-bindata creates a binary, don't forget to add $GOPATH/bin to your path It's important that go-bindata is in the path becuase
make generate
—the command that embeds ui code into binary— needs it.
In order to run Gocho service and start development on it there are some things to consider: the next steps need to be run only the first time if you don't want to modify the UI.
This steps need to be executed in the root directory of the project.
Build the UI files e.g. html, javascript and css.
$ make ui
It will create a ui/build
directory with the resulting files for the UI
As UI files are embedded inside the final binary, we use go-binddata to achieve this. The generate
command in the Makefile creates an assets/assets_gen.go
file with the embedded UI code.
$ make generate
So far the previous steps need to be run only the first time unless you are modifying UI, in that case check the UI Development
section.
To build gocho
binary and test it while you do changes run:
$ make build-dev
Which will create the gocho
binary at $GOPATH/bin/gocho
as that command runs go install github.com/donkeysharp/gocho/cmd/gocho
Gocho UI uses React and was intialized using Create React App.
All React code for the dashboard is located in the ui
directory. This directory has the package.json and the yarn.lock file, in order to develop and test the UI you need to run the next
$ cd ui
# Install UI dependencies
$ yarn install
# Start development server
$ yarn start
That will bring up a development server at http://localhost:3000 with the UI so it can be developed. The development server for UI is configured to use a proxy to http://localhost:1337
(see package.json
) so it's important to have a backend running, check Service Development
section.