Home »
Golang »
Golang Reference
Golang os.Getgid() Function with Examples
Golang | os.Getgid() Function: Here, we are going to learn about the Getgid() function of the os package with its usages, syntax, and examples.
Submitted by IncludeHelp, on November 18, 2021
os.Getgid()
In the Go language, the os package provides a platform-independent interface to operating system (Unix-like) functionality. The Getgid() function is an inbuilt function of the os package, it is used to get the numeric effective group id of the caller.
It accepts nothing and returns an integer value containing the numeric effective group id of the caller.
Note: On Windows systems, it returns -1.
Syntax
func Getgid() int
Parameters
Return Value
The return type of the os.Getgid() function is an int, it returns the numeric effective group id of the caller.
Example
// Golang program to demonstrate the
// example of Getgid() function
package main
import (
"fmt"
"os"
)
func main() {
id := os.Getgid()
fmt.Printf("id: %T, %v\n", id, id)
}
Output:
id: int, 14020
Golang os Package »