Display random quotes evertimes it is run:
https://golang.org/doc/install
export GOPATH=/Users/nandeshwar.sah/go
export GOROOT=/usr/local/go
export PATH=$PATH:/Users/nandeshwar.sah/go/bin
export PATH=$PATH:/usr/local/go/bin
export GOBIN=/usr/local/go/bin
alias dc='docker-compose'
alias dcup='docker-compose up -d'
alias dcdown='docker-compose down'
go run cmd/quote/main.go
go test $(go list ./pkg/*) -coverprofile r.txt
go tool cover -func r.txt
go tool cover -html r.txt
docker run -p 1922:1922 -t nandeshwar/quote
or
docker run -p 1922:1922 -e SERVER_RUN_DURATION_MIN=10 -e SERVER_RUN_DURATION_HOUR=10 -t nandeshwar/quote
docker-compose up -d
docker run -p 1922:1922 -e SERVER_RUN_DURATION_MIN=10 -e SERVER_RUN_DURATION_HOUR=10 -e TZ=America/Denver -t nandeshwar/quote
docker build -t nandeshwar/quote .
docker push nandeshwar/quote
or
docker-compose up -d --build
docker push nandeshwar/quote
docker-compose down
docker images -q -f "dangling=true" | xargs docker rmi
Step1: Create image specific to Raspberry pi
Install buildx with below commands,
git clone git://github.com/docker/buildx && cd buildx
make install
Create image compatible with raspberry pi with below command,
docker buildx create --name testbuilder
docker buildx ls
docker buildx use testbuilder
docker buildx build --platform linux/amd64,linux/arm64 --tag nandeshwar/quote-r:latest --push .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --tag nandeshwar/quote-r:latest --push .
sqlite3 ./db/quote.db
.tables
brew tap go-swagger/go-swagger
brew install go-swagger
1. copy swagger-ui folder as it is
2. change title in index.html
3. api.go has following lines at top of file and should be commented as given below
// Package Quote QuoteAPI.
//
// Consumes:
// - application/xml
// Produces:
// - application/json
//
// swagger:meta
4. Add line below in api.go
//go:generate swagger generate spec -m -o ../../swagger-ui/swagger.json
5. Link these 2 lines given below api.go
sh := http.StripPrefix("/swagger-ui/", http.FileServer(http.Dir("./swagger-ui/")))
mux.PathPrefix("/swagger-ui/").Handler(sh)
6. Add swagger tag in struct like given below
// swagger:model infoResponse
type Info struct {
7. Add swagger tag before function similar to below
// swagger:operation GET /api/quote/v1/info/{id} INFO info
// ---
// description: get INFO by id
// consumes:
// - "application/json"
// parameters:
// - name: id
// description: id to get info
// in: path
// required: true
// default: 1
// type: string
// Responses:
// '200':
// description: Ok
// schema:
// '$ref': '#/definitions/infoResponse'
// '400':
// description: Bad request
// '404':
// description: Not found
// '500':
// description: Internal server error
go generate ./...
http://localhost:1922/swagger-ui/
http://localhost:1922/swagger-ui/
go get google.golang.org/protobuf/cmd/protoc-gen-go
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
go get -u google.golang.org/grpc
protoc -I=./pkg/grpcquote/ --go_out=./pkg/grpcquote/ --go-grpc_out=./pkg/grpcquote/ ./pkg/grpcquote/event-detail.proto
https://grpc.io/docs/quickstart/go.html
Look "Before you begin" section
https://github.com/phuongdo/go-grpc-tutorial
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go run cmd/grpc_client/eventDetailClient.go
go run cmd/grpc_client/eventDetailClient.go get 41
go run cmd/grpc_client/eventDetailClient.go put event.json
go run cmd/grpc_client/eventDetailClient.go gets "1, 2, 3, 4, 5"
http://localhost:8000/
go run cmd/binaryclient/kafka/producer/kafkaproducer.go
go run cmd/binaryclient/kafka/consumer/kafkaconsumer.go
http://localhost:15672/
sudo go run cmd/binaryclient/rabbitmq/producer/producer.go
sudo go run cmd/binaryclient/rabbitmq/consumer/consumer.go
export EMAIL_SERVER="smtp.gmail.com"
export EMAIL_SERVER_PORT=587
export EMAIL_FROM="abc@gmail.com"
export EMAIL_FROM_PWD="****"
export EMAIL_TO_FOR_EVENTS="abc@gmail.com, xyz@gmail.com"
export EMAIL_TO_FOR_QUOTE_IMAGE="abc@gmail.com, xyz@gmail.com"
Note: for smtp gmail. go to gmail acccount -> Search -> Less secure app access -> turn it on
1. Add ssh public key in github
2. git remote set-url origin git@github.com:Nandeshwar/quote.git
3. git push origin <branch>