<p>Hello,</p>
<p>I'm fairly new to this (and am not an engineer by trade) so apologies if this info was readily available and I just wasn't googling for the right thing.</p>
<p>I need to read some values of the user's defaults settings in Mac.</p>
<p>There is a package readily available to read the registry in Windows: <a href="https://godoc.org/golang.org/x/sys/windows/registry" rel="nofollow">https://godoc.org/golang.org/x/sys/windows/registry</a></p>
<p>But I can't find an analogous version for Mac. </p>
<p>I see there's a sys/unix: <a href="https://godoc.org/golang.org/x/sys/unix" rel="nofollow">https://godoc.org/golang.org/x/sys/unix</a></p>
<p>But I don't see where/how you would read the defaults within that long list of functions. Any help is much appreciated.</p>
<hr/>**评论:**<br/><br/>icholy: <pre><p>My "they're writing malware" senses are tingling.</p></pre>solarnoise: <pre><p>I see your comment got upvoted and my reply and OP got downvoted. Real nice community you got here, friends. I'll be sure the door doesn't hit me on the way out.</p></pre>icholy: <pre><p>I think it's just being upvoted because it's funny. Don't know why you got downvoted.</p></pre>solarnoise: <pre><p>Sorry it came across that way.</p>
<p>I'm the creator of a plugin for a notable art program, and I wrote a binary part in golang to help parse files. I needed concurrency and just don't have the chops or patience for C++.</p>
<p>One thing I need to check for (as it can absolutely mess things up) is whether the user has the debug flag enabled for the host program. In Windows it's a registry key and in Mac it's in defaults. I just need to retrieve it.</p>
<p>I'm not sure what else to say... I have a long reddit post history and you can derive my real identity from it easily enough. I work in the video games industry but the plugin is my side project.</p>
<p>As an aside, wouldn't registry fiddling be one of the most obvious things an AV would catch?</p></pre>4ad: <pre><p>You can call <a href="https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/defaults.1.html" rel="nofollow">defaults(1)</a> through <code>os.Exec</code>.</p></pre>GoTheFuckToBed: <pre><p>settings are stored in plists files
<a href="https://github.com/DHowett/go-plist" rel="nofollow">https://github.com/DHowett/go-plist</a></p></pre>ChristophBerger: <pre><p>The only match I found on Github is <a href="https://github.com/grapswiz/dfs" rel="nofollow">grapswiz/dfs</a> (Search: <code>language:go sort:stars mac defaults</code>). Under the hood, it simply seems to call the <code>defaults</code> command (see the "commands" field in <a href="https://github.com/grapswiz/dfs/blob/master/definitions/10.12/dock.json" rel="nofollow">dock.json</a>. </p>
<p>Maybe that's what your code could do, too - call <code>defaults</code> via <code>os.Exec()</code> and fetch the output.</p></pre>solarnoise: <pre><p>Great, thank you! That sounds like it'll work.</p></pre>gogroob: <pre><p>You need to use CGO to interface with CFPreferences. I have an example here <a href="https://github.com/groob/mackit/blob/master/example/main.go" rel="nofollow">https://github.com/groob/mackit/blob/master/example/main.go</a></p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传