work on generating main.go and use config not hardcoded vals

This commit is contained in:
cubixle
2021-06-18 13:58:58 +01:00
parent feff0c38eb
commit f435f65536
10 changed files with 124 additions and 76 deletions
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"os"
"fmt"
"net"
"log"
"google.golang.org/grpc"
pb "github.com/cubixle/tuugen/example_project/internal/pb/service"
"github.com/cubixle/tuugen/example_project/internal/service"
)
func main() {
lis, err := net.Listen("tcp", fmt.Sprintf(":%s", getEnv("GRPC_PORT", "8090")))
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterServiceServer(s, service.New(store))
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}
func getEnv(name, defaultValue string) string {
v := os.Getenv(name)
if v == "" {
return defaultValue
}
return v
}
+2 -1
View File
@@ -1,6 +1,7 @@
project: tuugen_test_project
import_path: github.com/cubixle/tuugen/example_project
proto: service.proto
proto_file: service.proto
grpc_file: internal/pb/service/service_grpc.pb.go
service_name: Service
data_models:
- name: User