File: example_test.go

package info (click to toggle)
golang-blitiri-go-systemd 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 80 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 505 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package systemd_test

import (
	"fmt"
	"net"

	"blitiri.com.ar/go/systemd"
)

func serve(l net.Listener) {
	// Serve over the listener.
}

func Example() {
	listeners, err := systemd.Listeners()
	if err != nil {
		fmt.Printf("error getting listeners: %v", err)
		return
	}

	// Iterate over the listeners of a particular systemd socket.
	// The name comes from the FileDescriptorName option, defaults to the name
	// of the socket unit.
	for _, l := range listeners["service.socket"] {
		go serve(l)
	}
}