Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial generation for play.golang.org linking, ref #37

  • Loading branch information...
commit 056d0aff689f716687fade5666b02be736105a72 1 parent 0c18c96
@mmcgrana authored
Showing with 109 additions and 44 deletions.
  1. +1 −1  examples/json/json.go
  2. +1 −1  examples/reading-files/reading-files.go
  3. +1 −1  examples/slices/slices.go
  4. +1 −1  examples/url-parsing/url-parsing.go
  5. +1 −0  public/arrays
  6. +1 −0  public/atomic-counters
  7. +1 −0  public/base64-encoding
  8. +1 −0  public/channel-buffering
  9. +1 −0  public/channel-directions
  10. +1 −0  public/channel-synchronization
  11. +1 −0  public/channels
  12. +1 −0  public/closing-channels
  13. +1 −0  public/closures
  14. +1 −0  public/collection-functions
  15. +1 −0  public/command-line-arguments
  16. +1 −0  public/command-line-flags
  17. +1 −0  public/constants
  18. +1 −0  public/defer
  19. +1 −0  public/environment-variables
  20. +1 −0  public/epoch
  21. +1 −0  public/errors
  22. +1 −0  public/execing-processes
  23. +1 −0  public/exit
  24. +1 −0  public/for
  25. +1 −0  public/functions
  26. +1 −0  public/goroutines
  27. +1 −0  public/hello-world
  28. +1 −0  public/if-else
  29. +1 −0  public/interfaces
  30. +1 −0  public/json
  31. +1 −0  public/line-filters
  32. +1 −0  public/maps
  33. +1 −0  public/methods
  34. +1 −0  public/multiple-return-values
  35. +1 −0  public/mutexes
  36. +1 −0  public/non-blocking-channel-operations
  37. +1 −0  public/number-parsing
  38. +1 −0  public/panic
  39. +1 −0  public/pointers
  40. +1 −0  public/random-numbers
  41. +1 −0  public/range
  42. +1 −0  public/range-over-channels
  43. +1 −0  public/rate-limiting
  44. +1 −0  public/reading-files
  45. +1 −0  public/recursion
  46. +1 −0  public/regular-expressions
  47. +1 −0  public/select
  48. +1 −0  public/sha1-hashes
  49. +1 −0  public/signals
  50. +1 −0  public/slices
  51. +1 −0  public/sorting
  52. +1 −0  public/sorting-by-functions
  53. +1 −0  public/spawning-processes
  54. +1 −0  public/stateful-goroutines
  55. +1 −0  public/string-formatting
  56. +1 −0  public/string-functions
  57. +1 −0  public/structs
  58. +1 −0  public/switch
  59. +1 −0  public/tickers
  60. +1 −0  public/time
  61. +1 −0  public/time-formatting-parsing
  62. +1 −0  public/timeouts
  63. +1 −0  public/timers
  64. +1 −0  public/url-parsing
  65. +1 −0  public/values
  66. +1 −0  public/variables
  67. +1 −0  public/variadic-functions
  68. +1 −0  public/worker-pools
  69. +1 −0  public/writing-files
  70. +40 −40 tools/generate.go
