Golang os.Geteuid() Function with Examples

Golang | os.Geteuid() Function: Here, we are going to learn about the Geteuid() function of the os package with its usages, syntax, and examples.
Submitted by IncludeHelp, on November 18, 2021

os.Geteuid()

In the Go language, the os package provides a platform-independent interface to operating system (Unix-like) functionality. The Geteuid() function is an inbuilt function of the os package, it is used to get the numeric effective user id of the caller.

It accepts nothing and returns an integer value containing the numeric effective user id of the caller.

Note: On Windows Systems, it returns -1.

Syntax:

func Geteuid() int

Parameter(s):

  • None

Return Value:

The return type of the os.Geteuid() function is an int, it returns the numeric effective user id of the caller.

Example:

// Golang program to demonstrate the
// example of Geteuid() function

package main

import (
	"fmt"
	"os"
)

func main() {
	id := os.Geteuid()
	fmt.Printf("id: %T, %v\n", id, id)
}

Output:

id: int, 14069

Golang os Package »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.