My Snippetbox implementation From Lets Go Book
- Added Response Time & status, kinda like morgan in express
- Will not Change Middleware to compossable middleware like express because go middleware doesnt behave like express
- Best Practices building web app using go
- using std package like http, flag, context, httptest, and many more
- unit testing, mocking and end-to-end testing, integration testing in GO
- Add About Page to the App
- Add a debug mode
- more http e2e testing
- add Account page to the app
- Redirect appropriately after login
- Implement Change Password Features
Pre-Installation
- Having MySQL install
- creating new user, snippetbox db, users table, and snippets table
mysql -u root -p
#enter your password
CREATE DATABASE snippetbox CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE snippetbox;
CREATE TABLE snippets (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
created DATETIME NOT NULL,
expires DATETIME NOT NULL
);
CREATE INDEX idx_snippets_created ON snippets(created);
CREATE USER 'web'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON snippetbox.* TO 'web'@'localhost';
ALTER USER 'web'@'localhost' IDENTIFIED BY 'pass';
CREATE TABLE users (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
hashed_password CHAR(60) NOT NULL,
created DATETIME NOT NULL
);
ALTER TABLE users ADD CONSTRAINT users_uc_email UNIQUE (email);
mkdir project_path/tls
cd project_path/tls
go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=lslocalhost
you can run the project by :
go run ./cmd/web #Check https://localhost:4000 for the web
you can run the test by :
go test -v ./...
you can run the coverage by :
go test -cover ./...