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

Working directory for pmgo processes is not project folder #32

Open
Anton-Cao opened this issue Sep 19, 2018 · 4 comments
Open

Working directory for pmgo processes is not project folder #32

Anton-Cao opened this issue Sep 19, 2018 · 4 comments

Comments

@Anton-Cao
Copy link

(More of a detail than an issue with pmgo, but I spent some time debugging a bug that was caused by this so I'm hoping that noting it down here can help other people later.)

Child processes that the pmgo daemon manages have the same working directory as the pmgo process. This means the working directory is not the project folder, so relative file paths can break.

To get around this, you can change the working directory:

import (
        "os"
...

func main() {
        gopath := os.Getenv("GOPATH")
        err := os.Chdir(gopath + "/src/{path to project}")
        if err != nil {
                fmt.Println("error changing directories: ", err)
        }
...
@struCoder
Copy link
Owner

@Anton-Cao
Right.
when exe pmgo start command, pmgo will build your project from GOPATH/src.

@rafaelmaeuer
Copy link

This information needs to be added to readme or documentation

@helloworldpark
Copy link

helloworldpark commented Apr 30, 2019

I think this issue should also be fixed, since from go 1.11, projects no longer need to be placed under $GOPATH/src.

@youjianglong
Copy link

I submitted the pull request to the start command by adding the cwd parameter to specify the working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants