Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Accessing files away from service directory #182

Closed
vadimpiven opened this issue Mar 24, 2019 · 1 comment · Fixed by #206
Closed

Accessing files away from service directory #182

vadimpiven opened this issue Mar 24, 2019 · 1 comment · Fixed by #206
Labels
environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed

Comments

@vadimpiven
Copy link

I've found one rather strange thing - when trying to open a file from outside of the directory served,... it works! Even after packr2 build and mv to another directory program tries to find and open files by related path. The same time, http.Dir just throws an error at the same place. So I've considered such a behaviour as a bug (correct me if I'm wrong). Example program:

package main

import (
	"fmt"
	"github.com/gobuffalo/packr/v2"
	"net/http"
)

func main() {
	b := packr.New("static", "static")
	f1, err := b.Open("../main.go")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(f1)
	}

	d := http.Dir("static")
	f2, err := d.Open("../main.go")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(f2)
	}
}

and it's output:

package main

import (
	"fmt"
	"github.com/gobuffalo/packr/v2"
	"net/http"
)

func main() {
	b := packr.New("static", "static")
	f1, err := b.Open("../main.go")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(f1)
	}

	d := http.Dir("static")
	f2, err := d.Open("../main.go")
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(f2)
	}
}

open static/main.go: no such file or directory
@matthijskooijman
Copy link

The output you're showing is not entirely clear. I see just a single print, rather than two? It does not really show the problem clearly.

@markbates markbates added environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed labels May 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants