Home

Awesome

go-starter-kit wercker status Join the chat at https://gitter.im/olebedev/go-starter-kit

This project contains a quick starter kit for Facebook React Single Page Apps with Golang server side render via goja javascript engine, implemented in pure Golang and also with a set of useful features for rapid development of efficient applications.

What it contains?

Workflow dependencies

Note that probably not works at windows.

Project structure

The server's entry point
$ tree server
server
├── api.go
├── app.go
├── bindata.go <-- this file is gitignored, it will appear at compile time
├── conf.go
├── data
│   └── templates
│       └── react.html
├── main.go <-- main function declared here
├── react.go
└── utils.go

The ./server/ is flat golang package.

The client's entry point

It's simple React application

$ tree client
client
├── actions.js
├── components
│   ├── app
│   │   ├── favicon.ico
│   │   ├── index.js
│   │   └── styles.css
│   ├── homepage
│   │   ├── index.js
│   │   └── styles.css
│   ├── not-found
│   │   ├── index.js
│   │   └── styles.css
│   └── usage
│       ├── index.js
│       └── styles.css
├── css
│   ├── funcs.js
│   ├── global.css
│   ├── index.js
│   └── vars.js
├── index.js <-- main function declared here
├── reducers.js
├── router
│   ├── index.js
│   ├── routes.js
│   └── toString.js
└── store.js

The client app will be compiled into server/data/static/build/. Then it will be embedded into go package via go-bindata. After that the package will be compiled into binary.

Convention: javascript app should declare main function right in the global namespace. It will used to render the app at the server side.

Install

Clone the repo:

$ git clone git@github.com:olebedev/go-starter-kit.git $GOPATH/src/github.com/<username>/<project>
$ cd $GOPATH/src/github.com/<username>/<project>

Install dependencies:

$ make install

Run development

Start dev server:

$ make serve

that's it. Open http://localhost:5001/(if you use default port) at your browser. Now you ready to start coding your awesome project.

Build

Install dependencies and type NODE_ENV=production make build. This rule is producing webpack build and regular golang build after that. Result you can find at $GOPATH/bin. Note that the binary will be named as the current project directory.

License

MIT