This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- db/migrations/${timestamp}_create_user.down.sql | |
DROP TABLE public.users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- db/migrations/${timestamp}_create_user.up.sql | |
CREATE TABLE IF NOT EXISTS public.users | |
( | |
id SERIAL PRIMARY KEY, | |
username VARCHAR(100) NOT NULL UNIQUE | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cmd/api/main.go | |
package main | |
import ( | |
"github.com/boilerplate/cmd/api/router" | |
"github.com/boilerplate/pkg/application" | |
"github.com/boilerplate/pkg/exithandler" | |
"github.com/boilerplate/pkg/logger" | |
"github.com/boilerplate/pkg/server" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cmd/api/handlers/getuser/getuser.go | |
package getuser | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/boilerplate/pkg/application" | |
"github.com/julienschmidt/httprouter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cmd/api/router/router.go | |
package router | |
import ( | |
"github.com/boilerplate/cmd/api/handlers/getuser" | |
"github.com/boilerplate/pkg/application" | |
"github.com/julienschmidt/httprouter" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pkg/server/server.go | |
package server | |
import ( | |
"errors" | |
"log" | |
"net/http" | |
"github.com/julienschmidt/httprouter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.7" | |
volumes: | |
boilerplatevolume: | |
name: boilerplate-volume | |
networks: | |
boilerplatenetwork: | |
name: boilerplate-network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start from golang v1.13.4 base image to have access to go modules | |
FROM golang:1.13.4 | |
# create a working directory | |
WORKDIR /app | |
# Fetch dependencies on separate layer as they are less likely to | |
# change on every build and will therefore be cached for speeding | |
# up the next build | |
COPY ./go.mod ./go.sum ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cmd/api/main.go | |
package main | |
import ( | |
"log" | |
"github.com/boilerplate/pkg/application" | |
"github.com/boilerplate/pkg/exithandler" | |
"github.com/joho/godotenv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
GO111MODULE=off go get github.com/githubnemo/CompileDaemon | |
CompileDaemon --build="go build -o main cmd/api/main.go" --command=./main |