Run - palantir/godel GitHub Wiki
Summary
./godelw run can be used to run a product from source.
Tutorial start state
${GOPATH}/src/${PROJECT_PATH}exists, is the working directory and is initialized as a Git repository and Go module- Project contains
godelandgodelw - Project contains
main.go - Project contains
.gitignorethat ignores GoLand files - Project contains
echo/echo.go,echo/echo_test.goandecho/echoer.go godel/config/dist.ymlis configured to buildechgo2- Project is tagged as 0.0.1
Run
echgo2 is now defined as a product and can be built using build. Its functionality can be tested using tests or by
invoking the executable that was built with build.
Although the program can be run by building the product and invoking the executable (or by running go install and
running the executable), this can be cumbersome for quick iteration. ./godelw run can be used to quickly build and run
a product from source for faster iteration.
Use ./godelw run to invoke echgo2:
➜ ./godelw run echgo2 foo
/usr/local/go/bin/go run -ldflags -X main.version=0.0.1 /go/src/github.com/nmiyake/echgo2/main.go foo
foo
This uses go run to run the product. Note that the build flags configured for the product in its build section are
automatically provided to the go run invocation.
Because the run task uses go run, it does not build the product using the build parameters specified in the
configuration. This can be verified by running the command with the -version flag and verifying the output. All of the
flags and arguments provided after the name of the product to run are passed to the product using go run. The --
operator should be used after the product name to disable flag parsing. Run the following to run the equivalent of
echgo2 -version:
➜ ./godelw run echgo2 -- -version
/usr/local/go/bin/go run -ldflags -X main.version=0.0.1 /go/src/github.com/nmiyake/echgo2/main.go -version
echgo2 version: 0.0.1
Tutorial end state
${GOPATH}/src/${PROJECT_PATH}exists, is the working directory and is initialized as a Git repository and Go module- Project contains
godelandgodelw - Project contains
main.go - Project contains
.gitignorethat ignores GoLand files - Project contains
echo/echo.go,echo/echo_test.goandecho/echoer.go godel/config/dist.ymlis configured to buildechgo2- Project is tagged as 0.0.1