func main() { handle, _ := dl.Open("msvcrt.dll") proc, _ := dl.Sym(handle, "getenv") ret := dl.Call( proc, uintptr(unsafe.Pointer(&([]byte)("USERPROFILE")[0])), 0, 0) bytes := *((*[]byte)(unsafe.Pointer(ret))) println(string(bytes[0:clen(bytes)])) }
func main() { handle, _ := dl.Open("libc.so") proc, _ := dl.Sym(handle, "getenv") ret := dl.Call( proc, uintptr(unsafe.Pointer(&([]byte)("HOME")[0])), 0, 0) bytes := (([]byte)(unsafe.Pointer(ret))) println(string(bytes[0:clen(bytes)])) }