-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
This is a new proposal to replace #37113, which was closed for non-technical reasons.
Paraphrasing @rsc, the proposal is a new function in the path/filepath package:
// Resolve returns the path name as an absolute path that does not contain any symlinks.
// Resolve calls Clean on the result.
func Resolve(path string) stringThe expectation is that on Unix systems this will be essentially filepath.Abs(filepath.EvalSymlinks(path)) and on Windows it will essentially acquire a handle for the path and call GetFinalPathNameByHandle.
Objections to this approach (in my own words, apologies if I misrepresent some position):
- We should instead make
EvalSymlinkswork better on Windows, such thatfilepath.Abs(filepath.EvalSymlinks(path))will suffice on both Unix and Windows systems. This may involve changingEvalSymlinksto callGetFinalPathNameByHandle. However, any such change toEvalSymlinkson Windows may break programs that currently work on Windows. - It will be tempting to think that the proposed
Resolvefunction will return a canonical path, but it will not, neither on Unix nor Windows (on Unix it will not be canonical due to hard links and multiple mounts). Therefore this function will mislead people into writing buggy programs. In particular,os.SameFilecan return true for two different paths returned byResolve.
jimen0 and douglaslassance