【Golang】exec.Commandを使って別ユーザーの権限でコマンドを実行したい
サンプルコード
package main
import (
"fmt"
"os/exec"
"os/user"
"strconv"
"syscall"
)
func main() {
username := "test"
u, _ := user.Lookup(username)
uid, _ := strconv.Atoi(u.Uid)
gid, _ := strconv.Atoi(u.Gid)
cmd :...
tsurai.dev1 min read