Here, you can help find a shelter that best fits your need.
- Clone or download this repository and add it to your
GOPATH
if necessary. - Install Heroku command line tools.
- Create a new Postgres database from Heroku's Dashboard > Databases.
- Copy the Psql command from "Connection Settings." It should look like
heroku pg:psql --app [DATABASE]
. This command will open a psql shell to your database. - Set up tables and indices. The ddl.sql file contains SQL statements to create 22 tables with their columns and 8 indices. Pipe the file to the psql command. It should resemble:
cat ddl.sql | heroku pg:psql --app [DATABASE]
- Press enter and the command will execute. If successful, it should output 22 lines of
CREATE TABLE
followed by 8 lines ofCREATE INDEX
. Make note of any errors and adjust your ddl.sql accordingly. If you need to start over,DROP SCHEMA public CASCADE; CREATE SCHEMA public;
will give you a fresh slate. - Find your
DATABASE_URL
in your Connection Settings for your database on Heroku's dashboard. Copy this URL. You will need it to connect your GO app to your database.
- Create a file in your cloned repo named .env and containing the line
DATABASE_URL=[YOUR-URL-HERE]
. - From a terminal, navigate to your repo's cmd/lab7, and run
go install
- From your repo's root directory, run
heroku local
- Open an HTML page of your app in a browser and it should work.
- From Heroku's dashboard, create a new app. Set your app name (hereafter
app-name
) and runtime. - While the app is being created, you can run
heroku login
in a terminal and authenticate. - You copied your
DATABASE_URL
earlier--hopefully it's still on your clipboard. Go to Heroku's dashboard, navigate toapp-name
's settings, and in the config vars, create a variableDATABASE_URL
and set it to the URL you copied. - Navigate to your repo's root directory and run
heroku git:remote -a app-name
- You can now push your code up to the Heroku app with
git push heroku master
. - After you've pushed your code, you can open your app with
heroku open
or by visitinghttp://app-name.herokuapp.com/
Eduard Grigoryan, Megh Vakharia, and Brittney Hoy