You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
800 B

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)
}