英文:
Golang: Access a Windows share (from Linux application)
问题
在运行在Linux设备上的Go应用程序中,是否有一种正确的方法来连接到Windows共享,例如\windowspc\c$\myshare?
连接到目标UNC路径需要凭据来保存文件。
是否有最佳实践来实现这一点?
英文:
Is there a proper way to connect to a Windows share, such as \windowspc\c$\myshare, from a Go application that is compiled and running on a Linux device?
The share will require credentials to save a file to the target UNC path.
Is there a best practices to accomplish this?
答案1
得分: 7
理论上是可以的,但实际上不太可能。
Windows共享使用SMB/CIFS协议族。这些协议可以在Go中实现,并用于访问共享。不过,这是一个巨大的任务。
与其在应用程序中实现这个功能,最好的方式是要求从系统中挂载共享,然后从应用程序中像访问本地文件系统一样访问它。
如果你真的想使用SMB/CIFS,你可以在Go中检查Gnome VFS(虚拟文件系统)或FUSE作为C库,但这会变得混乱而丑陋。
英文:
Theoretically yes, practically no.
Windows shares use the SMB/CIFS family of protocols. Those can be implemented in Go and be used to access the shares. This is a huge task, though.
Instead of having this in your application the best way is to require the share to be mounted from your system and then access it like a local file system from the application.
If you really want to use SMB/CIFS you can check whether the Gnome VFS (virtual file system) or FUSE as C libraries from within Go, but this will be messy and ugly.
答案2
得分: 1
我刚刚在寻找GO语言中类似impacket的库时,发现了这个很棒的发现:https://github.com/gentlemanautomaton/smb。在同一个搜索中,我还找到了这个问题,所以我觉得我应该帮助你并在这里发布它。
英文:
I was just looking for a impacket alike lib in GO and came out with this awesome finding
https://github.com/gentlemanautomaton/smb
also in the same search this question came out so I figure I should help you and post it here.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论