V
V
Vadim Rublev2019-12-09 23:18:16
go
Vadim Rublev, 2019-12-09 23:18:16

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

1 answer(s)
A
Alexander Pavlyuk, 2019-12-09
@pav5000

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 question

Ask a Question

731 491 924 answers to any question