https://github.com/gerbenjacobs/unix-piping-course
This course will show you how to make a Go binary that acts as a unix tool. We will read data from stdin, convert it to our custom JSON model and push it through to stdout, completing the cycle.
https://github.com/gerbenjacobs/unix-piping-course
golang pipes tutorial unix
Last synced: 26 days ago
JSON representation
This course will show you how to make a Go binary that acts as a unix tool. We will read data from stdin, convert it to our custom JSON model and push it through to stdout, completing the cycle.
- Host: GitHub
- URL: https://github.com/gerbenjacobs/unix-piping-course
- Owner: gerbenjacobs
- Created: 2024-10-02T14:26:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-24T18:45:05.000Z (over 1 year ago)
- Last Synced: 2024-11-19T09:57:44.176Z (over 1 year ago)
- Topics: golang, pipes, tutorial, unix
- Language: Go
- Homepage: https://blog.gerbenjacobs.nl/using-unix-pipes-with-go/
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unix Piping Course with Go
This course will show you how to make a Go binary that acts as a unix tool.
We will read data from `stdin`, convert it to our custom JSON model and push it through to `stdout`, completing the cycle.
>This is a beginner to intermediate course for both Go and Unix, some things will be explained, but if you're unsure
you should be able to autonomously search for the right information.
## Background
The [Unix philosophy](https://en.wikipedia.org/wiki/Unix_philosophy) is to have tools only do one thing and by
reading and writing from `stdout` these tools can be combined to create pipelines of work that needs to be done.
An example you might have seen already is using `curl` to query a JSON endpoint and using `jq` to pretty-print
this to your screen.
```bash
curl -s https://dummyjson.com/test | jq
```
A lot of these small, do one thing well, tools are written in C, but there's no reason we can't make our own in Go!
## Requirements
- You'll need to have Go installed. (See [Go install](https://go.dev/doc/install))
- You'll need to run this in a Unix-based system (assuming macOS)
- (Optional) Docker
- (Optional) We will use `jq` as well
## Steps
This course is divided into steps, navigate to `step1` and make sure to read the individual READMEs.
> If you're really new to Go, you can check out `step0`, it will explain how to create an executable Go
> program along with how importing packages works. Make sure you have also done the [Go tour](https://go.dev/tour/)
> so you know the basic Go syntax.
The README explains what needs to be done and what the exercise is, it also contains background information.
If something is not covered don't be afraid to search for more information on Wikipedia, pkg.go.dev or StackOverflow.
Each step also contains a `ref.go` which is a reference and/or the answer for that step.
Reading this before you do the exercise is considered cheating! ;)