Static Files on Go Gin Returns 404

Viewed 26

I have an API service built with Go Gin. And I want to have a static folder which have images from uploaded files. I used this code to make a route.

r := gin.Default()

r.StaticFS("/uploads", http.Dir("./static"))

r.Run(":8080")

It worked on my local, but not working on my server side.

1 Answers

Your server is not only a binary file ? Go compiles without compiling static files in it, you need to upload static files as well ,or you can see the go:embed directive to compile static files into them Reference link https://echorand.me/posts/go-embed/

Related