View Makefile
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/connect: create to the local database | |
.PHONY: db/connect | |
db/connect: | |
sqlite3 db.sqlite | |
## db/migrations/new name=$1: create a new migration | |
.PHONY: db/migrations/new | |
db/migrations/new: | |
go run -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest create -seq -ext=.sql -dir=./resources/migrations ${name} |
View Makefile
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
# Change these variables as necessary. | |
MAIN_PACKAGE_PATH := ./cmd/example | |
BINARY_NAME := example | |
# ==================================================================================== # | |
# HELPERS | |
# ==================================================================================== # | |
## help: print this help message | |
.PHONY: help |
View main.go
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
package main | |
import ( | |
"encoding/json" | |
"errors" | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"strings" |
View workflow.yml
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
name: Audit and deploy | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: |
View workflow.yml
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
name: Audit | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main |
View index.html
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Your Page Title</title> | |
<meta name="description" content="Brief description"> | |
<meta name="author" content="Your name"> | |
View gist:fa02ec95402f687e5f08f54a575a55c7
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
func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request) { | |
id, err := app.readIDParam(r) | |
if err != nil { | |
// IT'S THIS LINE HERE THAT YOU NEED TO CHANGE to use the new notFoundResponse() helper. | |
app.notFoundResponse(w, r) | |
return | |
} | |
movie := data.Movie{ | |
ID: id, | |
CreatedAt: time.Now(), |
View gist:41f7e747ee10287bb881fab9e36ed07c
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
package main | |
import ( | |
"net/http" | |
"github.com/bmizerany/pat" | |
"github.com/justinas/alice" | |
) | |
func (app *application) routes() http.Handler { |
View gist:3e158aba800a3044f31bda3d32c72c56
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
package jsonlog | |
import ( | |
"encoding/json" | |
"io" | |
"os" | |
"runtime/debug" | |
"sync" | |
"time" | |
) |
View gist:a175f4da955cbf57cf2c10f6798a8a6f
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<h1>Simple CORS</h1> | |
<output></output> | |
<script> | |
document.addEventListener('DOMContentLoaded', function() { |
NewerOlder