Here, We will learn how to get the process id of the caller in go. We can do it by using Getpid() function in os package in go golang.
Function prototype:
func Getpid() int
Return value:
Getpid() function in os package returns
the process id of the caller.
Example with code:
package main
import "fmt"
import "os"
func main() {
pid := os.Getpid()
fmt.Println(pid)
}
Output:
1392
To learn more about golang, Please refer given below link:
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/