<p dir="auto">For instance, when I make a path on a windows system, it usually fails with a way too long error:</p>
<div class="highlight highlight-source-go notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="package main

import &quot;os&quot;

func main() {
    err := os.MkdirAll(`C:\Users\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV\WWWW\XXXX\YYYY\ZZZZ\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV\WWWW\XXXX\YYYY\ZZZZ`, os.ModePerm)
    if err != nil {
        panic(err)
    }
}
......
// result

mkdir C:\Users\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV\WWWW\XXXX\YYYY\
ZZZZ\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV: The filename or extensio
n is too long."><pre class="notranslate"><span class="pl-k">package</span> main

<span class="pl-k">import</span> <span class="pl-s">"os"</span>

<span class="pl-k">func</span> <span class="pl-en">main</span>() {
    <span class="pl-s1">err</span> <span class="pl-c1">:=</span> <span class="pl-s1">os</span>.<span class="pl-en">MkdirAll</span>(<span class="pl-s">`C:\Users\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV\WWWW\XXXX\YYYY\ZZZZ\AAAA\BBBB\CCCC\DDDD\EEEE\FFFF\GGGG\HHHH\IIII\JJJJ\KKKK\LLLL\MMMM\NNNN\OOOO\PPPP\QQQQ\RRRR\SSSS\TTTT\UUUU\VVVV\WWWW\XXXX\YYYY\ZZZZ`</span>, <span class="pl-s1">os</span>.<span class="pl-c1">ModePerm</span>)
    <span class="pl-k">if</span> <span class="pl-s1">err</span> <span class="pl-c1">!=</span> <span class="pl-c1">nil</span> {
        <span class="pl-en">panic</span>(<span class="pl-s1">err</span>)
    }
}
<span class="pl-c1">...</span><span class="pl-c1">...</span>
<span class="pl-c">// result</span>

