<p dir="auto">go version 1.5.3</p>
<p dir="auto">Suppose a directory Documents/ has sub-directories A/, B/, C/, and files a, b, c</p>
<p dir="auto">URL in address bar: <strong><a href="http://localhost/Documents/" rel="nofollow">http://localhost/Documents/</a></strong></p>
<p dir="auto">Everything is okay</p>
<p dir="auto">URL in address bar: <strong><a href="http://localhost/Documents" rel="nofollow">http://localhost/Documents</a></strong></p>
<p dir="auto">Sub-directory's href is "<strong><a href="http://localhost/A/" rel="nofollow">http://localhost/A/</a></strong>", NOT "<strong><a href="http://localhost/Documents/A/" rel="nofollow">http://localhost/Documents/A/</a></strong>".</p>
<p dir="auto">So do other sub-directories and files.</p>
<h2 dir="auto"></h2>
<p dir="auto"><a href="https://github.com/golang/go/blob/master/src/net/http/fs.go#L458-L461">https://github.com/golang/go/blob/master/src/net/http/fs.go#L458-L461</a></p>
<p dir="auto">Why is the <strong>redirect</strong> flag in <strong>serveFile(w, r, Dir(dir), file, false)</strong> set to be false?</p>
<p dir="auto">What's the difference between ServeFile and FileServer except that FileServer will add "/" for directories and remove "/" for files?</p>
<p dir="auto">As suggestion, I hope that ServeFile won't show directory structure. It only serves files.</p>
<h2 dir="auto">Edited</h2>
<p dir="auto">Code: <a href="http://130.211.241.67:3000/test.go" rel="nofollow">http://130.211.241.67:3000/test.go</a></p>
<p dir="auto">The following 2 URLs has the same html output. But as two URLs have different endings, broswer generates different links.<br>
<a href="http://130.211.241.67:3000/test" rel="nofollow">http://130.211.241.67:3000/test</a></p>
<p dir="auto"><a href="http://130.211.241.67:3000/test/" rel="nofollow">http://130.211.241.67:3000/test/</a></p>
<p dir="auto">Just click "testFile"</p>
<p dir="auto">The ServeFile function doesn't redirect directory URLs ends without "/" to right place.</p>
<p dir="auto">If ServeFile redirects, there are no difference between ServeFile and FileServer.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bradfitz/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bradfitz">@bradfitz</a> tested</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="127206401" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/13996" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/13996/hovercard?comment_id=172754548&amp;comment_type=issue_comment" href="https://github.com/golang/go/issues/13996#issuecomment-172754548">#13996 (comment)</a></p>
<p dir="auto">So I wonder how to modify it.</p>
<h2 dir="auto">Edited Jan 20, 2016, 13:40:00 UTC+8</h2>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/bradfitz/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/bradfitz">@bradfitz</a> 's test</p>
<blockquote>
<p dir="auto">If I change ServeFile's false to true and re-run the net/http tests, there are failures</p>
</blockquote>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="127206401" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/13996" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/13996/hovercard?comment_id=172754548&amp;comment_type=issue_comment" href="https://github.com/golang/go/issues/13996#issuecomment-172754548">#13996 (comment)</a></p>
<pre class="notranslate">Weak imports are currently not treated correctly. Most likely, ld does not have the
knowledge to handle weak imports, and simply ignores them.

Weak imports are important for cross-version API compatibility on OS X, allowing you to
check for the availability of APIs at runtime, without embedding a hard dependency on
that symbol into the binary.

See <a href="https://golang.org/issue/3131" rel="nofollow">https://golang.org/issue/3131</a> for a example of where this is an
issue.</pre>