package main import ( "flag" "fmt" "net" "git.chrishayward.xyz/x/users/proto" "git.chrishayward.xyz/x/users/server" "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\n", secretDefault) } // Create the network listener. lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port)) if err != nil { fmt.Printf("Failed to listen: %v", err) } // Start listening for requests. srv := grpc.NewServer() proto.RegisterUsersServer(srv, server.NewUsersServer(secret)) fmt.Printf("Listening on :%d", *port) srv.Serve(lis) }