mkdir <span class="pl-s1">C</span>:\U<span class="pl-s1">sers</span><span class="pl-cce">\A</span><span class="pl-s1">AAA</span><span class="pl-cce">\B</span><span class="pl-s1">BBB</span><span class="pl-cce">\C</span><span class="pl-s1">CCC</span><span class="pl-cce">\D</span><span class="pl-s1">DDD</span><span class="pl-cce">\E</span><span class="pl-s1">EEE</span><span class="pl-cce">\F</span><span class="pl-s1">FFF</span><span class="pl-cce">\G</span><span class="pl-s1">GGG</span><span class="pl-cce">\H</span><span class="pl-s1">HHH</span><span class="pl-cce">\I</span><span class="pl-s1">III</span><span class="pl-cce">\J</span><span class="pl-s1">JJJ</span><span class="pl-cce">\K</span><span class="pl-s1">KKK</span><span class="pl-cce">\L</span><span class="pl-s1">LLL</span><span class="pl-cce">\M</span><span class="pl-s1">MMM</span><span class="pl-cce">\N</span><span class="pl-s1">NNN</span><span class="pl-cce">\O</span><span class="pl-s1">OOO</span><span class="pl-cce">\P</span><span class="pl-s1">PPP</span><span class="pl-cce">\Q</span><span class="pl-s1">QQQ</span><span class="pl-cce">\R</span><span class="pl-s1">RRR</span><span class="pl-cce">\S</span><span class="pl-s1">SSS</span><span class="pl-cce">\T</span><span class="pl-s1">TTT</span>\U<span class="pl-s1">UUU</span><span class="pl-cce">\V</span><span class="pl-s1">VVV</span><span class="pl-cce">\W</span><span class="pl-s1">WWW</span><span class="pl-cce">\X</span><span class="pl-s1">XXX</span><span class="pl-cce">\Y</span><span class="pl-s1">YYY</span><span class="pl-cce">\</span>
<span class="pl-cce"></span><span class="pl-s1">ZZZZ</span><span class="pl-cce">\A</span><span class="pl-s1">AAA</span><span class="pl-cce">\B</span><span class="pl-s1">BBB</span><span class="pl-cce">\C</span><span class="pl-s1">CCC</span><span class="pl-cce">\D</span><span class="pl-s1">DDD</span><span class="pl-cce">\E</span><span class="pl-s1">EEE</span><span class="pl-cce">\F</span><span class="pl-s1">FFF</span><span class="pl-cce">\G</span><span class="pl-s1">GGG</span><span class="pl-cce">\H</span><span class="pl-s1">HHH</span><span class="pl-cce">\I</span><span class="pl-s1">III</span><span class="pl-cce">\J</span><span class="pl-s1">JJJ</span><span class="pl-cce">\K</span><span class="pl-s1">KKK</span><span class="pl-cce">\L</span><span class="pl-s1">LLL</span><span class="pl-cce">\M</span><span class="pl-s1">MMM</span><span class="pl-cce">\N</span><span class="pl-s1">NNN</span><span class="pl-cce">\O</span><span class="pl-s1">OOO</span><span class="pl-cce">\P</span><span class="pl-s1">PPP</span><span class="pl-cce">\Q</span><span class="pl-s1">QQQ</span><span class="pl-cce">\R</span><span class="pl-s1">RRR</span><span class="pl-cce">\S</span><span class="pl-s1">SSS</span><span class="pl-cce">\T</span><span class="pl-s1">TTT</span>\U<span class="pl-s1">UUU</span><span class="pl-cce">\V</span>VVV: <span class="pl-s1">The</span> <span class="pl-s1">filename</span> <span class="pl-s1">or</span> <span class="pl-s1">extensio</span>
<span class="pl-s1">n</span> <span class="pl-s1">is</span> <span class="pl-s1">too</span> <span class="pl-s1">long</span>.</pre></div>
<p dir="auto">To be clear, this is usually fixed by prepending <code class="notranslate">\\?\</code> to the path.</p>
<p dir="auto">What version of Go are you using (go version)? <strong>go1.5.3</strong><br>
What operating system and processor architecture are you using? <strong>windows/amd64 - Windows2012R2</strong><br>
What did you do? <strong>Create a very very long path, as per example</strong><br>
What did you expect to see? <strong>No error creating the directory</strong><br>
What did you see instead?  <strong>os.PathError creating the directory</strong></p>
<pre class="notranslate">This program creates directory, but fails to create file inside (CAREFUL IF CHANGING
THIS PROGRAM - YOU MIGHT END UP WITH FILES/DIRECTORIES YOU WILL NOT BE ABLE TO DELETE
WITH STANDARD SHELL TOOLS):

package main

import (
    "fmt"
    "log"
    "os"
    "strings"
)

func main() {
//  root := `\\?\c:\`
    root := `c:\`
    dir := root + strings.Repeat("d", 200)
    file := dir + `\` + strings.Repeat("f", 200)
    err := os.Mkdir(dir, 0777)
    if err != nil {
        log.Fatalf("Mkdir(%s): %v", dir, err)
    }
    f, err := os.Create(file)
    if err != nil {
        log.Fatalf("Create(%s): %v", file, err)
    }
    _, err = fmt.Fprintf(f, "Hello world")
    if err != nil {
        log.Fatalf("Fprintf(%s): %v", file, err)
    }
    err = f.Close()
    if err != nil {
        log.Fatalf("Close(%s): %v", file, err)
    }
    err = os.Remove(file)
    if err != nil {
        log.Fatalf("Remove(%s): %v", file, err)
    }
    err = os.Remove(dir)
    if err != nil {
        log.Fatalf("Remove(%s): %v", dir, err)
    }
}

This can be handled properly if we use \\?\ path prefix (uncomment line in the code).
But \\?\ prefixed paths needs to be "normalized": they have to be absolute, no
. or .. allowed, / is not allowed, UNC paths needs to be handled properly. See
<a href="http://goo.gl/th2fJ" rel="nofollow">http://goo.gl/th2fJ</a> for details, especially "Maximum Path Length Limitation"
section.

This issue has come up on our own builder: <a href="http://goo.gl/FbblU" rel="nofollow">http://goo.gl/FbblU</a>. Perhaps our own paths do
not need to be that long. I did not look into that yet.

Alex</pre>