Is there a way I can compile then run my compiled application, if its already running then exit recompile and run.

So current work flow is compile switch to terminal run binary, switch back make changes compile return to terminal Ctrl + C to kill then run again, be nice if I could do all this from inside emacs.

I guess a bash script could be an option but curious if others have this work flow and how it works ?

Currently in a golang workflow but even better if there is a generic solution.

  • olymk2OPB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Okay so what I think your saying is if i do something like this as the compilation command

    go build main.go && ./main
    

    Then when I run compilation again it will kill the buffer and running process and all will be good ?

    • JohnDoe365B
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      In which case I wonder why you are not running go run anyway?

      • olymk2OPB
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Probably because I was just getting into golang and following a tutorial which did not mention using go run, but I will now thanks :)

    • jsledB
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      yes, should do. It’ll prompt you if you want to kill the existing live compilation to start the new one. If it’s already dead, it’ll just launch the new compilation.

      One trick, as well, is if you rename the existing *compilation* buffer, it will live on its own lifecycle, so you rename it to *server* or whatever, and still do compilation cycles (eg. just go build main.go) while the existing main from the previous run is still live.

      • olymk2OPB
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Awesome I will give that a try :)