From 1943fe080370d47556cfdc96f62c83a446f7e84d Mon Sep 17 00:00:00 2001 From: Shivam Rathore Date: Mon, 24 Jun 2019 00:41:52 +0530 Subject: [PATCH] arrow keys navigation added | fixes mmcgrana/gobyexample#222 --- .gitignore | 2 ++ public/arrays | 14 ++++++++++++++ public/atomic-counters | 14 ++++++++++++++ public/base64-encoding | 14 ++++++++++++++ public/channel-buffering | 14 ++++++++++++++ public/channel-directions | 14 ++++++++++++++ public/channel-synchronization | 14 ++++++++++++++ public/channels | 14 ++++++++++++++ public/closing-channels | 14 ++++++++++++++ public/closures | 14 ++++++++++++++ public/collection-functions | 14 ++++++++++++++ public/command-line-arguments | 14 ++++++++++++++ public/command-line-flags | 14 ++++++++++++++ public/command-line-subcommands | 14 ++++++++++++++ public/constants | 14 ++++++++++++++ public/defer | 14 ++++++++++++++ public/environment-variables | 14 ++++++++++++++ public/epoch | 14 ++++++++++++++ public/errors | 14 ++++++++++++++ public/execing-processes | 14 ++++++++++++++ public/exit | 10 ++++++++++ public/file-paths | 14 ++++++++++++++ public/for | 14 ++++++++++++++ public/functions | 14 ++++++++++++++ public/goroutines | 14 ++++++++++++++ public/hello-world | 10 ++++++++++ public/http-clients | 14 ++++++++++++++ public/http-servers | 14 ++++++++++++++ public/if-else | 14 ++++++++++++++ public/interfaces | 14 ++++++++++++++ public/json | 14 ++++++++++++++ public/line-filters | 14 ++++++++++++++ public/maps | 14 ++++++++++++++ public/methods | 14 ++++++++++++++ public/multiple-return-values | 14 ++++++++++++++ public/mutexes | 14 ++++++++++++++ public/non-blocking-channel-operations | 14 ++++++++++++++ public/number-parsing | 14 ++++++++++++++ public/panic | 14 ++++++++++++++ public/pointers | 14 ++++++++++++++ public/random-numbers | 14 ++++++++++++++ public/range | 14 ++++++++++++++ public/range-over-channels | 14 ++++++++++++++ public/rate-limiting | 14 ++++++++++++++ public/reading-files | 14 ++++++++++++++ public/recursion | 14 ++++++++++++++ public/regular-expressions | 14 ++++++++++++++ public/select | 14 ++++++++++++++ public/sha1-hashes | 14 ++++++++++++++ public/signals | 14 ++++++++++++++ public/slices | 14 ++++++++++++++ public/sorting | 14 ++++++++++++++ public/sorting-by-functions | 14 ++++++++++++++ public/spawning-processes | 14 ++++++++++++++ public/stateful-goroutines | 14 ++++++++++++++ public/string-formatting | 14 ++++++++++++++ public/string-functions | 14 ++++++++++++++ public/structs | 14 ++++++++++++++ public/switch | 14 ++++++++++++++ public/tickers | 14 ++++++++++++++ public/time | 14 ++++++++++++++ public/time-formatting-parsing | 14 ++++++++++++++ public/timeouts | 14 ++++++++++++++ public/timers | 14 ++++++++++++++ public/url-parsing | 14 ++++++++++++++ public/values | 14 ++++++++++++++ public/variables | 14 ++++++++++++++ public/variadic-functions | 14 ++++++++++++++ public/waitgroups | 14 ++++++++++++++ public/worker-pools | 14 ++++++++++++++ public/writing-files | 14 ++++++++++++++ templates/example.tmpl | 14 ++++++++++++++ tools/generate.go | 4 ++++ 73 files changed, 992 insertions(+) diff --git a/.gitignore b/.gitignore index 0d20b64..acb800c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pyc +.idea +.vscode diff --git a/public/arrays b/public/arrays index 9f12e9d..b9f36ce 100644 --- a/public/arrays +++ b/public/arrays @@ -5,6 +5,20 @@ Go by Example: Arrays +

Go by Example: Arrays

diff --git a/public/atomic-counters b/public/atomic-counters index 9ba1895..c4df533 100644 --- a/public/atomic-counters +++ b/public/atomic-counters @@ -5,6 +5,20 @@ Go by Example: Atomic Counters +

Go by Example: Atomic Counters

