markbates / pkger

Embed static files in Go binaries (replacement for gobuffalo/packr)
MIT License
1.19k stars 60 forks source link

Trying to include static files using pkger.Dir("../frontend/build") results in "exit status 1: no Go files in /Users/me/app/frontend/build" #149

Closed rayterrill closed 3 years ago

rayterrill commented 3 years ago

Basic example:

package main

import (
    "github.com/gofiber/fiber/v2"
    "github.com/gofiber/fiber/v2/middleware/filesystem"
    "github.com/markbates/pkger"
)

func main() {
    app := fiber.New()

    //serve react app
    app.Use("/", filesystem.New(filesystem.Config{
        Root: pkger.Dir("../frontend/build"),
    }))

    app.Listen(":3000")
}

Is there some other way to specify that the static files are up a directory?

This appears to work fine if the build directory is in the same directory as the go code itself (i.e. Root: pkger.Dir("/build") ).

rayterrill commented 3 years ago

Digging into this a little more - looks like maybe I'm misunderstanding how this works and this is by design per "There are no relative paths. All paths are absolute to the modules root."