<p>This is what I have for code</p>
<pre><code>jesus = unsafe.Pointer(uintptr(jesus) + 0xAADDEC) //shifting a memory address w/ pointer arithmetic
fmt.Println(*jesus)
</code></pre>
<p>and this is my error</p>
<pre><code>.\main.go:118:14: invalid indirect of jesus (type unsafe.Pointer)
</code></pre>
<p>What gives, man? I need that juicy value it is pointing to (It's a memory address)</p>
<hr/>**评论:**<br/><br/>ChristophBerger: <pre><p><a href="https://www.reddit.com/r/golang/comments/7d54vq/how_do_i_get_the_underlying_value_on_a/" rel="nofollow">Original thread</a> (to avoid double effort for suggestions already given)</p>
<p>What type of data is behind that pointer?</p>
<p>In general, you need to convert the pointer to the desired type, in order to get a typed value back. So if <code>jesus</code> points to an <code>int64</code>, this should get the value back:</p>
<pre><code>fmt.Println(*(*int64)(jesus))
</code></pre></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传