View migrate.sh
#!/usr/bin/env bash
set -e
USAGE="Usage: migrate <up|down|new|init>"
# http://www.postgresql.org/docs/9.5/static/libpq-envars.html
export PGDATABASE=${PGDATABASE:-meetspace}
cd `dirname $0`/../migrations
View README.md

Gobridge Boston Day 1

Hello and welcome to gobridge's day 1 content! The goal of this page is to guide you through the basics of programming in Go using the site Go by Example.

Please follow along with the class as we do each lesson, try not to skip ahead, and focus on the lesson we're on. If you finish early, play around by changing the code we're working with for the current lesson, or help a friend!

Lesson 1: Hello World

  1. Open https://gobyexample.com and click on the first link, "Hello World"
View Dockerfile
FROM golang
ADD main.go ./
RUN go build -o greeter main.go
CMD ["./greeter"]
View Makefile
build:
# get all the deps
go get -d -v -t ./...
# check out the library to the right ref
checkit github.com/myaccount/mylib abc123
# build stuff!
go build ./...
View timeout_and_tick.go
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
View build-container
#!/usr/bin/env bash
# Makes a docker container for a static golang application.
# For a small app, this container is usually about 7mb.
#
# Usage:
# build-container myapp myuser/myapp cmd/myapp/main.go
set -e
# Version is the git sha for HEAD
version=$(git log -1 --format=format:%H)
View docker-cleanup.sh
# Docker
function docker-cleanup {
# Find all containers that have exited
containers=`docker ps -a -q -f status=exited | xargs`
if [[ $containers ]]; then
# Remove exited containers
docker rm $containers
else
echo "No containers to remove"
fi
View poro-json.rb
require 'active_support'
require 'active_support/core_ext/object/json'
class Person
def initialize(name, age, car)
@name = name
@age = age
@car = car
@birthyear = compute_birth_year
end
View athea.go
package athena
import (
accountant "codeship-accountant",
janus "codeship-janus",
ares "ares-api"
)
func main() {
// codeship accountant implements accountant interface
View restart-last-build
#!/usr/bin/env bash
# Usage: restart-last-build <project-id>
# You must set the environment variable API_KEY to your codeship API key, for example:
# $ CODESHIP_API_KEY=abc123 restart-last-build 1234
PROJECT_ID=$1
set -e
echo Restarting last build for project $PROJECT_ID