// WorkingDir returns the current working directory // (or "/???" if the directory cannot be identified), // with "/" as separator. func WorkingDir() string { … } // AbsFile returns the absolute filename for file in the given directory, // as rewritten by the rewrites argument. // For unrewritten paths, AbsFile rewrites a leading $GOROOT prefix to the literal "$GOROOT". // If the resulting path is the empty string, the result is "??". // // The rewrites argument is a ;-separated list of rewrites. // Each rewrite is of the form "prefix" or "prefix=>replace", // where prefix must match a leading sequence of path elements // and is either removed entirely or replaced by the replacement. func AbsFile(dir, file, rewrites string) string { … } // ApplyRewrites returns the filename for file in the given directory, // as rewritten by the rewrites argument. // // The rewrites argument is a ;-separated list of rewrites. // Each rewrite is of the form "prefix" or "prefix=>replace", // where prefix must match a leading sequence of path elements // and is either removed entirely or replaced by the replacement. func ApplyRewrites(file, rewrites string) (string, bool) { … } // applyRewrite applies the rewrite to the path, // returning the rewritten path and a boolean // indicating whether the rewrite applied at all. func applyRewrite(path, rewrite string) (string, bool) { … } // Does s have t as a path prefix? // That is, does s == t or does s begin with t followed by a slash? // For portability, we allow ASCII case folding, so that hasPathPrefix("a/b/c", "A/B") is true. // Similarly, we allow slash folding, so that hasPathPrefix("a/b/c", "a\\b") is true. // We do not allow full Unicode case folding, for fear of causing more confusion // or harm than good. (For an example of the kinds of things that can go wrong, // see http://article.gmane.org/gmane.linux.kernel/1853266.) func hasPathPrefix(s string, t string) bool { … }