File: 0001-godoc-symlinks.patch

package info (click to toggle)
golang-golang-x-tools 1%3A0.0~git20161028.0.b814a3b%2Bds-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 5,644 kB
  • sloc: yacc: 155; sh: 95; makefile: 27; asm: 18; xml: 11; ansic: 10
file content (35 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Description: Make godoc support symlinks.
 Due to the FHS, we use a symlink from /usr/share/golang/src to
 /usr/lib/golang/src, but godoc does not support that.
 .
 See also https://groups.google.com/forum/#!topic/golang-nuts/396pWLsz-WI
Debian-Bug: 669354
Author: Dmitry Azhichakov <dmitry@dsa.pp.ru>
Forwarded: https://golang.org/issue/1540

---

--- a/godoc/vfs/os.go
+++ b/godoc/vfs/os.go
@@ -61,5 +61,20 @@
 }
 
 func (root osFS) ReadDir(path string) ([]os.FileInfo, error) {
-	return ioutil.ReadDir(root.resolve(path)) // is sorted
+	dirName := root.resolve(path)
+	fis, err := ioutil.ReadDir(dirName) // is sorted
+	if err != nil {
+		return nil, err
+	}
+	// Replace symlinks with what they are pointing to
+	for i, fi := range fis {
+		if fi.Mode()&os.ModeSymlink != 0 {
+			fi, err = os.Stat(filepath.Join(dirName, fi.Name()))
+			if err != nil {
+				return nil, err
+			}
+		}
+		fis[i] = fi
+	}
+	return fis, nil
 }