# run server
docker-compose up
# play with client
docker exec $(docker ps -q --filter ancestor=gohexa) ./client add this is my first todo # add todo list
docker exec $(docker ps -q --filter ancestor=gohexa) ./client add this is my second todo
docker exec $(docker ps -q --filter ancestor=gohexa) ./client list #show all todos
docker exec $(docker ps -q --filter ancestor=gohexa) ./client update 1 #check todo in list with id 1
docker exec $(docker ps -q --filter ancestor=gohexa) ./client update 2
docker exec $(docker ps -q --filter ancestor=gohexa) ./client delete 1 #delete todo in list with id 1
# start datastore server
go get -u cloud.google.com/go/datastore
gcloud components install cloud-datastore-emulator
gcloud beta emulators datastore start
# export variable for datastore localhost
$(gcloud beta emulators datastore env-init)
# run server
go run cmd/server/main.go -grpc
# run client
go run cmd/client/main.go -grpc add todo text
go run cmd/client/main.go -grpc list
go run cmd/client/main.go -grpc update id
go run cmd/client/main.go -grpc delete id
# add todo
curl -X POST http://localhost/todos -H 'Content-Type: application/json' -d '{ "text": "second todo" } '
# list todos
curl http://localhost/todos -H 'Content-Type: application/json'
cat pb/add.json | prototool grpc pb \
--address 0.0.0.0:5000 \
--method pb.Todos/AddTodo \
--stdin
- install DELVE!! vscode debugger DELVE!! vscode doc doc
{
"name": "Launch Package Working",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${fileDirname}",
"env": {"DATASTORE_EMULATOR_HOST":"0.0.0.0:8081"},
},
{
"name": "Connect to server",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceFolder}",
"env": {"DATASTORE_EMULATOR_HOST":"0.0.0.0:8081"},
"args": [],
},
- run binary
./server
- GET PID of running process
lsof -i:5000
# or
ps aux | grep server
- run dlv
dlv attach 58400 --headless --listen=:2345 --log --api-version=2
- run vscode remote debugger and create breakpoints