// Open the cgroup hierarchy of the current container f, err := os.Open("/sys/fs/cgroup/memory/memory.limit_in_bytes") if err != nil { // Handle error } defer f.Close() // Read the maximum memory limit from the file var maxMemLimit int64 _, err = fmt.Fscanf(f, "%d", &maxMemLimit) if err != nil { // Handle error }