Package

ghz can be used programmatically as Go package within Go applications. See detailed godoc documentation. Example usage:

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/bojand/ghz/printer"
  6. "github.com/bojand/ghz/runner"
  7. )
  8. func main() {
  9. report, err := runner.Run(
  10. "helloworld.Greeter.SayHello",
  11. "localhost:50051",
  12. runner.WithProtoFile("greeter.proto", []string{}),
  13. runner.WithDataFromFile("data.json"),
  14. runner.WithInsecure(true),
  15. )
  16. if err != nil {
  17. fmt.Println(err.Error())
  18. os.Exit(1)
  19. }
  20. printer := printer.ReportPrinter{
  21. Out: os.Stdout,
  22. Report: report,
  23. }
  24. printer.Print("pretty")
  25. }