Answer the question
In order to leave comments, you need to log in
In the Go server, you need to specify the site directory and the specific file that should be sent in response to the URL. Apparently, in the ServeFile() function?
Please help me with the ServeFile() function. Or tell me another function to send [from server to client by URL] a file along with connected files.
Here it is - ServeFile(w, r, nameFile) - sends a file; and it is necessary to send accompanying files too.
Answer the question
In order to leave comments, you need to log in
If such questions arise, maybe you should use a framework?
For example https://github.com/gin-gonic/gin
It will look like this:
func main() {
router := gin.Default()
router.Static("/static", "./static")
router.StaticFile("/index.htm", "./static/index.htm")
router.Run(":8080")
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question