使用Go Lang创建用户和组。 但是Go Binary必须仅对特定用户执行

I have a Go Binary, which when executed will create a User and a Group.

But now I want this Go Binary to be executed only for a specific user?

Is it possible? If yes, how can I achieve this?

Any help is greatly appreciated.

Thanks in advance.

you can call the binary and pass a parameter specifying the use and then you in your code you check if you want to continue or not. i.e:

the first thing in your main function:

func main(){
    if os.Args[1]!="your specific user"{
         fmt.Println("code will not be executed for this user")
         return

    } 
    //continue what you want to do



}

then build your project, and call it like ./project user