-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
39 lines (30 loc) · 936 Bytes
/
client.go
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
28
29
30
31
32
33
34
35
36
37
38
39
package gowindows
import (
"github.com/d-strobel/gowindows/connection"
"github.com/d-strobel/gowindows/windows/local"
)
type Client struct {
Connection *connection.Connection
Local *local.Client
}
// NewClient returns a Client object that contains the Connection and the subpackages.
// Use this Client to run the functions inside the package directories.
func New(conf *connection.Config) (*Client, error) {
var err error
// Allocate a new Client
c := new(Client)
// Store new connection to the Client
c.Connection, err = connection.New(conf)
if err != nil {
return nil, err
}
// Build the client with the subpackages
c.Local = local.New(c.Connection)
return c, nil
}
// Close closes any open connection.
// Only ssh connection will be terminated here.
// To avoid surprises in the future, this should always be called in a defer statement.
func (c *Client) Close() error {
return c.Connection.Close()
}