Also, your function (as well as the one you seem to have copied and 
modified, did I get that right from your documentation?) will most probably 
not work correctly if there are symlinks "inside" the path and not just at 
the beginning of the given path. There's a reason to my limited 
understanding why the stdlib EvalSymlinks function has to iterate, in order 
to cover finding multiple symlinks along the path, and a previous symlink 
will influence later symlinks.

Some time ago, I had to get deeper into stdlib's EvalSymlinks in order to 
come up with a modified one that allows the path to be interpreted relative 
to an arbitrary other "root" path, even if the path to be resolved is 
seemingly absolute. It's a special use case when using Linux and doing 
funny mount namespace-related VFS accesses through Linux' process 
filesystem, and its "root" elements in particular. In case someone wants to 
know more, here we are: https://github.com/thediveo/procfsroot ... I'm 
using this to access the VFS view of containers without needing to spawn 
new processes, switching them into container mount namespaces, and then all 
the hassles of shuttling commands and responses forth and back. Instead, I 
resolve a path that is "absolute" to another mount namespace as relative to 
a suitable process filesystem entry and then can access the 
file/directory/etc. directly by the "resolved" path, using normal VFS 
syscalls from any arbitrary Go routine (and OS-level thread/task).
On Friday, August 4, 2023 at 10:14:18 AM UTC+2 TheDiveO wrote:

> As I couldn't figure this out from the repo's documentation: what's the 
> difference and what's the benefit compared to stdlib 
> https://pkg.go.dev/path/filepath#EvalSymlinks?
>
> On Thursday, August 3, 2023 at 8:57:08 PM UTC+2 Carlos Henrique Guardão 
> Gandarez wrote:
>
>> Hey there!
>>
>> I created a new lib to return a real path in Go.
>> https://github.com/gandarez/go-realpath
>>
>> Thanks.
>>
>> On Thursday, January 18, 2018 at 4:28:09 PM UTC-2 rgo...@redhat.com 
>> wrote:
>>
>>>
>>>
>>> On Monday, 16 July 2012 13:55:53 UTC+3, Rémy Oudompheng wrote:
>>>>
>>>> Did you have a look at filepath.EvalSymlinks? 
>>>>
>>>> Rémy. 
>>>>
>>>
>>> Confirmed to be working. Thanks Remy. 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4131ed67-d9cb-4755-90a6-96099d56f3d0n%40googlegroups.com.

Reply via email to