Sample project to test out go features
-
Setting Up Project
- Clone the repo into $GOPATH/bandi.com/
- Run
make
command inside $GOPATH/bandi.com/TestGo Folder - To RUN application
go run main.go
- To RUN grpc get user client use
go run examples/main/main_grpc_client.go
- To RUN tests
make test
- To RUN Benchmark Tests
make bench
or manually rungo test -bench=.
- Running Swagger Document
swagger serve data/swagger/apidocs.swagger.json
-
Sample Visual Studio Launch.json for Debugging code. (Setup Visual Studio by adding folder bandi.com in workspace)
-
Paste this in launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "auto", "program": "${workspaceFolder}/TestGo/main.go", "env": {}, "args": [] } ] }
-
-
After Launching Application
-
Create User
curl -X POST \ http://localhost:18081/organizations/bandi/users \ -H 'Content-Type: application/json' \ -d '{ "name": "kishore", "displayName": "bandi kishore", "email": "bandikishores@gmail.com" }'
-
Get User
curl -X GET http://localhost:18081/organizations/bandi/users/kishore?queryParam1=123 -H 'Host: localhost:18081' --header 'X-Custom-orgname: someCustom' --header 'authorization: bearer some_token_if8y3498eufhkfj'
OR
curl -X GET http://localhost:18081/users/kishore?queryParam1=123 -H 'Host: localhost:18081' --header 'X-Custom-orgname: someCustom'
-
For Streaming Responses
curl -X GET http://localhost:18081/organizations/bandi/streamusers/kishore?queryParam1=123 -H 'Host: localhost:18081'
OR
curl -X GET http://localhost:18081/streamusers/kishore?queryParam1=123 -H 'Host: localhost:18081'
-
Update User
curl -X PUT \ http://localhost:18081/organizations/bandi/users/kishore \ -H 'Content-Type: application/json' \ -d '{ "user" : { "name": "kishore", "displayName": "bandi kishore s", "email": "bandikishores@gmail.com" } }'
-
-
Testing GORM part. It currently uses secure psql, change accordingly.
- To Create Record
curl --location --request POST 'http://localhost:18081/objects/users'
--header 'Authorization: Bearer dsfv'
--header 'Content-Type: application/json'
--data-raw '{ "username": "bandi.kishore", "CreditCards": [ { "number": "6799e36389", "cvv": 948, "ID": "klshdfowe8" }, { "number": "6799e3389", "cvv": 183, "ID": "klsdvsdfv" } ] }'- To Get Records
curl --location --request GET 'http://localhost:18081/objects/users/bandi.kishore'
--header 'Authorization: Bearer sdv' -
Manual Installation and Compilation of Proto/Go
- Go Mod Created using
go mod init bandi.com/TestGo
- To Compile ProtoBuf from root directory
protoc --go_out=./pkg/ ./data/proto/addressbook.proto
- Go Mod Created using