Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
In [1]:
import (
"bufio"
"fmt"
"os"
)
In [10]:
fileInfo, err := os.Stat("manipulate-filesystem-in-golang.ipynb")
fileInfo
Out[10]:
In [12]:
fileInfo.Mode()
Out[12]:
In [16]:
os.Chmod("test.txt", 0777)
In [17]:
fileInfo, err := os.Stat("test.txt")
fileInfo
Out[17]:
In [18]:
fileInfo.Mode()
Out[18]:
In [19]:
os.Chmod("test.txt", 0664)
In [20]:
fileInfo, err := os.Stat("test.txt")
fileInfo
Out[20]:
In [21]:
fileInfo.Mode()
Out[21]:
In [ ]:
os.Create
In [ ]:
os.Write
ioutil.WriteFile¶
ioutil.WriteFile simply calls os.WriteFile .
ioutil.ReadFile¶
ioutil.ReadFile simply calls os.ReadFile .
Copy File¶
The GoLang standard library does not provide a function to copy files directly.
However,
you can copy a file using ioutil.ReadFile
+ ioutil.WriteFile
.
(*File).WriteString¶
WriteString is like Write, but writes the contents of string s rather than a slice of bytes.
In [ ]: