Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different paths for embedded/appended files #71

Closed
lmas opened this issue Dec 29, 2015 · 2 comments
Closed

Different paths for embedded/appended files #71

lmas opened this issue Dec 29, 2015 · 2 comments
Labels

Comments

@lmas
Copy link

lmas commented Dec 29, 2015

Hello.
So when I use Walk() I get different path names depending on if I have embedded/appended the files, to the compiled binary, or not. Example code:

    templatebox := rice.MustFindBox("templates")
    templates := template.New("ServerTemplates")
    templatebox.Walk("/", func(p string, i os.FileInfo, e error) error {
            if i.IsDir() {
                    return nil
            }
            s, e := templatebox.String(p)
            if e != nil {
                    log.Fatalf("Failed to load template: %s\n%s\n", p, e)
            }
            template.Must(templates.New(p).Parse(s))
            return nil
    })
    fmt.Println("Loaded templates:")
    for _, t := range templates.Templates() {
            fmt.Println(t.Name())
    }

Normal output is something like:

base.html
index.html

But when I embedd/append I get:

/base.html
/index.html

Took a while for me to notice that difference when my app broke, since it can't load files prefixed with /.
It's easily solved by calling Walk("", ... instead, but thought I should report this bug anyway. I guess it's an oversight in readDirNames().

@GeertJohan
Copy link
Owner

Thanks for reporting this. Will need to fix this for 2.0

@lmas
Copy link
Author

lmas commented Dec 13, 2023

Happy birthday the eight 😂 closing this as this has been superseded by embed.

@lmas lmas closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants