github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/docs/Run.md (about)

     1  Summary
     2  -------
     3  `./godelw run` can be used to run a product from source.
     4  
     5  Tutorial start state
     6  --------------------
     7  
     8  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
     9  * Project contains `godel` and `godelw`
    10  * Project contains `main.go`
    11  * Project contains `.gitignore` that ignores IDEA files
    12  * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go`
    13  * `godel/config/dist.yml` is configured to build `echgo`
    14  * Project is tagged as 0.0.1
    15  
    16  ([Link](https://github.com/nmiyake/echgo/tree/7799802bb82db52e99dda67edf9c98333b28fca3))
    17  
    18  Run
    19  ---
    20  
    21  `echgo` is now defined as a product and can be built using `build`. Its functionality can be tested using tests or by
    22  invoking the executable that was built with `build`.
    23  
    24  Although the program can be run by building the product and invoking the executable (or by running `go install` and
    25  running the executable), this can be cumbersome for quick iteration. `./godelw run` can be used to quickly build and run
    26  a product from source for faster iteration.
    27  
    28  Use `./godelw run` to invoke `echgo`:
    29  
    30  ```
    31  ➜ ./godelw run foo
    32  /usr/local/go/bin/go run /Volumes/git/go/src/github.com/nmiyake/echgo/main.go foo
    33  foo
    34  ```
    35  
    36  This uses `go run` to run the product. The above works because our project only defines a single product. If a project
    37  defines multiple products, then the `--product` flag must be used to specify the product that should be run:
    38  
    39  ```
    40  ➜ ./godelw run --product=echgo foo
    41  /usr/local/go/bin/go run /Volumes/git/go/src/github.com/nmiyake/echgo/main.go foo
    42  foo
    43  ```
    44  
    45  Because the `run` task uses `go run`, it does not build the product using the build parameters specified in the
    46  configuration. This can be verified by running the command with the `-version` flag and verifying the output. Flags that
    47  are meant to be processed by the program invoked by `run` must be prepended with `flag:` to distinguish them from flags
    48  that for the `run` task itself. Run the following to run the equivalent of `echgo -version`:
    49  
    50  ```
    51  ➜ ./godelw run flag:-version
    52  /usr/local/go/bin/go run /Volumes/git/go/src/github.com/nmiyake/echgo/main.go -version
    53  echgo version: none
    54  ```
    55  
    56  The output demonstrates that the code was run from source (if `echgo` was built using `./godelw build` and that
    57  executable was run, the version output would be the output of `git describe` since we configured the build parameters to
    58  set the version variable on build).
    59  
    60  Tutorial end state
    61  ------------------
    62  
    63  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
    64  * Project contains `godel` and `godelw`
    65  * Project contains `main.go`
    66  * Project contains `.gitignore` that ignores IDEA files
    67  * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go`
    68  * `godel/config/dist.yml` is configured to build `echgo`
    69  * Project is tagged as 0.0.1
    70  
    71  ([Link](https://github.com/nmiyake/echgo/tree/7799802bb82db52e99dda67edf9c98333b28fca3))
    72  
    73  Tutorial next step
    74  ------------------
    75  
    76  [Dist](https://github.com/palantir/godel/wiki/Dist)