Skip to content

Commit 5a286e2

Browse files
author
Tammer Saleh
committed
Better readme
1 parent faec148 commit 5a286e2

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
# Go Cookbook
22

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.
439

540
### Run locally
641

@@ -22,7 +57,7 @@ $ ./run_tests
2257
$ ./run_tests chapters/strings/reverse/test_reverse_by_character.go
2358
```
2459

25-
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.
2661

2762
### License
2863

0 commit comments

Comments
 (0)