File: 0001-godoc-symlinks.patch

package info (click to toggle)
golang-golang-x-tools 1%3A0.0~git20190125.d66bd3c%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 8,912 kB
  • sloc: asm: 1,394; yacc: 155; makefile: 109; sh: 108; ansic: 17; xml: 11
file content (35 lines) | stat: -rw-r--r-- 931 bytes parent folder | download
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
@@ -101,5 +101,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
 }