- Ubuntu 14.04 LTS i386 VM
- golang 1.5
- PostgreSQL 9.3
NOTE: Do not use the golang-v1.2.1 which come with ubuntu 14.04 distribution, because there is a compile issue with gopkg.in/pg.v3. I used v1.5 here.
sudo apt-get install postgresql
sudo -u postgres psql postgres
ALTER USER postgres WITH PASSWORD '123456'
sudo password postgres
Untar the source tarball to a directory. I choosed: "~/user-relationship".
cd ~/user-relationship
export GOPATH=~/user-relationship
go get github.com/gorilla/mux
go get gopkg.in/pg.v3
- Switch to linux user 'postgres' with the following command, and enter the password if you've set one:
su postgres
- Now, your command prompt should be shown as 'postgres'. Enter postgresql command prompt:
psql
- Now, your command prompt should be shown as 'postgres=#'. Import the SQL script:
\i init.sql
- When succeeds, you may return to your own linux account:
\q
# quit psql
exit
# quit linux account 'postgres'
Issue the following commands to compile the project and run the server:
cd ~/user-relationship/bin
go build app
./app
Frisby is quite suitable for RESTful API test. See frisby for details. In this project, for simplicity, very few test cases are provided.
- Install node.js & npm
Visit nodejs and download a suitable package to install. - Install frisby
cd test/
npm install -g frisby
- Install jasmine-node
sudo npm install -g jasmine-node
- Run test cases scripts under directory 'test/'
jasmine-node ./
- For simplicity, I used 'Bigint' rather than 'string' for user-id field