This document helps you get started developing Dapr CLI. If you find any problem while following this guide, please create a Pull Request to update this document.
- The Go language environment
1.21
(instructions).- Make sure that your GOPATH and PATH are configured correctly
export GOPATH=~/go export PATH=$PATH:$GOPATH/bin
- Delve for Debugging
- GolangCI-Lint
-
The Go language environment (instructions). Make sure that your GOPATH and PATH are configured correctly - You may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.
GOPATH=c:\go PATH=%GOPATH%\bin;...
-
Delve for Debugging
-
- Install Git with chocolatey and ensure that Git bin directory is in PATH environment variable
choco install git -y --package-parameters="/GitAndUnixToolsOnPath /WindowsTerminal /NoShellIntegration"
-
MinGW Install MinGW with chocolatey and ensure that MinGW bin directory is in PATH environment variable
choco install mingw
cd $GOPATH/src
mkdir -p github.com/dapr/cli
git clone /~https://github.com/dapr/cli.git github.com/dapr/cli
You can build Dapr CLI binaries via make
tool and find the binaries in ./dist/{os}_{arch}/release/
.
Note : for windows environment with MinGW, use
mingw32-make.exe
instead ofmake
.
- Build for your current local environment
cd $GOPATH/src/github.com/dapr/cli/
make build
- Cross compile for multi platforms
make build GOOS=linux GOARCH=amd64
make test
We highly recommend to use VSCode with Go plugin for your productivity. If you want to use the different editors, you can find the list of editor plugins for Delve.
This section introduces how to start debugging with Delve CLI. Please see Delve documentation for the detail usage.
$ cd $GOPATH/src/github.com/dapr/cli
$ dlv debug .
Type 'help' for list of commands.
(dlv) break main.main
(dlv) continue
This is useful to debug Dapr CLI when the process is running.
- Build Dapr CLI binaries for debugging
With
DEBUG=1
option, dapr CLI binaries will be generated without code optimization in./dist/{os}_{arch}/debug/
$ make DEBUG=1 build
- Find the process id and attach the debugger
$ dlv attach [pid]
# Specify the package that you want to test
# e.g. debugging ./pkg/api
$ dlv test ./pkg/api