aboutsummaryrefslogtreecommitdiff
path: root/cmd/trunks-example
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-03-27 16:34:31 +0700
committerShulhan <ms@kilabit.info>2021-03-27 16:34:31 +0700
commit413ed58f7df58644f030ddf70cbd3b234270e579 (patch)
tree786c92de15f3ac5fc9891f0ac2ae14466413ff57 /cmd/trunks-example
parentd36d1eee17e2b38109a76b735191003d14d35336 (diff)
downloadgorankusu-413ed58f7df58644f030ddf70cbd3b234270e579.tar.xz
cmd: rename the program trunks to trunks-example
The trunks directory on command is actually the main program for example package.
Diffstat (limited to 'cmd/trunks-example')
-rw-r--r--cmd/trunks-example/main.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/cmd/trunks-example/main.go b/cmd/trunks-example/main.go
new file mode 100644
index 0000000..854cf69
--- /dev/null
+++ b/cmd/trunks-example/main.go
@@ -0,0 +1,36 @@
+// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//
+// Program trunks provide an example how to use the Trunks module.
+//
+package main
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+
+ "git.sr.ht/~shulhan/trunks/example"
+ "github.com/shuLhan/share/lib/mlog"
+)
+
+func main() {
+ ex, err := example.New()
+ if err != nil {
+ mlog.Fatalf("%s\n", err)
+ }
+
+ go func() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
+ <-c
+ ex.Stop()
+ }()
+
+ err = ex.Start()
+ if err != nil {
+ mlog.Fatalf("%s\n", err)
+ }
+}