diff --git a/public/base64-encoding b/public/base64-encoding index 2c1da0d..fdbaaed 100644 --- a/public/base64-encoding +++ b/public/base64-encoding @@ -5,6 +5,20 @@ Go by Example: Base64 Encoding +

Go by Example: Base64 Encoding

diff --git a/public/channel-buffering b/public/channel-buffering index 2734939..a11749b 100644 --- a/public/channel-buffering +++ b/public/channel-buffering @@ -5,6 +5,20 @@ Go by Example: Channel Buffering +

Go by Example: Channel Buffering

diff --git a/public/channel-directions b/public/channel-directions index 02c7c0a..2c95a14 100644 --- a/public/channel-directions +++ b/public/channel-directions @@ -5,6 +5,20 @@ Go by Example: Channel Directions +

Go by Example: Channel Directions

diff --git a/public/channel-synchronization b/public/channel-synchronization index 00076f9..595487d 100644 --- a/public/channel-synchronization +++ b/public/channel-synchronization @@ -5,6 +5,20 @@ Go by Example: Channel Synchronization +

Go by Example: Channel Synchronization

diff --git a/public/channels b/public/channels index 94b14d7..25995b6 100644 --- a/public/channels +++ b/public/channels @@ -5,6 +5,20 @@ Go by Example: Channels +

Go by Example: Channels

diff --git a/public/closing-channels b/public/closing-channels index d873cd8..ff67861 100644 --- a/public/closing-channels +++ b/public/closing-channels @@ -5,6 +5,20 @@ Go by Example: Closing Channels +

Go by Example: Closing Channels

diff --git a/public/closures b/public/closures index d85af28..0bb3852 100644 --- a/public/closures +++ b/public/closures @@ -5,6 +5,20 @@ Go by Example: Closures +

Go by Example: Closures

diff --git a/public/collection-functions b/public/collection-functions index 07e970b..fce4ddd 100644 --- a/public/collection-functions +++ b/public/collection-functions @@ -5,6 +5,20 @@ Go by Example: Collection Functions +

Go by Example: Collection Functions

diff --git a/public/command-line-arguments b/public/command-line-arguments index b649bd2..a585d22 100644 --- a/public/command-line-arguments +++ b/public/command-line-arguments @@ -5,6 +5,20 @@ Go by Example: Command-Line Arguments +

Go by Example: Command-Line Arguments

diff --git a/public/command-line-flags b/public/command-line-flags index 43ec18f..32c7abe 100644 --- a/public/command-line-flags +++ b/public/command-line-flags @@ -5,6 +5,20 @@ Go by Example: Command-Line Flags +

Go by Example: Command-Line Flags

diff --git a/public/command-line-subcommands b/public/command-line-subcommands index 39b385b..333e048 100644 --- a/public/command-line-subcommands +++ b/public/command-line-subcommands @@ -5,6 +5,20 @@ Go by Example: Command-Line Subcommands +

Go by Example: Command-Line Subcommands

diff --git a/public/constants b/public/constants index c564424..0609217 100644 --- a/public/constants +++ b/public/constants @@ -5,6 +5,20 @@ Go by Example: Constants +

Go by Example: Constants

diff --git a/public/defer b/public/defer index 445d689..42299e5 100644 --- a/public/defer +++ b/public/defer @@ -5,6 +5,20 @@ Go by Example: Defer +

Go by Example: Defer

diff --git a/public/environment-variables b/public/environment-variables index 3d2e54c..56a1cc3 100644 --- a/public/environment-variables +++ b/public/environment-variables @@ -5,6 +5,20 @@ Go by Example: Environment Variables +

Go by Example: Environment Variables

diff --git a/public/epoch b/public/epoch index 46d62e7..60ecde3 100644 --- a/public/epoch +++ b/public/epoch @@ -5,6 +5,20 @@ Go by Example: Epoch +

Go by Example: Epoch

diff --git a/public/errors b/public/errors index 489f119..a473c1b 100644 --- a/public/errors +++ b/public/errors @@ -5,6 +5,20 @@ Go by Example: Errors +

Go by Example: Errors

diff --git a/public/execing-processes b/public/execing-processes index 85b155d..2d26b21 100644 --- a/public/execing-processes +++ b/public/execing-processes @@ -5,6 +5,20 @@ Go by Example: Exec'ing Processes +

Go by Example: Exec'ing Processes

diff --git a/public/exit b/public/exit index 4c6975d..7b32b81 100644 --- a/public/exit +++ b/public/exit @@ -5,6 +5,16 @@ Go by Example: Exit +

Go by Example: Exit

diff --git a/public/file-paths b/public/file-paths index f7b24a1..9dae4c6 100644 --- a/public/file-paths +++ b/public/file-paths @@ -5,6 +5,20 @@ Go by Example: File Paths +

Go by Example: File Paths

diff --git a/public/for b/public/for index 314f139..47f39c9 100644 --- a/public/for +++ b/public/for @@ -5,6 +5,20 @@ Go by Example: For +

Go by Example: For

diff --git a/public/functions b/public/functions index 7c89d83..8eeca6c 100644 --- a/public/functions +++ b/public/functions @@ -5,6 +5,20 @@ Go by Example: Functions +

Go by Example: Functions

diff --git a/public/goroutines b/public/goroutines index 40ba434..06f5e9b 100644 --- a/public/goroutines +++ b/public/goroutines @@ -5,6 +5,20 @@ Go by Example: Goroutines +

Go by Example: Goroutines

diff --git a/public/hello-world b/public/hello-world index d8b1872..f33d703 100644 --- a/public/hello-world +++ b/public/hello-world @@ -5,6 +5,16 @@ Go by Example: Hello World +

Go by Example: Hello World

diff --git a/public/http-clients b/public/http-clients index 5d5bf04..d1a9f50 100644 --- a/public/http-clients +++ b/public/http-clients @@ -5,6 +5,20 @@ Go by Example: HTTP Clients +

Go by Example: HTTP Clients

diff --git a/public/http-servers b/public/http-servers index 2dedf1a..68431cf 100644 --- a/public/http-servers +++ b/public/http-servers @@ -5,6 +5,20 @@ Go by Example: HTTP Servers +

Go by Example: HTTP Servers

diff --git a/public/if-else b/public/if-else index 2ed0680..dcc5aec 100644 --- a/public/if-else +++ b/public/if-else @@ -5,6 +5,20 @@ Go by Example: If/Else +

Go by Example: If/Else

diff --git a/public/interfaces b/public/interfaces index 277c8f8..909465b 100644 --- a/public/interfaces +++ b/public/interfaces @@ -5,6 +5,20 @@ Go by Example: Interfaces +

Go by Example: Interfaces

diff --git a/public/json b/public/json index 54979d2..f6a4146 100644 --- a/public/json +++ b/public/json @@ -5,6 +5,20 @@ Go by Example: JSON +

Go by Example: JSON

diff --git a/public/line-filters b/public/line-filters index d264214..d673b55 100644 --- a/public/line-filters +++ b/public/line-filters @@ -5,6 +5,20 @@ Go by Example: Line Filters +

Go by Example: Line Filters

diff --git a/public/maps b/public/maps index bf31208..bfaefce 100644 --- a/public/maps +++ b/public/maps @@ -5,6 +5,20 @@ Go by Example: Maps +

Go by Example: Maps

diff --git a/public/methods b/public/methods index c1ae6d0..cf9f7f7 100644 --- a/public/methods +++ b/public/methods @@ -5,6 +5,20 @@ Go by Example: Methods +

Go by Example: Methods

diff --git a/public/multiple-return-values b/public/multiple-return-values index 5392875..1bd021d 100644 --- a/public/multiple-return-values +++ b/public/multiple-return-values @@ -5,6 +5,20 @@ Go by Example: Multiple Return Values +

Go by Example: Multiple Return Values

diff --git a/public/mutexes b/public/mutexes index efc2253..f3c8476 100644 --- a/public/mutexes +++ b/public/mutexes @@ -5,6 +5,20 @@ Go by Example: Mutexes +

Go by Example: Mutexes

diff --git a/public/non-blocking-channel-operations b/public/non-blocking-channel-operations index ada60a3..64c17ca 100644 --- a/public/non-blocking-channel-operations +++ b/public/non-blocking-channel-operations @@ -5,6 +5,20 @@ Go by Example: Non-Blocking Channel Operations +

Go by Example: Non-Blocking Channel Operations

diff --git a/public/number-parsing b/public/number-parsing index 35e768e..e8c4f81 100644 --- a/public/number-parsing +++ b/public/number-parsing @@ -5,6 +5,20 @@ Go by Example: Number Parsing +

Go by Example: Number Parsing

diff --git a/public/panic b/public/panic index 59198af..4b08f98 100644 --- a/public/panic +++ b/public/panic @@ -5,6 +5,20 @@ Go by Example: Panic +

