Skip to content

Latest commit

 

History

History
81 lines (53 loc) · 1.41 KB

File metadata and controls

81 lines (53 loc) · 1.41 KB

Snippets app

This snippets app lets you store, edit, and manage reusable pieces of text or code — fast, organized, and always ready to copy-paste.

Preview 1 Preview 2
Snippets app preview 1 Snippets app preview 2
Preview 3 Preview 4
Snippets app preview 3 Snippets app preview 4

Stack

  • Golang
  • Mux (Router)
  • Go SQL Driver (Database)
  • Alice (Middleware)
  • NoSurf (CSRF protection)

How to run

1. Clone the repo

git clone https://github.com/takumade/snippets

2. Change directory

cd snippets

3. Database setup

Create database:

CREATE DATABASE snippetbox;
CREATE USER 'web'@'localhost' WITH PASSWORD 'pass';
GRANT ALL PRIVILEGES ON snippetbox.* TO 'web'@'localhost';
FLUSH PRIVILEGES;

Create tables:

internal/db/users.sql internal/db/snippets.sql internal/db/sessions.sql

4. Install dependencies

go mod tidy

5. Install certs

mkdir tls && cd tls && go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost

6. Run the server

go run ./cmd/web

Open your browser and navigate to http://localhost:4000

7. Runnning Tests

Simply run the following command:

go test -v ./cmd/web