package main import ( "flag" "fmt" "log" "net" "git.chrishayward.xyz/x/users/proto" "github.com/google/uuid" "google.golang.org/grpc" ) var ( secretDefault = uuid.NewString() secret = flag.String("secret", secretDefault, "--secret=SECRET") port = flag.Uint("port", 8080, "--port=8080") ) func main() { // Parse the optional flags. flag.Parse() // If the secret has not been set print it to the console. if *secret == secretDefault { fmt.Printf("SECRET=%s", secretDefault) } // Create the network listener. lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port)) if err != nil { log.Fatalf("Failed to listen: %v", err) } // Start listening for requests. srv := grpc.NewServer() proto.RegisterUsersServer(srv, newUsersServer(secret)) srv.Serve(lis) }