当前位置: 首页>>代码示例>>Golang>>正文


Golang Context.Projectdir方法代码示例

本文整理汇总了Golang中github.com/constabulary/gb.Context.Projectdir方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Projectdir方法的具体用法?Golang Context.Projectdir怎么用?Golang Context.Projectdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/constabulary/gb.Context的用法示例。


在下文中一共展示了Context.Projectdir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: restore

func restore(ctx *gb.Context) error {
	m, err := vendor.ReadManifest(manifestFile(ctx))
	if err != nil {
		return fmt.Errorf("could not load manifest: %v", err)
	}

	for _, dep := range m.Dependencies {
		fmt.Printf("Getting %s\n", dep.Importpath)
		repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, insecure)
		if err != nil {
			return fmt.Errorf("Could not process dependency: %s", err)
		}
		wc, err := repo.Checkout("", "", dep.Revision)
		if err != nil {
			return fmt.Errorf("Could not retrieve dependency: %s", err)
		}
		dst := filepath.Join(ctx.Projectdir(), "vendor", "src", dep.Importpath)
		src := filepath.Join(wc.Dir(), dep.Path)

		if err := vendor.Copypath(dst, src); err != nil {
			return err
		}

		if err := wc.Destroy(); err != nil {
			return err
		}

	}
	return nil
}
开发者ID:kalafut,项目名称:gb,代码行数:30,代码来源:restore.go

示例2: info

func info(ctx *gb.Context, args []string) error {
	fmt.Printf("GB_PROJECT_DIR=%q\n", ctx.Projectdir())
	fmt.Printf("GB_SRC_PATH=%q\n", joinlist(ctx.Srcdirs()...))
	fmt.Printf("GB_PKG_DIR=%q\n", ctx.Pkgdir())
	fmt.Printf("GB_BIN_SUFFIX=%q\n", ctx.Suffix())
	return nil
}
开发者ID:tbruyelle,项目名称:gb,代码行数:7,代码来源:info.go

示例3: makeenv

func makeenv(ctx *gb.Context) []envvar {
	return []envvar{
		{"GB_PROJECT_DIR", ctx.Projectdir()},
		{"GB_SRC_PATH", joinlist(ctx.Srcdirs()...)},
		{"GB_PKG_DIR", ctx.Pkgdir()},
		{"GB_BIN_SUFFIX", ctx.Suffix()},
		{"GB_GOROOT", runtime.GOROOT()},
	}
}
开发者ID:torfuzx,项目名称:gb,代码行数:9,代码来源:info.go

示例4: depset

func depset(ctx *gb.Context, args []string) error {
	paths := []struct {
		Root, Prefix string
	}{
		{filepath.Join(runtime.GOROOT(), "src"), ""},
		{filepath.Join(ctx.Projectdir(), "src"), ""},
	}
	m, err := vendor.ReadManifest(filepath.Join("vendor", "manifest"))
	if err != nil {
		return err
	}
	for _, d := range m.Dependencies {
		paths = append(paths, struct{ Root, Prefix string }{filepath.Join(ctx.Projectdir(), "vendor", "src", filepath.FromSlash(d.Importpath)), filepath.FromSlash(d.Importpath)})
	}

	dsm, err := vendor.LoadPaths(paths...)
	if err != nil {
		return err
	}
	for _, set := range dsm {
		fmt.Printf("%s (%s)\n", set.Root, set.Prefix)
		for _, p := range set.Pkgs {
			fmt.Printf("\t%s (%s)\n", p.ImportPath, p.Name)
			fmt.Printf("\t\timports: %s\n", p.Imports)
		}
	}

	root := paths[1] // $PROJECT/src
	rs := dsm[root.Root].Pkgs

	fmt.Println("missing:")
	for missing := range findMissing(pkgs(rs), dsm) {
		fmt.Printf("\t%s\n", missing)
	}

	fmt.Println("orphaned:")
	for orphan := range findOrphaned(pkgs(rs), dsm) {
		fmt.Printf("\t%s\n", orphan)
	}

	return nil
}
开发者ID:wmadisonDev,项目名称:gb,代码行数:42,代码来源:depset.go

示例5: fetch

func fetch(ctx *gb.Context, path string, recurse bool) error {
	m, err := vendor.ReadManifest(manifestFile(ctx))
	if err != nil {
		return fmt.Errorf("could not load manifest: %v", err)
	}

	repo, extra, err := vendor.DeduceRemoteRepo(path, insecure)
	if err != nil {
		return err
	}

	if m.HasImportpath(path) {
		return fmt.Errorf("%s is already vendored", path)
	}

	wc, err := repo.Checkout(branch, tag, revision)
	if err != nil {
		return err
	}

	rev, err := wc.Revision()
	if err != nil {
		return err
	}

	branch, err := wc.Branch()
	if err != nil {
		return err
	}

	dep := vendor.Dependency{
		Importpath: path,
		Repository: repo.URL(),
		Revision:   rev,
		Branch:     branch,
		Path:       extra,
	}

	if err := m.AddDependency(dep); err != nil {
		return err
	}

	dst := filepath.Join(ctx.Projectdir(), "vendor", "src", dep.Importpath)
	src := filepath.Join(wc.Dir(), dep.Path)

	if err := vendor.Copypath(dst, src); err != nil {
		return err
	}

	if err := vendor.WriteManifest(manifestFile(ctx), m); err != nil {
		return err
	}

	if err := wc.Destroy(); err != nil {
		return err
	}

	if !recurse {
		return nil
	}

	for done := false; !done; {

		paths := []struct {
			Root, Prefix string
		}{
			{filepath.Join(runtime.GOROOT(), "src"), ""},
			{filepath.Join(ctx.Projectdir(), "src"), ""},
		}
		m, err := vendor.ReadManifest(filepath.Join("vendor", "manifest"))
		if err != nil {
			return err
		}
		for _, d := range m.Dependencies {
			paths = append(paths, struct{ Root, Prefix string }{filepath.Join(ctx.Projectdir(), "vendor", "src", filepath.FromSlash(d.Importpath)), filepath.FromSlash(d.Importpath)})
		}

		dsm, err := vendor.LoadPaths(paths...)
		if err != nil {
			return err
		}

		is, ok := dsm[filepath.Join(ctx.Projectdir(), "vendor", "src", path)]
		if !ok {
			return fmt.Errorf("unable to locate depset for %q", path)
		}

		missing := findMissing(pkgs(is.Pkgs), dsm)
		switch len(missing) {
		case 0:
			done = true
		default:

			// sort keys in ascending order, so the shortest missing import path
			// with be fetched first.
			keys := keys(missing)
			sort.Strings(keys)
			pkg := keys[0]
			gb.Infof("fetching recursive dependency %s", pkg)
			if err := fetch(ctx, pkg, false); err != nil {
//.........这里部分代码省略.........
开发者ID:wmadisonDev,项目名称:gb,代码行数:101,代码来源:fetch.go

示例6: manifestFile

func manifestFile(ctx *gb.Context) string {
	return filepath.Join(ctx.Projectdir(), "vendor", manifestfile)
}
开发者ID:agonzalezro,项目名称:gb,代码行数:3,代码来源:main.go

示例7: makeenv

func makeenv(ctx *gb.Context) []envvar {
	return []envvar{
		{"GB_PROJECT_DIR", ctx.Projectdir()},
	}
}
开发者ID:agonzalezro,项目名称:gb,代码行数:5,代码来源:env.go


注:本文中的github.com/constabulary/gb.Context.Projectdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。