func srcLinkFunc(s string) string {
	s = path.Clean("/" + s)
	if !strings.HasPrefix(s, "/src/") {
		s = "/src" + s
	}
	return s
}
Original Source https://github.com/golang/tools/blob/master/godoc/godoc.go#L562
package main
import (
	"bytes"
	"flag"
	"fmt"
	"go/build"
	"io/ioutil"
	"log"
	"os"
	"path"
	"path/filepath"
	"runtime"
	"strings"
	"text/template"
	"golang.org/x/tools/godoc"
	"golang.org/x/tools/godoc/vfs"
)
var (
	verbose = flag.Bool("v", false, "verbose mode")
	goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory")
	tabWidth       = flag.Int("tabwidth", 4, "tab width")
	showTimestamps = flag.Bool("timestamps", false, "show timestamps with directory listings")
	altPkgTemplate = flag.String("template", "", "path to an alternate template file")
	showPlayground = flag.Bool("play", false, "enable playground in web interface")
	showExamples   = flag.Bool("ex", false, "show examples in command line mode")
	declLinks      = flag.Bool("links", true, "link identifiers to their declarations")
	srcLinkHashFormat = flag.String("hashformat", "#L%d", "source link URL hash format")
	srcLinkFormat = flag.String("srclink", "", "if set, format for entire source link")
)
func usage() {
	fmt.Fprintf(os.Stderr,
		"usage: godoc2md package [name ...]\n")
	flag.PrintDefaults()
	os.Exit(2)
}
var (
	pres *godoc.Presentation
	fs   = vfs.NameSpace{}
	funcs = map[string]interface{}{
		"comment_md":  commentMdFunc,
		"base":        path.Base,
		"md":          mdFunc,
		"pre":         preFunc,
		"kebab":       kebabFunc,
		"bitscape":    bitscapeFunc,  
		"trim_prefix": strings.TrimPrefix,
	}
)
func commentMdFunc(comment string) string {
	var buf bytes.Buffer
	ToMD(&buf, comment)
	return buf.String()
}
func mdFunc(text string) string {
	text = strings.Replace(text, "*", "\\*", -1)
	text = strings.Replace(text, "_", "\\_", -1)
	return text
}
func preFunc(text string) string {
	return "``` go\n" + text + "\n```"
}