Using FileServer to share files

1

I'm learning Golang and to practice I'm doing some small "projects", my idea is to just share a folder from my windows or some file through my local wifi network using Golang's net / http package. I used this little code below to "upar" a folder and then to access my cell phone or notebook through the ip address.

    import (
    "log"
    "net/http"
)

func main() {
    http.Handle("/", http.FileServer(http.Dir("C:\VIDEOS")))
    log.Fatal(http.ListenAndServe(":8080", nil))

}

The code works and I can access the files through the browser on my PC, but I would like to know how I can "free" access to other devices on my network accessing the files as well.

    
asked by anonymous 14.12.2017 / 20:49

1 answer

2

When you run your go code, Windows will ask you to allow other devices on your private network to access that port (8080). Just allow it to be accessible.

At the time of access, instead of using the localhost + port, you will need to use the IP address of the computer on that network plus the port. To know what the IP is, simply access the Command Prompt and use the command ipconfig/all .

    
14.12.2017 / 21:25