Exemplo n.º 1
0
func updatePackages(e *doc.Environment) {
	app, _ := e.Get(envAppKey).(*App)
	if app == nil {
		return
	}
	data, _ := app.Data().(*appData)
	if data == nil {
		return
	}
	for _, gr := range data.Groups {
		for _, pkg := range gr.Packages {
			if err := updatePackage(e, pkg); err != nil {
				log.Errorf("error updating %s: %s", pkg, err)
			}
		}
	}
}
Exemplo n.º 2
0
func packageDir(dctx *doc.Environment, p string) string {
	if strings.IndexByte(p, '.') > 0 {
		// Non std package
		return dctx.Join(dctx.Context.GOPATH, "src", p)
	}
	// Std package
	if strings.HasPrefix(p, "cmd") {
		return dctx.Join(dctx.Context.GOROOT, "src", p)
	}
	// pkg was removed from path to the source around go 1.4
	stdSrc := dctx.Join(dctx.Context.GOROOT, "src", "pkg")
	if !dctx.IsDir(stdSrc) {
		stdSrc = dctx.Join(dctx.Context.GOROOT, "src")
	}
	return dctx.Join(stdSrc, p)
}