diff --git a/README.md b/README.md new file mode 100644 index 0000000..b5c452a --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +eudaimonia +========== + +This runs . + +Start a test instance: + +```sh +go run main.go +``` diff --git a/assets/style.css b/assets/style.css index 684a91a..68c80a4 100644 --- a/assets/style.css +++ b/assets/style.css @@ -22,6 +22,11 @@ h1,h2 { margin-top: 2em; } +img { + width: 100%; + margin: 1em; +} + pre { background-color: #030303; margin-bottom: 2em; diff --git a/images/blog.png b/images/blog.png new file mode 100644 index 0000000..4a75800 Binary files /dev/null and b/images/blog.png differ diff --git a/main.go b/main.go index 6d9824e..be4ffef 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( const ( POSTS_DIR = "posts" ASSETS_DIR = "assets" + IMAGES_DIR = "images" TEMPLATES_DIR = "template" ) @@ -75,6 +76,7 @@ func main() { router.Delims("{{", "}}") router.LoadHTMLGlob("./templates/*.tmpl.html") router.Static("/assets", ASSETS_DIR) + router.Static("/images", IMAGES_DIR) router.Use(gin.Logger()) // Register endpoints. diff --git a/posts/blog.md b/posts/blog.md new file mode 100644 index 0000000..d0d07c2 --- /dev/null +++ b/posts/blog.md @@ -0,0 +1,34 @@ +Blog +==== + +This describes how this blog is constructed. Below is a description from the bottom up. + +- Go is used to parse markdown files and generate HTML for posts. Each time a + page is requested it will perform this conversion according to the URL + path. + +- Gin, a Go web framework, provides URL path routing, HTML templating, and + asset management. + +- The application runs on Kubernetes, specifically the managed Kubernetes + offering from Linode, LKE. + +- Traefik runs in Kubernetes and performs some network routing functions, + including: + + - Providing NAT into the Kubernetes network for external traffic. + - Provisioning a Linode NodeBalancer to provision an external IP. + +- AWS's Route53 service provides DNS that resolves to the NodeBalancer + external IP. + +- Gandi.net provides an SSL certificate which is loaded into Kubernetes as a + Secret and terminated by Traefik as part of routing to the blog web + service. + +[![Diagram of blog components](/images/blog.png)](/images/blog.png) + +Terraform provisions everything except the blog itself, which is deployed +directly via a Kubernetes manifest from GitHub Actions. + +See: diff --git a/posts/go-notes.md b/posts/go-notes.md index aa63d0b..c0ea46a 100644 --- a/posts/go-notes.md +++ b/posts/go-notes.md @@ -4,9 +4,9 @@ These are notes on the Go programming language. ## Basics -- Each Go file declares a package. - Style is enforced by the `go fmt` tool. Go expects certain styling to compile. +- Each Go file declares a package. - All Go programs have a main function in a main package. - Uppercase methods are public and exportable, lowercase methods are private. - Go constructs strings from **runes**, which are unicode characters. Unicode @@ -24,10 +24,12 @@ Go source is compiled and executed from a `GOPATH`. go install project Go dependencies are done with Go Modules. Dependencies will be detected within -their use in code and then automatically downloaded. +their use in code and then automatically included (but may need to be +downloaded). cd ./project go mod init project + go get go mod tidy Projects with a `main` package and a `main.go` file can be directly executed. @@ -36,8 +38,8 @@ Projects with a `main` package and a `main.go` file can be directly executed. ## Variables -Go has static types with hinting. You can explicitly declare types, or you can -have Go figure it out using `:=`. +Go has static types with hinting. You can explicitly declare types or you can +have Go figure it out. The following are equivalent: @@ -77,7 +79,7 @@ The `_` variable can be used to throw away unneeded information. Go will error on unused or over-declared variables. All variables, when declared, are initialized to their "zero value," which -depends on the type (e.g., booleans get 'False' and integers get 0). +depends on the type (e.g., booleans get `false` and integers get `0`). ## Types @@ -93,6 +95,19 @@ Type functions can also do some conversions. Each conversion creates a copy. Some times include: +- **int** and **uint8** and **unint64** are integers. + +- **float32** and **float64** are floating point types. + + var pi float64 = 3.1415926 + pi = float64(3.14159) + +- **string** is a string. + +- **bool** is a boolean. `!` is negation. + +- Also **byte**. + - **iota** can create constant enumerations and is an auto incrementing value. const ( @@ -111,17 +126,6 @@ Some times include: fmt.Printf("%d %d %d", zero, four, eight) // Prints '0 4 8'. -- **float32** and **float64** are floating point types. - - var pi float64 = 3.1415926 - pi = float64(3.14159) - -- **int** and **uint8** and **unint64** are integers. - -- **bool** is a boolean. `!` is negation. - -- Also **byte**. - - Also **error**--the built-in Go error type. - The empty value in Go is `nil`. @@ -135,7 +139,7 @@ Some times include: bar int } - s := &something(foo: "test") + s := &something{foo: "test"} s.bar = 3 Both examples below will instantiate a struct with zero-values. @@ -158,18 +162,18 @@ Strings can be indexed using array brackets and `:`. astr[0:4] astr[:4] -Looping over a string rune by rune: - - for i, r := range astr { - fmt.Printf("%d %c\n", i, r) - } - The `range` keyword allows k/v iteration. for _, r := range astr { ... } +Looping over a string rune by rune: + + for i, r := range astr { + fmt.Printf("%d %c\n", i, r) + } + Get string length with `len()`. Strings in back quotes, \`, are interpreted literally. Double quotes, `""`, diff --git a/templates/index.tmpl.html b/templates/index.tmpl.html index 716c3ef..c325734 100644 --- a/templates/index.tmpl.html +++ b/templates/index.tmpl.html @@ -9,7 +9,8 @@

eudaimonia.io

- I use this space to write. +

I use this space to write.

+

This is me: https://github.com/spacez320