Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion prep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ It doesn't matter what this does: what's important is the input command and the
Input command:

```console
curl -i 'http://localhost:8080/'
> curl -i 'http://localhost:8080/'
```

Expected output:
Expand Down
2 changes: 2 additions & 0 deletions projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Each project has its own directory with a README.md file that has instructions.

Most exercises finish with a list of optional extension tasks. It's highly recommended that you try them out. Note that often the extensions are open-ended and under-specified - make sure to think about them with a curious mind: Why are they useful? What trade-offs do they have?

1. [Output and Error Handling](./output-and-error-handling)
<br>An introduction to how to handle errors in Go, and how to present information to users of programs run on the command line.
1. [CLI & Files](./cli-files)
<br>An introduction to building things with Go by replicating the unix tools `cat` and `ls`.
1. [File Parsing](./file-parsing)
Expand Down
8 changes: 4 additions & 4 deletions projects/file-parsing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The format is as follows:
The tool `od` (which you can learn more about [here](https://man7.org/linux/man-pages/man1/od.1.html)) can be useful for exploring binary data. For instance, we can run:

```console
% od -t x1 projects/file-parsing/examples/custom-binary-le.bin
> od -t x1 projects/file-parsing/examples/custom-binary-le.bin
0000000 ff fe 0a 00 00 00 41 79 61 00 1e 00 00 00 50 72
0000020 69 73 68 61 00 ff ff ff ff 43 68 61 72 6c 69 65
0000040 00 19 00 00 00 4d 61 72 67 6f 74 00
Expand Down Expand Up @@ -99,21 +99,21 @@ Two examples of this are [`jq`](https://stedolan.github.io/jq/) (which allows yo
For example, you can use `jq` to answer the question "Who had the highest score" without needing to write a whole program:

```console
% jq -r '. | max_by(.high_score).name' file-parsing/examples/json.txt
> jq -r '. | max_by(.high_score).name' file-parsing/examples/json.txt
Prisha
```

Or use `fx` to do the same, but using more familiar JavaScript as the query language:

```console
% fx file-parsing/examples/json.txt '.sort((l, r) => r.high_score - l.high_score)[0].name'
> fx file-parsing/examples/json.txt '.sort((l, r) => r.high_score - l.high_score)[0].name'
Prisha
```

Similarly, a program called [`csvq`](https://github.com/mithrandie/csvq) can be used to query CSV files in a SQL-like query language:

```console
# cat examples/data.csv | csvq 'SELECT * ORDER BY `high score` DESC LIMIT 1'
> cat examples/data.csv | csvq 'SELECT * ORDER BY `high score` DESC LIMIT 1'
+--------+------------+
| name | high score |
+--------+------------+
Expand Down
2 changes: 2 additions & 0 deletions projects/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"order": [
"output-and-error-handling",
"cli-files",
"file-parsing",
"http-auth",
"server-database",
"multiple-servers",
Expand Down
20 changes: 11 additions & 9 deletions projects/multiple-servers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ There's a good, short guide to workloads on [scaleyourapp.com](https://scaleyour

Our file layout for this project will look like this:

```console
```
api/
api.go
assets/
Expand Down Expand Up @@ -108,12 +108,14 @@ Specifically, the `cmd/` files will import functionality from `api` and `static`

In reality, starting each will look like this:

API server:
```console
# api server
$ DATABASE_URL='postgres://localhost:5432/go-server-database' go run ./cmd/api-server --port 8081
> DATABASE_URL='postgres://localhost:5432/go-server-database' go run ./cmd/api-server --port 8081
```

# static server
$ go run ./cmd/static-server --path assets --port 8082
Static server:
```console
> go run ./cmd/static-server --path assets --port 8082
```

> 💡 See the [prep README.md](../prep/README.md#command-line-examples) for an explanation of this command line example.
Expand Down Expand Up @@ -328,7 +330,7 @@ import (
The rest is up to you: hook this together and make this work:

```console
$ go run ./cmd/static-server
> go run ./cmd/static-server
Hello!
```

Expand All @@ -339,14 +341,14 @@ To do that, add support for a command like flag: `--path` which will be where th
Make this work:

```console
$ go run ./cmd/static-server --path assets
> go run ./cmd/static-server --path assets
path: assets
```

We also want this server to run on a specific port. Make this work:

```console
$ go run ./cmd/static-server --path assets --port 8082
> go run ./cmd/static-server --path assets --port 8082
path: assets
port: 8082
```
Expand All @@ -364,7 +366,7 @@ It's possible to do this all in <20 lines of code.
At the end, you should be able to run the server and visit [http://localhost:8082](http://localhost:8082) to see the image gallery!

```console
$ go run ./cmd/static-server --path assets --port 8082
> go run ./cmd/static-server --path assets --port 8082
```

We aren't loading the list of images from an API yet; they're hard coded in the JavaScript. Making the API work is coming next.
Expand Down
Loading