Standard library / os

os.Getegid()

Returns effective group ID on Unix; may be -1 on unsupported systems. Used in permission reasoning, not as authorization by itself. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Getegid() int

Return Value

int

Returns effective group ID on Unix; may be -1 on unsupported systems.

Working Example

Example Snippetgo
package main
import (  "fmt"  "os")
func must(e error) {  if e != nil {    panic(e)  }}func main() { fmt.Println(os.Getegid() >= 0) }
Go Reference