Go by Example: Panic

diff --git a/public/pointers b/public/pointers index 16687f5..2caca80 100644 --- a/public/pointers +++ b/public/pointers @@ -5,6 +5,20 @@ Go by Example: Pointers +

Go by Example: Pointers

diff --git a/public/random-numbers b/public/random-numbers index 5de950f..29f47e9 100644 --- a/public/random-numbers +++ b/public/random-numbers @@ -5,6 +5,20 @@ Go by Example: Random Numbers +

Go by Example: Random Numbers

diff --git a/public/range b/public/range index e9aa99e..688bbdb 100644 --- a/public/range +++ b/public/range @@ -5,6 +5,20 @@ Go by Example: Range +

Go by Example: Range

diff --git a/public/range-over-channels b/public/range-over-channels index a3ba422..5b6e160 100644 --- a/public/range-over-channels +++ b/public/range-over-channels @@ -5,6 +5,20 @@ Go by Example: Range over Channels +

Go by Example: Range over Channels

diff --git a/public/rate-limiting b/public/rate-limiting index 07dc185..30b739f 100644 --- a/public/rate-limiting +++ b/public/rate-limiting @@ -5,6 +5,20 @@ Go by Example: Rate Limiting +

Go by Example: Rate Limiting

diff --git a/public/reading-files b/public/reading-files index d51206c..af5009b 100644 --- a/public/reading-files +++ b/public/reading-files @@ -5,6 +5,20 @@ Go by Example: Reading Files +

Go by Example: Reading Files

diff --git a/public/recursion b/public/recursion index bedbf2f..db074e2 100644 --- a/public/recursion +++ b/public/recursion @@ -5,6 +5,20 @@ Go by Example: Recursion +

Go by Example: Recursion

diff --git a/public/regular-expressions b/public/regular-expressions index 8db2fbd..237af8e 100644 --- a/public/regular-expressions +++ b/public/regular-expressions @@ -5,6 +5,20 @@ Go by Example: Regular Expressions +

Go by Example: Regular Expressions

diff --git a/public/select b/public/select index d6733a1..af53205 100644 --- a/public/select +++ b/public/select @@ -5,6 +5,20 @@ Go by Example: Select +

Go by Example: Select

diff --git a/public/sha1-hashes b/public/sha1-hashes index c28cf1d..f3e4155 100644 --- a/public/sha1-hashes +++ b/public/sha1-hashes @@ -5,6 +5,20 @@ Go by Example: SHA1 Hashes +

Go by Example: SHA1 Hashes

diff --git a/public/signals b/public/signals index 50f0ec1..9a1d9f5 100644 --- a/public/signals +++ b/public/signals @@ -5,6 +5,20 @@ Go by Example: Signals +

Go by Example: Signals

diff --git a/public/slices b/public/slices index fba69c9..4e30c3f 100644 --- a/public/slices +++ b/public/slices @@ -5,6 +5,20 @@ Go by Example: Slices +

Go by Example: Slices

diff --git a/public/sorting b/public/sorting index 73f22b1..219bc63 100644 --- a/public/sorting +++ b/public/sorting @@ -5,6 +5,20 @@ Go by Example: Sorting +

Go by Example: Sorting

diff --git a/public/sorting-by-functions b/public/sorting-by-functions index 92c0f41..a2efcc8 100644 --- a/public/sorting-by-functions +++ b/public/sorting-by-functions @@ -5,6 +5,20 @@ Go by Example: Sorting by Functions +

Go by Example: Sorting by Functions

diff --git a/public/spawning-processes b/public/spawning-processes index c6ba21e..d8396b9 100644 --- a/public/spawning-processes +++ b/public/spawning-processes @@ -5,6 +5,20 @@ Go by Example: Spawning Processes +

Go by Example: Spawning Processes

diff --git a/public/stateful-goroutines b/public/stateful-goroutines index a14245a..da6329c 100644 --- a/public/stateful-goroutines +++ b/public/stateful-goroutines @@ -5,6 +5,20 @@ Go by Example: Stateful Goroutines +

Go by Example: Stateful Goroutines

diff --git a/public/string-formatting b/public/string-formatting index c3118b0..c0652e6 100644 --- a/public/string-formatting +++ b/public/string-formatting @@ -5,6 +5,20 @@ Go by Example: String Formatting +

Go by Example: String Formatting

diff --git a/public/string-functions b/public/string-functions index 73b6019..4882c60 100644 --- a/public/string-functions +++ b/public/string-functions @@ -5,6 +5,20 @@ Go by Example: String Functions +

Go by Example: String Functions

diff --git a/public/structs b/public/structs index 31c03d0..ac4a3cb 100644 --- a/public/structs +++ b/public/structs @@ -5,6 +5,20 @@ Go by Example: Structs +

Go by Example: Structs

diff --git a/public/switch b/public/switch index c739ea3..fae75e8 100644 --- a/public/switch +++ b/public/switch @@ -5,6 +5,20 @@ Go by Example: Switch +

Go by Example: Switch

diff --git a/public/tickers b/public/tickers index 64f1044..286dfff 100644 --- a/public/tickers +++ b/public/tickers @@ -5,6 +5,20 @@ Go by Example: Tickers +

Go by Example: Tickers

diff --git a/public/time b/public/time index 443f568..90fbf1f 100644 --- a/public/time +++ b/public/time @@ -5,6 +5,20 @@ Go by Example: Time +

Go by Example: Time

diff --git a/public/time-formatting-parsing b/public/time-formatting-parsing index f16fbc9..602c729 100644 --- a/public/time-formatting-parsing +++ b/public/time-formatting-parsing @@ -5,6 +5,20 @@ Go by Example: Time Formatting / Parsing +

Go by Example: Time Formatting / Parsing

diff --git a/public/timeouts b/public/timeouts index 449446a..35315f4 100644 --- a/public/timeouts +++ b/public/timeouts @@ -5,6 +5,20 @@ Go by Example: Timeouts +

Go by Example: Timeouts

diff --git a/public/timers b/public/timers index 7004b5f..3ba794e 100644 --- a/public/timers +++ b/public/timers @@ -5,6 +5,20 @@ Go by Example: Timers +

Go by Example: Timers

diff --git a/public/url-parsing b/public/url-parsing index 8b17377..71874e9 100644 --- a/public/url-parsing +++ b/public/url-parsing @@ -5,6 +5,20 @@ Go by Example: URL Parsing +

Go by Example: URL Parsing

diff --git a/public/values b/public/values index 38966a3..648aed8 100644 --- a/public/values +++ b/public/values @@ -5,6 +5,20 @@ Go by Example: Values +

Go by Example: Values

diff --git a/public/variables b/public/variables index 9c1156a..0779d1c 100644 --- a/public/variables +++ b/public/variables @@ -5,6 +5,20 @@ Go by Example: Variables +

Go by Example: Variables

diff --git a/public/variadic-functions b/public/variadic-functions index 75ce887..f0355c4 100644 --- a/public/variadic-functions +++ b/public/variadic-functions @@ -5,6 +5,20 @@ Go by Example: Variadic Functions +

Go by Example: Variadic Functions

diff --git a/public/waitgroups b/public/waitgroups index 45792a8..5962f99 100644 --- a/public/waitgroups +++ b/public/waitgroups @@ -5,6 +5,20 @@ Go by Example: WaitGroups +

Go by Example: WaitGroups

diff --git a/public/worker-pools b/public/worker-pools index e1170bf..ddabd53 100644 --- a/public/worker-pools +++ b/public/worker-pools @@ -5,6 +5,20 @@ Go by Example: Worker Pools +

Go by Example: Worker Pools

diff --git a/public/writing-files b/public/writing-files index ca974bd..f4dd30d 100644 --- a/public/writing-files +++ b/public/writing-files @@ -5,6 +5,20 @@ Go by Example: Writing Files +

Go by Example: Writing Files

diff --git a/templates/example.tmpl b/templates/example.tmpl index c9cfb7d..8d6f1aa 100644 --- a/templates/example.tmpl +++ b/templates/example.tmpl @@ -5,6 +5,20 @@ Go by Example: {{.Name}} +

Go by Example: {{.Name}}

diff --git a/tools/generate.go b/tools/generate.go index a332128..33acb60 100644 --- a/tools/generate.go +++ b/tools/generate.go @@ -138,6 +138,7 @@ type Example struct { ID, Name string GoCode, GoCodeHash, URLHash string Segs [][]*Seg + PrevExample *Example NextExample *Example } @@ -270,6 +271,9 @@ func parseExamples() []*Example { examples = append(examples, &example) } for i, example := range examples { + if i > 0 { + example.PrevExample = examples[i-1] + } if i < (len(examples) - 1) { example.NextExample = examples[i+1] }