Skip to content

Commit 4b24952

Browse files
committed
Add WithUser docs
1 parent b50135a commit 4b24952

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

command_darwin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd {
1010
return cmd
1111
}
1212

13+
// WithUser allows the command to be run as a different
14+
// user.
15+
//
16+
// Example:
17+
//
18+
// cred := syscall.Credential{Uid: 1000, Gid: 1000}
19+
// c := NewCommand("echo hello", cred)
20+
// c.Execute()
1321
func WithUser(credential syscall.Credential) func(c *Command) {
1422
return func(c *Command) {
1523
c.baseCommand.SysProcAttr = &syscall.SysProcAttr{

command_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd {
1010
return cmd
1111
}
1212

13+
// WithUser allows the command to be run as a different
14+
// user.
15+
//
16+
// Example:
17+
//
18+
// cred := syscall.Credential{Uid: 1000, Gid: 1000}
19+
// c := NewCommand("echo hello", cred)
20+
// c.Execute()
1321
func WithUser(credential syscall.Credential) func(c *Command) {
1422
return func(c *Command) {
1523
c.baseCommand.SysProcAttr = &syscall.SysProcAttr{

command_windows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd {
1010
return cmd
1111
}
1212

13+
// WithUser allows the command to be run as a different
14+
// user.
15+
//
16+
// Example:
17+
//
18+
// token := syscall.Token(handle)
19+
// c := NewCommand("echo hello", token)
20+
// c.Execute()
1321
func WithUser(token syscall.Token) func(c *Command) {
1422
return func(c *Command) {
1523
c.baseCommand.SysProcAttr = &syscall.SysProcAttr{

0 commit comments

Comments
 (0)