Beispiel #1
0
func main() {
	// Parse flags
	fs := mailerFlagSet()
	fs.Parse(os.Args[1:])

	// Print the version if -version=true
	if fs.Lookup("version").Value.(flag.Getter).Get().(bool) {
		fmt.Println(version.String("pgpst-mailer"))
		return
	}

	// Create a new signal receiver
	sc := make(chan os.Signal, 1)
	signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)

	// Parse options
	options, err := mailer.NewOptions(fs)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// Create a new mailer
	mailer := mailer.NewMailer(options)

	// Spawn it in a new goroutine
	go mailer.Main()

	// Watch for a signal
	<-sc

	// Exit the mailer
	mailer.Exit()
}
Beispiel #2
0
func main() {
	// Parse flags
	fs := apiFlagSet()
	fs.Parse(os.Args[1:])

	// Print the version if -version=true
	if fs.Lookup("version").Value.(flag.Getter).Get().(bool) {
		fmt.Println(version.String("pgpst-api"))
		return
	}

	// Create a new signal receiver
	sc := make(chan os.Signal, 1)
	signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)

	// Create a new API
	api := api.NewAPI(api.NewOptions(fs))

	// Spawn it in a new goroutine
	go api.Main()

	// Watch for a signal
	<-sc

	// Exit the API
	api.Exit()
}
Beispiel #3
0
func (a *API) hello(c *gin.Context) {
	c.JSON(http.StatusOK, &gin.H{
		"name": version.String("pgpst-api"),
	})
}
Beispiel #4
0
func TestVersionFormat(t *testing.T) {
	Convey("version.String() should return a properly formatted string", t, func() {
		So(version.String("test"), ShouldEqual, "test v"+version.Version+" ("+runtime.Version()+")")
	})
}