@@ -111,14 +111,13 @@ type Conn struct {
111
111
}
112
112
}
113
113
114
- // New establishes a connection to any available bus and authenticates.
115
- // Callers should call Close() when done with the connection.
116
- // Deprecated: use NewWithContext instead
114
+ // Deprecated: use NewWithContext instead.
117
115
func New () (* Conn , error ) {
118
116
return NewWithContext (context .Background ())
119
117
}
120
118
121
- // NewWithContext same as New with context
119
+ // NewWithContext establishes a connection to any available bus and authenticates.
120
+ // Callers should call Close() when done with the connection.
122
121
func NewWithContext (ctx context.Context ) (* Conn , error ) {
123
122
conn , err := NewSystemConnectionContext (ctx )
124
123
if err != nil && os .Geteuid () == 0 {
@@ -127,44 +126,41 @@ func NewWithContext(ctx context.Context) (*Conn, error) {
127
126
return conn , err
128
127
}
129
128
130
- // NewSystemConnection establishes a connection to the system bus and authenticates.
131
- // Callers should call Close() when done with the connection
132
- // Deprecated: use NewSystemConnectionContext instead
129
+ // Deprecated: use NewSystemConnectionContext instead.
133
130
func NewSystemConnection () (* Conn , error ) {
134
131
return NewSystemConnectionContext (context .Background ())
135
132
}
136
133
137
- // NewSystemConnectionContext same as NewSystemConnection with context
134
+ // NewSystemConnectionContext establishes a connection to the system bus and authenticates.
135
+ // Callers should call Close() when done with the connection.
138
136
func NewSystemConnectionContext (ctx context.Context ) (* Conn , error ) {
139
137
return NewConnection (func () (* dbus.Conn , error ) {
140
138
return dbusAuthHelloConnection (ctx , dbus .SystemBusPrivate )
141
139
})
142
140
}
143
141
144
- // NewUserConnection establishes a connection to the session bus and
145
- // authenticates. This can be used to connect to systemd user instances.
146
- // Callers should call Close() when done with the connection.
147
- // Deprecated: use NewUserConnectionContext instead
142
+ // Deprecated: use NewUserConnectionContext instead.
148
143
func NewUserConnection () (* Conn , error ) {
149
144
return NewUserConnectionContext (context .Background ())
150
145
}
151
146
152
- // NewUserConnectionContext same as NewUserConnection with context
147
+ // NewUserConnectionContext establishes a connection to the session bus and
148
+ // authenticates. This can be used to connect to systemd user instances.
149
+ // Callers should call Close() when done with the connection.
153
150
func NewUserConnectionContext (ctx context.Context ) (* Conn , error ) {
154
151
return NewConnection (func () (* dbus.Conn , error ) {
155
152
return dbusAuthHelloConnection (ctx , dbus .SessionBusPrivate )
156
153
})
157
154
}
158
155
159
- // NewSystemdConnection establishes a private, direct connection to systemd.
160
- // This can be used for communicating with systemd without a dbus daemon.
161
- // Callers should call Close() when done with the connection.
162
- // Deprecated: use NewSystemdConnectionContext instead
156
+ // Deprecated: use NewSystemdConnectionContext instead.
163
157
func NewSystemdConnection () (* Conn , error ) {
164
158
return NewSystemdConnectionContext (context .Background ())
165
159
}
166
160
167
- // NewSystemdConnectionContext same as NewSystemdConnection with context
161
+ // NewSystemdConnectionContext establishes a private, direct connection to systemd.
162
+ // This can be used for communicating with systemd without a dbus daemon.
163
+ // Callers should call Close() when done with the connection.
168
164
func NewSystemdConnectionContext (ctx context.Context ) (* Conn , error ) {
169
165
return NewConnection (func () (* dbus.Conn , error ) {
170
166
// We skip Hello when talking directly to systemd.
@@ -174,7 +170,7 @@ func NewSystemdConnectionContext(ctx context.Context) (*Conn, error) {
174
170
})
175
171
}
176
172
177
- // Close closes an established connection
173
+ // Close closes an established connection.
178
174
func (c * Conn ) Close () {
179
175
c .sysconn .Close ()
180
176
c .sigconn .Close ()
@@ -217,7 +213,7 @@ func NewConnection(dialBus func() (*dbus.Conn, error)) (*Conn, error) {
217
213
218
214
// GetManagerProperty returns the value of a property on the org.freedesktop.systemd1.Manager
219
215
// interface. The value is returned in its string representation, as defined at
220
- // https://developer.gnome.org/glib/unstable/gvariant-text.html
216
+ // https://developer.gnome.org/glib/unstable/gvariant-text.html.
221
217
func (c * Conn ) GetManagerProperty (prop string ) (string , error ) {
222
218
variant , err := c .sysobj .GetProperty ("org.freedesktop.systemd1.Manager." + prop )
223
219
if err != nil {
0 commit comments