Browse Source

Go usage example in docs

pull/415/head
Pēteris Caune 4 years ago
parent
commit
11c02d89c1
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 43 additions and 0 deletions
  1. +19
    -0
      templates/docs/go.html
  2. +23
    -0
      templates/docs/go.md
  3. +1
    -0
      templates/front/base_docs.html

+ 19
- 0
templates/docs/go.html View File

@ -0,0 +1,19 @@
<h1>Go</h1>
<p>Below is an example of making a HTTP request to SITE_NAME from Go.</p>
<div class="go highlight"><pre><span></span><code><span class="kn">package</span> <span class="nx">main</span>
<span class="kn">import</span> <span class="s">&quot;fmt&quot;</span>
<span class="kn">import</span> <span class="s">&quot;net/http&quot;</span>
<span class="kn">import</span> <span class="s">&quot;time&quot;</span>
<span class="kd">func</span> <span class="nx">main</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">client</span> <span class="p">=</span> <span class="o">&amp;</span><span class="nx">http</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span>
<span class="nx">Timeout</span><span class="p">:</span> <span class="mi">10</span> <span class="o">*</span> <span class="nx">time</span><span class="p">.</span><span class="nx">Second</span><span class="p">,</span>
<span class="p">}</span>
<span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">client</span><span class="p">.</span><span class="nx">Head</span><span class="p">(</span><span class="s">&quot;PING_URL&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
<span class="nx">fmt</span><span class="p">.</span><span class="nx">Printf</span><span class="p">(</span><span class="s">&quot;%s&quot;</span><span class="p">,</span> <span class="nx">err</span><span class="p">)</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre></div>

+ 23
- 0
templates/docs/go.md View File

@ -0,0 +1,23 @@
# Go
Below is an example of making a HTTP request to SITE_NAME from Go.
```go
package main
import "fmt"
import "net/http"
import "time"
func main() {
var client = &http.Client{
Timeout: 10 * time.Second,
}
_, err := client.Head("PING_URL")
if err != nil {
fmt.Printf("%s", err)
}
}
```

+ 1
- 0
templates/front/base_docs.html View File

@ -25,6 +25,7 @@
{% include "front/docs_nav_item.html" with slug="python" title="Python" %}
{% include "front/docs_nav_item.html" with slug="ruby" title="Ruby" %}
{% include "front/docs_nav_item.html" with slug="php" title="PHP" %}
{% include "front/docs_nav_item.html" with slug="go" title="Go" %}
{% include "front/docs_nav_item.html" with slug="csharp" title="C#" %}
{% include "front/docs_nav_item.html" with slug="javascript" title="Javascript" %}
{% include "front/docs_nav_item.html" with slug="powershell" title="PowerShell" %}


Loading…
Cancel
Save