Skip to content

di3upham/go-app

Repository files navigation

go-app

Quick start Go-gRPC, MySQL

Run

Recompile the updated .proto file:

$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative model/sample.proto

Run unit test:

$ go test

MySQL:

mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
mysql> CREATE DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
mysql> GRANT ALL PRIVILEGES ON dbname.* TO 'user'@'localhost';
mysql> CREATE TABLE `orders` (`id` varchar(20), `status` varchar(10), `created_at` bigint, `product_url` varchar(1024), UNIQUE KEY `id` (`id`));

PostgreSQL:

$ sudo su -postgres
$ psql -c "ALTER USER username WITH PASSWORD 'password'"

Run the server:

$ go build
$ ./go-app daemon

From another terminal, run the client:

$ go build
$ ./go-app grpchello

From another terminal, call API:

$ ./go-app grpc-order-create https://abc.xyz
$ ./go-app grpc-order-read 1
$ curl localhost:9000/orders/1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages