Adding some comments to GetFile

This commit is contained in:
Denis-Cosmin Nutiu 2017-10-20 18:35:30 +03:00
parent 8604f6443b
commit 73e322b845

View file

@ -27,6 +27,7 @@ func GetFile(c net.Conn, path string) (int, error) {
fileName = path
}
// Open the file
file, err := os.Open(PATH + fileName)
if err != nil {
// Open file failed.
@ -35,6 +36,8 @@ func GetFile(c net.Conn, path string) (int, error) {
}
defer file.Close() // Closing the fd when the function has exited.
// Read all the data at once.
// we need to re-think this.
data, err := ioutil.ReadAll(file)
n, err := c.Write(data)
if err != nil {