Skip to content

Commit 7f0723f

Browse files
committed
util/sdjournal: minor style cleanup
1 parent 0acb493 commit 7f0723f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

sdjournal/journal.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ func NewJournal() (*Journal, error) {
8888
}
8989

9090
// NewJournalFromDir returns a new Journal instance pointing to a journal residing
91-
// in a given directory. Typically, the directory will be appended with /<machine-id>
92-
// which can be generated from util.GetMachineID() from this same library.
91+
// in a given directory. The supplied path may be relative or absolute; if
92+
// relative, it will be converted to an absolute path before being opened.
9393
func NewJournalFromDir(path string) (*Journal, error) {
9494
path, err := filepath.Abs(path)
9595
if err != nil {
@@ -100,9 +100,9 @@ func NewJournalFromDir(path string) (*Journal, error) {
100100
defer C.free(unsafe.Pointer(p))
101101

102102
j := &Journal{}
103-
errInt := C.sd_journal_open_directory(&j.cjournal, p, 0)
104-
if errInt < 0 {
105-
return nil, fmt.Errorf("failed to open journal in directory %v: %v", path, errInt)
103+
err := C.sd_journal_open_directory(&j.cjournal, p, 0)
104+
if err < 0 {
105+
return nil, fmt.Errorf("failed to open journal in directory %v: %v", path, err)
106106
}
107107

108108
return j, nil

util/util.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func CurrentUnitName() (unit string, err error) {
246246
}
247247

248248
// IsRunningSystemd checks whether the host was booted with systemd as its init
249-
// system. This functions similar to systemd's `sd_booted(3)`: internally, it
249+
// system. This functions similarly to systemd's `sd_booted(3)`: internally, it
250250
// checks whether /run/systemd/system/ exists and is a directory.
251251
// http://www.freedesktop.org/software/systemd/man/sd_booted.html
252252
func IsRunningSystemd() bool {
@@ -257,10 +257,10 @@ func IsRunningSystemd() bool {
257257
return fi.IsDir()
258258
}
259259

260-
// GetMachineID returns a host's 128-bit machine ID as a string. There is a systemd
261-
// library function, sd_id128_get_machine, which can be used to obtain the
262-
// machine ID. However, this function simply reads the string from /etc/machine-id.
263-
// To simplify things, we'll just read it directly from the file, too.
260+
// GetMachineID returns a host's 128-bit machine ID as a string. This functions
261+
// similarly to systemd's `sd_id128_get_machine`: internally, it simply reads
262+
// the contents of /etc/machine-id
263+
// http://www.freedesktop.org/software/systemd/man/sd_id128_get_machine.html
264264
func GetMachineID() (string, error) {
265265
machineID, err := ioutil.ReadFile("/etc/machine-id")
266266
if err != nil {

0 commit comments

Comments
 (0)