Repository for coding along with the Let's Go book by Alex Edwards
  • Go 80.2%
  • Go Template 10.8%
  • CSS 8.7%
  • JavaScript 0.3%
Find a file
Ryan Hendrickson 35b98b3a28
Add debug flag
2024-05-19 20:00:26 -07:00
cmd/web Add debug flag 2024-05-19 20:00:26 -07:00
internal Add integration test for UserModel 2024-05-13 14:10:25 -07:00
ui Add an about page 2024-05-17 15:35:45 -07:00
.gitignore Add HTTPS support 2024-05-11 12:48:42 -07:00
go.mod Add CSRF protection 2024-05-11 16:25:32 -07:00
go.sum Add CSRF protection 2024-05-11 16:25:32 -07:00
README.md Add HTTPS support 2024-05-11 12:48:42 -07:00

Snippetbox

Project built while following along with Let's Go by Alex Edwards.

Project Layout

The directory structure of this project closely follows Go's server project layout.

Cmd

The cmd directory contains the application specific code for the executable applications in the project.

Internal

The internal directory contains the ancillary non application specific code used in the project. Holds things like validation helpers, SQL database models, etc. The internal directory also carries a special meaning and behavior in Go. Any packages while live under this directory can only be imported by code inside the parent of the internal directory. That means packages that live in internal can only be imported by code inside the snippetbox project directory.

Looking at it another way, this means that any packages under internal cannot be imported by code outside our project. This is useful because it prevents other codebases from importing and relying on the (potentially un-versioned and unsupported) packages in our internal directory — even if the project code is publicly available somewhere like GitHub.

Ui

The ui directory contains the user interface assets used by the web application. Specifically ui/html will contain HTML templates while ui/static will contain static files (CSS, images, etc).

TLS

Need an easy way to generate TLS certs for HTTPS during local dev? Run go run /usr/local/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost in your shell (assuming Linux/MacOS machine).