oxequa / realize

Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
GNU General Public License v3.0
4.46k stars 230 forks source link

Go generate only runs on startup #183

Open AndreasBackx opened 6 years ago

AndreasBackx commented 6 years ago

I've got the following file that runs packr via go generate. But it only seems to run go generate when initially running realize start.

//go:generate packr
package main

import (
    "github.com/gobuffalo/packr"
    "path/filepath"
)

func SchemaString() string {
    box := packr.NewBox("./schema")
    schema := ""

    for _, filename := range box.List() {
        extension := filepath.Ext(filename)
        if extension == ".graphql" {
            schema += box.String(filename)
        }
    }
    return schema
}

The following is my .realize.yaml:

settings:
  legacy:
    force: false
    interval: 0s
schema:
- name: project
  path: .
  commands:
    generate:
      status: true
    install:
      status: true
    run:
      status: true
  watcher:
    extensions:
    - go
    - graphql
    paths:
    - /
    ignored_paths:
    - .git
    - .realize
    - vendor

Output:

[16:23:38][PROJECT] : Watching 13 file/s 5 folder/s
[16:23:38][PROJECT] : GO changed /path/to/project/main-packr.go
[16:23:38][PROJECT] : Install started
[16:23:38][PROJECT] : Install started
[16:23:38][PROJECT] : Install completed in 0.000 s
[16:23:39][PROJECT] : Install completed in 0.578 s
[16:23:39][PROJECT] : Running..
[16:23:39][PROJECT] : Starting server...
# Deleted the generated `main-packr.go` file. It does not regenerate it.
[16:23:43][PROJECT] : GO changed /path/to/project/main-packr.go
[16:23:43][PROJECT] : Install started
[16:23:44][PROJECT] : Install completed in 0.602 s
[16:23:44][PROJECT] : Running..
[16:23:44][PROJECT] : Starting server...
# Changing another file also does not regenerate it.
[16:23:48][PROJECT] : GO changed /path/to/project/main.go
[16:23:48][PROJECT] : Install started
[16:23:48][PROJECT] : Install completed in 0.111 s
[16:23:48][PROJECT] : Running..
[16:23:48][PROJECT] : Starting server...

Initially it starts out without a main-packr.go file which is initially generated by go generate which triggers a second install. But after that it is not regenerated indicating that go generate is only called on startup.

asoseil commented 6 years ago

Hi, i'll create a sample with packr as soon as possible in order to test this

mikegleasonjr commented 6 years ago

same with test, only run tests on startup

AndreasBackx commented 6 years ago

@Asoseil you can use this project of mine to test it. It was only a proof-of-concept project.

frankdugan3 commented 6 years ago

This seems to be unrelated to packr, it does the same thing for me with a simple script I wrote as well. It detects the change and rebuilds, but only runs go generate on startup.

alvarolm commented 6 years ago

same happening with test here

kcchu commented 6 years ago

The same problem happens with test/vet/fmt as well. Also, this affect 2.0.2 release and master while 2.0.1 is okay.