golang import "syscall"

package main

import (
    "fmt"
    "os"
    "os/signal"
    "os/user"
    "strconv"
    "syscall"

    "beego-demo/controllers"
    _ "beego-demo/routers"

    "github.com/astaxie/beego"
    _ "github.com/astaxie/beego/session/redis"
)

func setUserID() {
    userName := beego.AppConfig.String("user")
    u, err := user.Lookup(userName)
    if err != nil {
        fmt.Println("user config:", err)
        return
    }
    
    gid, _ := strconv.ParseInt(u.Gid, 0, 0)
    uid, _ := strconv.ParseInt(u.Uid, 0, 0)
    if err := syscall.Setregid(int(gid), int(gid)); err != nil {
        fmt.Println("setregid:", err)
    }
    if err := syscall.Setreuid(int(uid), int(uid)); err != nil {
        fmt.Println("setreuid:", err)
    }
}

bee run 后报错

.\main.go:28: undefined: syscall.Setregid
.\main.go:31: undefined: syscall.Setreuid
2016/09/08 14:27:58 [ERRO] ============== Build failed ===================
查看回复

相关问答