<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<ol dir="auto">
<li>What version of Go are you using (<code class="notranslate">go version</code>)?<br>
go version go1.6 darwin/amd64</li>
<li>What operating system and processor architecture are you using (<code class="notranslate">go env</code>)?<br>
mac os x 10.9.5</li>
<li>What did you do?<br>
(Use play.golang.org to provide a runnable example, if possible.)<br>
I want to download golang package for mac os x from an ISP in Iran using golang.org</li>
<li>What did you expect to see?<br>
I expect to see that golang is available for developers from Iran.<br>
You call golang "open-source" that it means its OPEN for anybody. we are developers too.</li>
<li>What did you see instead?</li>
<li>That’s an error.<br>
Your client does not have permission to get URL / from this server. (Client IP address: xxx.xxx.xxx.xxx)<br>
We're sorry, but this service is not available in your country. That’s all we know.</li>
</ol>
<p dir="auto">using go 1.5.1 and 1.6 on linux/x64</p>
<p dir="auto">given this string</p>
<div class="highlight highlight-source-go notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var cgroupname = &quot;/machine.slice/machine-rkt\\x2dbad20ebf\\x2de8b8\\x2d48fe\\x2dabba\\x2de2e3f72123fb.scope/system.slice/alpine-sh.service&quot;"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">cgroupname</span> <span class="pl-c1">=</span> <span class="pl-s">"/machine.slice/machine-rkt<span class="pl-cce">\\</span>x2dbad20ebf<span class="pl-cce">\\</span>x2de8b8<span class="pl-cce">\\</span>x2d48fe<span class="pl-cce">\\</span>x2dabba<span class="pl-cce">\\</span>x2de2e3f72123fb.scope/system.slice/alpine-sh.service"</span></pre></div>
<p dir="auto">trying to use this function to strip out part of it.  (yes, can use regex, but that's a different point)</p>
<div class="highlight highlight-source-go notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="func parseName(name string) (string, error) {
        splits := strings.Split(name, &quot;/&quot;)
        if len(splits) == 3 || len(splits) == 5 {
                if splits[1] == &quot;machine.slice&quot; {
                        replacer := strings.NewReplacer(&quot;machine-rkt-&quot;, &quot;&quot;, &quot;.scope&quot;, &quot;&quot;, &quot;\\x2d&quot;, &quot;-&quot;)
                        pod := replacer.Replace(splits[2])
                        pod = strings.Replace(pod, &quot;machine-rkt-&quot;, &quot;&quot;, -1)
                        if len(splits) == 3 {
                                return pod, nil
                        }
                        if splits[3] == &quot;system.slice&quot; {
                                container := strings.Replace(splits[4], &quot;.service&quot;, &quot;&quot;, -1)
                                return pod + &quot;:&quot; + container, nil
                        }
                }
        }

        return &quot;&quot;, fmt.Errorf(&quot;%s not handled by rkt handler&quot;, name)
}"><pre class="notranslate"><span class="pl-k">func</span> <span class="pl-en">parseName</span>(<span class="pl-s1">name</span> <span class="pl-smi">string</span>) (<span class="pl-smi">string</span>, <span class="pl-smi">error</span>) {
        <span class="pl-s1">splits</span> <span class="pl-c1">:=</span> <span class="pl-s1">strings</span>.<span class="pl-en">Split</span>(<span class="pl-s1">name</span>, <span class="pl-s">"/"</span>)
        <span class="pl-k">if</span> <span class="pl-en">len</span>(<span class="pl-s1">splits</span>) <span class="pl-c1">==</span> <span class="pl-c1">3</span> <span class="pl-c1">||</span> <span class="pl-en">len</span>(<span class="pl-s1">splits</span>) <span class="pl-c1">==</span> <span class="pl-c1">5</span> {
                <span class="pl-k">if</span> <span class="pl-s1">splits</span>[<span class="pl-c1">1</span>] <span class="pl-c1">==</span> <span class="pl-s">"machine.slice"</span> {
                        <span class="pl-s1">replacer</span> <span class="pl-c1">:=</span> <span class="pl-s1">strings</span>.<span class="pl-en">NewReplacer</span>(<span class="pl-s">"machine-rkt-"</span>, <span class="pl-s">""</span>, <span class="pl-s">".scope"</span>, <span class="pl-s">""</span>, <span class="pl-s">"<span class="pl-cce">\\</span>x2d"</span>, <span class="pl-s">"-"</span>)
                        <span class="pl-s1">pod</span> <span class="pl-c1">:=</span> <span class="pl-s1">replacer</span>.<span class="pl-en">Replace</span>(<span class="pl-s1">splits</span>[<span class="pl-c1">2</span>])
                        <span class="pl-s1">pod</span> <span class="pl-c1">=</span> <span class="pl-s1">strings</span>.<span class="pl-en">Replace</span>(<span class="pl-s1">pod</span>, <span class="pl-s">"machine-rkt-"</span>, <span class="pl-s">""</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>)
                        <span class="pl-k">if</span> <span class="pl-en">len</span>(<span class="pl-s1">splits</span>) <span class="pl-c1">==</span> <span class="pl-c1">3</span> {
                                <span class="pl-k">return</span> <span class="pl-s1">pod</span>, <span class="pl-c1">nil</span>
                        }
                        <span class="pl-k">if</span> <span class="pl-s1">splits</span>[<span class="pl-c1">3</span>] <span class="pl-c1">==</span> <span class="pl-s">"system.slice"</span> {
                                <span class="pl-s1">container</span> <span class="pl-c1">:=</span> <span class="pl-s1">strings</span>.<span class="pl-en">Replace</span>(<span class="pl-s1">splits</span>[<span class="pl-c1">4</span>], <span class="pl-s">".service"</span>, <span class="pl-s">""</span>, <span class="pl-c1">-</span><span class="pl-c1">1</span>)
                                <span class="pl-k">return</span> <span class="pl-s1">pod</span> <span class="pl-c1">+</span> <span class="pl-s">":"</span> <span class="pl-c1">+</span> <span class="pl-s1">container</span>, <span class="pl-c1">nil</span>
                        }
                }
        }

        <span class="pl-k">return</span> <span class="pl-s">""</span>, <span class="pl-s1">fmt</span>.<span class="pl-en">Errorf</span>(<span class="pl-s">"%s not handled by rkt handler"</span>, <span class="pl-s1">name</span>)
}</pre></div>
<p dir="auto">the strings.Replace for pod shouldn't be necessary, I'd expect the replacer to work correctly, but it doesn't.  Either it's buggy or i'm using it incorrectly, but I don't know what I'm doing wrong.</p>
<p dir="auto">can duplicate with <a href="https://play.golang.org/p/p_akq9d3YW" rel="nofollow">https://play.golang.org/p/p_akq9d3YW</a> by playing with comenting out line 18</p>