• Tom Limoncelli's avatar
    io/ioutil: change TempFile prefix to a pattern · 191efbc4
    Tom Limoncelli authored
    Users of TempFile need to be able to supply the suffix, especially
    when using operating systems that give semantic meaning to the
    filename extension such as Windows.  Renaming the file to include
    an extension after the fact is insufficient as it could lead to
    race conditions.
    
    If the string given to TempFile includes a "*", the random string
    replaces the "*". For example "myname.*.bat" will result in a random
    filename such as "myname.123456.bat".  If no "*' is included the
    old behavior is retained, and the random digits are appended to the
    end.
    
    If multiple "*" are included, the final one is replaced, thus
    permitting a pathological programmer to create filenames such as
    "foo*.123456.bat" but not "foo.123456.*.bat"
    
    Fixes #4896
    
    Change-Id: Iae7f0980b4de6d7d31b87c8c3c3d40767b283c1f
    Reviewed-on: https://go-review.googlesource.com/105675Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    191efbc4
Name
Last commit
Last update
..
testdata Loading commit data...
example_test.go Loading commit data...
ioutil.go Loading commit data...
ioutil_test.go Loading commit data...
tempfile.go Loading commit data...
tempfile_test.go Loading commit data...