go run ./cmd/web -dsn="user:pass@/snippetbox?parseTime=true"
go run ./cmd/web -help
-
create a tls directory under the root of the project.
-
Locate go and find
generate_cert.go
under src/crypto/tls. -
Run the following command to generate a self-signed certificate and private key:
cd tls
go run location_in_first_step_/generate_cert.go --rsa-bits=2048 --host=localhost
CREATE DATABASE test_snippetbox CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'test_web'@'localhost';
GRANT CREATE, DROP, ALTER, INDEX, SELECT, INSERT, UPDATE, DELETE ON test_snippetbox.* TO 'test_web'@'localhost';
ALTER USER 'test_web'@'localhost' IDENTIFIED BY 'pass';
IDE's should automatically pickup the *_test.go
files and run them. If not, run the following command:
go test ./...
go test ./... -cover