You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-2Lines changed: 37 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,41 @@
1
1
# Go Cookbook
2
2
3
-
Source for [the Go Cookbook](http://golangcookbook.com).
3
+
Source for [the Go Cookbook](http://golangcookbook.com), a community build and contributed collection of practical recipes for real world Golang development.
4
+
5
+
### Contributing
6
+
7
+
The Go Cookbook is built by the community, so your contributions are very welcome. Just send a pull request for any changes or additions.
8
+
9
+
#### Adding a New Recipe
10
+
11
+
Recipes are generated from the [_data/chapters.yml file](https://github.com/golangcookbook/golangcookbook.github.io/blob/master/_data/chapters.yml), which is used to build [the index page](https://github.com/golangcookbook/golangcookbook.github.io/blob/master/index.md). The `chapters.yml` file is roughly like this:
12
+
13
+
```
14
+
- title: Strings
15
+
recipes:
16
+
- title: Concatenating Strings
17
+
path: /chapters/strings/concatenation
18
+
wip: true
19
+
- title: Detecting a Substring
20
+
path: /chapters/strings/detecting
21
+
- title: Detecting All Substrings
22
+
path: false
23
+
```
24
+
25
+
Specifying `wip: true` puts "[Work in progress]" in front of the recipe in the index. Setting `path: false` causes the recipe to be listed without a link.
26
+
27
+
#### Recipe Format
28
+
29
+
Recipe files have a couple of required properties, which must be specified in the preamble like such:
30
+
31
+
```yaml
32
+
---
33
+
title: Processing a String One Word or Character at a Time
34
+
question: Given a string, how do I break it into words or characters and process each one in turn?
35
+
---
36
+
```
37
+
38
+
Also, to show example code, recipes can make use of the `{% include example.html example="filename" %}` helper. This will include both `filename.go` as example source code, and `filename.expected.escaped` as the output of that code. If you're curious, [that helper is defined here](https://github.com/golangcookbook/golangcookbook.github.io/blob/master/_includes/example.html). The `filename.expected.escaped` files are automatically generated by the `./run_tests` script, described below.
The `run_tests` script not only runs the tests, but also ensures that the `.expected`, `.go.escaped`, and `.expected.escaped` files are in place. These files are then used in the chapter templates to ensure all examples are up to date and correct.
60
+
The `run_tests` script not only runs the tests, but also ensures that the `.expected`, `.go.escaped`, and `.expected.escaped` files are in place. These files are then used in the recipe templates to ensure all examples are up to date and correct.
0 commit comments