gravityblast / fresh

Build and (re)start go web apps after saving/creating/deleting source files.
MIT License
3.78k stars 381 forks source link

Fresh does not support go mod vendor? #99

Open developerlaoz opened 5 years ago

developerlaoz commented 5 years ago

Fresh does not support go mod vendor?

I start a project with go mod. When I build and run my project, I can use go build -mod=vendor cmd/main.go and go run -mod=vendor cmd/main.go.

But I can not use fresh, because the source of build step in fresh is cmd := exec.Command("go", "build", "-o", buildPath(), root()).

Am I right? How can I use fresh in my project.

My project folder is : ├── cmd │   └── main.go ├── go.mod ├── go.sum ├── internal ├── runner.conf └── vendor

NiloofarGheibi commented 5 years ago

any progress on this issue?

Mizumaki commented 5 years ago

It seems fresh doesn't support go module mode, so I decided to use realize as an alternative for hot reload development.

My project folder is : ├── server │ └── main.go ├── go.mod ├── go.sum └── .realize.yaml (This is the replacement of runner.conf)

.realize.yaml is :

settings:
  legacy:
    force: false
    interval: 0s
schema:
  - name: name
    path: .
    commands:
      install:
        status: true
        method: go build -o tmp/app.out server/main.go
      run:
        status: true
        method: tmp/app.out
    watcher:
      extensions:
        - go
      paths:
        - /
      ignore:
        paths:
          - .git
          - .realize
          - vendor

ref: https://github.com/oxequa/realize/issues/217#issuecomment-459198990

After installing realize, realize start will work fine. 🥳

When you install realize, you may see this error: build github.com/oxequa/realize: cannot load gopkg.in/urfave/cli.v2.

The solution is

go get gopkg.in/urfave/cli.v2@master
GO111MODULE=off go get github.com/oxequa/realize

And please be careful realize seems dead project the same as fresh ☠️

kinyat commented 4 years ago

Thanks @Mizumaki! Your solution works great!