View
2  examples/json/json.go
@@ -68,7 +68,7 @@ func main() {
// Now let's look at decoding JSON data into Go
// values. Here's an example for a generic data
- // structure.
+ // structure.
byt := []byte(`{"num":6.0,"strs":["a","b"]}`)
// We need to provide a variable where the JSON
View
2  examples/reading-files/reading-files.go
@@ -69,7 +69,7 @@ func main() {
// The `bufio` package implements a buffered
// reader that may be useful both for its efficiency
// with many small reads and because of the additional
- // reading methods it provides.
+ // reading methods it provides.
r4 := bufio.NewReader(f)
b4, err := r4.Peek(5)
check(err)
View
2  examples/slices/slices.go
@@ -27,7 +27,7 @@ func main() {
// In addition to these basic operations, slices
// support several more that make them richer than
- // arrays. One is the builtin `append`, which
+ // arrays. One is the builtin `append`, which
// returns a slice containing one or more new values.
// Note that we need to accept a return value from
// append as we may get a new slice value.
View
2  examples/url-parsing/url-parsing.go
@@ -9,7 +9,7 @@ import "strings"
func main() {
- // We'll parse this example URL, which includes a
+ // We'll parse this example URL, which includes a
// scheme, authentication info, host, port, path,
// query params, and query fragment.
s := "postgres://user:pass@host.com:5432/path?k=v#f"
View
1  public/arrays
@@ -20,6 +20,7 @@
<body>
<div class="example" id="arrays">
<h2><a href="./">Go by Example</a>: Arrays</h2>
+ <a href="http://play.golang.org/p/l-A8eBnwio"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/atomic-counters
@@ -20,6 +20,7 @@
<body>
<div class="example" id="atomic-counters">
<h2><a href="./">Go by Example</a>: Atomic Counters</h2>
+ <a href="http://play.golang.org/p/sKIaNsJquU"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/base64-encoding
@@ -20,6 +20,7 @@
<body>
<div class="example" id="base64-encoding">
<h2><a href="./">Go by Example</a>: Base64 Encoding</h2>
+ <a href="http://play.golang.org/p/t6rFm2x4Yr"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/channel-buffering
@@ -20,6 +20,7 @@
<body>
<div class="example" id="channel-buffering">
<h2><a href="./">Go by Example</a>: Channel Buffering</h2>
+ <a href="http://play.golang.org/p/34PVHwO6Bn"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/channel-directions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="channel-directions">
<h2><a href="./">Go by Example</a>: Channel Directions</h2>
+ <a href="http://play.golang.org/p/P9Fujfpa1f"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/channel-synchronization
@@ -20,6 +20,7 @@
<body>
<div class="example" id="channel-synchronization">
<h2><a href="./">Go by Example</a>: Channel Synchronization</h2>
+ <a href="http://play.golang.org/p/0DfW-1RMqi"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/channels
@@ -20,6 +20,7 @@
<body>
<div class="example" id="channels">
<h2><a href="./">Go by Example</a>: Channels</h2>
+ <a href="http://play.golang.org/p/aVTMoY5FNt"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/closing-channels
@@ -20,6 +20,7 @@
<body>
<div class="example" id="closing-channels">
<h2><a href="./">Go by Example</a>: Closing Channels</h2>
+ <a href="http://play.golang.org/p/eFZ2SeKswH"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/closures
@@ -20,6 +20,7 @@
<body>
<div class="example" id="closures">
<h2><a href="./">Go by Example</a>: Closures</h2>
+ <a href="http://play.golang.org/p/gQtEWkhWyp"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/collection-functions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="collection-functions">
<h2><a href="./">Go by Example</a>: Collection Functions</h2>
+ <a href="http://play.golang.org/p/3PNdke3Wia"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/command-line-arguments
@@ -20,6 +20,7 @@
<body>
<div class="example" id="command-line-arguments">
<h2><a href="./">Go by Example</a>: Command-Line Arguments</h2>
+ <a href="http://play.golang.org/p/44uyYt_TRl"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/command-line-flags
@@ -20,6 +20,7 @@
<body>
<div class="example" id="command-line-flags">
<h2><a href="./">Go by Example</a>: Command-Line Flags</h2>
+ <a href="http://play.golang.org/p/9xlvGqQjhl"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/constants
@@ -20,6 +20,7 @@
<body>
<div class="example" id="constants">
<h2><a href="./">Go by Example</a>: Constants</h2>
+ <a href="http://play.golang.org/p/T5sj0eINnp"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/defer
@@ -20,6 +20,7 @@
<body>
<div class="example" id="defer">
<h2><a href="./">Go by Example</a>: Defer</h2>
+ <a href="http://play.golang.org/p/9aoHwzHcAo"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/environment-variables
@@ -20,6 +20,7 @@
<body>
<div class="example" id="environment-variables">
<h2><a href="./">Go by Example</a>: Environment Variables</h2>
+ <a href="http://play.golang.org/p/kfqLhpmEpw"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/epoch
@@ -20,6 +20,7 @@
<body>
<div class="example" id="epoch">
<h2><a href="./">Go by Example</a>: Epoch</h2>
+ <a href="http://play.golang.org/p/3jXHvYbLUz"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/errors
@@ -20,6 +20,7 @@
<body>
<div class="example" id="errors">
<h2><a href="./">Go by Example</a>: Errors</h2>
+ <a href="http://play.golang.org/p/BmDQXkPPTk"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/execing-processes
@@ -20,6 +20,7 @@
<body>
<div class="example" id="execing-processes">
<h2><a href="./">Go by Example</a>: Exec'ing Processes</h2>
+ <a href="http://play.golang.org/p/iEAD2cYC-h"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/exit
@@ -20,6 +20,7 @@
<body>
<div class="example" id="exit">
<h2><a href="./">Go by Example</a>: Exit</h2>
+ <a href="http://play.golang.org/p/CDiAh9SXRM"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/for
@@ -20,6 +20,7 @@
<body>
<div class="example" id="for">
<h2><a href="./">Go by Example</a>: For</h2>
+ <a href="http://play.golang.org/p/mGqqcBZ0jv"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/functions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="functions">
<h2><a href="./">Go by Example</a>: Functions</h2>
+ <a href="http://play.golang.org/p/2EXoOWfGf_"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/goroutines
@@ -20,6 +20,7 @@
<body>
<div class="example" id="goroutines">
<h2><a href="./">Go by Example</a>: Goroutines</h2>
+ <a href="http://play.golang.org/p/aIO_Wi3hJj"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/hello-world
@@ -20,6 +20,7 @@
<body>
<div class="example" id="hello-world">
<h2><a href="./">Go by Example</a>: Hello World</h2>
+ <a href="http://play.golang.org/p/H8bxSpw9Jq"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/if-else
@@ -20,6 +20,7 @@
<body>
<div class="example" id="if-else">
<h2><a href="./">Go by Example</a>: If/Else</h2>
+ <a href="http://play.golang.org/p/p_ykufAYRj"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/interfaces
@@ -20,6 +20,7 @@
<body>
<div class="example" id="interfaces">
<h2><a href="./">Go by Example</a>: Interfaces</h2>
+ <a href="http://play.golang.org/p/vx8bwC-Bmq"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/json
@@ -20,6 +20,7 @@
<body>
<div class="example" id="json">
<h2><a href="./">Go by Example</a>: JSON</h2>
+ <a href="http://play.golang.org/p/4L2wMVv7tW"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/line-filters
@@ -20,6 +20,7 @@
<body>
<div class="example" id="line-filters">
<h2><a href="./">Go by Example</a>: Line Filters</h2>
+ <a href="http://play.golang.org/p/OSS71nSpkV"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/maps
@@ -20,6 +20,7 @@
<body>
<div class="example" id="maps">
<h2><a href="./">Go by Example</a>: Maps</h2>
+ <a href="http://play.golang.org/p/D-F9YN_V8r"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/methods
@@ -20,6 +20,7 @@
<body>
<div class="example" id="methods">
<h2><a href="./">Go by Example</a>: Methods</h2>
+ <a href="http://play.golang.org/p/254m_9Yjwa"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/multiple-return-values
@@ -20,6 +20,7 @@
<body>
<div class="example" id="multiple-return-values">
<h2><a href="./">Go by Example</a>: Multiple Return Values</h2>
+ <a href="http://play.golang.org/p/LrDt1Wah0M"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/mutexes
@@ -20,6 +20,7 @@
<body>
<div class="example" id="mutexes">
<h2><a href="./">Go by Example</a>: Mutexes</h2>
+ <a href="http://play.golang.org/p/-_LKNceBru"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/non-blocking-channel-operations
@@ -20,6 +20,7 @@
<body>
<div class="example" id="non-blocking-channel-operations">
<h2><a href="./">Go by Example</a>: Non-Blocking Channel Operations</h2>
+ <a href="http://play.golang.org/p/M972dltae2"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/number-parsing
@@ -20,6 +20,7 @@
<body>
<div class="example" id="number-parsing">
<h2><a href="./">Go by Example</a>: Number Parsing</h2>
+ <a href="http://play.golang.org/p/N90EppECFk"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/panic
@@ -20,6 +20,7 @@
<body>
<div class="example" id="panic">
<h2><a href="./">Go by Example</a>: Panic</h2>
+ <a href="http://play.golang.org/p/c86oXzfQOt"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/pointers
@@ -20,6 +20,7 @@
<body>
<div class="example" id="pointers">
<h2><a href="./">Go by Example</a>: Pointers</h2>
+ <a href="http://play.golang.org/p/KdE4TBbUL2"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/random-numbers
@@ -20,6 +20,7 @@
<body>
<div class="example" id="random-numbers">
<h2><a href="./">Go by Example</a>: Random Numbers</h2>
+ <a href="http://play.golang.org/p/C0_kuFx3ET"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/range
@@ -20,6 +20,7 @@
<body>
<div class="example" id="range">
<h2><a href="./">Go by Example</a>: Range</h2>
+ <a href="http://play.golang.org/p/Ys3V-ohVRy"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/range-over-channels
@@ -20,6 +20,7 @@
<body>
<div class="example" id="range-over-channels">
<h2><a href="./">Go by Example</a>: Range over Channels</h2>
+ <a href="http://play.golang.org/p/WN7NNh9tvh"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/rate-limiting
@@ -20,6 +20,7 @@
<body>
<div class="example" id="rate-limiting">
<h2><a href="./">Go by Example</a>: Rate Limiting</h2>
+ <a href="http://play.golang.org/p/e7yzIk97-p"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/reading-files
@@ -20,6 +20,7 @@
<body>
<div class="example" id="reading-files">
<h2><a href="./">Go by Example</a>: Reading Files</h2>
+ <a href="http://play.golang.org/p/VcLqpSwnkN"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/recursion
@@ -20,6 +20,7 @@
<body>
<div class="example" id="recursion">
<h2><a href="./">Go by Example</a>: Recursion</h2>
+ <a href="http://play.golang.org/p/RFn-rf42ap"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/regular-expressions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="regular-expressions">
<h2><a href="./">Go by Example</a>: Regular Expressions</h2>
+ <a href="http://play.golang.org/p/7bnr2EXlxK"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/select
@@ -20,6 +20,7 @@
<body>
<div class="example" id="select">
<h2><a href="./">Go by Example</a>: Select</h2>
+ <a href="http://play.golang.org/p/NGSkDrli6L"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/sha1-hashes
@@ -20,6 +20,7 @@
<body>
<div class="example" id="sha1-hashes">
<h2><a href="./">Go by Example</a>: SHA1 Hashes</h2>
+ <a href="http://play.golang.org/p/YUaWWEeB4U"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/signals
@@ -20,6 +20,7 @@
<body>
<div class="example" id="signals">
<h2><a href="./">Go by Example</a>: Signals</h2>
+ <a href="http://play.golang.org/p/d42wO1q1oh"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/slices
@@ -20,6 +20,7 @@
<body>
<div class="example" id="slices">
<h2><a href="./">Go by Example</a>: Slices</h2>
+ <a href="http://play.golang.org/p/dPQErsP6Yc"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/sorting
@@ -20,6 +20,7 @@
<body>
<div class="example" id="sorting">
<h2><a href="./">Go by Example</a>: Sorting</h2>
+ <a href="http://play.golang.org/p/roQOJXtqAb"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/sorting-by-functions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="sorting-by-functions">
<h2><a href="./">Go by Example</a>: Sorting by Functions</h2>
+ <a href="http://play.golang.org/p/M06NADP985"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/spawning-processes
@@ -20,6 +20,7 @@
<body>
<div class="example" id="spawning-processes">
<h2><a href="./">Go by Example</a>: Spawning Processes</h2>
+ <a href="http://play.golang.org/p/utd_H-XJtC"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/stateful-goroutines
@@ -20,6 +20,7 @@
<body>
<div class="example" id="stateful-goroutines">
<h2><a href="./">Go by Example</a>: Stateful Goroutines</h2>
+ <a href="http://play.golang.org/p/2YrrJo4H6W"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/string-formatting
@@ -20,6 +20,7 @@
<body>
<div class="example" id="string-formatting">
<h2><a href="./">Go by Example</a>: String Formatting</h2>
+ <a href="http://play.golang.org/p/qayRuqXHym"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/string-functions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="string-functions">
<h2><a href="./">Go by Example</a>: String Functions</h2>
+ <a href="http://play.golang.org/p/COXm374QWe"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/structs
@@ -20,6 +20,7 @@
<body>
<div class="example" id="structs">
<h2><a href="./">Go by Example</a>: Structs</h2>
+ <a href="http://play.golang.org/p/OMCP5KFC10"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/switch
@@ -20,6 +20,7 @@
<body>
<div class="example" id="switch">
<h2><a href="./">Go by Example</a>: Switch</h2>
+ <a href="http://play.golang.org/p/8b5CajPcHn"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/tickers
@@ -20,6 +20,7 @@
<body>
<div class="example" id="tickers">
<h2><a href="./">Go by Example</a>: Tickers</h2>
+ <a href="http://play.golang.org/p/U0PO7ZZU3l"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/time
@@ -20,6 +20,7 @@
<body>
<div class="example" id="time">
<h2><a href="./">Go by Example</a>: Time</h2>
+ <a href="http://play.golang.org/p/NxuQTlVA2l"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/time-formatting-parsing
@@ -20,6 +20,7 @@
<body>
<div class="example" id="time-formatting-parsing">
<h2><a href="./">Go by Example</a>: Time Formatting / Parsing</h2>
+ <a href="http://play.golang.org/p/JqNGqbuqF1"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/timeouts
@@ -20,6 +20,7 @@
<body>
<div class="example" id="timeouts">
<h2><a href="./">Go by Example</a>: Timeouts</h2>
+ <a href="http://play.golang.org/p/CoBnJiRyx3"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/timers
@@ -20,6 +20,7 @@
<body>
<div class="example" id="timers">
<h2><a href="./">Go by Example</a>: Timers</h2>
+ <a href="http://play.golang.org/p/6fSHrYxpMu"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/url-parsing
@@ -20,6 +20,7 @@
<body>
<div class="example" id="url-parsing">
<h2><a href="./">Go by Example</a>: URL Parsing</h2>
+ <a href="http://play.golang.org/p/eaMv0skOfY"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/values
@@ -20,6 +20,7 @@
<body>
<div class="example" id="values">
<h2><a href="./">Go by Example</a>: Values</h2>
+ <a href="http://play.golang.org/p/fgGVOyuZdu"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/variables
@@ -20,6 +20,7 @@
<body>
<div class="example" id="variables">
<h2><a href="./">Go by Example</a>: Variables</h2>
+ <a href="http://play.golang.org/p/Zv45CSMaiD"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/variadic-functions
@@ -20,6 +20,7 @@
<body>
<div class="example" id="variadic-functions">
<h2><a href="./">Go by Example</a>: Variadic Functions</h2>
+ <a href="http://play.golang.org/p/wRPLOM1VIH"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/worker-pools
@@ -20,6 +20,7 @@
<body>
<div class="example" id="worker-pools">
<h2><a href="./">Go by Example</a>: Worker Pools</h2>
+ <a href="http://play.golang.org/p/y12QxBsKtT"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
1  public/writing-files
@@ -20,6 +20,7 @@
<body>
<div class="example" id="writing-files">
<h2><a href="./">Go by Example</a>: Writing Files</h2>
+ <a href="http://play.golang.org/p/5usz1Oc-xY"><img height="16" width="16" title="Run code" src="play.png" style="float:right" /></a>
<table>
View
80 tools/generate.go
@@ -124,24 +124,24 @@ type Seg struct {
}
type Example struct {
- Id, Name string
- GoCode, GoCodeHash, UrlHash string
- Segs [][]*Seg
- NextExample *Example
+ Id, Name string
+ GoCode, GoCodeHash, UrlHash string
+ Segs [][]*Seg
+ NextExample *Example
}
func parseHashFile(sourcePath string) (string, string) {
- var codehash,urlkey string
+ var codehash, urlkey string
lines := readLines(sourcePath)
- for idx,line := range lines {
- switch idx {
- case 0:
- codehash = line
- case 1:
- urlkey = line
- }
+ for idx, line := range lines {
+ switch idx {
+ case 0:
+ codehash = line
+ case 1:
+ urlkey = line
+ }
}
- return codehash,urlkey
+ return codehash, urlkey
}
func resetUrlHashFile(codehash, code, sourcePath string) string {
@@ -153,8 +153,8 @@ func resetUrlHashFile(codehash, code, sourcePath string) string {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
urlkey := string(body)
- data := fmt.Sprintf("%s\n%s",codehash,urlkey)
- ioutil.WriteFile(sourcePath,[]byte(data),0644)
+ data := fmt.Sprintf("%s\n%s", codehash, urlkey)
+ ioutil.WriteFile(sourcePath, []byte(data), 0644)
return urlkey
}
@@ -203,25 +203,25 @@ func parseSegs(sourcePath string) ([]*Seg, string) {
seg.CodeEmpty = (seg.Code == "")
seg.CodeLeading = (i < (len(segs) - 1))
}
- return segs,filecontent
+ return segs, filecontent
}
func parseAndRenderSegs(sourcePath string) ([]*Seg, string) {
- segs,filecontent := parseSegs(sourcePath)
+ segs, filecontent := parseSegs(sourcePath)
lexer := whichLexer(sourcePath)
for _, seg := range segs {
- if seg.Docs != "" {
- seg.DocsRendered = markdown(seg.Docs)
- }
- if seg.Code != "" {
- seg.CodeRendered = cachedPygmentize(lexer, seg.Code)
- }
+ if seg.Docs != "" {
+ seg.DocsRendered = markdown(seg.Docs)
+ }
+ if seg.Code != "" {
+ seg.CodeRendered = cachedPygmentize(lexer, seg.Code)
+ }
}
// we are only interested in the 'go' code to pass to play.golang.org
if lexer != "go" {
- filecontent = ""
- }
- return segs,filecontent
+ filecontent = ""
+ }
+ return segs, filecontent
}
func parseExamples() []*Example {
@@ -239,21 +239,21 @@ func parseExamples() []*Example {
example.Segs = make([][]*Seg, 0)
sourcePaths := mustGlob("examples/" + exampleId + "/*")
for _, sourcePath := range sourcePaths {
- switch strings.HasSuffix(sourcePath,".hash") {
- case true:
- example.GoCodeHash,example.UrlHash = parseHashFile(sourcePath)
- default:
- sourceSegs,filecontents := parseAndRenderSegs(sourcePath)
- if (filecontents != "") {
- example.GoCode = filecontents
- }
- example.Segs = append(example.Segs, sourceSegs)
- }
+ switch strings.HasSuffix(sourcePath, ".hash") {
+ case true:
+ example.GoCodeHash, example.UrlHash = parseHashFile(sourcePath)
+ default:
+ sourceSegs, filecontents := parseAndRenderSegs(sourcePath)
+ if filecontents != "" {
+ example.GoCode = filecontents
+ }
+ example.Segs = append(example.Segs, sourceSegs)
+ }
+ }
+ newCodeHash := sha1Sum(example.GoCode)
+ if example.GoCodeHash != newCodeHash {
+ example.UrlHash = resetUrlHashFile(newCodeHash, example.GoCode, "examples/"+example.Id+"/"+example.Id+".hash")
}
- newCodeHash := sha1Sum(example.GoCode)
- if (example.GoCodeHash != newCodeHash) {
- example.UrlHash = resetUrlHashFile(newCodeHash,example.GoCode,"examples/"+example.Id+"/"+ example.Id + ".hash")
- }
examples = append(examples, &example)
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.