Adding some comments to GetFile
This commit is contained in:
parent
8604f6443b
commit
73e322b845
1 changed files with 3 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue